﻿// When the page loads display all of the producrs
function Init()
{
	try
	{
	// read the query string
	ReadQueryString();

	var qs = "searchterm=";
	
	if (qsParm["searchterm"] != null)
	{
		// set the search term
		qs += qsParm["searchterm"];
	}

	var sectorName = "";
	// was a business area passed?
	if (qsParm["sectorid"] != null)
	{
		// get the sector name
		qs += "&sectorid=" + qsParm["sectorid"];

		var label = "";
		switch (qsParm["sectorid"])
		{
			case "1":
				label = "Transport";
			break;
			case "2":
				label = "Leisure";
			break;
			case "3":
				label = "Corporate";
			break;
			case "4":
				label = "Retail";
			break;
			case "5":
				label = "Media";
			break;
			case "6":
				label = "Hospitality";
			break;
			case "7":
				label = "Government";
			break;
		}

		// set the sector name
		sectorName = " | " + label;
	}

	
	document.getElementById("sectorlabel").innerHTML = sectorName;

	// get the products
	processAsyncRequest("getproducts.asp",qs,"dbcontent");
	
	// has the visitor already visited the site and chosen a search preference?
	var searchPreference = readCookie("SearchPreference");
	
	// if there isn't a cookie or the user has selected Smart Search as the preference - show the box
	if ((searchPreference == null || searchPreference == "0") && qsParm["sectorid"] == null && qsParm["searchterm"] == null)
	{	
		getSearchBoxPage(0);
	}	
	
	eraseCookie("SearchPreference");
	}
	catch(e)
	{
	 alert("An error has occured: " + e);
	}
}

var qsParm = new Array();
function ReadQueryString()
{
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
	var pos = parms[i].indexOf('=');
		if (pos > 0) {
		var key = parms[i].substring(0,pos);
		var val = parms[i].substring(pos+1);
		qsParm[key] = val;
		}
	}
}

checkboxCrossedNormal = new Image();
checkboxCrossedNormal.src = "img/checkboxcrossednormal.gif";

checkboxCheckedNormal = new Image();
checkboxCheckedNormal.src = "img/checkboxcheckednormal.gif";

checkboxUnCheckedNormal = new Image();
checkboxUnCheckedNormal.src = "img/checkboxuncheckednormal.gif";

function getCustomRadioButton(id,onclickAction)
{
	return "<IMG id='" + id + "' class='checkbox' onMouseOver='JavaScript:onRadioMouseOver(this);' onMouseOut='JavaScript:onRadioMouseOut(this);' onclick='JavaScript:" + onclickAction + "' src='img/checkboxuncheckednormal.gif'>";
}

function onRadioMouseOver(object)
{
	object.src = "img/checkboxcheckednormal.gif";
}

function onRadioMouseOut(object)
{
	object.src = "img/checkboxuncheckednormal.gif";
}

function getCustomCheckBox(id,onclickAction)
{
	return "<IMG id='" + id + "' class='checkbox' onMouseOver='JavaScript:onCheckBoxMouseOver(this);' onMouseOut='JavaScript:onCheckBoxMouseOut(this);' onclick='JavaScript:setCheckBoxStatus(this);" + onclickAction + "' src='img/checkboxuncheckednormal.gif'>";
}

function onCheckBoxMouseOver(object)
{
	var image = getImageNameFromSRC(object.src);
	
	// if the check box is checked - temp uncheck it
	if (image == "img/checkboxuncheckednormal.gif")
		object.src = "img/checkboxcrossednormal.gif";
}

function onCheckBoxMouseOut(object)
{
	var on=false;
	
	switch(object.id)
	{
		case "check1":
			on = checkBox1Clicked;
		break;
		case "check2":
			on = checkBox2Clicked;
		break;
		case "check3":
			on = checkBox3Clicked;
		break;
	}
	
	// if the check box is checked - dont remove the check
	if (on)
		return;
	
	var image = getImageNameFromSRC(object.src);
	
	// if the check box is not checked - temp check it
	if (image == "img/checkboxcrossednormal.gif")
		object.src = "img/checkboxuncheckednormal.gif";
}

var checkBox1Clicked = false;
var checkBox2Clicked = false;
var checkBox3Clicked = false;

function setCheckBoxStatus(object)
{
	var image = getImageNameFromSRC(object.src);
	var on = false;
	var boxchecked = false;
	
	// get the status of the checkbox
	switch(object.id)
	{
		case "check1":
			boxchecked = checkBox1Clicked;
		break;
		case "check2":
			boxchecked = checkBox2Clicked;
		break;
		case "check3":
			boxchecked = checkBox3Clicked;
		break;
	}
	
	// if the check box is not checked - uncheck it
	if (boxchecked==false)
	{
		object.src = "img/checkboxcrossednormal.gif";
		on = true;
	}
	else
	{
		object.src = "img/checkboxuncheckednormal.gif";
		on = false;
	}
		
	// remember the status of the check box
	switch(object.id)
	{
		case "check1":
			checkBox1Clicked = on;
		break;
		case "check2":
			checkBox2Clicked = on;
		break;
		case "check3":
			checkBox3Clicked = on;
		break;
	}
}

function getImageNameFromSRC(src)
{
	var imageUrlParts = src.split("/");
	
	return imageUrlParts[imageUrlParts.length-2] + "/" + imageUrlParts[imageUrlParts.length-1];
}

function getSearchBoxPage(pageNo)
{
	var searchBox = document.getElementById("searchbox");	
	
	switch (pageNo)
	{
		case 0: // To use the search or not to use the search...that is the question!
			searchBox.innerHTML="<H3>Would you like to perform a smart search?</H3>"+ getCustomRadioButton("radio1","getSearchBoxPage(1);") +" Yes - recommended for new visitors<br/>"+ getCustomRadioButton("radio2","RememberPreferenceViewAllProducts();CloseSearchPreference();") + " No - view all products";
		break;
		case 1:// Product Type?
			searchBox.innerHTML="<H3>What type of products are you looking for?</H3>"+ getCustomRadioButton("radio3","getDigitalSignageProducts();getSearchBoxPage(2);") +" Digital Signage<br/>" + getCustomRadioButton("radio4","getDirectionalAudioProducts();CloseSearchPreference();") +" Directional Audio<br/>" + getCustomRadioButton("radio5","getInteractiveKioskProducts();CloseSearchPreference();") +" Interactive Kiosks<br/>";
		break;
		case 2: // Digital Signage Product Type? - Local/Remote
			searchBox.innerHTML="<H3>Are you looking for a networked or a standalone solution?</H3>"+ getCustomRadioButton("radio6","getNetworkedDigitalSignageProducts();getSearchBoxPage(3);") +" Networked <br/>"+ getCustomRadioButton("radio7","getSolidaMediaProducts();CloseSearchPreference();") +" Standalone";
		break;
		case 3:
			searchBox.innerHTML="<H3>Are you looking for hardware only or complete digital signage solutions?</H3>"+ getCustomRadioButton("radio9","getSignageliveProducts();getSearchBoxPage(4);") +" Digital Signage Solutions (visit <a href='http://www.signagelive.com' target='_window'>signagelive.com</a> for more infomation)<br/>"+ getCustomRadioButton("radio8","getRMDisplayProducts();CloseSearchPreference();") +" Hardware Only (for use with third party software)";
		break;
		case 4:// signaglive - hardware, software or comms or all?
				searchBox.innerHTML="<H3>What type of signagelive product do you require? (all shown by default)</H3>"+ getCustomCheckBox("check1","getSignageliveProductsByType();") +" Hardware (with integrated signagelive software)<br/>"+ getCustomCheckBox("check2","getSignageliveProductsByType();") +" Software (for third party hardware)<br/>"+ getCustomCheckBox("check3","getSignageliveProductsByType();") +" Communications&nbsp;"
				//<INPUT TYPE='Button' VALUE='Finish' onclick='JavaScript:CloseSearchPreference();'>";
		break;
	}
	/*
	Original Code
	switch (pageNo)
	{
		case 0: // To use the search or not to use the search...that is the question!
			searchBox.innerHTML="<H3>Would you like to perform a smart search?</H3><INPUT TYPE = 'Radio' id = 'radioSmartSearch' name = 'radioSearchPreference' onclick='JavaScript:getSearchBoxPage(1);'>Yes - recommended for new visitors<br/><INPUT TYPE = 'Radio' id= 'radioNormalSearch' name = 'radioSearchPreference' onclick='JavaScript:RememberPreferenceViewAllProducts();CloseSearchPreference();'>No - view all products";
		break;
		case 1:// Product Type?
			searchBox.innerHTML="<H3>What type of products are you looking for?</H3><INPUT TYPE ='Radio' name = 'radioProductGroup' onclick='JavaScript:getDigitalSignageProducts();getSearchBoxPage(2);'>&nbsp;Digital Signage<br/><INPUT TYPE ='Radio' name = 'radioProductGroup' onclick='JavaScript:getDirectionalAudioProducts();CloseSearchPreference();'>&nbsp;Directional Audio<br/><INPUT TYPE ='Radio' name = 'radioProductGroup' onclick='JavaScript:getInteractiveKioskProducts();CloseSearchPreference();'>&nbsp;Interactive Kiosks<br/>";
		break;
		case 2: // Digital Signage Product Type? - Local/Remote
			searchBox.innerHTML="<H3>Are you looking for a networked or a standalone solution?</H3><INPUT TYPE ='Radio' name = 'radioDigitalSignageProductType' onclick='JavaScript:getNetworkedDigitalSignageProducts();getSearchBoxPage(3);'>&nbsp;Networked <br/><INPUT TYPE ='Radio' name = 'radioDigitalSignageProductType' onclick='JavaScript:getSolidaMediaProducts();CloseSearchPreference();'>&nbsp;Standalone";
		break;
		case 3:
			searchBox.innerHTML="<H3>Are you looking for hardware only or complete digital signage solutions?</H3><INPUT TYPE ='Radio' name = 'radioSolutions' onclick='JavaScript:getRMDisplayProducts();CloseSearchPreference();'>&nbsp;Hardware Only (for use with third party software)<br/><INPUT TYPE ='Radio' name = 'radioSolutions' onclick='JavaScript:getSignageliveProducts();getSearchBoxPage(4);'>&nbsp;Digital Signage Solutions (visit <a href='http://www.signagelive.com' target='_window'>signagelive.com</a> for more infomation)";
		break;
		case 4:// signaglive - hardware, software or comms or all?
					searchBox.innerHTML="<H3>What type of signagelive product do you require? (all shown by default)</H3><INPUT TYPE ='checkbox' checked id = 'checkboxSignageliveProductTypeHardware' onclick='JavaScript:getSignageliveProductsByType();'>&nbsp;Hardware (with integrated signagelive software)<br/><INPUT TYPE ='checkbox' checked id = 'checkboxSignageliveProductTypeSoftware' onclick='JavaScript:getSignageliveProductsByType();'>&nbsp;Software (for third party hardware)<br/><INPUT TYPE ='checkbox' checked id = 'checkboxSignageliveProductTypeComms' onclick='JavaScript:getSignageliveProductsByType();'>&nbsp;Communications&nbsp;<INPUT TYPE='Button' VALUE='Finish' onclick='JavaScript:CloseSearchPreference();'>";
		break;
	}*/
	
	// show the search preference box
	OpenSearchPreference();
}

// open the search preference box
function OpenSearchPreference()
{
	// show the background mask
	var backgroundmask = document.getElementById("backgroundmask");
	backgroundmask.style.visibility= "visible";
	
	var searchPreferencePopup = document.getElementById("searchPreferencePopup");
	
	searchPreferencePopup.style.visibility = "visible";
}

// closes the search preference box
function CloseSearchPreference()
{
	// show the background mask
	var backgroundmask = document.getElementById("backgroundmask");
	backgroundmask.style.visibility= "hidden";
	
	var searchPreferencePopup = document.getElementById("searchPreferencePopup");
	
	searchPreferencePopup.style.visibility = "hidden";
}

function RememberPreferenceViewAllProducts()
{
	createCookie("SearchPreference","1",1);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function getInteractiveKioskProducts()
{
	getProductsByCategory(new Array("14"),new Array("23"),null,null);
}

function getDirectionalAudioProducts()
{
	getProductsByCategory(new Array("14"),new Array("25"),null,null);
}

function getDigitalSignageProducts()
{
	getProductsByCategory(new Array("14","1"),new Array("2","3","4","6","20"),null,null);
}

function getSolidaMediaProducts()
{
	getProductsByCategory(new Array("14"),new Array("20"),null,null);
}

function getNetworkedDigitalSignageProducts()
{
	getProductsByCategory(new Array("14","1"),new Array("2","3","4","6"),null,null);
}

function getSignageliveProducts()
{
	getProductsByCategory(new Array("1"),null,null,null);
}

function getRMDisplayProducts()
{	
	getProductsByCategory(new Array("14"),new Array("6"),null,null);
}


function getSignageliveProductsByType()
{
	var category2Categories = new Array();
	// is hardware selected?
	if (checkBox1Clicked)
	{
		category2Categories[category2Categories.length] = "4";
	}
	
	// is software selected
	if (checkBox2Clicked)
	{
		category2Categories[category2Categories.length] = "2";
	}
	
	if (checkBox3Clicked)
	{
		category2Categories[category2Categories.length] = "3";
	}
	
	getProductsByCategory(new Array("1"),category2Categories,null,null);
}


function getProductsByCategory(category1,category2,category3,category4)
{
	var qs = "searchTerm=";
	
	if (category1 != null)
	{
		for (var i=0; i < category1.length;i++)
		{
			qs += "&category1ref=" + category1[i];
		}
	}
		
	if (category2 != null)
	{
		for (var j=0; j < category2.length;j++)
		{
			qs += "&category2ref=" + category2[j];
		}
	}
		
	if (category3 != null)
	{
		for (var k=0; k< category3.length;i++)
		{
			qs += "&category3ref=" + category3[k];
		}
	}
		
	if (category4 != null)
	{
		for (var l=0; l < category4.length;l++)
		{
			qs += "&category4ref=" + category4[l];
		}
	}
	
	// process the request
	processAsyncRequest("getproducts.asp",qs,"dbcontent");
}

// SEARCH METHODS
function search()
{
	var searchText = document.getElementById("searchText");
	
	// check that the element has been found
	if (searchText != null)
	{
		// check if a valid term has been entered
		if (searchText.value != "")
		{
			// process the request
			processAsyncRequest("getproducts.asp","searchterm=" + searchText.value,"dbcontent");
		}
	}
}

function checkEnter(e)
{ 
	//e is event object passed from function invocation
	
	var characterCode //literal character code will be stored in this variable

	if(e && e.which)
	{ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	if(characterCode == 13)
	{ 
		//if generated character code is equal to ascii 13 (if enter key)
		var searchText = document.getElementById("searchText");
		searchText.blur();
	}
}

// SEARCH METHODS

// AJAX METHODS

var xmlHttp;
var m_OutputTagID;

var currentPage = 0;
var dbitemsPerPage = 10;
var xmlDoc;

function processAsyncRequest(serverPage,qs,outputTagID)
{
	if (outputTagID != null)
	{
		m_OutputTagID = outputTagID;
		//document.getElementById(m_OutputTagID).innerHTML="";
	}
	if (qs.length==0)
	{ 
		if (m_OutputTagID != null)
		{
			document.getElementById(m_OutputTagID).innerHTML="";
		}
		return;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 

	var url=serverPage;
	url=url+"?"+qs;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		if (m_OutputTagID != null)
		{
			// remember the XML document
			xmlDoc = xmlHttp.responseXML;
			// display the first page of results			
			getPage(1,true);
		}		
	} 
}

function getPage(pageNo,forceRefresh)
{
	// dont change the page if the current page is selected
	// only refresh the page if told to do so
	if (pageNo != currentPage | forceRefresh)
	{
		// remember the current page
		currentPage=pageNo;
		
		var element = document.getElementById(m_OutputTagID);

		// display the appropriate X dbItems (where X = dbitemsPerPage)
		if (xmlDoc.documentElement.childNodes.length > 0)
		{	
			var itemsReturned = xmlDoc.documentElement.childNodes.length;

			var pages = Math.round(itemsReturned/dbitemsPerPage);
			
			// check if there was a remainder if the remainder is less than 5 need to add another page as the rounding method would not have done this for us
			if (itemsReturned%dbitemsPerPage>0 & itemsReturned%dbitemsPerPage<5)
				pages++;
				
			// calculate the start and end index of the items to be displayed
			var startItemIndex = (pageNo-1) * dbitemsPerPage;
			var endItemIndex = startItemIndex + dbitemsPerPage;
			
			// only display the number of items that have actually been returned
			if (endItemIndex > itemsReturned )
				endItemIndex = itemsReturned;
			
			// add the search control
			var dbcontent = "";// createSearchControl();
					
			// add the top menu		
			dbcontent += createMenu(0,startItemIndex,endItemIndex,itemsReturned,pages);			
			
			// add the results
			for(var i=startItemIndex; i < endItemIndex; i++)
			{					
				dbcontent += createdbItemNode(xmlDoc.documentElement.childNodes[i]);
			}

			// add the menu to the bottom of the products
		//	dbcontent += createMenu(1,startItemIndex,endItemIndex,itemsReturned,pages);
			
			element.innerHTML = dbcontent;
		}
		else
		{
			element.innerHTML = "<div id = 'noproducts'>Your search returned no results</div>";
		}		
	}
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
} 

// END AJAX METHODS

// DOM OBJECT CREATION METHODS
function clearContents(input)
{
	// only clear the contents if the default content is being displayed
	if (input.value=="Key word Search...")
		input.value = "";
}

function createSearchControl()
{
	var search = "";
	search += "<div id='search'>";
		search += "<div id='searchControl'>";
			search += "<img src='img/search.gif' alt='Search' />";
			search += "<INPUT TYPE ='Text' value = 'Key word Search...' onfocus='JavaScript:clearContents(this);'>";
		search += "</div>";	
		search += "?";	
	search += "</div>";
	return search;	
}

function createMenu(type,startItemIndex,endItemIndex,itemsReturned,pages)
{
	// add the meun to the top of the products
	var menu = "";
	
	menu = "<div id='dbmenu'>";
if (type==0)
		menu += "<div id='dbPageMenuTopIntro'>";
	else
		menu += "<div id='dbPageMenuBottomIntro'>";
		
	menu += " DISPLAYING RESULTS " + (startItemIndex+1) + "-" + endItemIndex + " OF " + itemsReturned ;
	menu += "</div>";

	if (type==0)
		menu += "<div id='dbPageMenuTop'>";
	else
		menu += "<div id='dbPageMenuBottom'>";

	menu += "PAGES: " ;
	// add the pages
	for(var i=1; i<=pages;i++)
	{
		// select the selected page
		if (i==currentPage)
		{
			menu += "<a href='JavaScript:getPage(" + i + ",false);' class='pagelinkselected'>" + i +"</a>";
		}
		else
		{					
			menu += "<a href='JavaScript:getPage(" + i + ",false);' class='pagelink'>" + i +"</a>";
		}
	}
	menu += "</div>";
	menu += "</div>";
	
	return menu;
}

var getImageXHTML;

function showImage(imageName)
{
	return;	
	var largeImageDiv = document.getElementById("largeImageDiv");
	if (largeImageDiv != null)
	{		
		largeImageDiv.innerHTML="";
	}
	getImageXHTML=GetXmlHttpObject();
	if (getImageXHTML==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url="getLargeImage.asp";
	url=url+"?" + "image=" + imageName;
	url=url+"&sid="+Math.random();
	getImageXHTML.onreadystatechange=OnLargeImageLoaded;
	getImageXHTML.open("GET",url,true);
	getImageXHTML.send(null);
}

function OnLargeImageLoaded()
{
	if (getImageXHTML.readyState==4 || getImageXHTML.readyState=="complete")
	{ 
		var largeImageDiv = document.getElementById("largeImageDiv");
		if (largeImageDiv != null)
		{
			largeImageDiv.style.position = "absolute";
			largeImageDiv.style.left = 0;			
			largeImageDiv.style.top = 0;
			largeImageDiv.innerHTML=getImageXHTML.responseText;
		}		
	}
}



function createdbItemNode(node)
{
	var dbItemNode = "";
	try
	{
		dbItemNode +="<div class='dbitem'>";
				
		var category1 = SelectSingleNode(node,"Category1");
		var category2 = SelectSingleNode(node,"Category2");
		var category3 = SelectSingleNode(node,"Category3");
		var category4 = SelectSingleNode(node,"Category4");

		dbItemNode += "<SPAN>";
		if (category1 != "")
			dbItemNode += category1;
		
		if (category2 != "")
			dbItemNode += " > " + category2;

		if (category3 != "")
			dbItemNode += " > " + category3;

		if (category4 != "")
			dbItemNode += " > " + category4;
		dbItemNode += "</SPAN>";

		// is there an image to load?
		var image = SelectSingleNode(node,"Image_Small");
		if (image != "")
		{		
			dbItemNode += "<img onmouseover='JavaScript:showImage(\"" + SelectSingleNode(node,"Image_Large") + "\");'  src='productimg/" + image + "'/>"
		}
		else
		{
			dbItemNode += "<img src='productimg/image_unavailable.gif'/>"
		}
		
		// show the name of the product
		dbItemNode += "<h1>" + SelectSingleNode(node,"Description_Short") + "</h1>"
		
		// show the description of the product
		dbItemNode += "<p>" + SelectSingleNode(node,"Description_Large") + "</p>"
		
		var dbLinks = "";
		var linksCount = 0;
		
		var webshopLink = SelectSingleNode(node,"WebShopLink");
		if(webshopLink != null && webshopLink != "")
		{
			dbLinks += "<img onclick='javascript:window.open(\"" + webshopLink + "\");' class='dbitemLink' alt='Open Web Shop' src = 'img/ShoppingCart.gif'/>"
			linksCount++;
		}
		
		// is there a PDF to download?
		var pdfLink = SelectSingleNode(node,"PDF");
		if (pdfLink != null && pdfLink != "")
		{
			dbLinks += "<img onclick='javascript:window.open(\"productpdf/" + pdfLink + "\");' class='dbitemLink' alt='View PDF' src = 'img/acrobat_icon.jpg'/>"
			linksCount++;
		}	
		
		var dbItemMenu = "<div class ='dbItemMenu'>";
		if (linksCount == 2)
		{
			// move across 20 pixels
			dbItemMenu = "<div class ='dbItemMenu' style='margin-left:350px;'>";		
		}
		dbItemMenu += dbLinks;		
		
		dbItemMenu += "</div>";
		
		dbItemNode += dbItemMenu;

	//	var options = "<a href='#' onclick='JavaScript:getOptions(\"" + SelectSingleNode(node,"ProductID") + "\");'>Options</a>";
	//	dbItemNode += options;
				
		dbItemNode += "</div>"
	}
	catch(ex)
	{
		alert("Exception: " + ex);
		dbItemNode = ""
	}
	return dbItemNode;
}


var getOptionsXHTML;

function getOptions(productID)
{
	var optionsPopup = document.getElementById("optionsPopup");	
	if (optionsPopup != null)
	{		
		optionsPopup.innerHTML="";
	}
	getOptionsXHTML=GetXmlHttpObject();
	if (getOptionsXHTML==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url="getproductoptions.asp";
	url=url+"?" + "productid=" + productID;
	url=url+"&sid="+Math.random();
	getOptionsXHTML.onreadystatechange=showOptions;
	getOptionsXHTML.open("GET",url,true);
	getOptionsXHTML.send(null);
}

function showOptions()
{
	if (getOptionsXHTML.readyState==4 || getOptionsXHTML.readyState=="complete")
	{ 
		var optionsPopup = document.getElementById("optionsPopup");
		if (optionsPopup != null)
		{
			optionsPopup.style.position = "absolute";
			optionsPopup.style.left = 0;			
			optionsPopup.style.top = 0;
			optionsPopup.innerHTML=getOptionsXHTML.responseText;
		}		
	}
}

function SelectSingleNode(node, elementPath)
    {
        if(window.ActiveXObject)
        {
            return node.selectSingleNode(elementPath).text;
        }
        else
        {
			var nodes = node.getElementsByTagName(elementPath);
			
			if (nodes.length == 1)
			{
				return nodes[0].textContent;
			}
			else
			{
				return "";
			}
        }
    }

// END DOM OBJECT CREATION METHODS

