// Global variables declaration area
		
var xmlhttp='';
var result ='';
var client_productID ='';
var shipping_text='';
var arrProductFeatures='';

function AjaxInit(url,value)
{

	try
		{
			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;
			}
	  	}
	}
	if (value=='PRODUCT_DETAILS')
	{
	   // xmlhttp.onreadystatechange=FetchData
	}
	else if (value=='PAGINATION')
	{

		xmlhttp.onreadystatechange=FetchProductID
	}
//	else if ( value=='TECH_SPECS')
//	{
//	
//		xmlhttp.onreadystatechange=fetchTechSpecs
//	}
	else if ( value=='PRODUCT_VIDEOS')
	{
	
		xmlhttp.onreadystatechange=fetchproductVideo
	}
	
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
		
function changeTabTextColor1(id)
{
	if(document.getElementById(id).className == 'black_14px')
		document.getElementById(id).className = 'dynared_14px';
}
function changeTabTextColor2(id)
{
	if(document.getElementById(id).className == 'dynared_14px')
		document.getElementById(id).className = 'black_14px';
}
// managing tab data while moving from one tab to another	
function showData(id, cornerImgPath)
{
	document.getElementById('top_center_MAIN').bgColor = '#FFFFFF';
 	document.getElementById('top_left_corner_MAIN').src= cornerImgPath+'corner3x3_white.png'
 	document.getElementById('top_right_corner_MAIN').src= cornerImgPath+'corner3x3_white.png'
 	document.getElementById('td_middle_left_corner_MAIN').bgColor = '#FFFFFF';
 	document.getElementById('texttd_MAIN').bgColor = '#FFFFFF';
	document.getElementById('texttd_MAIN').className = 'black_14px';
 	document.getElementById('td_middle_right_corner_MAIN').bgColor = '#FFFFFF';
 	document.getElementById('td_bottom_MAIN').bgColor = '#FFFFFF';
 	
 	if(document.getElementById('TECHSPECS')!=null)
	{
		document.getElementById('top_center_TECHSPECS').bgColor = '#FFFFFF';
	 	document.getElementById('top_left_corner_TECHSPECS').src= cornerImgPath+'corner3x3_white.png'
	 	document.getElementById('top_right_corner_TECHSPECS').src= cornerImgPath+'corner3x3_white.png'
	 	document.getElementById('td_middle_left_corner_TECHSPECS').bgColor = '#FFFFFF';
	 	document.getElementById('texttd_TECHSPECS').bgColor = '#FFFFFF';
		document.getElementById('texttd_TECHSPECS').className = 'black_14px';
	 	document.getElementById('td_middle_right_corner_TECHSPECS').bgColor = '#FFFFFF';
	 	document.getElementById('td_bottom_TECHSPECS').bgColor = '#FFFFFF';
	}
 	
 	if(document.getElementById('VIDEOS')!=null)
	{
	 	document.getElementById('top_center_VIDEOS').bgColor = '#FFFFFF';
	 	document.getElementById('top_left_corner_VIDEOS').src= cornerImgPath+'corner3x3_white.png'
	 	document.getElementById('top_right_corner_VIDEOS').src= cornerImgPath+'corner3x3_white.png'
	 	document.getElementById('td_middle_left_corner_VIDEOS').bgColor = '#FFFFFF';
	 	document.getElementById('texttd_VIDEOS').bgColor = '#FFFFFF';
		document.getElementById('texttd_VIDEOS').className = 'black_14px';
	 	document.getElementById('td_middle_right_corner_VIDEOS').bgColor = '#FFFFFF';
	 	document.getElementById('td_bottom_VIDEOS').bgColor = '#FFFFFF';
	}
 	
	if(document.getElementById('ACCESSORIES')!=null)
	{
	 	document.getElementById('top_center_ACCESSORIES').bgColor = '#FFFFFF';
	 	document.getElementById('top_left_corner_ACCESSORIES').src= cornerImgPath+'corner3x3_white.png'
	 	document.getElementById('top_right_corner_ACCESSORIES').src= cornerImgPath+'corner3x3_white.png'
	 	document.getElementById('td_middle_left_corner_ACCESSORIES').bgColor = '#FFFFFF';
	 	document.getElementById('texttd_ACCESSORIES').bgColor = '#FFFFFF';
		document.getElementById('texttd_ACCESSORIES').className = 'black_14px';
	 	document.getElementById('td_middle_right_corner_ACCESSORIES').bgColor = '#FFFFFF';
	 	document.getElementById('td_bottom_ACCESSORIES').bgColor = '#FFFFFF';
	 }
	 
	 if(document.getElementById('FAQ')!=null)
	{
	 	document.getElementById('top_center_FAQ').bgColor = '#FFFFFF';
	 	document.getElementById('top_left_corner_FAQ').src= cornerImgPath+'corner3x3_white.png'
	 	document.getElementById('top_right_corner_FAQ').src= cornerImgPath+'corner3x3_white.png'
	 	document.getElementById('td_middle_left_corner_FAQ').bgColor = '#FFFFFF';
	 	document.getElementById('texttd_FAQ').bgColor = '#FFFFFF';
		document.getElementById('texttd_FAQ').className = 'black_14px';
	 	document.getElementById('td_middle_right_corner_FAQ').bgColor = '#FFFFFF';
	 	document.getElementById('td_bottom_FAQ').bgColor = '#FFFFFF';
	 }
	
	if (id == 'MAIN')
	{
   	  	document.getElementById('top_center_MAIN').bgColor = '#000000';
	 	document.getElementById('top_left_corner_MAIN').src= cornerImgPath+'corner3x3_TL.png'
	 	document.getElementById('top_right_corner_MAIN').src= cornerImgPath+'corner3x3_TR.png'
	 	document.getElementById('td_middle_left_corner_MAIN').bgColor = '#000000';
	 	document.getElementById('texttd_MAIN').bgColor = '#000000';
		document.getElementById('texttd_MAIN').className = 'white_14px';
	 	document.getElementById('td_middle_right_corner_MAIN').bgColor = '#000000';
	 	document.getElementById('td_bottom_MAIN').bgColor = '#000000';
   	  	
   	  	
   	  	document.getElementById('dvDescription').style.display = 'block';
	    document.getElementById('dvTechSpecs').style.display = 'none' ;  	
	    document.getElementById('dvVideos').style.display = 'none';
     	document.getElementById('dvAccessories').style.display = 'none';	   
		document.getElementById('dvFaq').style.display = 'none';
	}
	else if (id == 'TECHSPECS')
	{
	  	document.getElementById('top_center_TECHSPECS').bgColor = '#000000';
	 	document.getElementById('top_left_corner_TECHSPECS').src= cornerImgPath+'corner3x3_TL.png'
	 	document.getElementById('top_right_corner_TECHSPECS').src= cornerImgPath+'corner3x3_TR.png'
	 	document.getElementById('td_middle_left_corner_TECHSPECS').bgColor = '#000000';
	 	document.getElementById('texttd_TECHSPECS').bgColor = '#000000';
		document.getElementById('texttd_TECHSPECS').className = 'white_14px';
	 	document.getElementById('td_middle_right_corner_TECHSPECS').bgColor = '#000000';
	 	document.getElementById('td_bottom_TECHSPECS').bgColor = '#000000';
	  	
   	    document.getElementById('dvTechSpecs').style.display = 'block' ;
   	  	document.getElementById('dvDescription').style.display = 'none';
	   	document.getElementById('dvVideos').style.display = 'none';
	    document.getElementById('dvAccessories').style.display = 'none';	   	    
		document.getElementById('dvFaq').style.display = 'none';
	}
	else if(id == 'VIDEOS')
	{
   	    document.getElementById('top_center_VIDEOS').bgColor = '#000000';
	 	document.getElementById('top_left_corner_VIDEOS').src= cornerImgPath+'corner3x3_TL.png'
	 	document.getElementById('top_right_corner_VIDEOS').src= cornerImgPath+'corner3x3_TR.png'
	 	document.getElementById('td_middle_left_corner_VIDEOS').bgColor = '#000000';
	 	document.getElementById('texttd_VIDEOS').bgColor = '#000000';
		document.getElementById('texttd_VIDEOS').className = 'white_14px';
	 	document.getElementById('td_middle_right_corner_VIDEOS').bgColor = '#000000';
	 	document.getElementById('td_bottom_VIDEOS').bgColor = '#000000';
	  	
   	    document.getElementById('dvVideos').style.display = 'block';
	    document.getElementById('dvTechSpecs').style.display = 'none' ;  	
   	  	document.getElementById('dvDescription').style.display = 'none';
	    document.getElementById('dvAccessories').style.display = 'none';	   
	    document.getElementById('dvFaq').style.display = 'none';
	    
	}
	else if(id == 'ACCESSORIES')
	{
   	  	document.getElementById('top_center_ACCESSORIES').bgColor = '#000000';
	 	document.getElementById('top_left_corner_ACCESSORIES').src= cornerImgPath+'corner3x3_TL.png'
	 	document.getElementById('top_right_corner_ACCESSORIES').src= cornerImgPath+'corner3x3_TR.png'
	 	document.getElementById('td_middle_left_corner_ACCESSORIES').bgColor = '#000000';
	 	document.getElementById('texttd_ACCESSORIES').bgColor = '#000000';
		document.getElementById('texttd_ACCESSORIES').className = 'white_14px';
	 	document.getElementById('td_middle_right_corner_ACCESSORIES').bgColor = '#000000';
	 	document.getElementById('td_bottom_ACCESSORIES').bgColor = '#000000';
   	  	
   	  	document.getElementById('dvAccessories').style.display = 'block';	   
	    document.getElementById('dvVideos').style.display = 'none';
   	  	document.getElementById('dvTechSpecs').style.display = 'none' ;
   	  	document.getElementById('dvDescription').style.display = 'none';
	   	document.getElementById('dvFaq').style.display = 'none';
	} else if(id == 'FAQ')
	{
   	  	document.getElementById('top_center_FAQ').bgColor = '#000000';
	 	document.getElementById('top_left_corner_FAQ').src= cornerImgPath+'corner3x3_TL.png'
	 	document.getElementById('top_right_corner_FAQ').src= cornerImgPath+'corner3x3_TR.png'
	 	document.getElementById('td_middle_left_corner_FAQ').bgColor = '#000000';
	 	document.getElementById('texttd_FAQ').bgColor = '#000000';
		document.getElementById('texttd_FAQ').className = 'white_14px';
	 	document.getElementById('td_middle_right_corner_FAQ').bgColor = '#000000';
	 	document.getElementById('td_bottom_FAQ').bgColor = '#000000';
   	 	
   	 	document.getElementById('dvAccessories').style.display = 'none';	   
	    document.getElementById('dvVideos').style.display = 'none';
   	  	document.getElementById('dvTechSpecs').style.display = 'none' ;
   	  	document.getElementById('dvDescription').style.display = 'none';
	    document.getElementById('dvFaq').style.display = 'block';
	}
}
	  
function pagination(id,productID)
{
	var randomnumber=Math.random();
	var url='';
	if (id =='PREVOIUS')
	{
		url= urlAppender + '/fetchProductID.do?reqCode=getProductID&ProductID='+productID+'&RandomNumber='+randomnumber+'&MODE='+id;//dirPath+
	}
	else
	{
		url= urlAppender + '/fetchProductID.do?reqCode=getProductID&ProductID='+productID+'&RandomNumber='+randomnumber+'&MODE='+id;//dirPath+
	}
	AjaxInit(url,'PAGINATION');
}
	 
// get next prevoius product id with in same category
function FetchProductID()
{
	if(xmlhttp.readyState==4)
	{
		if (xmlhttp.status ==200)
		{
			if ( xmlhttp.responseText!="")
			{
				var URLCodeNameArr = xmlhttp.responseText;
				var Arr_URLCodeNameArr = URLCodeNameArr.split('~')
				window.location.href = Arr_URLCodeNameArr[0]+Arr_URLCodeNameArr[1]+'.shtml';
			}
		}
	}	
}

function showVideo()
{
	document.getElementById('trVideos').style.display= 'block';
}

function getAccessoriesItemsofProduct(productID, productName)
{
	var xmlHttp;
	var randomNum = Math.random();
	var url = '';
	if(BrowserDetect.browser=='Firefox' || BrowserDetect.browser=='Explorer'){
		url= urlAppender + '/getAccessoriesItem.action?ProductID='+productID+'&RNo='+randomNum;//dirPath+
	}
	else{
		url= urlAppender + '/getAccessoriesItem.action?ProductID='+productID+'&ProductName='+productName+'&RNo='+randomNum;//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)
			{	
				var accessories_result = xmlHttp.responseText;
				document.getElementById('trAccessories').style.display= 'block';
				document.getElementById('tdAccessories').style.display= 'block';
				document.getElementById('tdAccessories').innerHTML = accessories_result;
			}
		}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("ProductName", productName);
		xmlHttp.setRequestHeader("Content-type", "text/html; charset=UTF-8");
	xmlHttp.send(null);
}


var imageCount = 0;
var currentImagePosition=0;
function showImagePopupDiv(imageCount1)
{
	imageCount = imageCount1;
	if(imageCount != 0){
	
	var imagePath = document.getElementById("imageGallery"+currentImagePosition).src;
	document.getElementById("imageShowImg").src = imagePath;
	document.getElementById("overlay").style.display = "block";
//	var divHeight=document.getElementById("tableMainTop").offsetHeight;
  	 	//alert(divHeight);
//  	 	divHeight = divHeight + 120;
  	 	//alert(divHeight);
//  	document.getElementById("overlay").style.height = divHeight+'px';
	document.getElementById("dialogue_image").style.display = "block";
	
	findPos(document.getElementById("tdImagePosition"));
	document.getElementById('dialogue_image').style.left = curleft+45+'px';
	
	findPos(document.getElementById("tdImageDivAlignment"));
	
	document.getElementById("divImageArrowLeft").style.top = '75px';
	document.getElementById("divImageArrowLeft").style.left = curleft+10+'px';
	document.getElementById("divImageArrowRight").style.top = '75px';
	document.getElementById("divImageArrowRight").style.left= curleft+460+'px';
	document.getElementById("divImageArrowLeft").style.display = "block";
	document.getElementById("divImageArrowRight").style.display = "block";
	/* change overlay div size*/
	winW = document.body.offsetWidth;
	totalWidth = document.getElementById('tableMainTop').offsetWidth;
	if(winW > totalWidth) {
		document.getElementById('overlay').style.width = winW + "px";
	} else {
		document.getElementById('overlay').style.width = (totalWidth ) + "px";
	}
	var winH = document.getElementById('tableMain').offsetHeight;
	
	document.getElementById('overlay').style.height = winH + 120 + "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 closeEnlargeImageShow(){
	document.getElementById("dialogue_image").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()
{
	if(document.getElementById("divImageArrow1").style.display == 'none')
	{
		document.getElementById("divImageArrow1").style.top = '160px';
		document.getElementById("divImageArrow1").style.left = '20px';
		document.getElementById("divImageArrow1").style.display = "block";
	}
}
function hideArrowOnImage1()
{
	if(document.getElementById("divImageArrow1").style.display == 'block')
	{
		document.getElementById("divImageArrow1").style.display = "none";
	}
}
function showArrowOnImage2()
{
	if(document.getElementById("divImageArrow2").style.display == 'none')
	{
		document.getElementById("divImageArrow2").style.top = '160px';
		document.getElementById("divImageArrow2").style.left = '360px';
		document.getElementById("divImageArrow2").style.display = "block";
	}
}
function hideArrowOnImage2()
{
	if(document.getElementById("divImageArrow2").style.display == 'block')
	{
		document.getElementById("divImageArrow2").style.display = "none";
	}
}

function buttonmouseoverImage(obj)
{
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#000000";
}
function buttonmouseoutImage(obj)
{
	obj.style.backgroundColor="#000000";
	obj.style.color="#FFFFFF";
}
