// JavaScript Document


if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }
  
 
		
	function initiateLight(prodId)
        {
		$(document).ready(function(){
			tb_show("PROMOSIE","/generatePromotion.php?height=520&width=500&prod_id="+prodId+"","images/cart.jpg");
		});
	 }
	/*Event.observe(window, 'load', initiateLight, false);*/
	
	
  function checkNumberTemplate(varThis,formName) {
	
	var valid = true;
	var msg = '';
	
	if (varThis.value == "") {
	  valid = false;	
	  msg += '- You cellphone number can not be empty. Selfoon nommer kan nie leeg wees nie\r\n';	
	}
	
	if (!IsNumeric(varThis.value)) {
	  valid = false;
	  msg += "- You cellphone number must be a number. Selfoon nommer moet 'n nommer wees\r\n";	
	}
	
	if (varThis.value.length != 10) {
		valid = false;
	   msg += "- Cellphone number must be 10 numbers.Selfoon nommer moet 10 nommers wees.\r\n"   	
	}
	
	// now display messages
	if (msg) {
	   alert(msg); 	
	}
	
	if (valid) {
	    formName.submit();	
	}
	
	return valid;
	
	
	
	
 }
 
 function checkEmailTemplate(varThis,formName) {
	
	 var emailRegex = new RegExp(/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
	
	var valid = true;
	var msg = '';
	
	if (varThis.value == "") {
	  valid = false;	
	  msg += '- You email address can not be empty. Epos address kan nie leeg wees nie\r\n';	
	}
	
	if (!emailRegex.test(varThis.value)) {
	  valid = false;
	  msg += "- You email address is not valid. Epos moet waardig wees\r\n";	
	}
	
	
	
	// now display messages
	if (msg) {
	   alert(msg); 	
	}
	
	if (valid) {
	    formName.submit();	
	}
	
	return valid;
	
	
	
	
 }