var blk1  = "https://www.paypal.com/cart/";
var blk1a = "add=1";
var blk1d = "display=1";
var blk2  = "&business=scott%40holyscott.com&cs=1";
var blk3  = "&item_name=Custom%20";
var blk3n = "Test";
var blk4  = "&amount=";
var blk4a = "505.00";

var blk5  = "" + "";

var blk6 = "18";

var winpar = "width=800,height=640,scrollbars," +
             "location," + "resizable,status";

function validate(){ //Begin
if(document.customquote.ATX_Case.selectedIndex==1)
{
alert("Please select which case you would like.");
document.customquote.ATX_Case.focus();
return false;
}
if(document.customquote.subject.selectedIndex==0)
{
alert("Please select a subject of inquiry.");
document.customquote.subject.focus();
return false;
}
if(document.customquote.firstname.value == "")
{ 
alert('Please enter your First Name.'); 
document.customquote.firstname.focus(); 
return false; 
}
eMail = document.customquote.email.value
if((eMail.indexOf('@') < 0) || ((eMail.charAt(eMail.length-4) != '.') && (eMail.charAt(eMail.length-3) != '.')))
{ 
alert('Please enter your Email Address.'); 
document.customquote.email.focus(); 
return false; 
} 
if((document.customquote.subject.selectedIndex > 2) && (document.customquote.payment.selectedIndex > 3))
{
CallPay(this.form)
return true;
}
} //End

function createWinScr(pageName,x,y) {
 var winl = (screen.width - x) / 2;
 var wint = (screen.height - y) / 2;
 newWin=window.open("", "pageName", 'toolbar=no,width='+x+',height='+y+',location=no,status=no,menubar=no,framewidth=0,frameheight=0,marginwidth=0,marginheight=0,border=0,scrollbars=no,top='+wint+',left='+winl);
 newWin.document.write('<html><head><title>Screenshot</title></head>');	
 newWin.document.write('<BODY BGCOLOR=#000000 LINK=#CCCCCC VLINK=#C0C0C0 ALINK=#999999 topmargin=10 leftmargin=0 rightmargin=0 bottommargin=0 style="FONT-SIZE: 12px; TEXT-ALIGN: justify; COLOR: #000000; FONT-FAMILY: TAHOMA, ARIAL, HELVETICA">');
 newWin.document.write('<center><a href=# OnClick=window.close()><img border=0 src='+pageName+'>');
 newWin.document.write('<BR><font face=verdana,arial size=1>Close this window</a>');
 newWin.document.close();
// newWin.location.href=pageName;
 newWin.focus();
}
function createWin(pageName,x,y) {
 var winl = (screen.width - x) / 2;
 var wint = (screen.height - y) / 2;
 newWin=window.open("", "pageName", 'toolbar=no,width='+x+',height='+y+',location=no,status=no,scrollbars=no,resize=no,menubar=no,framewidth=0,frameheight=0,marginwidth=0,marginheight=0,border=1,top='+wint+',left='+winl);
 newWin.location.href=pageName;
 newWin.focus();
}

function AddBoth (strn1, strn2, arg) {  
  AddStyle (strn1, "0"); 
  AddPrice (strn2, arg);  
}

function AddPrice (strn, arg) {  
var r1,r2,pos;

 r1 = blk4a * 1.0 + 0.005; 
 r2 = strn * 1.0;
  strn = escape (r1 + r2);  
  pos = strn.indexOf ("."); 
  blk4a = strn.substring (0, pos + 3);  

  if (arg != "0") CallPay ();
}

function AddNegative (strn, arg) {  
var r1,r2,pos,neg;

 r1 = blk4a * 1.0 + 0.005; 

 r2 = strn * 1.0;
  strn = escape (r1 - r2);  
  pos = strn.indexOf ("."); 
  blk4a = strn.substring (0, pos + 3); 

  if (arg != "0") CallPay ();
}

function AddMultip (strn, arg) {  
var r1,r2,pos,mult;

 r1 = blk4a * 1.0 + 0.005; 

 r2 = strn * 1.0;
  strn = escape (r1 * r2);  
  pos = strn.indexOf ("."); 
  blk4a = strn.substring (0, pos + 3);  

  if (arg != "0") CallPay ();
}

function AddStyle (strn, arg) {  
  blk3n = blk3n + "%2C%20" + escape (strn);
  if (arg != "0") CallPay ();
}

function CallPay () { 
  window.open (blk1 + blk1a + blk2 + blk3 + blk3n + blk4 + blk4a + blk5,
               "cartwin",
               winpar);
}

function CallView () { 
  window.open (blk1 + blk1d +  
               blk2,
               "cartwin",
               winpar);
}

function MakeBuy (obj1) {  
var i,j,obj,temp,pick,pos,neg,mult;
var stax, tax, dec_pos, with_tax ; 
var r1, r2;

var aray = new Array ();
  SetBoth("0", "0", "0"); 
  j = 0;
  tax = 0.0
 ; 
  for (i=1; i<blk6; i++) {    
    obj = obj1.elements[i];    
    pick = obj.selectedIndex;   
    aray[j] = obj.options[pick].value;  

    temp = aray[j];  
    j = j + 1;       

    pos  = temp.indexOf ("+$");  
    stax = temp.indexOf("%")  ; 
	neg = temp.indexOf("-$")  ; 
	mult = temp.indexOf("*$")  ; 
    
   if (stax > 0) {
	   tax = temp.substring(stax-3, stax) ;
  
  }
   else {
	if (pos > 0) {AddPrice (temp.substring (pos + 2), "0");}
	if (mult > 0) {AddMultip (temp.substring (mult + 2), "0");}
    if (neg > 0) {AddNegative (temp.substring (neg + 2), "0");}

	}
  }

  with_tax = blk4a * (1.0 + tax) ; 
  r1 = with_tax * 1.0 + 0.005; 

temp_withtax = escape (r1 ); 
dec_pos = temp_withtax.indexOf ("."); 

blk4a = temp_withtax.substring(0, dec_pos + 3) ;
  obj1.elements[0].value = "$" + blk4a ;

  AddStyle (aray.join (", "), "0");  
}

function SetBoth (strn1, strn2, arg) {  
  SetDesc  (strn1);
  SetPrice (strn2);
  if (arg != "0") CallPay ();
}

function SetDesc (strn) { 
  blk3n = escape (strn);
}

function SetPrice (strn) {  
  blk4a = "0.00";
  AddPrice (strn, "0");
}

function MakePrice (strn) {  
obj1.elements[0].value = "$" + blk4a;
}


function dollarFormat(valuein) {
var tDollars
var formatStr = ""
var decipos = valuein.indexOf(".")
if (decipos == -1)
	decipos = valuein.length
var dollars = valuein.substring(0,decipos)
var Outdollars = ""
var dollen = dollars.length
tDollars = dollars.substring(dollen-3, dollen)
if (dollen >3 ) {
	   while (dollen > 0 ) {
		if (tDollars.length == 3) {
		   Outdollars = ","+tDollars+Outdollars
		   dollen = dollen-3
		}
		else {
		     Outdollars = tdollars+Outdollars
		     dollen = 0
		}
          }	
	 if (Outdollars.substring(0,1) == ",")
		dollars = Outdollars.substring(1, Outdollars.length)
	  else
		dollars=Outdollars
      }
var cents = valuein.substring(decipos+1,decipos+3)
if (cents == "")
  cents ="00"
if (cents.length == 1)
   cents = cents+"0"
var formatStr = "$"+dollars+"."+cents
return formatStr
}