//function initialize() {
//  // initialize the DHTML History
//  // framework
//  dhtmlHistory.initialize();
//  // subscribe to DHTML history change
//  dhtmlHistory.addListener(historyChange);
//  // if this is the first time we have
//  // loaded the page...
//}
//Method will be called on back forward button of Browser
//function historyChange(newLocation, historyData) {
//  if(historyData != null && newLocation != '')
//  {
//	  if(newLocation.indexOf('IndexPage') != -1)
//	    getIndexData(historyData);
//	  else
//	  if(newLocation.indexOf('ProductPage') != -1)
//	  	getProductPage(historyData);
//	  else
//	  if(newLocation.indexOf('StaticPage') != -1)
//	  	getStaticPage(historyData);
//	  else
//	  if(newLocation.indexOf('GiftCardPage') != -1)
//	  	getGiftCardPage();
//	  else
//	  if(newLocation.indexOf('ShoppingCartPage') != -1)
//	  	getShoppingCartPage();
//	  else
//	  if(newLocation.indexOf('AffiliateSalesStatic') != -1)
//	  	getAffiliateSalesStatic();		
//	  else
//	  if(newLocation.indexOf('SearchResultPage') != -1)
//	  	getSearchResultPage(historyData);	
//  }  	
//}
function showWaitImage()
{
	document.getElementById("divAjaxCall").style.display = "block";
	window.scroll(0,0);
	if(document.getElementById("refineReslutsDiv") != null)
		document.getElementById("refineReslutsDiv").style.display="none";
}
function hideWaitImage()
{
	document.getElementById("divAjaxCall").style.display = "none";
	//document.getElementById("searchkeyWord").focus();
	//document.getElementById("topMenuHeaderForFocus").focus();
}

//Method to call index page
function getIndexData(indexParameter)
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/productlist.action?'+indexParameter+'&RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				//document.all('tdMainData').innerHTML = xmlHttp.responseText;
				document.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					if(indexParameter=='')
						dhtmlHistory.add("IndexPage"+indexParameter, indexParameter);
					else
						dhtmlHistory.add("IndexPage="+indexParameter, indexParameter);
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
//Method to show static page
function getProductPage(indexParameter)
{
	var xmlHttp;
	var randomNumber=Math.random();
	//alert(indexParameter);
	var url= urlAppender + '/productdetail.action?'+indexParameter+'&RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				//document.all('tdMainData').innerHTML = xmlHttp.responseText;
				document.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("ProductPage="+indexParameter, indexParameter);
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
//Method to show static page
function getStaticPage(indexParameter)
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/staticpagedata.action?staticPageID='+indexParameter+'&RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				//document.all('tdMainData').innerHTML = xmlHttp.responseText;
				document.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("StaticPage="+indexParameter, indexParameter);
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
//Method to show shopping cart page
function getShoppingCartPage()
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/shoppingcartdata.action?RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	document.getElementById("emptyCartDiv").style.display = "none";
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				//document.all('tdMainData').innerHTML = xmlHttp.responseText;
				document.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				document.all('productCount').innerHTML = document.shoppingCartItems.hdnProductCount1.value;
				document.getElementById("hdnproductCount").value = document.shoppingCartItems.hdnProductCount1.value;
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("ShoppingCartPage=true", "");
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
//Method to call gift card page
function getGiftCardPage()
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/giftcartdata.action?RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				//document.all('tdMainData').innerHTML = xmlHttp.responseText;
				document.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("GiftCardPage=true", '');
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
//Method to call gift card page
function getSearchResultPage(searchkeyWord)
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/searchresult.action?searchkeyWord='+searchkeyWord+'&RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				//document.all('tdMainData').innerHTML = xmlHttp.responseText;
				document.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("SearchResultPage="+searchkeyWord, searchkeyWord);
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
//To Change Ajax-NonAjax Status
function ajaxToggle()
{
	var xmlHttp;
	var randomNo = Math.random();
	var url= urlAppender + '/ajaxtoggle.action?randomNumber='+randomNo;//dirPath+
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				window.location.href= urlAppender + '/index.shtml';
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function toggleAjaxButtonImg1()
{
	if(AjaxToggle=='true')
	{
		document.all('ajaxbutton').src=gizmineImagePath+"ajax_onh.gif";
	}else{
		document.all('ajaxbutton').src=gizmineImagePath+"ajax_offh.gif";
	}	
}
function toggleAjaxButtonImg2()
{
	if(AjaxToggle=='true')
	{
		document.all('ajaxbutton').src=gizmineImagePath+"ajax_on.gif";
	}else{
		document.all('ajaxbutton').src=gizmineImagePath+"ajax_off.gif";
	}	
}


//Method to call gift card page
function removeSubscriber()
{
	var xmlHttp;
	var randomNumber=Math.random();
	var subscriberEmailID = document.all('subscriberEmailID').value
	//alert(document.all('subscriberEmailID').value);
	var url= urlAppender + '/removesubscriberbyemail.action?subscriberEmailID='+subscriberEmailID+'&RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				//document.all('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				
				if(xmlHttp.responseText == 'fail'){
					document.getElementById("trUnsubscribMessage").style.display = "block";
					document.getElementById("tdUnsubscribMessage").innerHTML = "Email does not exist.Please try again!";
				}else{
					document.getElementById("tableUnsubscribMessage").style.display = "none";
					document.getElementById("trUnsubscribSuccessMessage").style.display = "block";
					document.getElementById("tdUnsubscribSuccessMessage").innerHTML = "Successfully Unsubscribe";
				}	
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}

//Method to call close promotion message on
function closePromotionMessageAjax()
{
	//alert("Hi");
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/closepromotionmessage.action?RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	document.getElementById("tdPromotionMessage").style.display = "none";
	document.getElementById("tdPromotionMessageSpace").style.display = "none";
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
