// JavaScript Document
function makeNewWindow(url,width,height, scrollbars) 
{
	var var1
	if (scrollbars==true)
	{
		var1="yes"
	}
	else
	{
		var1="no"
	}
	var windowOpened
	var newWindow
	var w = screen.width; // Get the width of the screen
    var h = screen.height; // Get the height of the screen
    var left = (w - width)/2;
    var top = (h - height)/2;
	if (left<10) left = 10;
	if (top<10) top = 10;
	var high = height + 0 // customizable
	var wide = width + 0  // customizable
	if (windowOpened) 
	{
		newWindow.close();
	}
	newWindow=window.open(url, "newwin",
        "toolbar=no,resizable=yes,scrollbars="+var1+",menubar=no,left = "+left+",top = "+top+",width="+wide+",height="+high);
	windowOpened=true;
}

function makeNewWindow2(url,width,height, scrollbars) // this one gives you the ability to open multiple popup windows off the same link
{
	var var1
	if (scrollbars==true)
	{
		var1="yes"
	}
	else
	{
		var1="no"
	}
	var windowOpened=false;
	var newWindow
	var w = screen.width; // Get the width of the screen
    var h = screen.height; // Get the height of the screen
    var left = (w - width)/2;
    var top = (h - height)/2;
	if (left<10) left = 10;
	if (top<10) top = 10;
	var high = height + 0 // customizable
	var wide = width + 0  // customizable
	if (windowOpened) 
	{
		newWindow.close();
	}
	var rand=Math.floor(Math.random()*10000000000000000);
	rand=rand+'';
	newWindow=window.open(url, rand,
        "toolbar=no,resizable=yes,scrollbars="+var1+",menubar=no,left = "+left+",top = "+top+",width="+wide+",height="+high);
	//windowOpened=true;
}

function updateShipAddress(form)
{
     var index=form.shipaddress.selectedIndex;
     var id=form.shipaddress.options[index].value;
     if( index!=-1 )
     {
          form.shipcompany.value=addresses[id]["company"];
          form.shipname.value=addresses[id]["name"];
          form.shipaddress1.value=addresses[id]["address1"];
          form.shipaddress2.value=addresses[id]["address2"];
          form.shipcity.value=addresses[id]["city"];
          form.shipstate.value=addresses[id]["state"];
          form.shipzip.value=addresses[id]["zip"];
          form.shipcountry.value=addresses[id]["country"];
          form.shipphone.value=addresses[id]["phone"];
     }
}

function updateBillAddress(form)
{
     var index=form.billaddress.selectedIndex;
     var id=form.billaddress.options[index].value;
     if( index!=-1 )
     {
          form.billcompany.value=addresses[id]["company"];
          form.billname.value=addresses[id]["name"];
          form.billaddress1.value=addresses[id]["address1"];
          form.billaddress2.value=addresses[id]["address2"];
          form.billcity.value=addresses[id]["city"];
          form.billstate.value=addresses[id]["state"];
          form.billzip.value=addresses[id]["zip"];
          form.billcountry.value=addresses[id]["country"];
          form.billphone.value=addresses[id]["phone"];
     }
}

function highlight(element)
{
     element.style.backgroundColor='#FFFF99';
}

function unhighlight(element)
{
     element.style.backgroundColor='#FFFFFF';
}

