var urlAppender = '';
var shoppingPopupFlag = true;
var curleft = curtop = 0;
var tempX = 0;
var tempY = 0;
var imagePath;

//To show wait image in ajax call
function showWaitImage()
{
	document.getElementById("divAjaxCall").style.display = "block";
	window.scroll(0,0);
}
function showWaitImageWithoutScrool()
{
	document.getElementById("divAjaxCall").style.display = "block";
}
//To remove wait image after ajax call
function hideWaitImage()
{
	document.getElementById("divAjaxCall").style.display = "none";
}
function showPopUp(divHeight)
{
	document.getElementById("dialogue").style.display = "";
	document.getElementById("overlay").style.display = "";
	document.getElementById("overlay").style.height = divHeight+'px';
}
function hidePopUp()
{
	document.getElementById("dialogue").style.display = "none";
	document.getElementById("overlay").style.display = "none";
}
function showProcessingPopUp(divHeight,topPosition)
{
	window.scroll(0,0);
	document.getElementById("dialogue").style.display = "";
	document.getElementById("overlay").style.display = "";
	document.getElementById("overlay").style.height = divHeight+'px';
	document.getElementById("divProcessingPopUp").style.display = "block";
	document.getElementById("divProcessingPopUp").style.top = topPosition + 'px';
	var divWidth = document.body.clientWidth;
	var elementWidth = document.getElementById("divProcessingPopUpMsg").offsetWidth;
	divWidth = (divWidth / 2) - (elementWidth/2);
	document.getElementById("divProcessingPopUp").style.left= divWidth + 'px';
}
function hideProcessingPopUp()
{
	document.getElementById("dialogue").style.display = "none";
	document.getElementById("overlay").style.display = "none";
	document.getElementById("divProcessingPopUp").style.display = "none";
}

//To get psition of object
function findPos(obj) {
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}
/************************************************************************
    
    Method Name:       validateEmail()
    Purpose:           FUNCTION TO VALIDATE EMAIL ADDRESS
    Input Parameters:  EMAIL ADDRESS
    Output Parameters: TRUE/ FALSE
************************************************************************/
function validateEmail(strValue) 
{
	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;
	}			
}
//Methods for button mouse over effect
function buttonmouseover_general(obj)
{
	obj.style.backgroundColor="#B92025";
	obj.style.color="#FFFFFF";
}
function buttonmouseout_general(obj)
{
	obj.style.backgroundColor="#000000";
	obj.style.color="#FFFFFF";
}
function buttonmouseover(obj)
{
	obj.style.backgroundColor="#B92025";
	obj.style.color="#FFFFFF";
}
function buttonmouseout(obj)
{
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#000000";
}
function buttonmouseover1(obj)
{
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#000000";
}
function buttonmouseout1(obj)
{
	obj.style.backgroundColor="#000000";
	obj.style.color="#FFFFFF";
}
function buttonmouseoverProductDetail(obj)
{
	obj.style.backgroundColor="#ECF4FF";
	obj.style.color="#000000";
}
function buttonmouseoutProductDetail(obj)
{
	obj.style.backgroundColor="#797979";
	obj.style.color="#FFFFFF";
}

//To get hidden data (to create product detail pop-ups in top & left menu)
function getHiddenFieldsForMenu() {
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/getHiddenFieldsForMenu.action?RandomNumber='+randomNumber;
	try {
		xmlHttp=new XMLHttpRequest();
	} catch (e) {		
		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('divHiddenValues').innerHTML = xmlHttp.responseText;
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
//To hide pop-up from left menu
function hidePopupDiv() {
	document.getElementById("divProductDetail").style.display = "none";
}
//To show pop-up from left menu
function showPopupDiv(categoryValue, productUrlCode_1, rightMenu, topCategoryValue) {
	var productSelected;
	if(rightMenu) {
		findPos(document.getElementById('lmenu_'+productUrlCode_1));
		document.getElementById("divProductDetail").style.top=(curtop+3)+'px';
		document.getElementById("divProductDetail").style.left=(curleft+130)+'px';
		productSelected = document.getElementById('lmenu_'+productUrlCode_1).innerHTML;
		document.getElementById("divProductDetail").style.display="block";
		document.getElementById("divProductDetail").style.width=170+'px';
	} else {
		findPos(document.getElementById(productUrlCode_1));
		document.getElementById("divProductDetail").style.top=(curtop-6)+'px';
		document.getElementById("divProductDetail").style.left=(curleft+169)+'px';
		productSelected = document.getElementById(productUrlCode_1).innerHTML;
		document.getElementById("divProductDetail").style.display="block";
		document.getElementById("divProductDetail").style.width=170+'px';
	}
		
	var textToBeDisplayed = '';
	var productInformation = '';
	var valueOfCategory =  document.getElementById('hidden_'+categoryValue).value;
	var productsArray = valueOfCategory.split('|');
	for(i = 0; i < productsArray.length; i++) {
		var particularProduct = productsArray[i].split('~');
		if(particularProduct[0] == productUrlCode_1) {
			productInformation = particularProduct[1];
			break;
		}
	}
	var borderColor = '#B92025';
	if(rightMenu) {
		borderColor = '#B92025';
	}
	var textToBeDisplayed = '<table cellspacing=0 cellpadding=0 bgcolor=\"#FFFFFF"\ style=\"border: 2px; border-color:'+borderColor+';border-style: solid;\">'+
							'<tr><td style=\"padding:10px\">'+
							'<table cellspacing=0 cellpadding=0 bgcolor=\"#FFFFFF\"><tr> ';
	textToBeDisplayed = textToBeDisplayed + '<td bordercolor=blue width=\"150px\" height=\"70px\" bgcolor=\"#FFFFFF\" align=\"center\">'+
											' <img height=\"70px\" src=\"'+imagepath+'product/'+productUrlCode_1+'_sm.jpg\" align=\"middle\"></td></tr>';
	textToBeDisplayed = textToBeDisplayed + '<tr><td height=\"5px\"></td></tr><tr><td bordercolor=red valign=\"top\" class=\"mouseove_10px\">'+productInformation+'</td>';
	textToBeDisplayed = textToBeDisplayed + '</tr> </table></td></tr></table>';
	 document.getElementById("divProductDetail").innerHTML = textToBeDisplayed;
}
//To show product detail at top-menu
function showPopupDivTopMenu(categoryValue, productUrlCode_1) { 
	var productSelected;
//	alert('showPopupDivTopMenu:- categoryValue: '+categoryValue+' productUrlCode_1: '+productUrlCode_1);
	if(categoryValue=='gadgets_gizmine')
		categoryValue = 269;
	document.getElementById("divProductDetail_"+categoryValue).style.display="block";

	var textToBeDisplayed = '';
	var productInformation = '';
//	alert(document.getElementById('hidden_'+categoryValue));
	var valueOfCategory =  document.getElementById('hidden_'+categoryValue).value;
	
	var productsArray = valueOfCategory.split('|');
	for(i = 0; i < productsArray.length; i++) {
		var particularProduct = productsArray[i].split('~');
		if(particularProduct[0] == productUrlCode_1) {
			productInformation = particularProduct[1];
			break;
		}
	}
//	alert(productInformation);
	var borderColor = '#BEBEBE';
	var textToBeDisplayed = "";
	if(productUrlCode_1 != ''){
		textToBeDisplayed = textToBeDisplayed + '<table id=\"tableProductDiscription'+categoryValue+'\" cellspacing=0 cellpadding=0 border=\"0\" bgcolor=\"#FFFFFF"\ width=\"100%\" >';
		textToBeDisplayed =	textToBeDisplayed + '<tr><td valign=\"top\"><table border=0 cellspacing=\"5px\" bgcolor=\"#FFFFFF\" width=\"100%\">';
		textToBeDisplayed =	textToBeDisplayed + '<tr><td bordercolor=blue valign=\"top\" style=\"padding-left:5px; padding-right:5px;\" height=\"70px\" align=\"center\">'
											  +	'<table cellspacing=0 cellpadding=0><tr><td width=\"70px\">'
											//  +'<object data=\"'+imagepath+'loading.gif\">' 
											  +'<img style=\" background-image: url('+imagepath+'loading_topmenu.gif);background-repeat: no-repeat;background-position: center;\" align=\"center\" height=\"70px\" src=\"'+imagepath+'product/'+productUrlCode_1+'_sm.jpg\">'
											 // +'</object>'
											  +'</td></tr></table></td></tr>';
		textToBeDisplayed =	textToBeDisplayed + '<tr height=\"70px\"> ';
		textToBeDisplayed = textToBeDisplayed + '<td bordercolor=red valign=\"top\" style=\"padding-left:5px; padding-right:5px;\" class=\"black_12px\" height=\"70px\">'+productInformation+'</td>';
		textToBeDisplayed = textToBeDisplayed + '</tr> </table></td></tr></table>';
	} else {
		textToBeDisplayed = textToBeDisplayed + '<table id=\"tableProductDiscription'+categoryValue+'\" cellspacing=0 cellpadding=0 border=\"0\" bgcolor=\"#FFFFFF"\ height=\"140px\"  width=\"100%\" >';
		textToBeDisplayed = textToBeDisplayed + '<tr><td height=\"140px\"></td></tr>';
		textToBeDisplayed = textToBeDisplayed + '</table>';	
	}
	if(categoryValue==269)
		categoryValue = 'gadgets'
	document.getElementById("divProductDetail_"+categoryValue).innerHTML = textToBeDisplayed;
	
}
//To show error popup
function showMessagePopUp(popupDivID,id,hndID){
	document.getElementById(popupDivID).style.display = 'none';
	findPos(document.getElementById(id));
	
	var divWidth = document.getElementById(id).offsetWidth;
	document.getElementById(popupDivID).style.width = '251px';//divWidth;
	document.getElementById(popupDivID).style.display = 'block';
	document.getElementById('innerDiv_NewsletterMsg').innerHTML = document.getElementById(hndID).value;
	var divHeight = document.getElementById(popupDivID).offsetHeight;
	var topPos = curtop;
	topPos = topPos - divHeight;
	curleft = curleft + (divWidth/2) -125;
	document.getElementById(popupDivID).style.top = topPos +'px';
	document.getElementById(popupDivID).style.left= curleft+'px';
}
//To hide error popup
function hideMessagePopUp(popupDivID){
	document.getElementById(popupDivID).style.display = 'none';
	
}



function compareProducts(size)
{
	var ctrl = "chk";
	var id ="";
	var arrProductID = new Array();
	var strProductID='';
	var flag = false;
	for ( var i =0; i< size ;i++)
	{
	 	ctrl = "chk"+i;
	 	if (document.getElementById(ctrl).checked ==true)
	 	{
	 		if ( size >1)
	 		{
	 			id += document.getElementById(ctrl).value +",";
	 		
	 		}
	 		else
	 		{
	 			id = document.getElementById(ctrl).value ;
	 		}
	 		flag=true;
	 		
	 	}
	}
	
	strProductID = id;
	if (flag==true)
	{
		arrProductID = strProductID.split(',');
		if(arrProductID.length==2 )
		{	
			document.all('divErrorMessage').style.display='block';
			document.all('tdErrorMessage').innerHTML = document.getElementById('hidden_atleast_two_products').value;
			return false;
		}
		else if (arrProductID.length>4)
		{
			document.all('divErrorMessage').style.display='block';
			document.all('tdErrorMessage').innerHTML = document.getElementById('hidden_more_than_three').value;
			return false;
		}
		document.all('divErrorMessage').style.display='none';
		window.location.href = strSiteUrl + urlAppender +'/'+id+'/comparison.shtml';
	}
}

function removeCompareProducts(id)
{
	
	var arrProductID = new Array();
	var strProductID='';
		
	window.location.href = strSiteUrl + urlAppender +'/'+id+'/comparison.shtml';
	
	var ctrl = "chk";
	var id ="";
	var arrProductID = new Array();
	var strProductID='';
	var flag = false;
	for ( var i =0; i< size ;i++)
	{
	 	ctrl = "chk"+i;
	 	if (document.getElementById(ctrl).checked ==true)
	 	{
	 		if ( size >1)
	 		{
	 			id += document.getElementById(ctrl).value +",";
	 		
	 		}
	 		else
	 		{
	 			id = document.getElementById(ctrl).value ;
	 		}
	 		flag=true;
	 		
	 	}
	}
	
	strProductID = id;
	if (flag==true)
	{
		arrProductID = strProductID.split(',');
		if( arrProductID.length==2 )
		{
			document.all('trAlertMessage').style.display='block';
			document.all('lblAlertMessage').innerHTML = document.getElementById('hidden_atleast_two_products').value;
			return false;
		}
		else if (arrProductID.length>4)
		{
			document.all('trAlertMessage').style.display='block';
			document.all('lblAlertMessage').innerHTML = document.getElementById('hidden_more_than_three').value;
			return false;
		}
		document.all('trAlertMessage').style.display='none';
		window.location.href = strSiteUrl + urlAppender +'/'+id+'/comparison.shtml';
	}
}

//To subscribe user for newsletter
function subscribeCustomer(methodType, popupDivID, id)
{  
	var xmlHttp;
	if(methodType == 'Footer'){
	var email = document.all('txtEmailFooter').value;
	} else {
	var email = document.all('txtEmailNewsletter').value;
	}
	var subscribedForDailyNewsLetter = "N";
	
	if(!validateEmail(email))
	{
		if(methodType == 'Footer'){	
			showMessagePopUp(popupDivID,id,'hnd_txtEmailFooter_validemail');
			document.getElementById("txtEmailFooter").className = 'textfield_normal_blue'
		}else{
			showMessagePopUpNewsletter('div_Error_popup_newsletter','txtEmailNewsletter','hdn_txtEmailNewsletter_validemail');
			document.getElementById("txtEmailNewsletter").className = 'textfield_normal_blue'
		}
		return false;
	}
	var randomNumber=Math.random();
	var url= "";
	var url= urlAppender + '/subscriber.action?email='+email+'&subscribedForDailyNewsLetter='+subscribedForDailyNewsLetter+'&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)
			{	
				if(methodType == 'Footer'){
					findPos(document.getElementById(id));
					var divWidth = document.getElementById(id).offsetWidth;
					document.getElementById(popupDivID).style.width = '251';
					document.getElementById(popupDivID).style.display = 'block';
					document.getElementById('innerDiv_NewsletterMsg').innerHTML = xmlHttp.responseText;
					var divHeight = document.getElementById(popupDivID).offsetHeight;
					var topPos = curtop;
					topPos = topPos - divHeight;
					curleft = curleft + (divWidth/2) - 125;
					document.getElementById(popupDivID).style.top = topPos +'px';
					document.getElementById(popupDivID).style.left= curleft+'px';
				} else {
					findPos(document.getElementById(id));
					var divWidth = document.getElementById(id).offsetWidth;
					document.getElementById(popupDivID).style.width = '251px';
					document.getElementById(popupDivID).style.display = 'block';
					document.getElementById('innerDiv_NewsletterMsg').innerHTML = xmlHttp.responseText;
					var divHeight = document.getElementById(popupDivID).offsetHeight;
					var topPos = curtop;
					topPos = topPos - divHeight;
					curleft = curleft + (divWidth/2) - 125;
					document.getElementById(popupDivID).style.top = topPos +'px';
					document.getElementById(popupDivID).style.left= curleft+'px';
				}
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function removesubscribeCustomerPopup(){
	document.all('divNewsletterMsg').style.display = 'none';
}
/* form submit on enter key */
function validateKeyCodeNewsletter(methodType)
{	
	if(BrowserDetect.browser=='Firefox'){
	if(document.implementation.createDocument) {
		document.onkeyup = function alertkey(e)
							{
								if(e.which==13){
									subscribeCustomer("TopMenu");
									return false;
							 	}		
							};
	 }	
	} else {
		if((event.charCode != null && event.charCode == 13)  || (event.keyCode != null && event.keyCode == 13 )){
			  subscribeCustomer("TopMenu");
			return false;
		}	
	}

}
/* form submit on enter key */
function  validateKeyCodeNewsletterRightLink()
{	
	if(BrowserDetect.browser=='Firefox'){
	if(document.implementation.createDocument) {
		document.onkeyup = function alertkey(e)
							{
								if(e.which==13){
									subscribeCustomer("Right");
									return false;
							 	}		
							};
	 }	
	} else {
		if((event.charCode != null && event.charCode == 13)  || (event.keyCode != null && event.keyCode == 13 )){
			  subscribeCustomer("Right");
			return false;
		}	
	}
}
function getAccessoriesItems(productData, categoryID)
{
	var xmlHttp;
	if(productData != 'mainCategory')
	{
		productDataArr = productData.split('~');
		var productID = productDataArr[0];
		var productName = productDataArr[1];
		var randomNum = Math.random();
		var url='';
		if(BrowserDetect.browser=='Firefox' || BrowserDetect.browser=='Explorer'){
			url= urlAppender + '/getAccessoriesItem.action?ProductID='+productID+'&RandomNumber='+randomNum;//dirPath+
		}
		else
		{
			url= urlAppender + '/getAccessoriesItem.action?ProductID='+productID+'&ProductName='+productName+'&RandomNumber='+randomNum;//dirPath+
		}	
		showWaitImage();
		try
			{
			//Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
			}
		catch (e)
			{		
			//Internate Explorer
			try
			  {
			  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			  }
			catch (e)
				{
				try
			 	{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			 	}
				catch (e)
				{
				alert("Your browser does not support AJAX!");
				return false;
				}
		  	}
		}
		xmlHttp.onreadystatechange=function()
		{
	  	if(xmlHttp.readyState==4)
			{
			if (xmlHttp.status ==200)
				{	
					
					
					document.getElementById('dvCategoryPage').innerHTML  = xmlHttp.responseText;
					hideWaitImage();
				}
			}
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("ProductName", productName);
		xmlHttp.setRequestHeader("Content-type", "text/html; charset=UTF-8");
		
		xmlHttp.send(null);
	}	
}


//To show shopping-cart pop-up
function getShoppingPopup(){
	findPos(document.getElementById("shoppingCartMenu"));
	var xmlHttp;
	
	var randomNumber = Math.random();
	var url= urlAppender + '/shoppingcartpopup.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("shoppingCartPopupDiv").innerHTML = xmlHttp.responseText;
				document.getElementById("shoppingCartPopupDiv").style.top = curtop+13;
				document.getElementById("shoppingCartPopupDiv").style.left = curleft-252;
				document.getElementById("shoppingCartPopupDiv").style.display = "block";
				shoppingPopupFlag = false;
			}
		}
	}
	if(shoppingPopupFlag == true)
	{
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);
	}
	else
	{
		document.getElementById("shoppingCartPopupDiv").style.top = curtop+13;
		document.getElementById("shoppingCartPopupDiv").style.left = curleft-252;
		document.getElementById("shoppingCartPopupDiv").style.display = "block";
	}
}
//To hide shopping-cart pop-up
function removeShoppingCart(){
	document.getElementById("shoppingCartPopupDiv").style.display = "none";
}

function openGizmineProduct(categoryCode, productCode)
{
	window.open('http://www.gizmine.com/'+categoryCode+'/'+productCode+'.shtml','Gizmine')
}

function showGizmineProduct()
{
	var xmlHttp;
	var randomNumber=Math.random();
	var url= urlAppender + '/gizmineProductPage.do?RandomNumber='+randomNumber
	showWaitImage();
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
				document.all('dvMain').style.display='none';
				document.all('dvProductMain').style.display ='block';
				document.all('dvProductCenter').style.display = 'block';
				document.all('dvLeftMenu').style.display = 'block';
				document.all('dvProductCenter').innerHTML = xmlHttp.responseText;
				document.all('dvLeftMenu').innerHTML = '';
				document.title = 'Dynamism - Gizmine Top 20 products';
				hideWaitImage();
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
//To change version image on mouse over
function chnageVersionImg2(obj)
{
//	obj.src = imgName;
	obj.className = "flag_style2";
}
function chnageVersionImg1(obj)
{
//	obj.src = imgName;
	obj.className = "flag_style1";
}
//To change version image (US) on mouse over
function changeUSVersionImg(flagCallType, imgName)
{
	if(flagCallType==1)
	{
		document.all('uslinkimage1').src = imgName;
		document.all('uslinkimage').className = "flag_style1";
	}
	else
	{
		document.all('uslinkimage1').src = imgName;
		document.all('uslinkimage').className = "flag_style2";
	}
}

//To show image border in listing page
function showImageBorder(indexValue)
{
	document.getElementById("imageTable_"+indexValue).style.borderColor='#B92025';
	document.getElementById("imageTable1_"+indexValue).style.borderColor='#B92025';
}
//To hide image border in listing page
function hideImageBorder(indexValue)
{
	document.getElementById("imageTable_"+indexValue).style.borderColor='#BDBDBE';
	document.getElementById("imageTable1_"+indexValue).style.borderColor='#FFFFFF';
}
//To hide image border in Category page
function hideImageBorderCategoryPage(indexValue,chkID)
{
	if(document.getElementById("chk"+chkID) != null && document.getElementById("chk"+chkID).checked == true){
	
	} else {
		document.getElementById("imageTable_"+indexValue).style.borderColor='#BDBDBE';
		document.getElementById("imageTable1_"+indexValue).style.borderColor='#FFFFFF';
	}
}
//To show hide image border in Category page @checked and unchecked on checkbox
function toggleImageBorder(indexValue,chkID)
{

	if(document.getElementById("chk"+chkID).checked == true){
		showImageBorder(indexValue);
	} else {
		document.getElementById("imageTable_"+indexValue).style.borderColor='#BDBDBE';
		document.getElementById("imageTable1_"+indexValue).style.borderColor='#FFFFFF';
	}
}
//To call product page
function callProductPage(urlStr){
	if(BrowserDetect.browser=='Explorer') {
		window.location.href = urlStr;
	}
	else
	{
		return false;
	}
}

function changeCompareRemoveImage(id,imageName){
	document.getElementById(id).src= imageName;
}

function showVersionOption()
{
	var divTop = document.body.clientHeight;
	var divWidth = document.body.clientWidth;
	divTop = (divTop / 2 ) - 72 ;
	divWidth = (divWidth / 2) - 145;
	document.getElementById("div_VERSIONPOPUP").style.display = "block";
	document.getElementById("div_VERSIONPOPUP").style.left= divWidth + 'px';
	document.getElementById("div_VERSIONPOPUP").style.top= '200px';

	document.getElementById("div_CLOSEVERSIONPOPUP").style.display = "block";
	document.getElementById("div_CLOSEVERSIONPOPUP").style.left= (divWidth+270)+'px';
	document.getElementById("div_CLOSEVERSIONPOPUP").style.top= '200px';
	
	/* 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"; 
}
function closeVersionOption()
{
	document.getElementById("overlay").style.display = "none";
	document.getElementById("div_VERSIONPOPUP").style.display = "none";
	document.getElementById("div_CLOSEVERSIONPOPUP").style.display = "none";
}
function changeVersion(newURL)
{
	window.location.href = newURL;
	document.getElementById("div_VERSIONPOPUP").style.display = "none";
	document.getElementById("overlay").style.display = "none";
	document.getElementById("div_CLOSEVERSIONPOPUP").style.display = "none";
}

//To add Affilaite partner
function addAffiliatePartnerCode(strAffiliatePartnerCode)
{
	var xmlHttp;
	var randomNumber=Math.random();
	
	var url= urlAppender + '/addAffiliatePartnerCode.action?'+strAffiliatePartnerCode;//dirPath+
	showWaitImage();
	try
		{
		//Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
	catch (e)
		{		
		//Internate Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
			{
			try
		 	{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 	}
			catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
	  	}
	}
	xmlHttp.onreadystatechange=function()
	{
  	if(xmlHttp.readyState==4)
		{
		if (xmlHttp.status ==200)
			{	
			}
		}
	}
	xmlHttp.open("POST",url,true);//GET
	xmlHttp.send(null);
}
function backToTop(){
	window.scrollTo(0,0);
}
function txtBoxChangeFocus(obj){
	 var id = obj.id;
	 var textControlID = id.split("lab_");
	 if(!document.getElementById(textControlID[1]).disabled)
		document.getElementById(textControlID[1]).focus();	
}
function onClickForward(forwardURL){
	window.location.href = forwardURL;
}
function showTopErrorDiv(hdnObject)
{
	document.getElementById('divErrorMessage').style.display = "block";
	document.getElementById('tdErrorMessage').innerHTML = document.getElementById(hdnObject).value;
}
function hideTopErrorDiv()
{
	document.getElementById('divErrorMessage').style.display = "none";
	document.getElementById('tdErrorMessage').innerHTML = '';
}
function onLoadBlankTextBox(){
	var numberOfForms = document.forms.length;
	for(var i=0;i<numberOfForms;i++){
		for(var j=0; j< document.forms[i].elements.length; j++){
			if(document.forms[i].elements[j].type == 'text' && document.forms[i].elements[j].value != '')
			  if(document.getElementById("lab_"+document.forms[i].elements[j].id) != null )
			  	document.getElementById("lab_"+document.forms[i].elements[j].id).style.display = 'none';
			if(document.forms[i].elements[j].type == 'password' && document.forms[i].elements[j].value != '')
			  if(document.getElementById("lab_"+document.forms[i].elements[j].id) != null )
			  	document.getElementById("lab_"+document.forms[i].elements[j].id).style.display = 'none';  	
		}
	}
}
