// JScript File


function disp()
{
    document.getElementById('trthts').style.display = "block";
    document.getElementById('trdtls').style.display = "none";
}
function disp1()
{
    document.getElementById('trthts').style.display = "none";
    document.getElementById('trdtls').style.display = "block";
}
function Enable()
{
    document.getElementById('trInventoryDt1').style.display = "none";
    document.getElementById('trInventoryDt').style.display = "block";
    document.getElementById('btndtp').style.display = "block";
}

function FillAll(path)
{
    if(document.getElementById("chkAll").checked == true)
    {
		document.getElementById("txtSFName").value    	= document.getElementById("txtBFName").value
		document.getElementById("txtSLName").value    	= document.getElementById("txtBLName").value
		document.getElementById("txtSAddress").value 	= document.getElementById("txtBAddress").value
		document.getElementById("txtSCity").value    	= document.getElementById("txtBCity").value
		document.getElementById("txtSState").value   	= document.getElementById("txtBState").value
		document.getElementById("txtSZip").value 		= document.getElementById("txtBZip").value 
		document.getElementById("txtSEmail").value   	= document.getElementById("txtBEmail").value
		document.getElementById("txtSPhone").value   	= document.getElementById("txtBPhone").value
		document.getElementById("txtScountry").value   	= document.getElementById("txtBCountry").value
		document.getElementById("drpScountry").value   	= document.getElementById("drpBcountry").value
    
        document.getElementById("txtSFName").disabled		="disabled";  
        document.getElementById("txtSLName").disabled		="disabled"; 
        document.getElementById("txtSAddress").disabled		="disabled"; 
        document.getElementById("txtSCity").disabled		="disabled"; 
        document.getElementById("txtSState").disabled		="disabled"; 
        document.getElementById("txtSZip").disabled			="disabled"; 
        document.getElementById("txtSEmail").disabled		="disabled"; 
        document.getElementById("txtSPhone").disabled		="disabled"; 
        document.getElementById("txtScountry").disabled		="disabled"; 
        document.getElementById("drpScountry").disabled		="disabled"; 
       
    }
    else
    {
    
		document.getElementById("txtSFName").value    	= "";
		document.getElementById("txtSLName").value    	= "";
		document.getElementById("txtSAddress").value 	= "";
		document.getElementById("txtSCity").value    	= "";
		document.getElementById("txtSState").value   	= "";
		document.getElementById("txtSZip").value 		= "";
		document.getElementById("txtSEmail").value   	= "";
		document.getElementById("txtSPhone").value   	= "";
		document.getElementById("txtScountry").value   	= "";
		document.getElementById("drpScountry").value 	= "";
    
        document.getElementById("txtSFName").disabled 	= "";
        document.getElementById("txtSLName").disabled 	= "";
        document.getElementById("txtSAddress").disabled = "";
        document.getElementById("txtSCity").disabled 	= "";
        document.getElementById("txtSState").disabled 	= "";
        document.getElementById("txtSZip").disabled 	= "";
        document.getElementById("txtSEmail").disabled 	= "";
        document.getElementById("txtSPhone").disabled 	= "";
        document.getElementById("txtScountry").disabled = "";
        document.getElementById("drpScountry").disabled = "";
    
    }
      getExtraShipAmountPayPal(path,document.getElementById("txtSZip").value,document.getElementById("drpScountry").value)
}

function FillAll_Wire(path)
{
    if(document.getElementById("chkAll_wire").checked == true)
    {
		document.getElementById("txtSFName_w").value    	= document.getElementById("txtBFName_w").value
		document.getElementById("txtSLName_w").value    	= document.getElementById("txtBLName_w").value
		document.getElementById("txtSAddress_w").value 		= document.getElementById("txtBAddress_w").value
		document.getElementById("txtSCity_w").value    		= document.getElementById("txtBCity_w").value
		document.getElementById("txtSState_w").value   		= document.getElementById("txtBState_w").value
		document.getElementById("txtSZip_w").value 			= document.getElementById("txtBZip_w").value 
		document.getElementById("txtSEmail_w").value   		= document.getElementById("txtBEmail_w").value
		document.getElementById("txtSPhone_w").value   		= document.getElementById("txtBPhone_w").value
		document.getElementById("txtScountry_w").value   	= document.getElementById("txtBCountry_w").value
		document.getElementById("drpScountry_w").value   	= document.getElementById("drpBcountry_w").value
    
        document.getElementById("txtSFName_w").disabled		= "disabled"; 
        document.getElementById("txtSLName_w").disabled		= "disabled"; 
        document.getElementById("txtSAddress_w").disabled	= "disabled"; 
        document.getElementById("txtSCity_w").disabled		= "disabled"; 
        document.getElementById("txtSState_w").disabled		= "disabled"; 
        document.getElementById("txtSZip_w").disabled		= "disabled"; 
        document.getElementById("txtSEmail_w").disabled		= "disabled"; 
        document.getElementById("txtSPhone_w").disabled		= "disabled"; 
        document.getElementById("txtScountry_w").disabled	= "disabled"; 
        document.getElementById("drpScountry_w").disabled	= "disabled"; 
       
    }
    else
    { 
		document.getElementById("txtSFName_w").value 		= "";
		document.getElementById("txtSLName_w").value		= "";
		document.getElementById("txtSAddress_w").value 		= "";
		document.getElementById("txtSCity_w").value    		= "";
		document.getElementById("txtSState_w").value   		= "";
		document.getElementById("txtSZip_w").value 			= "";
		document.getElementById("txtSEmail_w").value   		= "";
		document.getElementById("txtSPhone_w").value   		= "";
		document.getElementById("txtScountry_w").value		= "";
		document.getElementById("drpScountry_w").value 		= ""; 
        document.getElementById("txtSFName_w").disabled 	= "";
        document.getElementById("txtSLName_w").disabled 	= "";
        document.getElementById("txtSAddress_w").disabled 	= "";
        document.getElementById("txtSCity_w").disabled 		= "";
        document.getElementById("txtSState_w").disabled 	= "";
        document.getElementById("txtSZip_w").disabled 		= "";
        document.getElementById("txtSEmail_w").disabled 	= "";
        document.getElementById("txtSPhone_w").disabled 	= "";
        document.getElementById("txtScountry_w").disabled 	= "";
        document.getElementById("drpScountry_w").disabled 	= "";
    
    }
    getExtraShipAmount(path,document.getElementById("txtSZip_w").value,document.getElementById("drpScountry_w").value,document.frmwtrans.hidShipCost.value)
}

function FillAll_MO(path)
{
    if(document.getElementById("chkAll_MO").checked == true)
    {
		document.getElementById("txtSFName_MO").value    	= document.getElementById("txtBFName_MO").value
		document.getElementById("txtSLName_MO").value    	= document.getElementById("txtBLName_MO").value
		document.getElementById("txtSAddress_MO").value 		= document.getElementById("txtBAddress_MO").value
		document.getElementById("txtSCity_MO").value    		= document.getElementById("txtBCity_MO").value
		document.getElementById("txtSState_MO").value   		= document.getElementById("txtBState_MO").value
		document.getElementById("txtSZip_MO").value 			= document.getElementById("txtBZip_MO").value 
		document.getElementById("txtSEmail_MO").value   		= document.getElementById("txtBEmail_MO").value
		document.getElementById("txtSPhone_MO").value   		= document.getElementById("txtBPhone_MO").value
		document.getElementById("txtScountry_MO").value   	= document.getElementById("txtBCountry_MO").value
		document.getElementById("drpScountry_MO").value   	= document.getElementById("drpBcountry_MO").value
    
        document.getElementById("txtSFName_MO").disabled		="disabled";  
        document.getElementById("txtSLName_MO").disabled		="disabled"; 
        document.getElementById("txtSAddress_MO").disabled		="disabled"; 
        document.getElementById("txtSCity_MO").disabled 		= "disabled";
        document.getElementById("txtSState_MO").disabled		="disabled"; 
        document.getElementById("txtSZip_MO").disabled 			= "disabled";
        document.getElementById("txtSEmail_MO").disabled		="disabled"; 
        document.getElementById("txtSPhone_MO").disabled		="disabled"; 
        document.getElementById("txtScountry_MO").disabled		="disabled"; 
        document.getElementById("drpScountry_MO").disabled		="disabled"; 
       
    }
    else
    {
    
		document.getElementById("txtSFName_MO").value    	= "";
		document.getElementById("txtSLName_MO").value    	= "";
		document.getElementById("txtSAddress_MO").value 	= "";
		document.getElementById("txtSCity_MO").value    	= "";
		document.getElementById("txtSState_MO").value   	= "";
		document.getElementById("txtSZip_MO").value 		= "";
		document.getElementById("txtSEmail_MO").value   	= "";
		document.getElementById("txtSPhone_MO").value   	= "";
		document.getElementById("txtScountry_MO").value   	= "";
		document.getElementById("drpScountry_MO").value 	= "";
    
        document.getElementById("txtSFName_MO").disabled 	= "";
        document.getElementById("txtSLName_MO").disabled 	= "";
        document.getElementById("txtSAddress_MO").disabled = "";
        document.getElementById("txtSCity_MO").disabled 	= "";
        document.getElementById("txtSState_MO").disabled 	= "";
        document.getElementById("txtSZip_MO").disabled 	= "";
        document.getElementById("txtSEmail_MO").disabled 	= "";
        document.getElementById("txtSPhone_MO").disabled 	= "";
        document.getElementById("txtScountry_MO").disabled = "";
        document.getElementById("drpScountry_MO").disabled = "";
    
    }
	 
    getExtraShipAmount(path,document.getElementById("txtSZip_MO").value,
													document.getElementById("drpScountry_MO").value,document.frmMO.hidShipCost.value)
}
	function ProcessCart() {
		
		var ShippingCost = 0;
		var GrandTotal = 0;
		
		if(document.frmcart.hidShipCost.value != "" && document.frmcart.hidGrandTotal.value != "") {
			document.frmcart.submit();
			return true;
		} else {
			alert("Please process properly on Cart !");
			return false;
		}
	}
	
	function shipment(shipval) {
		var shipping_value = shipval;
		var sub_total = replaceAll(document.getElementById("hidSubTotal").value, [[",", ""]]) ;

		var mySplitResult = shipping_value.split("_");

		//alert(mySplitResult[1])
		
		document.getElementById("tdShipCost").innerHTML = "<font size='2' face='Verdana'>$"+parseFloat(mySplitResult[1]).toFixed(2) + "</font>";
		document.getElementById("hidShipCost").value = parseFloat(mySplitResult[1]).toFixed(2);
		document.getElementById("hidShipMethod").value = mySplitResult[0];
		
		document.getElementById("tdGrandTotal").innerHTML = "<font size='2' face='Verdana'><b>$" + eval(parseFloat(mySplitResult[1]) + parseFloat(sub_total)).toFixed(2) + "</b></font>";
		document.getElementById("hidGrandTotal").value =  eval(parseFloat(mySplitResult[1]) + parseFloat(sub_total)).toFixed(2);
	}
	
	function explode(inputstring, separators, includeEmpties) {
		inputstring = new String(inputstring);
		separators = new String(separators);
		
		if(separators == "undefined") {
		separators = " :;";
		}
		
		fixedExplode = new Array(1);
		currentElement = "";
		count = 0;
		
		for(x=0; x < inputstring.length; x++) {
		char = inputstring.charAt(x);
		if(separators.indexOf(char) != -1) {
		if ( ( (includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) { } 
		else {
		fixedExplode[count] = currentElement;
		count++;
		currentElement = ""; } }
		else { currentElement += char; }
		}
		
		if (( ! (includeEmpties <= 0) && (includeEmpties != false)) || (currentElement != "")) {
		fixedExplode[count] = currentElement; } 
		return fixedExplode;
		}
	
	function checkstep2() {
		
		with (window.document.frmstep2) {
		
			if(checktext(txtBFName,"First Name") == false) {
				return false;
			}
			if(checktext(txtBLName,"Last Name") == false) {
				return false;
			}
			if(checktext(txtBAddress,"Address") == false) {
				return false;
			}
			if(checktext(txtBCity,"City Name") == false) {
				return false;
			}
			if(checktext(txtBState,"State Name") == false) {
				return false;
			}
			if(checktext(txtBZip,"Zip Name") == false) {
				return false;
			}
			if(checktext(drpBcountry,"Country Name") == false) {
				return false;
			}
			if(checktext(txtBPhone,"Phone Number") == false) {
				return false;
			}
			if(!IsNumber(txtBPhone.value)) {
				alert("Please enter proper phone number");
				return false;
			}
			if(!IsEmail(txtBEmail.value)) {
				alert("Please enter proper Email Address");
				txtBEmail.focus();
				return false;
			}

			if(chkAll.checked == false) {
			
				if(checktext(txtSFName,"Shipping First Name") == false) {
					return false;
				}
				if(checktext(txtSLName,"Shipping Last Name") == false) {
					return false;
				}
				if(checktext(txtSAddress,"Shipping Address") == false) {
					return false;
				}
				if(checktext(txtSCity,"Shipping City Name") == false) {
					return false;
				}
				if(checktext(txtSState,"Shipping State Name") == false) {
					return false;
				}
				if(checktext(txtSZip,"Shipping Zip Code") == false) {
					return false;
				}
				if(checktext(drpScountry,"Shipping Country Name") == false) {
					return false;
				}
				if(checktext(txtSPhone,"Shipping Phone Number") == false) {
					return false;
				}
				if(!IsNumber(txtSPhone.value)) {
					alert("Please enter proper shipping phone number");
					return false;
				}
				
				if(!IsEmail(txtSEmail.value)) {
					alert("Please enter proper shipping Email Address");
					txtSEmail.focus();
					return false;
				}
			}
			if(chkpolicy_pp.checked != true) {
				alert("Please agree on shipping policy");
				return false;
			}
			return true;
		}
	}
	
	function paymentoption(option1,option1A,option2,option2A,type)
	{
	
		if(type == "true")
		{
			document.getElementById('tdimp').style.display = "block"; 
			document.getElementById('tblWireInfo').style.display = "none";
		}
		else
		{
			document.getElementById('tdimp').style.display = "none";
			document.getElementById('tblWireInfo').style.display = "block";
		}
		document.getElementById(option1).style.display = "block";
		document.getElementById(option1A).style.display = "block";
		document.getElementById(option2).style.display = "none";
		document.getElementById(option2A).style.display = "none";
	}
	
	function chksellbag() {
	
		with(window.document.frmsellyourbag) {
		
			if(checktext(vOwnerName,"Owner Name") == false) {
				return false;
			}
			
			if(!IsEmail(vEmailAddress.value)) 
			{
				alert("Enter Your E-mail Address");
				return false;
			}
			
			if(checktext(vPhone,"Phone Number") == false) {
				return false;
			}
			
			return true;
		}
	}
	/*
	function confPolicy() 
	{
		with(window.document.frmconfirm) {
		
			if(chkpolicy.checked != true) {
				alert("Please agree on shipping policy");
				return false;
			}
			
			return true;
		}
	}*/
	
	/*******************************************************************
	/*
	Simple Image Trail script- By JavaScriptKit.com
	Visit http://www.javascriptkit.com for this script and more
	This notice must stay intact
	*/
	
	var offsetfrommouse=[20,-165]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
	var displayduration=0; //duration in seconds image should remain visible. 0 for always.
	var currentimageheight = 370;	// maximum image size.
	
	if (document.getElementById || document.all){
		document.write('<div id="trailimageid" style="z-index:100;">'); 
		document.write('</div>');
	}
	
	function gettrailobj(){
		if (document.getElementById)
			return document.getElementById("trailimageid").style
		else if (document.all)
			return document.all.trailimagid.style
	}
	
	function gettrailobjnostyle(){
		if (document.getElementById)
			return document.getElementById("trailimageid")
		else if (document.all)
			return document.all.trailimagid
	}
	
	
	function truebody(){
		return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}
	
	function showtrail(imagename,title,description,pricepoint){
	
		document.onmousemove=followmouse;
		newHTML = '<div style="padding:5px; background-color:none; border:0; ">';
		
		newHTML = newHTML + '<h2>' + title + '</h2>';
		newHTML = newHTML + description + '<br/>';
		newHTML = newHTML + pricepoint + '<br/>';
	
		newHTML = newHTML + '<div align="center" style="padding: 8px 2px 2px 2px;">';
		newHTML = newHTML + '<img src="' + imagename + '" border="0"></div>';
		newHTML = newHTML + '</div>';
		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="inline";
		
		gettrailobj().position="absolute";
		currentimageheight = ('trailInnerDiv').offsetHeight;
	}
	
	function showtrailBatch(imagename,title,filetype) {
		document.onmousemove=followmouseBatch;
	
		newHTML = '<div style="padding: 5px; background-color: #FFF; border:10px solid #cccccc;" id="trailInnerDiv">';
		
		newHTML = newHTML + '<h2>' + title + '</h2>';
		newHTML = newHTML + '<div align="center" style="padding: 8px 2px 2px 2px;">';	
		newHTML = newHTML + '<img src="' + imagename + '" border="0"></div>';	
		newHTML = newHTML + '</div>';
		
		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="inline";
		gettrailobj().position="absolute";
		currentimageheight = $('trailInnerDiv').offsetHeight;
		
	}
	
	function hidetrail(){
		gettrailobj().innerHTML = " ";
		gettrailobj().display="none"
		document.onmousemove=""
		gettrailobj().left="-500px"
	
	}
	
	function followmouse(e){
	
		var xcoord=offsetfrommouse[0]
		var ycoord=offsetfrommouse[1]
	
		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
	
		if (typeof e != "undefined"){
			if (docwidth - e.pageX < 180){
				xcoord = e.pageX - xcoord - 100; // Move to the left side of the cursor
			} else {
				xcoord += e.pageX;
			}
			if (docheight - e.pageY < (currentimageheight + 110)){
				ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
			} else {
				ycoord += e.pageY;
			}
	
		} else if (typeof window.event != "undefined"){
			if (docwidth - event.clientX < 180){
				xcoord = event.clientX + truebody().scrollLeft - xcoord - 50; // Move to the left side of the cursor
			} else {
				xcoord += truebody().scrollLeft+event.clientX
			}
			if (docheight - event.clientY < (currentimageheight + 110)){
				ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
			} else {
				ycoord += truebody().scrollTop + event.clientY;
			}
		}
	
		if(ycoord < 0) { ycoord = ycoord*-1; }
		gettrailobj().left=xcoord+"px"
		gettrailobj().top=ycoord+"px"
	
	}
	
	function followmouseBatch(e){
		var xcoord=offsetfrommouse[0]
		var ycoord=offsetfrommouse[1]
	
		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
	
		var trailInnerDiv = $('trailInnerDiv');
		var currentimageheight = trailInnerDiv.offsetHeight;
		var currentimagewidth = trailInnerDiv.offsetWidth;
	
		scrollPos = Position.realOffset(truebody());
		
		if (typeof e != "undefined"){
			if (docwidth - e.pageX < 180){
				xcoord = e.pageX - xcoord - 100; // Move to the left side of the cursor
			} else {
				xcoord += e.pageX;
			}
			if ((e.pageY - scrollPos[1]) + currentimageheight > docheight){
				ycoord = -ycoord + (e.pageY - currentimageheight);
			} else {
				ycoord += e.pageY;
			}
		} else if (typeof window.event != "undefined"){
			if (event.clientX + currentimagewidth > docwidth){
				xcoord = -xcoord + ((event.clientX + scrollPos[0]) - currentimagewidth); // Move to the left side of the cursor
			} else {
				xcoord += (event.clientX + scrollPos[0]);
			}
			if (event.clientY + currentimageheight > docheight){
				ycoord = -ycoord + ((event.clientY + scrollPos[1]) - currentimageheight);
			} else {
				ycoord += (event.clientY + scrollPos[1]);
			}
		}
	
		if(ycoord < 0) { ycoord = ycoord*-1; }
	
		gettrailobj().left=xcoord+"px"
		gettrailobj().top=ycoord+"px"
	
	}
	
	/************ end simple image trail script ****************************************/
	
	
	
	
