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");
//	//<font class=\"black_10px\" >"+skuName+"</font><br><br>
//	//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);
//	//alert(leftPos);
//	//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 = "<table><tr><td><font class=\"black_10px\" >"+skuName+"</font></td></tr><tr><td><font class=\"black_10px\">"+skuDescription+"</font></td></tr><tr><td><font class=\"black_10px\">"+skuPrice+"</font></td></tr></table>";
//	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"));
	//alert(curleft);
	//findPos(document.getElementById("tdRefineResult"));
	document.getElementById("refineReslutsDiv").style.display="block";
	//curleft = curleft - 100;
	//alert(document.getElementById("refineReslutsDiv").style.left);
	if(BrowserDetect.browser=='Safari' || BrowserDetect.browser=='Firefox'){
		//document.getElementById("refineReslutsDiv").style.left = curleft+"px";
		//alert('hi');
		document.getElementById("refineReslutsDiv").style.top = curtop+14+"px";
	}else if(BrowserDetect.browser=='Explorer'){
		//document.getElementById("refineReslutsDiv").style.left = curleft+"px";
		//alert('hi123');
		document.getElementById("refineReslutsDiv").style.top = curtop+14+"px";
	}
	else
	{
		//alert('hi456');
		document.getElementById("refineReslutsDiv").style.top = curtop+14+"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"));
//	document.getElementById("emptyCartDiv").style.left = curleft+16;
	if(BrowserDetect.browser=='Explorer') {
		document.getElementById("emptyCartDiv").style.top = curtop+19;
		document.getElementById("emptyCartDiv").style.left = curleft+11;
	}
	else if(BrowserDetect.browser=='Firefox')
	{
		document.getElementById("emptyCartDiv").style.top = curtop+19;
		document.getElementById("emptyCartDiv").style.left = curleft+12;
	}
	else{
		document.getElementById("emptyCartDiv").style.top = curtop+16;
		document.getElementById("emptyCartDiv").style.left = curleft+12;
	}
}

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;
	
	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;
	//alert(window.screen.width);
	//var leftPos = (window.screen.width - 900)/2;
	//if(leftPos<0) leftPos=0;
	//alert(leftPos)
	//var leftPos = 0;
	//alert(window.document.body.clientWidth);
	//alert(document.width);
	
	
	
	//leftPos = (window.screen.width - 900)/2;
	// if(window.screen.width<900) leftPos=0;
	//alert(window.screen.width +'		'+leftPos);
	//leftPos = (window.document.body.clientWidth - 900)/2;
	//if(window.document.body.clientWidth<900) leftPos=0;
	
	//findPos(document.getElementById("productImageBox"));
	//document.getElementById("dialogue").style.top = '0px';
	//document.getElementById("dialogueParent").style.top = '0px';
	//document.getElementById("dialogueParent").style.left = '0px';
	//document.getElementById("dialogue").style.left = leftPos+'px';
	var imagePath = document.getElementById("imageGallery"+currentImagePosition).src;
	document.getElementById("imageShowImg").src = imagePath;
	document.getElementById("overlay").style.display = "block";
	document.getElementById("dialogue").style.display = "block";
	//document.getElementById("dialogueParent").style.display = "block";
	//
	
	findPos(document.getElementById("tdImageDivAlignment"));
	
	//alert(curleft+'		'+curtop);
	
	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(){
	//stopSlides();
	document.getElementById("dialogue").style.display = "none";
	//document.getElementById("dialogueParent").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()
{
	//alert('hi21');
	if(document.getElementById("divImageArrow2").style.display == 'none')
	{
		//alert('hi21 pankaj');
		document.getElementById("divImageArrow2").style.top = '230px';
		document.getElementById("divImageArrow2").style.left = '360px';
		document.getElementById("divImageArrow2").style.display = "block";
		//alert('hi21 kumar');
	}
}
function hideArrowOnImage2()
{
	//alert('hi22');
	if(document.getElementById("divImageArrow2").style.display == 'block')
	{
		document.getElementById("divImageArrow2").style.display = "none";
	}
}
function checkMouseLeave (element, evt) {
  //alert(evt);
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}
function containsDOM (container, containee) {
	//var isParent = false;
	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="#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 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){
	//alert(checkoutlink);
	var randomNumber=Math.random();
	var quantity = document.getElementById("txtQuantity"+productSKU).value;
	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);
	}
	document.getElementById("tdTextQuantityError").innerHTML = "";
	if(quantity==null || quantity=="" ){
		//document.getElementById("tdTextQuantityError").innerHTML = "You have forgot to enter the Quantity";
		document.getElementById("spanTextQuantityError1").style.display = "block";
		document.getElementById("spanTextQuantityError2").style.display = "none";
		return false;
	}
	if(isNaN(quantity))
	{
//		document.getElementById("tdTextQuantityError").innerHTML = "Not a valid Quantity."
		document.getElementById("spanTextQuantityError1").style.display = "none";
		document.getElementById("spanTextQuantityError2").style.display = "block";
		return false;
	}
	
	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 & update quantity)----------------------//
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 add remove product & 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 add gift card on shopping cart----------------------------------//

function addGiftCardtoCart(giftCardID)
{
	var xmlHttp;
	var randomNumber = Math.random();
	
	document.getElementById('tdSenderName').className= 'pinkbold_12px';
	document.getElementById('tdRecipientName').className= 'pinkbold_12px';
	document.getElementById('tdRecipientEmail').className= 'pinkbold_12px';

	if(document.getElementById('txtSenderName').value == '')
	{
		document.getElementById('tdSenderName').className= 'whitebold_maroon_12px';
		document.getElementById('errorMsgGiftItem').innerHTML = 'Please enter Your Name.';
		return false;
	}
	else
	if(document.getElementById('txtRecipientName').value == '')
	{
		document.getElementById('tdRecipientName').className= 'whitebold_maroon_12px';
		document.getElementById('errorMsgGiftItem').innerHTML = 'Please enter Recipient Name.';
		return false;
	}
	else
	if(!validateEmail(document.getElementById('txtRecipientEmail').value))
	{
		document.getElementById('tdRecipientEmail').className= 'whitebold_maroon_12px';
		document.getElementById('errorMsgGiftItem').innerHTML = 'Not a valid email address.';
		return false;
	}

	var SenderName = document.getElementById('txtSenderName').value;
	var RecipientName = document.getElementById('txtRecipientName').value;
	var RecipientEmail = document.getElementById('txtRecipientEmail').value;
	var SenderMessage = document.getElementById('txtAreaSenderMessage').value;
	for(var i=0;i<SenderMessage.length;i++){
		c = SenderMessage.charCodeAt(i);
		if(c==13){
			var re = new RegExp(SenderMessage.charAt(i));
			SenderMessage = SenderMessage.replace(re, "<br>");
		}
		if(SenderMessage.charAt(i)=='&')
		{
			var re = new RegExp(SenderMessage.charAt(i));
			SenderMessage = SenderMessage.replace(re, "and");
		}
	}
	var url= urlAppender + '/addtogiftcart.action?GiftCardID='+giftCardID+'&SenderName='+SenderName+'&RecipientName='+RecipientName+'&RecipientEmail='+RecipientEmail+'&SenderMessage='+SenderMessage+'&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("POST",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";
	}
}


//--------------------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);
}


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()
{
			findPos(document.getElementById("tdprice_1"));
			priceShow1();
			ajaxCallForMenuStateAdd("price");
			document.getElementById("priceDiv1").style.left = curleft+140+'px';
			document.getElementById("priceDiv1").style.top = curtop-30+'px';
}
function priceShow1(){
	document.getElementById("priceDiv1").style.display="block";
	document.getElementById("tdprice").style.backgroundColor = "#142A6A";
	document.getElementById("tdprice_2").style.backgroundColor = "#142A6A";
	document.getElementById("tdprice_2").style.color = "#FFFFFF";
}
function priceHide1(){
	document.getElementById("priceDiv1").style.display="none";	
	document.getElementById("tdprice").style.backgroundColor = "#E3E7F2";
	document.getElementById("tdprice_2").style.backgroundColor = "#E3E7F2";
	document.getElementById("tdprice_2").style.color = "#000000";
	ajaxCallForMenuStateRemove("price");
	
}

//--------------------Function which shows/Hides the Color Popup in Left Menu------------------//
function callColorFunction1()
{
	findPos(document.getElementById("tdcolor_1"));
	colorShow1();
	ajaxCallForMenuStateAdd("color");
	document.getElementById("colorDiv1").style.left = curleft+140+'px';
	document.getElementById("colorDiv1").style.top = curtop-30+'px';
}
function colorShow1(){
	document.getElementById("colorDiv1").style.display="block";
	document.getElementById("tdcolor").style.backgroundColor = "#142A6A";
	document.getElementById("tdcolor_2").style.backgroundColor = "#142A6A";
	document.getElementById("tdcolor_2").style.color = "#FFFFFF";
}
function colorHide1(){
	document.getElementById("colorDiv1").style.display="none";	
	document.getElementById("tdcolor").style.backgroundColor = "#E3E7F2";
	document.getElementById("tdcolor_2").style.backgroundColor = "#E3E7F2";
	document.getElementById("tdcolor_2").style.color = "#000000";
	ajaxCallForMenuStateRemove("color");
}
//--------------------Function which shows/Hides the Brand Popup in Left Menu------------------//

function callBrandFunction1()
{
			if(flag==0){
				brandShow1();
				flag = 1;
			}else{
				brandHide1();
				flag = 0;
			}	
}
function brandShow1(){
	
	//document.getElementById("imgBrand").src=gizmineImagePath+"dropdown.gif";
	//ajaxCallForMenuStateAdd("brand");
	
	findPos(document.getElementById("tdbrand_1"));
	curtop = curtop;//-9
	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 = "#41AD49";
	document.getElementById("tdbrand_2").style.color = "#FFFFFF";
	//document.getElementById("spanbrand_1").style.backgroundColor = "#41AD49";
	//document.getElementById("spanbrand_1").style.color = "#FFFFFF";
	
	flag = 1;
}
function brandHide1(){
	flag = 0;
	document.getElementById("brandDiv1").style.display="none";
	
	document.getElementById("tdbrand_2").style.backgroundColor = "#EFFFE1";
	document.getElementById("tdbrand_2").style.color = "#000000";
	//document.getElementById("spanbrand_1").style.backgroundColor = "#EFFFE1";
	//document.getElementById("spanbrand_1").style.color = "#000000";
	
	//document.getElementById("imgBrand").src=gizmineImagePath+"dropdown.gif";
	ajaxCallForMenuStateRemove("brand");
}
function brandChangeColor()
{
	document.getElementById("tdbrand_2").style.backgroundColor = "#41AD49";
	document.getElementById("tdbrand_2").style.color = "#FFFFFF";
	//document.getElementById("spanbrand_1").style.backgroundColor = "#41AD49";
	//document.getElementById("spanbrand_1").style.color = "#FFFFFF";
}
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){
	//alert(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="";
	}
	//alert(email);
	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);
}

//To show and hide image border in listing page
function showImageBorder(indexValue)
{
	//document.getElementById("imageTable"+indexValue).style.borderWidth='2px';
//	alert(document.getElementById("imageTable_"+indexValue));
	document.getElementById("imageTable_"+indexValue).style.borderColor='#E91D8E';
	document.getElementById("imageTable1_"+indexValue).style.borderColor='#E91D8E';
//	alert(indexValue+"1");
}
function hideImageBorder(indexValue)
{
	//document.getElementById("imageTable"+indexValue).style.borderWidth='1px';
	document.getElementById("imageTable_"+indexValue).style.borderColor='#BDBDBE';
	document.getElementById("imageTable1_"+indexValue).style.borderColor='#FFFFFF';
}

//For Feature rotation functionality
var index = -1;
function setIndex() {
	//index = Math.floor(Math.random() * imagesDivArray.length);
}

function rotateImageDivs() {
	//flagRotateImage = 1;
	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(categoryID,categoryName, categoryCode){
	//brandHide1();
	document.getElementById("tdbrand_2").innerHTML = categoryName;
	document.getElementById("divSubCategory"+document.getElementById("hdnSelecteParentCategoryID").value).style.display="none";
	document.getElementById("hdnSelecteParentCategoryID").value = categoryID;
	document.getElementById("divSubCategory"+categoryID).style.display="block";
	if(AjaxToggle == 'true')
	   getIndexData('category=~'+categoryCode);
	else
	   window.location.href = urlAppender + "/category=~"+categoryCode+"/index.shtml";
}

function getColorList(color){
	document.getElementById("spanbrand_1").style.display = "none";
	document.getElementById("spanbrand_2").style.display = "block";
	document.getElementById("spanbrand_2").innerHTML = color;
	brandHide1();
	flag = 0;
}

function callProductPage(urlStr){
	if(BrowserDetect.browser=='Explorer') {
		window.location.href = urlStr;
	}
	else
	{
		return false;
	}
}