function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}



function checkuserinfo()
{
 if(document.userinfo.useremail.value.length!=0)
  {
    if (document.userinfo.useremail.value.charAt(0)=="." ||        
         document.userinfo.useremail.value.charAt(0)=="@"||       
         document.userinfo.useremail.value.indexOf('@', 0) == -1 || 
         document.userinfo.useremail.value.indexOf('.', 0) == -1 || 
         document.userinfo.useremail.value.lastIndexOf("@")==document.userinfo.useremail.value.length-1 || 
         document.userinfo.useremail.value.lastIndexOf(".")==document.userinfo.useremail.value.length-1)
     {
      alert("Incorrect Email Address format ! ");
      document.userinfo.useremail.focus();
      return false;
      }
   }
 else
  {
   alert("Please fill in the Email Address !");
   document.userinfo.useremail.focus();
   return false;
   }
}

function check0()
{
   if(checkspace(document.shop0.username.value)) {
	document.shop0.username.focus();
    alert("Please fill in the User Name!");
	return false;
  }
  }



function trans_form()
{
var f
f = document.receiveaddr

f.billing_name.value = f.realname.value
f.billing_surname.value = f.surname.value
f.billing_email.value = f.delivery_email.value
f.billing_address1.value = f.address.value
f.billing_address2.value = f.city.value
f.billing_address3.value = f.userqq.value
f.billing_postcode.value = f.postcode.value
f.billing_telg.value = f.usertelg.value
f.billing_tel.value = f.usertel.value
f.billing_mobileg.value = f.usermobileg.value
f.billing_mobile.value = f.usermobile.value


}

function YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}


function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}



function DrawImage(ImgD){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= 100/100){
     if(image.width>100){  
     ImgD.width=100;
     ImgD.height=(image.height*100)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }

     }
    else{
     if(image.height>100){  
     ImgD.height=100;
     ImgD.width=(image.width*100)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }

     }
    }
   }
   
   
function DrawImage_cart(ImgD){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= 60/60){
     if(image.width>60){  
     ImgD.width=60;
     ImgD.height=(image.height*60)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }

     }
    else{
     if(image.height>60){  
     ImgD.height=60;
     ImgD.width=(image.width*60)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }

     }
    }
   }   
   

   

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
 }
 
function view(what) { 

		var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=1,location=no,menu=no,width=10,height=10'); 
		imgwin.focus(); 
		imgwin.document.open(); 
		imgwin.document.write("<html>\n"); 
		imgwin.document.write("<head>\n"); 
		imgwin.document.write("<title>Full Size</title>\n"); 

		imgwin.document.write("<sc"+"ript>\n"); 
		imgwin.document.write("function resize() {\n"); 
		imgwin.document.write("pic = document.il;\n"); 
		imgwin.document.write("if (eval(pic).height) { var name = navigator.appName\n"); 
		imgwin.document.write("  if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 40; myWidth = eval(pic).width + 12;\n"); 
		imgwin.document.write("  } else { myHeight = eval(pic).height + 9; myWidth = eval(pic).width; }\n"); 
		imgwin.document.write("  clearTimeout();\n"); 
		imgwin.document.write("  var height = screen.height;\n"); 
		imgwin.document.write("  var width = screen.width;\n"); 
		imgwin.document.write("  var leftpos = width / 2 - myWidth / 2;\n"); 
		imgwin.document.write("  var toppos = height / 2 - myHeight / 2; \n"); 
		imgwin.document.write("  self.moveTo(leftpos, toppos);\n"); 
		imgwin.document.write("  self.resizeTo(myWidth, myHeight);\n"); 
		imgwin.document.write("}else setTimeOut(resize(), 100);}\n"); 
		imgwin.document.write("</sc"+"ript>\n"); 

		imgwin.document.write("</head>\n"); 
		imgwin.document.write('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">\n'); 

		imgwin.document.write("<a href='javascript:window.close()' title='Close Window'><img alt='Close Window' border=0 src='"+what+"' xwidth=100 xheight=9 name=il onload='resize();'></a>\n"); 
		imgwin.document.write("</body>\n"); 
		imgwin.document.close(); 

	} 


function submit_billing_address(submitType){
    if(submitType==1){
		
        billing_address.action='?action=save_billing_address';
	}else{
        billing_address.action='?action=save_billing_address&methord=SameAddress';
	}
	billing_address.submit();
} 

function submit_delivery_address(submitType){
    if(submitType==1){
        delivery_address.action='?action=save_delivery_address';
	}else{
        delivery_address.action='?action=save_delivery_address&methord=SameAddress';
	}
	delivery_address.submit();
}



function count_total_spend()
{
var f
f = document.receiveaddr

if ((f.donationfee.value)=="")

f.total_spend.value = parseInt(f.total_spend_before.value)


else

f.total_spend.value = parseInt(f.total_spend_before.value) + parseInt(f.donationfee.value)


f.total_spend.value = formatAsMoney(parseInt(f.total_spend.value));
f.total_spend3.value = formatAsMoney(parseInt(f.donationfee.value));


}

function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00' 
              : ( (mnt*10 == Math.floor(mnt*10)) ? 
                       mnt + '0' : mnt);
}


function checkpostcode(fn, formfield, returnto)
{
var formname = fn.name
var suburb = eval("document."+formname+"."+formfield+".value")
//alert (suburb)
if (suburb == ""){
alert("Please enter your suburb.")
return false;
}else{
var postpage = "postcodechecker.asp?suburb="+suburb+"&fn="+formname+"&returnto="+returnto
MP_openBrWindow(postpage,"postcodecheck","scrollbars=yes, width=300,height=300, resizable=yes", "300", "300")

}
}

function insertpostcode(pc, fname, returncode){
	
eval("document."+fname+"."+returncode+".value = "+pc)

}


function openwin_card_preview(item) { 
window.open ("preview.asp?id="+item+"", "preview", "height=600, width=760, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no, top=170, left=220") 
} 

function openwin_card_preview_print(item) { 
window.open ("preview.asp?id="+item+"&typ=print", "preview", "height=600, width=760, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no, top=170, left=220") 
} 

//home page mousecover event start

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//home page mousecover event end


function change_address_type_display(type_name){
	
	
	if(type_name == "street"){
	document.getElementById("div_type_street").style.display = "block"; 
	document.getElementById("div_type_pobox").style.display = "none"; 
	document.getElementById("div_type_privatebag").style.display = "none"; 
	}
	
	if(type_name == "pobox"){
	document.getElementById("div_type_street").style.display = "none"; 
	document.getElementById("div_type_pobox").style.display = "block"; 
	document.getElementById("div_type_privatebag").style.display = "none"; 
	}
	
	if(type_name == "privatebag"){
	document.getElementById("div_type_street").style.display = "none"; 
	document.getElementById("div_type_pobox").style.display = "none"; 
	document.getElementById("div_type_privatebag").style.display = "block"; 
	}
	
	
}




function chk_submit_billing_form(){

   var billing_address_type_value='';
   
   for(i=0,len=document.form_billing_address.billing_address_type.length;i<len;i++)
   {
       if(document.form_billing_address.billing_address_type[i].checked){
       billing_address_type_value = document.form_billing_address.billing_address_type[i].value;
       }
   }
   
	var err = ""
	var mess = "Sorry we could not submit your form as there is errors:\n\n"
	 

	if(document.form_billing_address.billing_title.value.length<1){   
		err += "Please select a value for the field 'Title'.\n"
		document.form_billing_address.billing_title.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_title.style.backgroundColor = "#ffffff";
	}
   
   if(document.form_billing_address.billing_name.value.length<1){   
		err += "Please enter a value for the field 'First Name'.\n"
		document.form_billing_address.billing_name.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_name.style.backgroundColor = "#ffffff";
	}
   
   
   if(document.form_billing_address.Billing_surname.value.length<1){   
		err += "Please enter a value for the field 'Last Name'.\n"
		document.form_billing_address.Billing_surname.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.Billing_surname.style.backgroundColor = "#ffffff";
	}

	if (document.form_billing_address.billing_email.value.charAt(0)=="." ||        
		document.form_billing_address.billing_email.value.charAt(0)=="@"||       
		document.form_billing_address.billing_email.value.indexOf('@', 0) == -1 || 
		document.form_billing_address.billing_email.value.indexOf('.', 0) == -1 || 
		document.form_billing_address.billing_email.value.lastIndexOf("@")==document.form_billing_address.billing_email.value.length-1 || 
		document.form_billing_address.billing_email.value.lastIndexOf(".")==document.form_billing_address.billing_email.value.length-1){
		err += "Please enter a value for the field 'Billing Email' \n"
		document.form_billing_address.billing_email.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_email.style.backgroundColor = "#ffffff";
	}

    
	 if(document.form_billing_address.billing_telg.value.length<1){   
		err += "Please enter a value for the field 'Phone prefix code'.\n"
		document.form_billing_address.billing_telg.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_telg.style.backgroundColor = "#ffffff";
	}
	
	
	 if(document.form_billing_address.billing_tel.value.length<1){   
		err += "Please enter a value for the field 'Phone'.\n"
		document.form_billing_address.billing_tel.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_tel.style.backgroundColor = "#ffffff";
	}
	
	
	
	if(document.form_billing_address.billing_mobileg.value.length<1){   
		err += "Please enter a value for the field 'Mobile prefix code'.\n"
		document.form_billing_address.billing_mobileg.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_mobileg.style.backgroundColor = "#ffffff";
	}
	
	
	 if(document.form_billing_address.billing_mobile.value.length<1){   
		err += "Please enter a value for the field 'Mobile'.\n"
		document.form_billing_address.billing_mobile.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_mobile.style.backgroundColor = "#ffffff";
	}
	
	
	if(document.form_billing_address.billing_attn.value.length<1){   
		err += "Please enter a value for the field 'Attn'.\n"
		document.form_billing_address.billing_attn.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_attn.style.backgroundColor = "#ffffff";
	}
	
	
	if(billing_address_type_value=="Street Address"){
		
			if(document.form_billing_address.billing_address1.value.length<1){   
				err += "Please enter a value for the field 'Street Number'.\n"
				document.form_billing_address.billing_address1.style.backgroundColor = "#99cc00";
			}else{
				document.form_billing_address.billing_address1.style.backgroundColor = "#ffffff";
			}
			
			if(document.form_billing_address.billing_address_line2.value.length<1){   
				err += "Please enter a value for the field 'Street Name'.\n"
				document.form_billing_address.billing_address_line2.style.backgroundColor = "#99cc00";
			}else{
				document.form_billing_address.billing_address_line2.style.backgroundColor = "#ffffff";
			}
		
		}
	
	if(billing_address_type_value=="PO Box"){
		
				if(document.form_billing_address.billing_pobox.value.length<1){   
				err += "Please enter a value for the field 'PO Box'.\n"
				document.form_billing_address.billing_pobox.style.backgroundColor = "#99cc00";
			}else{
				document.form_billing_address.billing_pobox.style.backgroundColor = "#ffffff";
			}
		}
	
	
	if(billing_address_type_value=="Private Bag"){
		
				if(document.form_billing_address.billing_privatebag.value.length<1){   
				err += "Please enter a value for the field 'Private Bag'.\n"
				document.form_billing_address.billing_privatebag.style.backgroundColor = "#99cc00";
			}else{
				document.form_billing_address.billing_privatebag.style.backgroundColor = "#ffffff";
			}	
		}
	
	
	
	 if(document.form_billing_address.billing_address2.value.length<1){   
		err += "Please enter a value for the field 'Suburb'.\n"
		document.form_billing_address.billing_address2.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_address2.style.backgroundColor = "#ffffff";
	}
	
	 if(document.form_billing_address.billing_address3.value.length<1){   
		err += "Please enter a value for the field 'City'.\n"
		document.form_billing_address.billing_address3.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_address3.style.backgroundColor = "#ffffff";
	}
	
	 if(document.form_billing_address.billing_postcode.value.length<1){   
		err += "Please enter a value for the field 'Post Code'.\n"
		document.form_billing_address.billing_postcode.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_postcode.style.backgroundColor = "#ffffff";
	}
	

 
	if(err != ""){
	alert(mess+err);
	return false;
	}else{
	 document.form_billing_address.action='?action=save_billing_address';
	 document.form_billing_address.submit();

	}

} 




function chk_submit_payment_form(){

   var billing_address_type_value='';
   
   for(i=0,len=document.receiveaddr.billing_address_type.length;i<len;i++)
   {
       if(document.receiveaddr.billing_address_type[i].checked){
       billing_address_type_value = document.receiveaddr.billing_address_type[i].value;
       }
   }
   
   var source_value='';
   
   for(i=0,len=document.receiveaddr.source.length;i<len;i++)
   {
       if(document.receiveaddr.source[i].checked){
       source_value = document.receiveaddr.source[i].value;
       }
   }
   
   
   
	var err = ""
	var mess = "Sorry we could not submit your form as there is errors:\n\n"
	 

	if(document.receiveaddr.billing_title.value.length<1){   
		err += "Please select a value for the field 'Title'.\n"
		document.receiveaddr.billing_title.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_title.style.backgroundColor = "#ffffff";
	}
   
   if(document.receiveaddr.billing_name.value.length<1){   
		err += "Please enter a value for the field 'First Name'.\n"
		document.receiveaddr.billing_name.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_name.style.backgroundColor = "#ffffff";
	}
   
   
   if(document.receiveaddr.billing_surname.value.length<1){   
		err += "Please enter a value for the field 'Last Name'.\n"
		document.receiveaddr.billing_surname.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_surname.style.backgroundColor = "#ffffff";
	}

	if (document.receiveaddr.billing_email.value.charAt(0)=="." ||        
		document.receiveaddr.billing_email.value.charAt(0)=="@"||       
		document.receiveaddr.billing_email.value.indexOf('@', 0) == -1 || 
		document.receiveaddr.billing_email.value.indexOf('.', 0) == -1 || 
		document.receiveaddr.billing_email.value.lastIndexOf("@")==document.receiveaddr.billing_email.value.length-1 || 
		document.receiveaddr.billing_email.value.lastIndexOf(".")==document.receiveaddr.billing_email.value.length-1){
		err += "Please enter a value for the field 'Billing Email' \n"
		document.receiveaddr.billing_email.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_email.style.backgroundColor = "#ffffff";
	}

    
	/*if(document.receiveaddr.billing_telg.value.length<1){   
		//err += "Please enter a value for the field 'Phone prefix code'.\n"
		document.receiveaddr.billing_telg.style.backgroundColor = "#99cc00";
	}else{
		if(isNaN(document.receiveaddr.billing_telg.value))
		{
			document.receiveaddr.billing_telg.style.backgroundColor="#99cc00";
			err+="Please input number for the field 'Phone prefix code'.\n";
		}
		else document.receiveaddr.billing_telg.style.backgroundColor = "#ffffff";
	}
	
	
	 var phone_mobile=false;
	 
	 if(document.receiveaddr.billing_tel.value.length<1){   
		//err += "Please enter a value for the field 'Phone'.\n"
		document.receiveaddr.billing_tel.style.backgroundColor = "#99cc00";
	}else{
		if(isNaN(document.receiveaddr.billing_tel.value))
		{
			document.receiveaddr.billing_tel.style.backgroundColor="#99cc00";
			err+="Please input number for field 'Phone'.\n";
		}		
		else
		{
			document.receiveaddr.billing_tel.style.backgroundColor = "#ffffff";
			phone_mobile=true;
		}
	}
	
	
	
	if(document.receiveaddr.billing_mobileg.value.length<1){   
		//err += "Please enter a value for the field 'Mobile prefix code'.\n"
		document.receiveaddr.billing_mobileg.style.backgroundColor = "#99cc00";
	}else{
		if(isNaN(document.receiveaddr.billing_mobileg.value))
		{
			document.receiveaddr.billing_mobileg.style.backgroundColor="#99cc00";
			err+="PLease input number for the field 'Mobile prefix code'.\n";
		}
		else document.receiveaddr.billing_mobileg.style.backgroundColor = "#ffffff";		
	}
	
	
	 if(document.receiveaddr.billing_mobile.value.length<1){   
		//err += "Please enter a value for the field 'Mobile'.\n"
		document.receiveaddr.billing_mobile.style.backgroundColor = "#99cc00";
	}else{
		if(isNaN(document.receiveaddr.billing_mobile.value))
		{
			document.receiveaddr.billing_mobile.style.backgroundColor="#99cc00";
			err+="Please input number for field 'Mobile'.\n";
		}
		else
		{
			document.receiveaddr.billing_mobile.style.backgroundColor = "#ffffff";
			phone_mobile=true;
		}
	}*/
	
	
	if(billing_address_type_value=="Street Address"){
		
			/*
			if(document.receiveaddr.billing_address1.value.length<1){   
				err += "Please enter a value for the field 'Street Number'.\n"
				document.receiveaddr.billing_address1.style.backgroundColor = "#99cc00";
			}else{
				document.receiveaddr.billing_address1.style.backgroundColor = "#ffffff";
			}
			*/
			
			if(document.getElementById("billing_streettype").value.length<1)
			{
				err+="Please select 'street type'.\n";
				document.getElementById("billing_streettype").style.backgroundColor="#99cc00";
			}
			else
			{
				document.getElementById("billing_streettype").style.backgroundColor="#ffffff";
			}
			
			if(document.receiveaddr.billing_address_line2.value.length<1){   
				err += "Please enter a value for the field 'Street Name'.\n"
				document.receiveaddr.billing_address_line2.style.backgroundColor = "#99cc00";
			}else{
				document.receiveaddr.billing_address_line2.style.backgroundColor = "#ffffff";
			}
		
		}
	
	if(billing_address_type_value=="PO Box"){
		
				if(document.receiveaddr.billing_pobox.value.length<1 || isNaN(document.receiveaddr.billing_pobox.value)){   
				err += "Please enter numerical value for the field 'PO Box'.\n"
				document.receiveaddr.billing_pobox.style.backgroundColor = "#99cc00";
			}else{
				document.receiveaddr.billing_pobox.style.backgroundColor = "#ffffff";
			}
		}
	
	
	if(billing_address_type_value=="Private Bag"){
		
				if(document.receiveaddr.billing_privatebag.value.length<1){   
				err += "Please enter a value for the field 'Private Bag'.\n"
				document.receiveaddr.billing_privatebag.style.backgroundColor = "#99cc00";
			}else{
				document.receiveaddr.billing_privatebag.style.backgroundColor = "#ffffff";
			}	
		}
	
	
	/*
	 if(document.receiveaddr.billing_address2.value.length<1){   
		err += "Please enter a value for the field 'Suburb'.\n"
		document.receiveaddr.billing_address2.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_address2.style.backgroundColor = "#ffffff";
	}
	*/
	
	 if(document.receiveaddr.billing_address3.value.length<1){   
		err += "Please enter a value for the field 'City'.\n"
		document.receiveaddr.billing_address3.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_address3.style.backgroundColor = "#ffffff";
	}
	
	 if(document.receiveaddr.billing_postcode.value.length<1){   
		err += "Please enter a value for the field 'Post Code'.\n"
		document.receiveaddr.billing_postcode.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_postcode.style.backgroundColor = "#ffffff";
	}
	
	var div_source;
	div_source=document.getElementById("div_source");
	
	if(div_source!=null)
	{		
    if(source_value==''){   
		err += "Please select a value for the field 'Where did you hear about Oxfam Unwrapped'.\n"
		document.getElementById("div_source").style.backgroundColor = "#99cc00";
	}else{
		document.getElementById("div_source").style.backgroundColor = "#ffffff";
	}
	}
 
 	//if(!phone_mobile) err+="Please enter either 'phone number' or 'mobile number'.\n";
	
	if(err != ""){
	alert(mess+err);
	return false;
	}else{
	//alert("ok")
	//return false;
	document.receiveaddr.action='?action=ok';
	document.receiveaddr.submit_form.disabled = true; 
	document.receiveaddr.submit_form.value = 'Your order is being processed...'
	document.receiveaddr.submit();
	}

} 



function chk_submit_billing_form_new(){


	var err = ""
	var mess = "Sorry we could not submit your form as there is errors:\n\n"
	 

	if(document.form_billing_address.billing_title.value.length<1){   
		err += "Please select a value for the field 'Title'.\n"
		document.form_billing_address.billing_title.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_title.style.backgroundColor = "#ffffff";
	}
   
   if(document.form_billing_address.billing_name.value.length<1){   
		err += "Please enter a value for the field 'First Name'.\n"
		document.form_billing_address.billing_name.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_name.style.backgroundColor = "#ffffff";
	}
   
   
   if(document.form_billing_address.Billing_surname.value.length<1){   
		err += "Please enter a value for the field 'Last Name'.\n"
		document.form_billing_address.Billing_surname.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.Billing_surname.style.backgroundColor = "#ffffff";
	}

	if (document.form_billing_address.billing_email.value.charAt(0)=="." ||        
		document.form_billing_address.billing_email.value.charAt(0)=="@"||       
		document.form_billing_address.billing_email.value.indexOf('@', 0) == -1 || 
		document.form_billing_address.billing_email.value.indexOf('.', 0) == -1 || 
		document.form_billing_address.billing_email.value.lastIndexOf("@")==document.form_billing_address.billing_email.value.length-1 || 
		document.form_billing_address.billing_email.value.lastIndexOf(".")==document.form_billing_address.billing_email.value.length-1){
		err += "Please enter a value for the field 'Billing Email' \n"
		document.form_billing_address.billing_email.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_email.style.backgroundColor = "#ffffff";
	}

    
	
	
	
	
	 if(document.form_billing_address.billing_address1.value.length<1){   
		err += "Please enter a value for the field 'Address Line 1'.\n"
		document.form_billing_address.billing_address1.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_address1.style.backgroundColor = "#ffffff";
	}
	

	
	
	
	 if(document.form_billing_address.billing_address3.value.length<1){   
		err += "Please enter a value for the field 'City'.\n"
		document.form_billing_address.billing_address3.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_address3.style.backgroundColor = "#ffffff";
	}
	
	 if(document.form_billing_address.billing_postcode.value.length<1){   
		err += "Please enter a value for the field 'Post Code'.\n"
		document.form_billing_address.billing_postcode.style.backgroundColor = "#99cc00";
	}else{
		document.form_billing_address.billing_postcode.style.backgroundColor = "#ffffff";
	}
	

 
	if(err != ""){
	alert(mess+err);
	return false;
	}else{
	 document.form_billing_address.action='?action=save_billing_address';
	 document.form_billing_address.submit();

	}

} 




function chk_submit_payment_form_new(typ){

 
   
   /*var source_value='';
   
   for(i=0,len=document.receiveaddr.source.length;i<len;i++)
   {
       if(document.receiveaddr.source[i].checked){
       source_value = document.receiveaddr.source[i].value;
       }
   }*/
   
   
   
	var err = ""
	var mess = "Sorry we could not submit your form as there is errors:\n\n"
	 

	if(document.receiveaddr.billing_title.value.length<1){   
		err += "Please select a value for the field 'Title'.\n"
		document.receiveaddr.billing_title.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_title.style.backgroundColor = "#ffffff";
	}
   
   if(document.receiveaddr.billing_name.value.length<1){   
		err += "Please enter a value for the field 'First Name'.\n"
		document.receiveaddr.billing_name.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_name.style.backgroundColor = "#ffffff";
	}
   
   
   if(document.receiveaddr.billing_surname.value.length<1){   
		err += "Please enter a value for the field 'Last Name'.\n"
		document.receiveaddr.billing_surname.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_surname.style.backgroundColor = "#ffffff";
	}

	if (document.receiveaddr.billing_email.value.charAt(0)=="." ||        
		document.receiveaddr.billing_email.value.charAt(0)=="@"||       
		document.receiveaddr.billing_email.value.indexOf('@', 0) == -1 || 
		document.receiveaddr.billing_email.value.indexOf('.', 0) == -1 || 
		document.receiveaddr.billing_email.value.lastIndexOf("@")==document.receiveaddr.billing_email.value.length-1 || 
		document.receiveaddr.billing_email.value.lastIndexOf(".")==document.receiveaddr.billing_email.value.length-1){
		err += "Please enter a value for the field 'Billing Email' \n"
		document.receiveaddr.billing_email.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_email.style.backgroundColor = "#ffffff";
	}

	
	if(document.receiveaddr.billing_address1.value.length<1){   
		err += "Please enter a value for the field 'Address Line 1'.\n"
		document.receiveaddr.billing_address1.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_address1.style.backgroundColor = "#ffffff";
	}
	

	 if(document.receiveaddr.billing_address3.value.length<1){   
		err += "Please enter a value for the field 'City'.\n"
		document.receiveaddr.billing_address3.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_address3.style.backgroundColor = "#ffffff";
	}
	
	 if(document.receiveaddr.billing_postcode.value.length<1){   
		err += "Please enter a value for the field 'Post Code'.\n"
		document.receiveaddr.billing_postcode.style.backgroundColor = "#99cc00";
	}else{
		document.receiveaddr.billing_postcode.style.backgroundColor = "#ffffff";
	}
	
	var div_source;
	div_source=document.getElementById("div_source");
	
	//if(div_source!=null)
//	{		
//    if(source_value==''){   
//		err += "Please select a value for the field 'Where did you hear about Oxfam Unwrapped'.\n"
//		document.getElementById("div_source").style.backgroundColor = "#99cc00";
//	}else{
//		document.getElementById("div_source").style.backgroundColor = "#ffffff";
//	}
//	}
 
 	//if(!phone_mobile) err+="Please enter either 'phone number' or 'mobile number'.\n";
	
	if(err != ""){
	alert(mess+err);
	return false;
	}else{
	//alert("ok")
	//return false;
	if(typ==''){
	document.receiveaddr.action='?action=ok';
	document.receiveaddr.submit_form.disabled = true; 
	document.receiveaddr.submit_form.value = 'Your order is being processed...'
	document.receiveaddr.submit();	
	
	}else{
	document.receiveaddr.action='?action=ok&typ=corp';	
	document.receiveaddr.Submit3.disabled = true; 
	document.receiveaddr.Submit3.value = 'Your order is being processed...'
	document.receiveaddr.submit();		
	}
	

	}

} 
