var urlAppender = '';
var skuNameDisplayDiv = "";
var curleft =  0;
var curtop = 0;
//var categoryString = "";
var currentImagePosition=0;
var slideFlag=false;
var imageText;
var productUrl = '';
var shoppingPopupFlag = true;
var statusbitForFeedBack = "yes";
var flag = 0;
/* form submit on enter key */
function  validateKeyCodeNewsletter()
{	
	if(BrowserDetect.browser=='Firefox'){
	if(document.implementation.createDocument) {
		document.onkeyup = function alertkey(e)
							{
								if(e.which==13){
									subscribeCustomer();
									return false;
							 	}		
							};
	 }	
	} else {
		if((event.charCode != null && event.charCode == 13)  || (event.keyCode != null && event.keyCode == 13 )){
			subscribeCustomer();
			return false;
		}	
	}

}

//------------------------------Function for product Details in Left side on mouseover-------------------------------//

function showProductDetail(productSkuID){
	var skuName = document.getElementById("hdnName"+productSkuID).value;
	var skuDescription = document.getElementById("hdnskuDescription"+productSkuID).value;
	var skuPrice = document.getElementById("hdnprice"+productSkuID).value;
	var skuImage = document.getElementById("skuImage"+productSkuID);
	descriptionDiv = document.getElementById("productDescriptionOnMouseHover");
	descriptionDiv.innerHTML = "<table width='100%'><tr><td style=\"padding: 8px;\"><font class=\"black_10px\" >"+skuDescription+"</font><br><br><font class=\"black_10px\">"+skuPrice+"</font></td></tr></table>";
	
	findPos(document.getElementById("tdBlankSpaceStart"));
	
	var leftPos = curleft;
	
	findPos(skuImage);
	
	curleft = curleft-(150+175)-155;
	
	descriptionDiv.style.top=curtop+'px';
	descriptionDiv.style.left=leftPos+'px';
	descriptionDiv.style.display = "block";
	skuNameDisplayDiv = document.getElementById("skuNameDisplay"+productSkuID);
	skuNameDisplayDiv.innerHTML = "<font class=\"black_10px\">"+skuName+"</font>";
	skuNameDisplayDiv.style.display="block";
	
	hideCategoryWelcomeMessage();
	
}


//--------------------------Function for Remove the Description From Left Side On MouseOut---------------------------//

function onMouseOutDescriptionRemoved(){
	if(descriptionDiv!=null){
		descriptionDiv.style.display = "none";
	}
	if(skuNameDisplayDiv!=null){
		skuNameDisplayDiv.style.display="none";
	}	
	showCategoryWelcomeMessage();
}

//--------------------------Function to find the exact Left and Top Position of the Object---------------------------//

function findPos(obj) {
	//var obj = document.getElementById('trproducttabs');
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}

//---------------------------Function to Show the Refine Result Div--------------------------------------------------//

function refineResult(){
	//findPos(document.getElementById("tdRefineResult"));
	findPos(document.getElementById("tdForRefineResultPosition"));
	document.getElementById("refineReslutsDiv").style.display="block";
	if(BrowserDetect.browser=='Safari' || BrowserDetect.browser=='Firefox'){
		document.getElementById("refineReslutsDiv").style.top = curtop+10+"px";
		document.getElementById("refineReslutsDiv").style.left = curleft+"px";
	}else if(BrowserDetect.browser=='Explorer'){
		document.getElementById("refineReslutsDiv").style.top = curtop+10+"px";
		document.getElementById("refineReslutsDiv").style.left = curleft+"px";
	}
	else
	{
		document.getElementById("refineReslutsDiv").style.top = curtop+10+"px";
		document.getElementById("refineReslutsDiv").style.left = curleft+"px";
	}
}

//---------------------------Function to Hide the Refine Result Div--------------------------------------------------//

function removeRefineResult(){
	document.getElementById("refineReslutsDiv").style.display="none";
}

//---------------------------Funtions To Show the Shopping Cart on the Top Menu--------------------------------------//

function emptyShoppingCart(){
	findPos(document.getElementById("tdHeader2"));
	if(BrowserDetect.browser=='Explorer') {
		document.getElementById("emptyCartDiv").style.top = curtop+19;
		document.getElementById("emptyCartDiv").style.left = curleft-132;
	}
	else if(BrowserDetect.browser=='Firefox')
	{
		document.getElementById("emptyCartDiv").style.top = curtop+18;
		document.getElementById("emptyCartDiv").style.left = curleft-132;
	}
	else{
		document.getElementById("emptyCartDiv").style.top = curtop+18;
		document.getElementById("emptyCartDiv").style.left = curleft-132;
	}
}

function displayCart(){
	document.getElementById("emptyCartDiv").style.display = "block";
}

//---------------------------Funtion to Close the Shopping Cart on the Top Menu--------------------------------------//

function removeShoppingCart(){
	document.getElementById("emptyCartDiv").style.display = "none";
	document.getElementById("topMenuHeaderForFocus").focus();
}

//----------------------------------Function to Validate the EMail-----------------------------------------//

function validateEmail(strValue) 
{

	//var objRegExp  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;  //check for valid email  return 
	//var objRegExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	//var objRegExp  = /(^[a-z,0-9]([a-z,0-9_\.]*)@([a-z,0-9_\.\-]*)([.][a-z]{3})$)|(^[a-z,0-9]([a-z,0-9_\.]*)@([a-z,0-9_\.\-]*)(\.[a-z]{2,3})(\.[a-z]{2})*$)/i;
	var objRegExp  = /(^[a-z,0-9]([a-z,0-9_\.\-]*)@([a-z,0-9_\.\-]*)([.][a-z]{3})$)|(^[a-z,0-9]([a-z,0-9_\.\-]*)@([a-z,0-9_\.\-]*)(\.[a-z]{2,3})(\.[a-z]{2})*$)/i;
	
	if (objRegExp.test(strValue))
	{
		return true;
		
	}
	else
	{
		return false;
	}			
}

//----------------------Functions to open the Slide Show of Images on Product Page-------------------------------//
imageCount = 0;
function showImagePopupDiv(imageCount1)
{
	imageCount = imageCount1;
	imageCount = document.getElementById("hdnImageCount").value;
	
	var imagePath = document.getElementById("imageGallery"+currentImagePosition).src;
	document.getElementById("imageShowImg").src = imagePath;
	document.getElementById("overlay").style.display = "block";
	document.getElementById("dialogue").style.display = "block";
	
	findPos(document.getElementById("tdImageDivAlignment"));
	
	document.getElementById("divImageArrowLeft").style.top = '75px';
	document.getElementById("divImageArrowLeft").style.left = curleft+10+'px';
	document.getElementById("divImageArrowRight").style.top = '75px';
	document.getElementById("divImageArrowRight").style.left= curleft+460+'px';
	document.getElementById("divImageArrowLeft").style.display = "block";
	document.getElementById("divImageArrowRight").style.display = "block";
	/* change overlay div size*/
	winW = document.body.offsetWidth;
	totalWidth = document.getElementById('tableMain').offsetWidth;
	if(winW > totalWidth) {
		document.getElementById('overlay').style.width = winW + "px";
	} else {
		document.getElementById('overlay').style.width = (totalWidth + 50 ) + "px";
	}
	var winH = document.getElementById('tableMain').offsetHeight;
	
	document.getElementById('overlay').style.height = winH + "px";
}

function previousImage(){
	currentImagePosition=currentImagePosition-1;
	if(currentImagePosition<0){
		currentImagePosition=imageCount-1;
	}
	var imagePath = document.getElementById("imageGallery"+currentImagePosition).src;
	document.getElementById("imageShowImg").src = imagePath;
}

function nextImage(){
	currentImagePosition=currentImagePosition+1;
	if(currentImagePosition==imageCount){
		currentImagePosition=0;
	}
	var imagePath = document.getElementById("imageGallery"+currentImagePosition).src;
	document.getElementById("imageShowImg").src = imagePath;
}

function startSlides(){
	slideFlag = true;	
	document.getElementById("slideStartText").style.display="none";
	document.getElementById("slideStopText").style.display="block";
	startSlideShow();
}

function stopSlides(){
	slideFlag = false;	
	document.getElementById("slideStartText").style.display="block";
	document.getElementById("slideStopText").style.display="none";
	stopSlideShow();
}

function startSlideShow(){
	if(slideFlag==true){
		setTimeout('startSlideShow('+imageCount+')',1000);
		currentImagePosition=currentImagePosition+1;
		if(currentImagePosition==imageCount){
			currentImagePosition=0;
		}
		var imagePath = document.getElementById("imageGallery"+currentImagePosition).src;
		document.getElementById("imageShowImg").src = imagePath;
	}	
}

function stopSlideShow(){
	document.getElementById("slideStartText").style.display="block";
	document.getElementById("slideStopText").style.display="none";
	currentImagePosition=0;
	imagePath = document.getElementById("imageGallery"+currentImagePosition).src;
	document.getElementById("imageShowImg").src = imagePath;
}

function closeEnlargeImageShow(){
	document.getElementById("dialogue").style.display = "none";
	document.getElementById("overlay").style.display = "none";

	document.getElementById("divImageArrowLeft").style.display = "none";
	document.getElementById("divImageArrowRight").style.display = "none";
}

function enlargeImage(imageID,imageCount1){
	currentImagePosition = imageID;
	showImagePopupDiv(imageCount1);
}
function showArrowOnImage1()
{
	//alert('hi11');
	if(document.getElementById("divImageArrow1").style.display == 'none')
	{
		document.getElementById("divImageArrow1").style.top = '230px';
		document.getElementById("divImageArrow1").style.left = '20px';
		document.getElementById("divImageArrow1").style.display = "block";
	}
}
function hideArrowOnImage1()
{
	//alert('hi12');
	if(document.getElementById("divImageArrow1").style.display == 'block')
	{
		document.getElementById("divImageArrow1").style.display = "none";
	}
}
function showArrowOnImage2()
{
	if(document.getElementById("divImageArrow2").style.display == 'none')
	{
		document.getElementById("divImageArrow2").style.top = '230px';
		document.getElementById("divImageArrow2").style.left = '360px';
		document.getElementById("divImageArrow2").style.display = "block";
	}
}
function hideArrowOnImage2()
{
	if(document.getElementById("divImageArrow2").style.display == 'block')
	{
		document.getElementById("divImageArrow2").style.display = "none";
	}
}
function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}
function containsDOM (container, containee) {
	do {
	if ((isParent = container == containee))
	break;
	containee = containee.parentNode;
	}
	while (containee != null);
	return isParent;
}

//-----------------Funtions which Specifies the style of Button----------------------------------//

//function buttonmouseover(obj)
//{
//	obj.style.backgroundColor="#FFFFFF";
//	obj.style.color="#000000";
//}
//function buttonmouseout(obj)
//{
//	obj.style.backgroundColor="#797979";
//	obj.style.color="#FFFFFF";
//}
function buttonmouseover(obj)
{
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#000000";
}
function buttonmouseout(obj)
{
	obj.style.backgroundColor="#142A6A";
	obj.style.color="#FFFFFF";
}
function buttonmouseoverImage(obj)
{
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#ff0099";
}
function buttonmouseoutImage(obj)
{
	obj.style.backgroundColor="#ff0099";
	obj.style.color="#FFFFFF";
}
function buttonmouseover1(obj)
{
	obj.style.backgroundColor="#797979";
	obj.style.color="#FFFFFF";
}
function buttonmouseout1(obj)
{
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#797979";
}
//----------------Function With Ajax Call For Staic Web Pages of Top Menu------------------------//


function staticPage(staticPageID){
	var randomNumber=Math.random();
	var url = urlAppender + '/staticpagedata.action?staticPageID='+staticPageID;
	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("centerDiv").innerHTML = xmlHttp.responseText;
			}
		}	
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}

//----------------Function To Show The Product Detail Page------------------------//

function showProductDetailwithAjax(categoryString,colorString,priceString,productUrlCode){

	productUrl = productUrlCode;
	var randomNumber=Math.random();
	var url = urlAppender + '/productdetail.action?category='+categoryString+'&color='+colorString+'&price='+priceString+'&productURLCode='+productUrl;
	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("center").innerHTML = xmlHttp.responseText;
			}
		}	
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}


//-----------------------Function Showing ADD to Cart Functionality----------------------//

function addToCart(productID,productSKU, checkoutlink){
	var randomNumber=Math.random();
	var quantity = document.getElementById("txtQuantity"+productSKU).value;
	document.getElementById("spanTextQuantityError1").style.display = "none";
	document.getElementById("spanTextQuantityError2").style.display = "none";
	if(quantity==null || quantity=="" ){
		document.getElementById("spanTextQuantityError1").style.display = "block";
		document.getElementById("spanTextQuantityError2").style.display = "none";
		return false;
	}
	if(isNaN(quantity))
	{
		document.getElementById("spanTextQuantityError1").style.display = "none";
		document.getElementById("spanTextQuantityError2").style.display = "block";
		return false;
	}
	if(document.getElementById("hdnproductCount").value!=null){
		var productCount = document.getElementById("hdnproductCount").value;
		document.getElementById("productCount").innerHTML = parseInt(productCount) + parseInt(quantity);
		document.getElementById("hdnproductCount").value = parseInt(productCount) + parseInt(quantity);
	}
	var url = urlAppender + '/addtocart.action?ProductID='+productID+'&SKU='+productSKU+'&Quantity='+quantity+"&RNO="+randomNumber;
	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){
				var skuDesc = document.getElementById("skuNametd"+productSKU).innerHTML;
				document.getElementById(productSKU+"ID").innerHTML = quantity+" "+skuDesc+" "+document.getElementById("messageofcarthidden").value+"<br>"+checkoutlink;
				shoppingPopupFlag = true;
			}
		}	
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}



//---------------------------Function To update shopping cart (to add remove product)----------------------//
// To update shopping cart (to remove added product)
function removeFromCart(deleteType,position)
{
	var xmlHttp;
	var randomNumber = Math.random();
	var url= urlAppender + '/removefromcart.action?deleteType='+deleteType+'&position='+position+'&RandomNumber='+randomNumber;//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)
			{	
				shoppingPopupFlag = true;
				if(AjaxToggle == 'true')
					getShoppingCartPage();
				else
					window.location.href = urlAppender + "/shoppingcart.shtml";
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

// To update shopping cart (to update quantity)
function updateCart(count, countGift)
{
	var xmlHttp;
	var randomNumber = Math.random();
	var quantityArray = "";
	var deletedItem = "";
	var ctrl = "";
	var ctrl1 = "";
	for (var i =0; i< count ;i++)
	{
//	 	ctrl = "chkAddedItem"+i;
	 	ctrl1 = "quantity"+i;
//	 	if(document.getElementById(ctrl).checked == true)
//	 	{
//	 		deletedItem += i+"~";
//	 	}
	 	if(isNaN(document.getElementById(ctrl1).value))
		{
			alert('Not a valid quantity.')
			return false;
		}
	 	quantityArray += document.getElementById(ctrl1).value + "~";
	}
	var quantityArrayGift = "";
	var deletedItemGift = "";
	for (var i =0; i< countGift ;i++)
	{
//	 	ctrl = "chkAddedItemGift"+i;
	 	ctrl1 = "quantityGift"+i;
//	 	if(document.getElementById(ctrl).checked == true)
//	 	{
//	 		deletedItemGift += i+"~";
//	 	}
	 	if(isNaN(document.getElementById(ctrl1).value))
		{
			alert('Not a valid quantity.')
			return false;
		}
	 	quantityArrayGift += document.getElementById(ctrl1).value + "~";
	}
	var url= urlAppender + '/updatecart.action?quantityArray='+quantityArray+'&deletedItem='+deletedItem+'&quantityArrayGift='+quantityArrayGift+'&deletedItemGift='+deletedItemGift+'&RandomNumber='+randomNumber;
	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)
			{	
				shoppingPopupFlag = true;
				if(AjaxToggle == 'true')
					getShoppingCartPage();
				else
					window.location.href = urlAppender + "/shoppingcart.shtml";
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


//---------------------------Function to get the shopping Cart Popup Page-------------------------------------//

function getShoppingPopup(){
	emptyShoppingCart();
	var xmlHttp;
	var randomNumber = Math.random()*1000;
	findPos(document.getElementById("shoppingCartMenu"));
	var url= urlAppender + '/shoppingcartpopupdata.action?RandomNumber='+randomNumber;
	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("emptyCartDiv").innerHTML = xmlHttp.responseText;
				document.getElementById("emptyCartDiv").style.display = "block";
				shoppingPopupFlag = false;
			}
		}
	}
	if(shoppingPopupFlag == true)
	{
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);
	}
	else
	{
		document.getElementById("emptyCartDiv").style.display = "block";
	}
}

//--------------------Methods for gift guide category -----------------------------------------------//
function callSubCategoryPopupGiftGuide(categoryCode)
{
	document.getElementById("tdcategory"+categoryCode).style.backgroundColor = "#fe007a";
	document.getElementById("tdcategory_2"+categoryCode).style.backgroundColor = "#fe007a";
}
function hideSubCategoryPopupGiftGuide(categoryCode){
	document.getElementById("tdcategory"+categoryCode).style.backgroundColor = "#d70010";
	document.getElementById("tdcategory_2"+categoryCode).style.backgroundColor = "#d70010";
}
//--------------------End----------------------------------------------------------------------------//
//--------------------Function which shows/Hides the subcategory Popup in Left Menu------------------//
function callSubCategoryPopup(categoryCode,isChild)
{
		//showCategoryMessage(categoryCode);
		document.getElementById("tdcategory"+categoryCode).style.backgroundColor = "#142A6A";
		document.getElementById("tdcategory_2"+categoryCode).style.backgroundColor = "#142A6A";
		if(document.getElementById("divForHref"+categoryCode)!=null)
			document.getElementById("divForHref"+categoryCode).style.backgroundColor = "#142A6A";
		if(isChild==true){	
			findPos(document.getElementById("tdcategory_1"+categoryCode));
			showSubCategoryPopup(categoryCode,isChild);
			document.getElementById("imgCategory"+categoryCode).src=gizmineImagePath+"expand_green.gif";
			document.getElementById("subCategoryPopup1"+categoryCode).style.left = curleft+140+'px';
			document.getElementById("subCategoryPopup1"+categoryCode).style.top = curtop-26+'px';
		}	
}

function showSubCategoryPopup(categoryCode,isChild){
	document.getElementById("subCategoryPopup1"+categoryCode).style.display="block";
	document.getElementById("tdcategory_2"+categoryCode).style.color = "#000000";
}
function hideSubCategoryPopup(categoryCode,isChild){
	//hideCategoryMessage(categoryCode);
		document.getElementById("tdcategory"+categoryCode).style.backgroundColor = "#E3E7F2";
		document.getElementById("tdcategory_2"+categoryCode).style.backgroundColor = "#E3E7F2";
	if(document.getElementById("divForHref"+categoryCode)!=null)
			document.getElementById("divForHref"+categoryCode).style.backgroundColor = "#E3E7F2";	
	if(isChild==true){
		document.getElementById("subCategoryPopup1"+categoryCode).style.display="none";	
		document.getElementById("tdcategory_2"+categoryCode).style.color = "#000000";
		document.getElementById("imgCategory"+categoryCode).src=gizmineImagePath+"deflate_green.gif";
	}	
//	ajaxCallForMenuStateRemove(categoryCode);
}
//for kumiko 
function hideSubCategoryPopupKumiko(categoryCode,isChild){
	//hideCategoryMessage(categoryCode);
		document.getElementById("tdcategory"+categoryCode).style.backgroundColor = "#FFEAF1";
		document.getElementById("tdcategory_2"+categoryCode).style.backgroundColor = "#FFEAF1";
	if(document.getElementById("divForHref"+categoryCode)!=null)
			document.getElementById("divForHref"+categoryCode).style.backgroundColor = "#FFEAF1";	
	if(isChild==true){
		document.getElementById("subCategoryPopup1"+categoryCode).style.display="none";	
		document.getElementById("tdcategory_2"+categoryCode).style.color = "#000000";
		document.getElementById("imgCategory"+categoryCode).src=gizmineImagePath+"deflate_green.gif";
	}	
//	ajaxCallForMenuStateRemove(categoryCode);
}
//end
function callShowAllSKU()
{
	document.getElementById("tdcategoryShowallsku").style.backgroundColor = "#142A6A";
	document.getElementById("tdcategory_2Showallsku").style.backgroundColor = "#142A6A";
	if(document.getElementById("divForHrefShowallsku")!=null)
		document.getElementById("divForHrefShowallsku").style.backgroundColor = "#142A6A";
			
}
function hideShowAllSKU(){
	document.getElementById("tdcategoryShowallsku").style.backgroundColor = "#E3E7F2";
	document.getElementById("tdcategory_2Showallsku").style.backgroundColor = "#E3E7F2";
	if(document.getElementById("divForHrefShowallsku")!=null)
		document.getElementById("divForHrefShowallsku").style.backgroundColor = "#E3E7F2";	
}

function callSubCategoryPopup1(categoryCode,isChild)
{
	//showCategoryMessage(categoryCode);
	findPos(document.getElementById("tdcategory_1"+categoryCode));
	showSubCategoryPopup1(categoryCode,isChild);
	document.getElementById("imgCategory"+categoryCode).src=gizmineImagePath+"expand_blue.gif";
	document.getElementById("subCategoryPopup1"+categoryCode).style.left = curleft+145+'px';//140
	document.getElementById("subCategoryPopup1"+categoryCode).style.top = curtop-20+'px';//26
//	ajaxCallForMenuStateAdd(categoryCode);
}
function showSubCategoryPopup1(categoryCode,isChild){
	document.getElementById("subCategoryPopup1"+categoryCode).style.display="block";
	document.getElementById("tdcategory"+categoryCode).style.backgroundColor = "#3FAE4A";
	document.getElementById("tdcategory3"+categoryCode).style.backgroundColor = "#3FAE4A";
	document.getElementById("tdcategory4"+categoryCode).style.backgroundColor = "#3FAE4A";
	document.getElementById("tdcategory_2"+categoryCode).style.backgroundColor = "#3FAE4A";
	document.getElementById("tdcategory_2"+categoryCode).style.color = "#FFFFFF";
}
function hideSubCategoryPopup1(categoryCode){
	//hideCategoryMessage(categoryCode);
	document.getElementById("subCategoryPopup1"+categoryCode).style.display="none";	
	document.getElementById("tdcategory"+categoryCode).style.backgroundColor = "#E3E7F2";
	document.getElementById("tdcategory3"+categoryCode).style.backgroundColor = "#E3E7F2";
	document.getElementById("tdcategory4"+categoryCode).style.backgroundColor = "#E3E7F2";
	document.getElementById("tdcategory_2"+categoryCode).style.backgroundColor = "#E3E7F2";
	document.getElementById("tdcategory_2"+categoryCode).style.color = "#000000";
//	ajaxCallForMenuStateRemove(categoryCode);
	document.getElementById("imgCategory"+categoryCode).src=gizmineImagePath+"deflate_blue.gif";
}

function showCategoryMessage(categoryCode)
{
	hideCategoryWelcomeMessage();
	if(document.getElementById("tdBlankSpaceStart")!=null)
	{
		findPos(document.getElementById("tdBlankSpaceStart"));
		document.getElementById("categoryMessage"+categoryCode).style.display="block";
		document.getElementById("categoryMessage"+categoryCode).style.left = curleft+'px';
		document.getElementById("categoryMessage"+categoryCode).style.top = curtop+'px';
	}
}
function hideCategoryMessage(categoryCode)
{
	if(document.getElementById("tdBlankSpaceStart")!=null)
	{
		document.getElementById("categoryMessage"+categoryCode).style.display="none";
		document.getElementById("categoryMessageDescription").style.display="none";
		document.getElementById("categoryMessageWelcome").style.display="none";
	}
	showCategoryWelcomeMessage();
}

function clicked(){
	status = status+1;
}

//--------------------Function which shows/Hides the Price Popup in Left Menu------------------//

function callPriceFunction1()
{
	if(document.getElementById("priceDiv1").style.display == 'none' && document.getElementById("priceDiv2").style.display == 'none')
	{
		if(document.getElementById("hiddenFlagprice").value == "open"){
			priceShow1();
		}else if(document.getElementById("hiddenFlagprice").value == "fullopen"){
			callPriceFunction2();
		}
		document.getElementById("imgPrice").src=gizmineImagePath+"expand_green.gif";
		//ajaxCallForMenuStateAdd("price");
	}
	else
	{
		priceHide1();
		priceHide2();
		document.getElementById("imgPrice").src=gizmineImagePath+"deflate_green.gif";
		//ajaxCallForMenuStateRemove("price");
	}
}
function callPriceFunction2()
{
	if(document.getElementById("priceDiv2").style.display == 'none')
	{
		priceShow2();
		document.getElementById("imgPrice").src=gizmineImagePath+"expand_green.gif";
	}
	else
	{	
		priceHide1();
		priceHide2();
		document.getElementById("imgPrice").src=gizmineImagePath+"deflate_green.gif";
	}
}
function priceShow1(){
	document.getElementById("priceDiv2").style.display="none";
	document.getElementById("priceDiv1").style.display="block";
	document.getElementById("tdprice").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdprice_2").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdprice_2").style.color = "#000000";
	document.getElementById("hiddenFlagprice").value = "open";
}
function priceHide1(){
	document.getElementById("priceDiv1").style.display="none";	
		
	document.getElementById("tdprice").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdprice_2").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdprice_2").style.color = "#000000";
}
function priceShow2(){
	document.getElementById("priceDiv1").style.display="none";
	document.getElementById("priceDiv2").style.display="block";
	document.getElementById("tdprice").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdprice_1").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdprice_2").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdprice_2").style.color = "#000000";
	document.getElementById("hiddenFlagprice").value == "fullopen";
}
function priceHide2(){
	document.getElementById("priceDiv2").style.display="none";	
		
	document.getElementById("tdprice").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdprice_1").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdprice_2").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdprice_2").style.color = "#000000";
}

//--------------------Function which shows/Hides the Color Popup in Left Menu------------------//
function callColorFunction1()
{
	if(document.getElementById("colorDiv1").style.display == 'none' && document.getElementById("colorDiv2").style.display == 'none')
	{
		if(document.getElementById("hiddenFlagcolor").value == "open"){
			colorShow1();
		}else if(document.getElementById("hiddenFlagcolor").value == "fullopen"){
			callColorFunction2();
		}	
		document.getElementById("imgColor").src=gizmineImagePath+"expand_green.gif";
		//ajaxCallForMenuStateAdd("color");
	}
	else
	{
		colorHide1();
		colorHide2();
		document.getElementById("imgColor").src=gizmineImagePath+"deflate_green.gif";
		//ajaxCallForMenuStateRemove("color");
	}
}
function callColorFunction2()
{
	if(document.getElementById("colorDiv2").style.display == 'none')
	{
		colorShow2();
		document.getElementById("imgColor").src=gizmineImagePath+"expand_green.gif";
	}
	else
	{	
		colorHide1();
		colorHide2();
		document.getElementById("imgColor").src=gizmineImagePath+"deflate_green.gif";
	}
}
function colorShow1(){
	document.getElementById("colorDiv2").style.display="none";
	document.getElementById("colorDiv1").style.display="block";
	document.getElementById("tdcolor").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdcolor_2").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdcolor_2").style.color = "#000000";
	document.getElementById("hiddenFlagcolor").value = "open";
}
function colorHide1(){
	document.getElementById("colorDiv1").style.display="none";	
		
	document.getElementById("tdcolor").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdcolor_2").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdcolor_2").style.color = "#000000";
}
function colorShow2(){
	document.getElementById("colorDiv1").style.display="none";
	document.getElementById("colorDiv2").style.display="block";
	document.getElementById("tdcolor").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdcolor_1").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdcolor_2").style.backgroundColor = "#DEFF7F";
	document.getElementById("tdcolor_2").style.color = "#000000";
	document.getElementById("hiddenFlagcolor").value = "fullopen";
}
function colorHide2(){
	document.getElementById("colorDiv2").style.display="none";	
		
	document.getElementById("tdcolor").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdcolor_1").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdcolor_2").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdcolor_2").style.color = "#000000";
}
//--------------------Function which shows/Hides the Brand Popup in Left Menu------------------//


function callBrandFunction1()
{
			if(flag==0){
				brandShow1();
				flag = 1;
			}else{
				brandHide1();
				flag = 0;
			}	
}
function brandShow1(){
	findPos(document.getElementById("tdbrand_1"));
	curtop = curtop;
	if(document.getElementById("brandDiv1").style.display!="block")
	{
		document.getElementById("brandDiv1").style.left = curleft+'px';
		document.getElementById("brandDiv1").style.top = curtop+'px';
		document.getElementById("brandDiv1").style.display="block";
	}
	document.getElementById("tdbrand_2").style.backgroundColor = "#3FAE4A";
	document.getElementById("tdbrand_2").style.color = "#FFFFFF";
	flag = 1;
}
function brandHide1(){
	flag = 0;
	if(document.getElementById("brandDiv1").style.display!="none")
	{
		document.getElementById("brandDiv1").style.display="none";
	}
	document.getElementById("tdbrand_2").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdbrand_2").style.color = "#000000";
}
function brandChangeColor()
{
	document.getElementById("tdbrand_2").style.backgroundColor = "#3FAE4A";
	document.getElementById("tdbrand_2").style.color = "#FFFFFF";
	callBrandFunction1();
}


function showCategoryWelcomeMessage()
{
//	if(document.getElementById("tdBlankSpaceStart")!=null)
//	{
//		findPos(document.getElementById("tdBlankSpaceStart"));
//		document.getElementById("categoryMessageWelcome").style.display="block";
//		document.getElementById("categoryMessageWelcome").style.left = curleft+'px';
//		document.getElementById("categoryMessageWelcome").style.top = curtop+'px';
//	}
}
function hideCategoryWelcomeMessage()
{
	if(document.getElementById("tdBlankSpaceStart")!=null)
	{
		document.getElementById("categoryMessageWelcome").style.display="none";
		document.getElementById("categoryMessageDescription").style.display="none";
	}
}
//-------------------Function to Show the given No. of Result On Page ---------------------------------//
function resultByPage(flagAjaxMode, number,urlString){
	var xmlHttp;
	var randomNumber = Math.random();
	var url= urlAppender + '/setnumberofresultperpage.action?ResultCount='+number;
	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)
			{	
				if(flagAjaxMode == 'true')
				{
					getIndexData(urlString);
				} else {
					window.location.href = urlString;
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}

function showSelected(code){
	document.getElementById("showSelectedCategoryPink"+code).className = "pink_12px";
}

function ximageChanged(categoryCode, urlPath){
	document.getElementById("image"+categoryCode).src = urlPath+"gizmine/x_smallred.gif";
}
function ximageRestore(categoryCode, urlPath){
	document.getElementById("image"+categoryCode).src = urlPath+"gizmine/x_small.gif";
}

function getWelcomeMessage(){
//	if(document.getElementById("categoryMessageWelcome") != null)
//	{
//		document.getElementById("categoryMessageWelcome").style.display="block";
//		document.getElementById("categoryMessageDescription").style.display="none";
//	}
}

function hideWelcomeMessageOnOut(){
	//if(document.getElementById("categoryMessageWelcome") != null)
	//{
	//	document.getElementById("categoryMessageWelcome").style.display="none";
	//	document.getElementById("categoryMessageDescription").style.display="none";
	//}
}



function subscribeCustomer()
{
	var xmlHttp;
	var newsletterType="both";
	var email = document.getElementById("txtEmail").value;
	var subscribedForWebsite = 'Gizmine';
	//if(document.getElementById("SubscribedForDaily").checked && document.getElementById("SubscribedForWeekly").checked){
//		newsletterType="both";
	//}else if(document.getElementById("SubscribedForDaily").checked){
//		 newsletterType = "daily";
//	}else if(document.getElementById("SubscribedForWeekly").checked){
//		 newsletterType = "weekly";
//	}else {
//		newsletterType="";
//	}
	if(!validateEmail(email))
	{
		//document.getElementById("trNewsletterMessage").style.display = "block";
		document.getElementById("spanNewsletterMessage1").style.display = "none";
		document.getElementById("spanNewsletterMessage2").style.display = "block";
		document.getElementById("spanNewsletterMessage3").style.display = "none";
		document.getElementById("spanNewsletterMessageresponseText").style.display = "none";
		document.getElementById("spanNewsletterMessageSorry").style.display = "none";
		return;
	}else if(newsletterType == "")
	{
		document.getElementById("spanNewsletterMessage2").style.display = "none";
		document.getElementById("spanNewsletterMessage1").style.display = "none";
		document.getElementById("spanNewsletterMessage3").style.display = "block";
		document.getElementById("spanNewsletterMessageresponseText").style.display = "none";
		document.getElementById("spanNewsletterMessageSorry").style.display = "none";
		return;
	}
	else
	{
		var randomNumber=Math.random();
		var url= urlAppender + '/subscriber.action?email='+email+'&RandomNumber='+randomNumber+'&subscribedForWebsite='+subscribedForWebsite+'&newsletterType='+newsletterType;//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)
				{	
					//document.getElementById("trNewsletterMessage").style.display = "block";
					document.getElementById("spanNewsletterMessageresponseText").innerHTML = xmlHttp.responseText;
					document.getElementById("spanNewsletterMessage2").style.display = "none";
					document.getElementById("spanNewsletterMessage1").style.display = "none";
					document.getElementById("spanNewsletterMessage3").style.display = "none";
					document.getElementById("spanNewsletterMessageresponseText").style.display = "block";
					document.getElementById("spanNewsletterMessageSorry").style.display = "none";
					document.getElementById("txtEmail").value = document.getElementById("entermail").value;
				} else {
					//document.getElementById("trNewsletterMessage").style.display = "block";
					document.getElementById("spanNewsletterMessageSorry").style.display = "block";
					document.getElementById("spanNewsletterMessage2").style.display = "none";
					document.getElementById("spanNewsletterMessage1").style.display = "none";
					document.getElementById("spanNewsletterMessage3").style.display = "none";
					document.getElementById("spanNewsletterMessageresponseText").style.display = "none";
				}
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
  }	
}
function closenewsLetterPopup(){
	document.getElementById("newsLetterPopup").style.display = "none";	
	document.getElementById("trNewsletter1").style.display = "none";
}

function ajaxCallForMenuStateAdd(categoryCode)
{
	var xmlHttp;
	var randomNumber=Math.random()*1000;
	var url = urlAppender+"/menuSessionState.action?RNO="+randomNumber+"&categoryCode="+categoryCode;
	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("GET",url,true);
	xmlHttp.send(null);
  }

function ajaxCallForMenuStateRemove(categoryCode){
	var xmlHttp;
	var randomNumber=Math.random()*1000;
	var url = urlAppender+"/menuSessionStateremove.action?RNO="+randomNumber+"&categoryCode="+categoryCode;
	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("GET",url,true);
	xmlHttp.send(null);
}

function getDataOfAffiliatedSales(){

	var name = document.affiliatedsales.yourName.value;
	var email = document.affiliatedsales.yourEmail.value;
	var blog = document.affiliatedsales.yourBlog.value;
	var additionalMessage = document.affiliatedsales.yourAdditionalMessage.value;
	if(name==""){
		document.getElementById("name").style.display = "block";
		document.getElementById("email").style.display = "none";
		document.getElementById("email2").style.display = "none";
		document.getElementById("blog").style.display = "none";
		document.getElementById("additionalMessage").style.display = "none";
		return false;
	}
	if(email==""){
		document.getElementById("name").style.display = "none";
		document.getElementById("email").style.display = "block";
		document.getElementById("email2").style.display = "none";
		document.getElementById("blog").style.display = "none";
		document.getElementById("additionalMessage").style.display = "none";
		return false;
	}
	if(!validateEmail(email)){
		document.getElementById("name").style.display = "none";
		document.getElementById("email").style.display = "none";
		document.getElementById("email2").style.display = "block";
		document.getElementById("blog").style.display = "none";
		document.getElementById("additionalMessage").style.display = "none";
		return false;
	}
	if(blog==""){
		document.getElementById("name").style.display = "none";
		document.getElementById("email").style.display = "none";
		document.getElementById("email2").style.display = "none";
		document.getElementById("blog").style.display = "block";
		document.getElementById("additionalMessage").style.display = "none";
		return false;
	}
	
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/affiliateSalesSubmit.action?&RNO='+randomNumber+'&name='+name+'&email='+email+'&blog='+blog+'&additionalMessage='+additionalMessage;//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)
			{	
				document.getElementById("informationCollectionBlock").innerHTML = document.affiliatedsales.hdnAffiliateConfrmMessage.value;
				//"Thank you. We will contact you soon.";
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}

function getAffiliateSalesStatic(){
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/getAffiliateSalesPage.action?&RNO='+randomNumber;//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)
			{	
				document.getElementById("tdMainData").innerHTML = xmlHttp.responseText;
				if(AjaxToggle == 'true')
				{
					dhtmlHistory.add("AffiliateSalesStatic="+true, "AffiliateSalesStatic");
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}

/* form submit on enter key */
function  validateKeyCodeNewsletterByAffiliateSalesPage()
{	
	if(BrowserDetect.browser=='Firefox'){
	if(document.implementation.createDocument) {
		document.onkeyup = function alertkey(e)
							{
								if(e.which==13){
									subscribeCustomerByAffiliateSalesPage();
									return false;
							 	}		
							};
	 }	
	} else {
		if((event.charCode != null && event.charCode == 13)  || (event.keyCode != null && event.keyCode == 13 )){
			subscribeCustomerByAffiliateSalesPage();
			return false;
		}	
	}

}


function subscribeCustomerByAffiliateSalesPage()
{
	var xmlHttp;
	var newsletterType="both";
	var email = document.getElementById("txtEmailByAffiliatePage").value;
	var subscribedForWebsite = 'Gizmine';
//	if(document.getElementById("SubscribedForDailyByAffiliatePage").checked && document.getElementById("SubscribedForWeeklyByAffiliatePage").checked){
//		newsletterType="both";
//	}else if(document.getElementById("SubscribedForDailyByAffiliatePage").checked){
//		 newsletterType = "daily";
//	}else if(document.getElementById("SubscribedForWeeklyByAffiliatePage").checked){
//		 newsletterType = "weekly";
//	}else {
//		newsletterType="";
//	}
	if(!validateEmail(email))
	{
		document.getElementById("spanNewsletterMessage1ByAffiliatePage").style.display = "none";
		document.getElementById("spanNewsletterMessage2ByAffiliatePage").style.display = "block";
		document.getElementById("spanNewsletterMessage3ByAffiliatePage").style.display = "none";
		document.getElementById("spanNewsletterMessageresponseTextByAffiliatePage").style.display = "none";
		document.getElementById("spanNewsletterMessageSorryByAffiliatePage").style.display = "none";
		return;
	}else if(newsletterType == "")
	{
		document.getElementById("spanNewsletterMessage2ByAffiliatePage").style.display = "none";
		document.getElementById("spanNewsletterMessage1ByAffiliatePage").style.display = "none";
		document.getElementById("spanNewsletterMessage3ByAffiliatePage").style.display = "block";
		document.getElementById("spanNewsletterMessageresponseTextByAffiliatePage").style.display = "none";
		document.getElementById("spanNewsletterMessageSorryByAffiliatePage").style.display = "none";
		return;
	}
	else
	{
		var randomNumber=Math.random();
		var url= urlAppender + '/subscriber.action?email='+email+'&RandomNumber='+randomNumber+'&subscribedForWebsite='+subscribedForWebsite+'&newsletterType='+newsletterType;//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)
				{	
					//document.getElementById("trNewsletterMessageByAffiliatePage").style.display = "block";
					document.getElementById("spanNewsletterMessageresponseTextByAffiliatePage").innerHTML = xmlHttp.responseText;
					document.getElementById("spanNewsletterMessage2ByAffiliatePage").style.display = "none";
					document.getElementById("spanNewsletterMessage1ByAffiliatePage").style.display = "none";
					document.getElementById("spanNewsletterMessage3ByAffiliatePage").style.display = "none";
					document.getElementById("spanNewsletterMessageresponseTextByAffiliatePage").style.display = "block";
					document.getElementById("spanNewsletterMessageSorryByAffiliatePage").style.display = "none";
					document.getElementById("txtEmailByAffiliatePage").value = document.getElementById("entermailByAffiliatePage").value;
				} else {
					//document.getElementById("trNewsletterMessageByAffiliatePage").style.display = "block";
					document.getElementById("spanNewsletterMessageSorryByAffiliatePage").style.display = "block";
					document.getElementById("spanNewsletterMessage2ByAffiliatePage").style.display = "none";
					document.getElementById("spanNewsletterMessage1ByAffiliatePage").style.display = "none";
					document.getElementById("spanNewsletterMessage3ByAffiliatePage").style.display = "none";
					document.getElementById("spanNewsletterMessageresponseTextByAffiliatePage").style.display = "none";
				}
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
  }	
}

//To show and hide image border in listing page
function showImageBorder(indexValue)
{
	document.getElementById("imageTable_"+indexValue).style.borderColor='#E91D8E';
	document.getElementById("imageTable1_"+indexValue).style.borderColor='#E91D8E';
}
function hideImageBorder(indexValue)
{
	document.getElementById("imageTable_"+indexValue).style.borderColor='#BDBDBE';
	document.getElementById("imageTable1_"+indexValue).style.borderColor='#FFFFFF';
}
function rotateImageDivs() {
	if(document.getElementById("SlideShow")!=null)
	{
		if(document.all) {
			document.images.SlideShow.style.filter="blendTrans(duration=2)";
			document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
			document.images.SlideShow.filters.blendTrans.Apply();
			abc();
		}
		else
		{
			$(document.images.SlideShow).fadeTo("slow", 0.1);
			setTimeout('abc()', slideShowSpeed1);
		}
		if (document.all) {
			document.images.SlideShow.filters.blendTrans.Play();
		}
		else
		{
			$(document.images.SlideShow).fadeTo("slow", 1.0);
		}
	}
	else
	{
		setTimeout('rotateImageDivs()', slideShowSpeed);
	}
}
function abc()
{
	advLink.href = imageLink[j11];
	document.images.SlideShow.src = preLoad[j11].src;
	j11 = j11 + 1;
	if (j11 > (p11 - 1)) j11 = 0;
	t11 = setTimeout('rotateImageDivs()', slideShowSpeed);
}

function getCategoryList(viewType,categoryCode_new,categoryID_new,categoryName_new){
	document.getElementById("tdbrand_2").innerHTML = categoryName_new;
	document.getElementById("divSubCategory"+document.getElementById("hdnSelecteParentCategoryID_1").value).style.display="none";
	document.getElementById("hdnSelecteParentCategoryID_1").value = categoryID_new;
	document.getElementById("divSubCategory"+categoryID_new).style.display="block";
	if(viewType == 'viewAll'){
	if(AjaxToggle == 'true')
	   getIndexData('category=~'+categoryCode_new);
	else
	   window.location.href = urlAppender + "/category=~"+categoryCode_new+"/index.shtml";
	}
}

function callProductPage(urlStr){
	if(BrowserDetect.browser=='Explorer') {
		window.location.href = urlStr;
	}
	else
	{
		return false;
	}
}

//To be called when customer will enter Konami codes
function addFreeGift()
{
	var xmlHttp;
	var randomNumber = Math.random();
	showWaitImage();
	
	var url= urlAppender + '/addFreeGift.action?randomNumber='+randomNumber;
	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)
			{	
				
				hideWaitImage();
				var divTop = document.body.clientHeight;
				var divWidth = document.body.clientWidth;
				divTop = (divTop / 2 ) - 180;
				divWidth = (divWidth / 2) - 330;
				document.getElementById("dialogue_freegift").style.display = "block";
				document.getElementById("dialogue_freegift").style.width ='290px';
				document.getElementById("dialogue_freegift").style.top= divTop + 'px';
				document.getElementById("dialogue_freegift").style.left= divWidth + 'px';
				document.all('dialogue_freegift').innerHTML = xmlHttp.responseText;
				
				/* change overlay div size*/
				winW = document.body.offsetWidth;
				totalWidth = document.getElementById('tableMain').offsetWidth;
				if(winW > totalWidth) {
				   document.getElementById('overlay').style.width = winW + "px";
				} else {
					document.getElementById('overlay').style.width = (totalWidth + 50 ) + "px";
				}
				document.getElementById('overlay').style.height = "1800px";
				document.getElementById("overlay").style.display = "block"; 
				
				if(document.getElementById("hdnproductCount").value!=null){
					var productCount = document.getElementById("hdnproductCount").value;
					var freeGiftQuantity = document.getElementById("freeGiftQuantity").value;
					document.getElementById("productCount").innerHTML = parseInt(productCount) + parseInt(freeGiftQuantity);
					document.getElementById("hdnproductCount").value = parseInt(productCount) + parseInt(freeGiftQuantity);
				}
			}
		}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}

function closeFreeGiftPopup()
{
	document.getElementById("overlay").style.display = "none";
	document.getElementById("dialogue_freegift").style.display = "none";
}

function chnageVersionImg(obj, imgName)
{
	obj.src = imgName;
}
function changeUSVersionImg(imgName, flagCallType)
{
	document.all('uslinkimage').src = imgName;
	if(flagCallType==1)
		document.all('uslink').style.textDecoration = 'underline';
	else
		document.all('uslink').style.textDecoration = 'none';
}
