function WWC_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=WWC_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n);  
  return x;
}

function WWC_validateForm() { //v4.0
	 var myerror = document.getElementById('myerror');
	 myerror.innerHTML = "<div id='progressPane'><img src='../images/attention_mh.gif' /><strong>We are processing your entry.</strong>Thank you for your patience.<br/><br/><img src='/images/thickbox/loadingAnimation.gif' align='absmiddle' /></div>" ;
 	 tb_show('', '#TB_inline?height=350&width=400&inlineId=myerror&model=true', '');
  var i,p,q,nm,nm2,test,num,min,max,errors='',args=WWC_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=WWC_findObj(args[i]);
 
    if (val) { nm=val.name; nm2=val.title; if ((val=val.value)!="") {
	
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm2+' must contain an e-mail address.\n';
			
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm2+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm2+' must contain a number between '+min+' and '+max+'.\n';
    } } } 
	
	else if (test.charAt(0) == 'R') errors += '- '+nm2+' is required.<br/>';}
 
	} 
	/*if(fileupload.value == ''){
	}else{
	errors = '<b>- You must select a Jpeg (1MB-5MB) file  to upload.</b><br />' + errors;
	};*/
	
    var theform = document.form1;
	var iagree = document.getElementById('iagree1');
	if(iagree){
		if(theform.iagree1.checked == false || theform.iagree2.checked == false || theform.iagree8.checked == false || theform.iagree3.checked == false || theform.iagree4.checked == false || theform.iagree5.checked == false || theform.iagree6.checked == false || theform.iagree7.checked == false  ){
			errors = '<b>- To be qualified to enter, you must meet all seven requirements.</b><br />' + errors;
		}else{
	
		};
	};
	var terms = document.getElementById('terms');
	if(terms){
		if(theform.terms.checked == false){
			errors = '<b>- To proceed you must read and agree (by checking the "I agree..." checkbox) to the Terms and Conditions of the contest.</b><br />' + errors;
		}else{
	
		};
	};
		
  if (errors) {  
		myerror.innerHTML = "<img src='../images/error_mh.gif' /><strong>We're sorry, there has been a problem with your entry submission.</strong><br />" + errors ;
 	 tb_show('', '#TB_inline?height=350&width=400&inlineId=myerror', '');
 };
   document.WWC_returnValue = (errors == '');
};

function WWC_ShowProgess(){
	 var myerror = document.getElementById('myerror');
	 myerror.innerHTML = "<div id='progressPane'><img src='../images/attention_mh.gif' /><h3>We are processing your entry.</h3>Thank you for your patience.<br/><br/><img src='/images/thickbox/loadingAnimation.gif' align='absmiddle' /></div>" ;
 	 tb_show('', '#TB_inline?height=350&width=400&inlineId=myerror', '');
};