function validate(formname)
{var error='blank'var error2='blank'var valid='true'var radchecked=false
var radname='blank'var boxchecked=false
var boxname='blank'radios=new Array("blank")
rad_val=new Array();theForm=document.getElementById(formname);for(i=0;i<theForm.elements.length;i++){if(theForm.elements[i].name.substring(0,4)=="req_"){if(theForm.elements[i].type=='radio'){radios.push(theForm.elements[i].name)}}}
radios=unique(radios)
radios.shift();for(i=0;i<radios.length;i++){rad_val[i]=false}
for(i=0;i<theForm.elements.length;i++){if(theForm.elements[i].name.substring(0,4)=="req_"){var idname=theForm.elements[i].name.substring(4,theForm.elements[i].name.length)
document.getElementById(idname).style.color='';if(theForm.elements[i].type=="text"||theForm.elements[i].type=="textarea"||theForm.elements[i].type=="button"){if(theForm.elements[i].value==""){document.getElementById(idname).style.color='#C44B90';valid='false'}
if(theForm.elements[i].name=="req_email"){if(!(checkemail(theForm.elements[i].value))){valid='false';document.getElementById(idname).style.color='#C44B90';}}
if(theForm.elements[i].name=="req_email_confirm"){if(theForm.req_email.value!=theForm.elements[i].value){valid='false';document.getElementById(idname).style.color='#C44B90';}}}
if(theForm.elements[i].type=="password"){if(theForm.elements[i].value==""){document.getElementById(idname).style.color='#C44B90';valid='false'}
if(theForm.elements[i].name=="req_password_confirm"){if(theForm.req_password.value!=theForm.elements[i].value){valid='false';document.getElementById(idname).style.color='#C44B90';}}}
if(theForm.elements[i].type=="file "){if(theForm.elements[i].value==""){document.getElementById(idname).style.color='#d8007e';valid='false'}}
if(theForm.elements[i].type=="checkbox"){if(boxname==theForm.elements[i].name){if(boxchecked==false)
boxchecked=theForm.elements[i].checked}
else{boxname=theForm.elements[i].name
boxchecked=theForm.elements[i].checked}
if(boxchecked==false)
error2=idname
if(boxchecked==true)
error2='blank'}
if(theForm.elements[i].type=="select-one")
if(theForm.elements[i].selectedIndex==0){if(theForm.elements[i].name.substring(0,8)=="req_from")
document.getElementById('from_dates').style.color='#C44B90';else if(theForm.elements[i].name.substring(0,7)=="req_to_")
document.getElementById('to_dates').style.color='#C44B90';else
document.getElementById(idname).style.color='#C44B90';valid='false'}
if(theForm.elements[i].type=='radio'){rad_index=get_index(theForm.elements[i].name,radios);if(rad_val[rad_index]==false)
rad_val[rad_index]=theForm.elements[i].checked;}}}
for(i=0;i<radios.length;i++){if(rad_val[i]==false){valid='false';document.getElementById(radios[i].substring(4,radios[i].length)).style.color='#C44B90';}}
if(error2!='blank'){document.getElementById(error2).style.color='#C44B90';document.getElementById(error2).style.visibility='visible';valid='false';}
if(valid=='true'){for(i=0;i<theForm.elements.length;i++)
if(theForm.elements[i].name.substring(0,4)=="req_")
theForm.elements[i].name=theForm.elements[i].name.substring(4,theForm.elements[i].name.length);if(theForm.from_month)
theForm.evt_date_from.value=theForm.from_month.options[theForm.from_month.selectedIndex].value+'/'+theForm.from_day.value+'/'+theForm.from_year.value;if(theForm.evt_date_to)
theForm.evt_date_to.value=theForm.to_month.value+'/'+theForm.to_day.value+'/'+theForm.to_year.value;}
if(valid=='false'){if(document.getElementById(formname+'_alert'))
document.getElementById(formname+'_alert').style.display="block";else
if(document.getElementById('alert'))
document.getElementById('alert').style.display="block";if(document.getElementById(formname+'_anchor'))
window.location.hash=formname+'_anchor';else
window.scrollTo(0,510);return false;}
return true;}
function get_index(n,h){for(z=0;z<h.length;z++){if(h[z]==n)
return z;}
return-1;}
function unique(a){tmp=new Array(0);for(i=0;i<a.length;i++){if(!contains(tmp,a[i])){tmp.length+=1;tmp[tmp.length-1]=a[i];}}
return tmp;}
function contains(a,e){for(j=0;j<a.length;j++)if(a[j]==e)return true;return false;}
function checkemail(str){var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if(filter.test(str))
testresults=true
else{testresults=false}
return(testresults)}
function gotoAnchor(anchorName){if(document.layers){var anchor=document.anchors[anchorName];window.scrollTo(anchor.x,anchor.y);return;}
else if(document.getElementById){var anchor=document.anchors[anchorName];var coords={x:0,y:0};while(anchor){coords.x+=anchor.offsetLeft;coords.y+=anchor.offsetTop;anchor=anchor.offsetParent;}
window.scrollTo(coords.x,coords.y);}}
