var currImage = null;
var currImageWin = null;
var xmlhttp;
var xmlResponse = "";
var callback = "xmlProcessResponse();";

function viewImage(whichImage) {
	currImage = new Image();
	currImage.src = whichImage;

	if (currImageWin != null) currImageWin.close();
	
	// come up with a better solution than another hit on the server.
	currImageWin = window.open(whichImage, "imageWin", "menubar=no,width="+ (currImage.width + 20)+",height="+(currImage.height + 20));
	resizeViewImageWindow();
	
}


function resizeViewImageWindow() {
	if (currImage != null && currImageWin != null) {
		if (currImage.width == 0 || currImage.height == 0) {
			setTimeout("resizeViewImageWindow()", 5);
		} else {
			currImageWin.resizeTo(currImage.width + 80, currImage.height + 120);
		}
	}
}


function loadXMLDoc(url)
{
xmlhttp=null;
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {
    xmlResponse = xmlhttp.responseText;
     eval(callback); 
    }
  else
    {
    alert("Problem retrieving XML data");
    }
  }
}


function doCallBack(callbackJS, closeWin, args) {
	eval("window.opener." + callbackJS + "(" + args + ");");
	if (closeWin) {
		window.close();
	}
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}


// find the Y coord of an object
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}




function shipToBill(blPopulate)
{
	if(blPopulate)
	{
		document.getElementById("Checkout_address1_S_FirstName").value = document.getElementById("Checkout_address1_FirstName").value;
		document.getElementById("Checkout_address1_S_LastName").value = document.getElementById("Checkout_address1_LastName").value;
		document.getElementById("Checkout_address1_S_Address1").value = document.getElementById("Checkout_address1_Address1").value;
		document.getElementById("Checkout_address1_S_Address2").value = document.getElementById("Checkout_address1_Address2").value;
		document.getElementById("Checkout_address1_S_City").value = document.getElementById("Checkout_address1_City").value;
		document.getElementById("Checkout_address1_S_Zip").value = document.getElementById("Checkout_address1_Zip").value;
		document.getElementById("Checkout_address1_S_Phone").value = document.getElementById("Checkout_address1_Phone").value;
		document.getElementById("Checkout_address1_S_State").selectedIndex = document.getElementById("Checkout_address1_State").selectedIndex;
		//document.getElementById("Checkout_address1:S_State").selectedIndex;


	}
	else
	{
		document.getElementById("Checkout_address1_S_FirstName").value = "";
		document.getElementById("Checkout_address1_S_LastName").value =  "";
		document.getElementById("Checkout_address1_S_Address1").value =  "";
		document.getElementById("Checkout_address1_S_Address2").value =  "";
		document.getElementById("Checkout_address1_S_City").value =  "";
		document.getElementById("Checkout_address1_S_Zip").value =  "";
		document.getElementById("Checkout_address1_S_Phone").value =  "";
		document.getElementById("Checkout_address1_S_State").selectedIndex = 0;
		//document.getElementById("Checkout_address1:S_State").selectedIndex;


	}
	


}

