// JavaScript Document
function help(helpType,w,h) {
	if(w == null)
		w= 485;
	if(h == null)
		h= 256;	
	popit=open("","DisplayWindow4","maximize=no,titlebar=0,resizable=yes,statusBar=yes,toolbar=no,scrollbars=yes,width="+w+",height="+h+",top=200,left=200");
	popit.location.href = '/blocks/dsp_help.cfm?i=' + helpType;
	popit.focus();
	}

function stopback() { 
	history.go(1);
	}

//all the stuff below will need to be un-escaped to see the pop-up (also dsp_homeMiddle)
//check if the cookie exists
function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}
//get the value of the cookie
function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
//open the pop up only once 
function openpopupNewUser(){
	if(GetCookie('popUpCookie8')==null){
		var exp = new Date();
		var expDays = 100;
		exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); 
		document.cookie="popUpCookie8=1; expires=" + exp.toGMTString();	
		var popurl="http://www.bid4assets.com/display/pop_govt2.cfm?"
		winpops=window.open(popurl,"","width=650,height=280,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=300,top=50")
	}
}

/*function popJewelry() {
	var popURL = "http://www.bid4assets.com/listing/display/dsp_jewelryPolicy.cfm"
	winpops=window.open(popURL,"","width=420,height=480,scrollbars,left=300,top=50")
}
*/

function popWindow(popurl,w,h){
	if(w == null)
		w=520;
	if(h == null)
		h= 520;	
	winpops=window.open(popurl,"",'toolbar=no,width='+w+',height='+h+',directories=no,status=no,scrollbars=yes,resize=no,menubar=no')
}


//******************************Moved from Auction/index.cfm***************************************************
function whatsNew() {
	popit=open("","DisplayWindow4","maximize=no,titlebar=0,resizable=yes,statusBar=yes,toolbar=no,scrollbars=yes,width=620,height=400");
	popit.location.href = 'index.cfm?fuseaction=whatsNew&auctionID=0';
}
function currencyConverter() {
	popit=open("","DisplayWindow18","maximize=no,titlebar=0,resizable=yes,statusBar=yes,toolbar=no,scrollbars=auto,width=500,height=400,top=200,left=200");
	popit.location.href = 'http://www.oanda.com/convert/classic?user=seller&lang=en';
}
//function to open new window and display the help for authBidder
function AuthorizeBidder() {
	popit=open("","DisplayWindow18","toolbar=no,scrollbars=yes,width=500,height=255");
	popit.location.href = 'http://www.bid4assets.com/auction/display/dsp_authBidder.html';
	popit.focus();
}	

//******************************Moved from Auction/Display/dsp_bidBox.cfm***************************************
function receipt(auctionID, bidID) {
	popit=open("","DisplayWindow4","maximize=no,titlebar=0,resizable=yes,statusBar=yes,toolbar=yes,scrollbars=auto,width=550,height=600,top=200,left=200");
	popit.location.href = 'index.cfm?fuseaction=bidReceipt&auctionID='+auctionID+'&bidID='+bidID;
}
//******************************Moved from Auction/Display/dsp_bidBoxStep3.cfm***************************************
function DisableButtons(){
	document.biddingForm.cancel.disabled=true;
	document.biddingForm.bidNow.disabled=true;
	document.biddingForm.bidNow.value = 'Processing....';
	return true;
}

//******************************POP UP's POP UP's POP UP's***************************************
//******************************POP UP's POP UP's POP UP's***************************************
//******************************POP UP's POP UP's POP UP's***************************************

function openpopup(popUrl){
	if(popUrl == null) var popUrl="../help/index.cfm?fuseaction=howtobid";
	winpops=window.open(popUrl,"","width=650,height=450,scrollbars,left=250,top=150")
	winpops.focus();
}


function TOS() {
	popit=open("","DisplayWindow4","maximize=no,titlebar=0,resizable=yes,statusBar=no,toolbar=yes,scrollbars=yes,width=350,height=400,top=200,left=200");
	popit.location.href = '/help/index.cfm?fuseAction=termsofservice';
	}


/**********************************************************************************/
/********************************** ACH ******************************************/
/**********************************************************************************/
function aba_check(achRoutingNumber, alerttext)
	{
	var aba = achRoutingNumber.value;
	
	
			
	if (aba.length != 9)
		{
		alert('Your Routing Number must be at least 9 digits long');
		return false;
		}
	
	var num1 = aba.charAt(0);
	var num2 = aba.charAt(1);
	var num3 = aba.charAt(2);
	var num4 = aba.charAt(3);
	var num5 = aba.charAt(4);
	var num6 = aba.charAt(5);
	var num7 = aba.charAt(6);
	var num8 = aba.charAt(7);
	//Check digit
	var num9 = aba.charAt(8);
	
	num1 = num1 * 3;
	num2 = num1 + (num2 * 7);
	num3 = num2 + (num3 * 1);
	num4 = num3 + (num4 * 3);
	num5 = num4 + (num5 * 7);
	num6 = num5 + (num6 * 1);
	num7 = num6 + (num7 * 3);
	num8 = num7 + (num8 * 7);
	num9 = num9 * 1;
	
	var rme1 = num8/10;
	var rme2 = Math.round(rme1);
		
	if (rme2>rme1)
		{
		var temp = rme2 - 1;
		}
	else
		{
		var temp = rme2;
		}
	if(num9==0)
		{
		var finalcheck = temp * 10;
		}
	else
		{
		var finalcheck = (temp + 1) * 10;
		}
	var finalnum = num8 + num9;

	if(finalcheck==finalnum)
		{
		return true;
		}
	else
		{
		alert(alerttext);
		return false;
		}	
	}
	
/*This method writes to a document */
/*Currently used for Additional Information tab on the auction pages*/
function writeText(text, linkName, type){
	if(type == 1)
		document.write("<a href='javascript:void(0)' onclick=javascript:AI=window.open('"+text+"','AdditionalInfo','maximize=yes,titlebar=0,resizable=yes,statusBar=yes,toolbar=yes,scrollbars=yes,width=620,height=400');AI.focus()>"+linkName+"</a>")	
	else
		document.write(text)
}	

