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('RelatedItemPage') != -1)
	  	getRelatedProductPage(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('SearchResultPage') != -1)
	  	getSearchResultPage(historyData);
	  else	
	  if(newLocation.indexOf('CloseoutPage') != -1)
	  	getCloseoutPage();
	  else
	  if(newLocation.indexOf('DownloadPage') != -1)
	  	getDownloadPage();
	  else
	  if(newLocation.indexOf('TwitterPage') != -1)
	  	getTwitterPage();	
  }  	
}
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();
	hideTwitterCampaignPage_remove();
///	docu
	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.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("IndexPage="+indexParameter, indexParameter);
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
//Method to show product page
function getProductPage(indexParameter)
{
	var xmlHttp;
	var randomNumber=Math.random();
	//alert(indexParameter);
	var url= urlAppender + '/productdetail.action?'+indexParameter+'&RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	hideTwitterCampaignPage_remove();
	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.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 closeout page
function getCloseoutPage()
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/closeoutdata.action?RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	hideTwitterCampaignPage_remove();
	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.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("CloseoutPage=true", "");
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
//Method to show download page
function getDownloadPage()
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/downloadfilelistdata.action?RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle;
	showWaitImage();
	hideTwitterCampaignPage_remove();
	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.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("DownloadPage=true", "");
				}
			}
		}
	}
	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();
	hideTwitterCampaignPage_remove();
	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.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();
	hideTwitterCampaignPage_remove();
	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.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();
	hideTwitterCampaignPage_remove();
	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(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();
	hideTwitterCampaignPage_remove();
	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.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 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);
}
//Method to show related item page
function getRelatedProductPage(productURLCode)
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/relatedproductdata.action?RandomNumber='+randomNumber+'&AjaxToggle='+AjaxToggle+'&productURLCode='+productURLCode;
	showWaitImage();
	hideTwitterCampaignPage_remove();
	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.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("RelatedItemPage="+productURLCode, productURLCode);
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
function callRelatedProductPage()
{
	getRelatedProductPage(document.getElementById('hdnProductURLCode').value);
}
//Method to show Twitter page
function getTwitterPage()
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/twitterdata.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.getElementById('tdMainData').innerHTML = xmlHttp.responseText;
				hideWaitImage();
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("TwitterPage=true", "");
				}
				if(document.getElementById('divDisableTwitterPage') != null)
					hideTwitterCampaignPage();
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}