// JavaScript Document
function validateContact(v_captcha) {
	if (document.contact.fname.value == "") {
		 alert('Please enter a name.');
		 document.contact.fname.focus();
		 return false;
	}
	if (document.contact.email.value == "") {
		 alert('Please enter an email address.');
		 document.contact.email.focus();
		 return false;
	}
	if (isValidEmail(document.contact.email.value) != true) {
		 alert('Please enter a valid email address.');
		 document.contact.email.focus();
		 return false;
	}
	if (document.contact.message.value == "") {
		 alert('Please enter a message!');
		 document.contact.message.focus();
		 return false;
	}
  if (document.contact.sCaptcha.value != v_captcha) {
		 alert('Security Codes do not match?');
		 document.contact.sCaptcha.focus();
		 return false;		
	}
  return true;
}

function isValidEmail(str) {
	return (/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(str))
}

function open_win(url){
  window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=400, height=400");
}

var xmlhttp;
function loadDetails(prid) {
	var intprid = prid;
  xmlhttp=null;
  if (window.XMLHttpRequest) {// code for Firefox, Opera, IE7, etc.
    xmlhttp=new XMLHttpRequest();
  } else if (window.ActiveXObject) {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (xmlhttp!=null) {
	  var url = '/store/pc/show_details.asp?prid=' + intprid;
    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.readyState==4) {// 4 = "loaded"
    if (xmlhttp.status==200) {// 200 = "OK"  
      document.getElementById('prod_details_container').innerHTML=xmlhttp.responseText;
    } else {
        alert("Problem retrieving data:" + xmlhttp.statusText + " Status: " + xmlhttp.status);
    }
  }
}
