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 Remove the Description From Left Side On MouseOut---------------------------//

//--------------------------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+180;//+11
	}
	else if(BrowserDetect.browser=='Firefox')
	{
		document.getElementById("emptyCartDiv").style.top = curtop+19;
		document.getElementById("emptyCartDiv").style.left = curleft+181;//+12
	}
	else{
		document.getElementById("emptyCartDiv").style.top = curtop+16;
		document.getElementById("emptyCartDiv").style.left = curleft+181;//+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;
	if(imageCount != 0){
	//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";
	}
	
	findPos(document.getElementById("tdsmallnextprev"));
	curleft = curleft-175;
	document.getElementById("divsmallnextprev").style.left= curleft+'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 = '130px';
		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 = '130px';
		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="#2E1E1C";
}
function buttonmouseout(obj)
{
	obj.style.backgroundColor="#E6E4E3";//142A6A  #2E1E1C
	obj.style.color="#2E1E1C";
}
function buttonmouseoverImage(obj)
{
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#293D82";
}
function buttonmouseoutImage(obj)
{
	obj.style.backgroundColor="#293D82";
	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 Showing ADD to Cart Functionality----------------------//

function addToCart(productID,productSKU, checkoutlink){
	checkoutlink = '<span  style="white-space: nowrap;">'+checkoutlink+'</span>';
	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 skuName = document.getElementById("skuNametd"+productSKU).value;
				document.getElementById(productSKU+"ID").innerHTML = quantity+" "+skuName+document.getElementById("messageofcarthidden").value+" "+checkoutlink;
//				document.getElementById(productSKU+"ID").innerHTML = quantity+" "+document.getElementById("messageofcarthidden").value+"<br>"+checkoutlink;
				shoppingPopupFlag = true;
			}
		}	
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}

function addToCartCloseout(productID, productSKU, checkoutlink){
	checkoutlink = '<span  style="white-space: nowrap;">'+checkoutlink+'</span>';
	var randomNumber=Math.random();
	var quantity = document.getElementById("txtQuantity"+productSKU+"-"+productID).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 skuName = document.getElementById("skuNametd"+productSKU+"-"+productID).innerHTML;
				document.getElementById(productSKU+"-"+productID+"ID").innerHTML = quantity+" "+skuName+document.getElementById("messageofcarthidden").value+"<br>"+checkoutlink;
				shoppingPopupFlag = true;
			}
		}	
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}
//-----------------------Function Showing ADD to Cart Functionality In Related item ----------------------//

function addToCartRelatedItem(productID,productSKU, checkoutlink){
	
	checkoutlink = '<span  style="white-space: nowrap;">'+checkoutlink+'</span>';
	var randomNumber=Math.random();
	var quantity = document.getElementById("txtQuantityRelatedItem"+productSKU+"-"+productID).value;
	
	document.getElementById("spanTextQuantityError1RelatedItem").style.display = "none";
	document.getElementById("spanTextQuantityError2RelatedItem").style.display = "none";
	
	if(quantity==null || quantity=="" ){
		document.getElementById("spanTextQuantityError1RelatedItem").style.display = "block";
		document.getElementById("spanTextQuantityError2RelatedItem").style.display = "none";
		return false;
	}
	if(isNaN(quantity))
	{
		document.getElementById("spanTextQuantityError1RelatedItem").style.display = "none";
		document.getElementById("spanTextQuantityError2RelatedItem").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 skuName = document.getElementById("skuNametdRelatedItem"+productSKU+"-"+productID).value;
				document.getElementById(productSKU+"-"+productID+"ID").innerHTML = quantity+" "+skuName+document.getElementById("messageofcarthiddenRelatedItem").value+" "+checkoutlink;

				shoppingPopupFlag = true;
			}
		}	
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
}
//---------------------------Function To update shopping cart (to remove 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 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 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 subscribeCustomer()
{
	var xmlHttp;
//	var newsletterType="daily";
	var email = document.getElementById("txtEmail").value;
//	var subscribedForWebsite = 'Gizmine';
	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
	{
		var randomNumber=Math.random();
		var url= urlAppender + '/subscriber.action?email='+email+'&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)
				{	
				//	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.borderColor='#2E1E1C';//E91D8E
	document.getElementById("imageTable1_"+indexValue).style.borderColor='#2E1E1C';
}
function hideImageBorder(indexValue)
{
	document.getElementById("imageTable_"+indexValue).style.borderColor='#FFFFFF';
	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 callProductPage(urlStr){
	if(BrowserDetect.browser=='Explorer') {
		window.location.href = urlStr;
	}
	else
	{
		return false;
	}
}
function openwindow(pagelike)
{
	var wHnd = window.open(pagelike, "", "height=400,width=535,menubar=no,resizable=yes,titlebar=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,directories=no")
}
function hideTwitterCampaignPage()
{
	document.getElementById("overlay").style.display = "block";
	document.getElementById("divDisableTwitterPage").style.display = "block";
	findPos(document.getElementById("tableMainTwitterPage"));
	document.getElementById('overlay').style.left = curleft-10;
	document.getElementById('overlay').style.top = curtop-10;
	document.getElementById('divDisableTwitterPage').style.left = curleft+20;
	document.getElementById('divDisableTwitterPage').style.top = curtop+150;
	var winH = document.getElementById('tableMainTwitterPage').offsetHeight;
	document.getElementById('overlay').style.height = (winH+20) + "px";
	document.getElementById('overlay').style.width = '725px';
}
function hideTwitterCampaignPage_remove()
{
	document.getElementById("overlay").style.display = "none";
	if(document.getElementById('divDisableTwitterPage') != null)
		document.getElementById("divDisableTwitterPage").style.display = "none";
}