function submitSearch()
{
	document.searchForm.submit();
}

function searchWholeRange()
{
	document.searchForm.CurrentTab.value = "1";
	document.searchForm.submit();
}
		
function submitProductShowroom()
{
	document.SearchOptForm.submit();
}

var newwindow;
function openTemsAndConditions()
{
	newwindow = window.open("http://www.appliance-outlet.co.uk/TermsConditions.html","TermsConditions","width=450,height=600,scrollbars=yes,location=no");
	if(window.focus){newwindow.focus()}
}

function isNumberKey(evt)
{
   var charCode = (evt.which) ? evt.which : event.keyCode
   if (charCode > 31 && (charCode < 48 || charCode > 57))
      return false;

   return true;
}

function submitEnqForm() 
{
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{            
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
		self.xmlHttpReq.open('POST', '../servlets/FormRequests', true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){ if (self.xmlHttpReq.readyState == 4){
			updateFormSubmit(self.xmlHttpReq.responseXML);
			}
		}
	var strQuery = postRequestQueryString();
	self.xmlHttpReq.send(strQuery);
}
	
function postRequestQueryString() 
{
	var strHeader = document.getElementById("Header").value;
	var strCusName = document.getElementById("CusName").value;
	var strPhone   = document.getElementById("Phone").value;
	var strEmail   = document.getElementById("Email").value;
	var strEnquiry = document.getElementById("Enquiry").value;
	var strItemCode = document.getElementById("ItemCode").value;
	var strCatCode = document.getElementById("CatCode").value;
	var strManuCode = document.getElementById("ManuCode").value;
	var strPage = document.getElementById("Page").value;
	qstr = 'ItemCode=' + escape(strItemCode) + '&Operation=' + escape('ADDCUSTENQR') + '&CusName=' + escape(strCusName) + '&Phone=' + escape(strPhone) + '&Email=' + escape(strEmail) + '&Enquiry=' + escape(strEnquiry) + '&CatCode=' + escape(strCatCode) 	+ '&ManuCode=' + escape(strManuCode) + '&Header=' + escape(strHeader) + '&Page=' + escape(strPage);  
	return qstr;
}
	
function updateFormSubmit(response)
{
	docElement  = response.documentElement;
	if(docElement.getElementsByTagName('MsgCode')[0].firstChild.data == 'E')
	{
		document.getElementById("resMsg").style.color = '#D90000';
		document.getElementById("resMsg").innerText  = docElement.getElementsByTagName('Msg')[0].firstChild.data;		
	}
	else
	{
		document.getElementById("resMsg").innerText  = docElement.getElementsByTagName('Msg')[0].firstChild.data;
		emptyEnquiryForm();
	}
}

function emptyEnquiryForm() 
{
	document.getElementById("Header").value = "";
	document.getElementById("CusName").value = "";
	document.getElementById("Phone").value = "";
	document.getElementById("Email").value = "";
	document.getElementById("Enquiry").value = "";
}


function submitSortProdsByPrice(iCatCode,iManuCode,iSortBy) 
{
	sortPriceTempMsg();
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{            
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
		self.xmlHttpReq.open('POST', '/catalog/servlets/SearchOperations', true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function(){ if (self.xmlHttpReq.readyState == 4){
			updateSortByPriceRes(self.xmlHttpReq.responseText);
			}
		}
	var strQuery = getSortItemByPriceQuery(iCatCode,iManuCode,iSortBy);
	self.xmlHttpReq.send(strQuery);
}

function getSortItemByPriceQuery(iCatCode,iManuCode,iSortBy) 
{
	qstr = 'Operation=' + escape('SortProdByPrice') + '&ManuCode=' + escape(iManuCode) + '&CatCode=' + escape(iCatCode) + '&SortBy=' + escape(iSortBy) ;  
	return qstr;
}

function updateSortByPriceRes(response)
{
	document.getElementById("prodList").innerHTML   = response;
}

function sortPriceTempMsg()
{
	qstr = '<div class="plsWait"><p>Please wait........</p></div>';
	document.getElementById("prodList").innerHTML   = qstr;
}

function showThumbImage(sImageName,sManuId,iItemCode)
{
	qstr = '<img src=' + '"' + '/catalog/Images/Items/' + sManuId + '/' + 'Thumbs/' + sImageName + '"' + ' alt=' + '"' + 'Bosch HMT75M651B Microwaves' + '">';
	document.getElementById(iItemCode).innerHTML   = qstr;
}


