// Son of Suckerfish Drop-down Menu
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("dd");
	for (var i=0; i<sfEls.length; ++i) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// Create Email Address
function createAddress(account, domain, tld, title) {
	emailE = account
	emailE = (emailE + '@' + domain + tld)
	document.write('<a href="mailto:' + emailE + '" title="' + title +'">' + emailE + '</a>')
}

// Load Flash File
function loadFlash(fsrc, fwidth, fheight) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + fwidth + '" height="' + fheight + '">');
	document.write('<param name="movie" value="' + fsrc + '" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<embed src="' + fsrc + '" wmode="transparent" quality="high" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + fwidth + '" height="' + fheight + '"></embed>');
	document.write('</object>');
}

// Replaces the large image when a small image is rolled over
function roll(img_name1, img_src1) {
   document[img_name1].src = img_src1;
}
var xmlHttp

function showUser(str)


{ //Show page is loading

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="getuser.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
 } 
}function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
function checkforblanks()

	{
	for (var i = 0; i < arguments.length; i += 2)
		{
		if (!arguments[i])
			{alert("Please enter " + arguments[i+1] + ".");return false;}
		}
if ( document.order_form.terms.checked == false )
    {
        alert ( "Please agree to our Terms & Conditions box." );
        return false;
    }
	return true;
		
}

function validate()
	{
	// Make sure none of the required fields are empty
	var isFull = checkforblanks(document.order_form.fname.value, "your first name",
					document.order_form.lname.value, "your last name",
					document.order_form.cstreet.value, "your Street",
							document.order_form.ctown.value, "your town or city",
					document.order_form.ccountry.value, "your country",
					document.order_form.telephone.value, "your Telephone Number",
					document.order_form.email.value, "your e-mail address");
					
					if ( document.order_form.payopt.value == 'Credit_Card' )
    {	
		// Make sure none of the required fields are empty
	var isFull = checkforblanks(document.order_form.card_name.value, "your card name",
	document.order_form.card_number.value, "your card number",
	document.order_form.card_expiry.value, "your card expiry date",
	document.order_form.security_code.value, "your card security code");
	}
	
	if (!isFull)
		{return false;}
	
}

	
function copyAddress() {
  document.order_form.dfname.value=document.order_form.fname.value
	document.order_form.dlname.value=document.order_form.lname.value
  document.order_form.dstreet.value=document.order_form.cstreet.value
	document.order_form.dsuburb.value=document.order_form.csuburb.value
	document.order_form.dtown.value=document.order_form.ctown.value
  document.order_form.dpostcode.value=document.order_form.cpostcode.value
	document.order_form.dcountry.value=document.order_form.ccountry.value
}

function doPopups() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("privacy")) {
      links[i].onclick = function() {
        window.open("http://www.offsettherest.com/privacy-policy-popup.html","blank","toolbar=no,scrollbars=yes,width=750,height=700");
        return false;
      }
    }
  }
}
window.onload = doPopups;
