/////////////////////////////////////////////////////////////////
//This will toggle the layer or do the opposite
function toggleLayer(whichLayer)
{

       //alert(whichLayer);
	if (document.getElementById)
	{
	   //alert("1");
	
	    // this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"inline";
//                style2.display = "inline";

	}
	else if (document.all)
		{
	//alert("2");

		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
                //style2.display = "inline";

	}
	else if (document.layers)
	{
//alert("3");

		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
                //style2.display = "inline";
	}
}//end toggleLayer(whichLayer)

//////////////////////////////////////////////////////
//this will show and individual layer
function showLayer(whichLayer)
{
	if (document.getElementById)
	{
	    // this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		//style2.display = style2.display? "":"inline";
        style2.display = "inline";
	}
	else if (document.all)
		{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "block";
	}
}//end showLayer(whichLayer)
/////////////////////////////////////////////
//this will hide an individual layer
function hideLayer(whichLayer)
{
	if (document.getElementById)
	{
	    // this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		//style2.display = style2.display? "":"inline";
		style2.display = "";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "";
	}
}//end hideLayer(whichLayer)
/////////////////////////////////////////////
//this will hide all layers
function hideAllLayers()
{
	//hideLayer('otherPricesId');
	hideLayer('accessoriesId');
	hideLayer('kitsPackagesId');
	hideLayer('descriptionId');
	hideLayer('rebatesId');
	hideLayer('kitDetailsId');
	hideLayer('wibId');
	hideLayer('productReviewsId');
	hideLayer('answersId');
	
}//end hideAllLayers()
/////////////////////////////////////////////
//show one layer and hide the rest of them
function showOneLayerOnly(whichLayer)
{
	hideAllLayers();
	showLayer(whichLayer);
}//end hideAllLayers()
/////////////////////////////////////////////
function render(imgName,path,img) 
{
	//	 This routine changes the SRC of one image for another
	//   imgName - the NAME="" value of the desired <IMG> tag
	//   path - the relative, or absolute, path to the desired image
	//   img - the actual filename of the images
	
	// tests to see if the browser supports the image object (swapping ability)
	if (document.images) 
	{
        if (typeof(document[imgName])=='object')
        {
        		document[imgName].src = path + img;
        		//document[imgName].src = path + img + ".gif"		
        }
	}
}
////////////////////////////////////////////////
function turnOffAllImages(path)
{
	render("msp_tab",path,"msp_tab.jpg"); 
	render("om_tab",path,"om_tab.jpg"); 
	render("acc_tab",path,"acc_tab.jpg"); 
	render("pd_tab",path,"pd_tab.jpg"); 
	render("wib_tab",path,"wib_tab.jpg"); 	
	render("rebate_tab",path,"rebate_tab.jpg");
	render("kitDetails_tab",path,"kitDetails_tab.jpg");
	render("productReviews_tab",path,"productReviews_tab.jpg");
	render("answers_tab",path,"answers_tab.jpg");

}
///////////////////////////////
function showImage(imgName,path,img)
{
    //alert("path = " + path);
    
	//turn off all the images before showing the one we want
	turnOffAllImages(path);	
	//show this image
	render(imgName,path,img); 
}
//////////////////////////////////////////////////////
//this will move a layer
function moveLayer(whichLayer,top,left)
{
	if (document.getElementById)
	{
	   	//alert("1");
	    // this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		//style2.display = style2.display? "":"inline";
        //style2.display = "inline";
		style2.top = top;
		style2.left = left;
	}
	else if (document.all)
		{
	   	//alert("2");
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "block";
		style2.top = top;
		style2.left = left;

	}
	else if (document.layers)
	{
		//alert("3");
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "block";
		style2.top = top;
		style2.left = left;

	}
}//end showLayer(whichLayer)

///////////////////////////////////////////////////
////This is used for Verify By Visa layers   //////
///////////////////////////////////////////////////
/////////////////////////////////////////////
//this will hide all layers
function hideAllVbvLayers()
{
	//hideLayer('otherPricesId');
	hideLayer('masterCardId');
	hideLayer('visaId');
	hideLayer('vbvTextId');
}//end hideAllLayers()
/////////////////////////////////////////////
//show one layer and hide the rest of them
function showOneVbvLayerOnly(whichLayer)
{
    
	hideAllVbvLayers();
	showLayer(whichLayer);
	showLayer("vbvTextId");//always show the verify by Visa text
}//end hideAllLayers()
/////////////////////////////////////////////
function getCeditCardType(pan)
{
        var cardType="";
        //4000000000000002
        //alert("pan = " + pan.length);
        //alert("start  = " + pan.substr(0,1));
        
		if (pan.length == 16 && pan.substr(0,1)=="4") 
		{
			cardType = "CARD_TYPE_VISA";
		} 
		else if (pan.length == 13 && pan.substr(0,1)=="5") 
		{
			cardType = "CARD_TYPE_MC";
		} 
		else if (pan.length == 16 && pan.substr(0,1)=="5") 
		{
			cardType = "CARD_TYPE_MC";
		} 
		else if (pan.length == 15 && pan.substr(0,4)=="2131") {
			cardType = "CARD_TYPE_JCB";
		} else if (pan.length == 15 && pan.substr(0,4)=="1800") {
			cardType = "CARD_TYPE_JCB";
		} else if (pan.length == 16 && pan.substr(0,1)=="3") {
			cardType = "CARD_TYPE_JCB";
		} else if (pan.length == 15 && pan.substr(0,2)=="34") {
			cardType = "CARD_TYPE_AMEX";
		} else if (pan.length == 15 && pan.substr(0,2)=="37") {
			cardType = "CARD_TYPE_AMEX";
		}

		return cardType;
}
/////////////////////////////////////////////////
function displayVbvInfo(cardObj)
{
  hideAllVbvLayers();
  //alert(cardObj.value);
  
  type =  getCeditCardType(cardObj.value)
  //alert("type = " + type);

  if(type == "CARD_TYPE_VISA" )
  {
	 showOneVbvLayerOnly("visaId")
  }
  else if(type == "CARD_TYPE_MC")
  {
	  showOneVbvLayerOnly("masterCardId")
  }
}
///////////////////////////////////////////////