var formHasFocus = false;
function checkEmail(strEmail){if(strEmail.length>=5&&strEmail.indexOf('@')!=-1&&strEmail.indexOf('.')!=-1){var atpos=strEmail.indexOf('@');var dotpos=strEmail.indexOf('.',atpos);var user=strEmail.substring(0,atpos);var domname=strEmail.substring(atpos+1,dotpos);var domlast=strEmail.substring(dotpos+1);if(user.length>0&&domname.length>0&&domlast.length>0){return true}else{return false}}else{return false}}
function checkSearch(){var objSk=document.getElementById('searchForm').sk;if(objSk.value!=''){if (objSk.value!=''){location.href='/search.php?sk='+objSk.value;return false}else{alert('Error! You must complete the field correctly!');objSk.focus();return false}}else{alert('Error! You must complete the field correctly!');objSk.focus();return false}}
function controlGotFocus(){formHasFocus=true}
function controlLostFocus(){formHasFocus=false}
function loadContactUsCode(){var objContactForm=document.getElementById('contactusform');if (objContactForm.fcode.value==''){objContactForm.fcode.focus()}}
function loadContactUs(){if (!formHasFocus) document.getElementById('contactusform').fname.focus()}
function checkContactUs(){var objContactForm=document.getElementById('contactusform');if (objContactForm.fname.value==''){alert('You must write down a name!');objContactForm.fname.focus();return false}else{if (!checkEmail(objContactForm.femail.value)){alert('The e-mail address must be valid!');objContactForm.femail.focus();return false}else{if (objContactForm.fmessage.value==''){alert('You must write down a message!');objContactForm.fmessage.focus();return false}else{if (objContactForm.fcode.value.length!=4){alert('The verifiaction code must have a length of four characters!');objContactForm.fcode.focus();return false}else{return true}}}}}
function loadSuggestCatCode(){var objCode=document.getElementById('suggestcatform').fcode;if (objCode.value==''){objCode.focus()}}
function loadSuggestCat(){if (!formHasFocus) document.getElementById('suggestcatform').fname.focus()}
function checkSuggestCat(){var objSuggestCatForm=document.getElementById('suggestcatform');if (objSuggestCatForm.fname.value==''){alert('You must write down a name!');objSuggestCatForm.fname.focus();return false}else{if (!checkEmail(objSuggestCatForm.femail.value)){alert('The e-mail address must be valid!');objSuggestCatForm.femail.focus();return false}else{if (objSuggestCatForm.fcatname.value==''){alert('You must write down a name for the category!');objSuggestCatForm.fcatname.focus();return false}else{if (objSuggestCatForm.fcatdesc.value==''){alert('You must write down a description for the category!');objSuggestCatForm.fcatdesc.focus();return false}else{if (objSuggestCatForm.fwebsite.value==''){alert('You must specify an example website to be listed in this category!');objSuggestCatForm.fwebsite.focus();return false}else{if (objSuggestCatForm.fcode.value.length!=4){alert('The verifiaction code must have a length of four characters!');objSuggestCatForm.fcode.focus();return false}else{return true}}}}}}}
function loadSubmitURLCode(){var objCode=document.getElementById('submiturlform').fcode;if (objCode.value=='') objCode.focus()}
function loadSubmitURL(){if (!formHasFocus) document.getElementById('submiturlform').furl.focus()}
function showHideChangeCat(intCat){var objChangeCat=document.getElementById('changecat');if (objChangeCat.style.visibility=='visible'){objChangeCat.style.visibility='hidden'}else{objChangeCat.style.visibility='visible';var objIframeElement=document.getElementById('changecatiframe');if (intCat==0) objIframeElement.src='change-category.php';else objIframeElement.src='change-category.php?selcat='+intCat}return false}
function changeCat(){var objSubmitURLForm=document.getElementById('submiturlform');var objIframeElement=document.getElementById('changecatiframe');var objIframeDoc=(objIframeElement.contentDocument)?objIframeElement.contentDocument:document.frames['changecatiframe'].document;var objControls=objIframeDoc.getElementsByTagName('input');for (i=0;i<objControls.length;i++){if (objControls[i].name=='cat'&&objControls[i].checked) objSubmitURLForm.fcat.value=objControls[i].value}objSubmitURLForm.fcatname.value=objIframeDoc.getElementById('cat'+objSubmitURLForm.fcat.value).value;document.getElementById('changecat').style.visibility='hidden'}
function checkSubmitURL(intCat){var objSubmitURLForm=document.getElementById('submiturlform');if (objSubmitURLForm.furl.value==''){alert('You must specify your website URL!');objSubmitURLForm.furl.focus();return false}else{if (objSubmitURLForm.ftitle.value==''){alert('You must write down a title!');objSubmitURLForm.ftitle.focus();return false}else{if (objSubmitURLForm.fdesc.value==''){alert('You must write down a description!');objSubmitURLForm.fdesc.focus();return false}else{if (objSubmitURLForm.fcat.value==0){alert('You must select a category!');var objIframeElement=document.getElementById('changecatiframe');if (intCat==0) objIframeElement.src='change-category.php'; else objIframeElement.src='change-category.php?selcat='+intCat;document.getElementById('changecat').style.visibility='visible';return false}else{if (objSubmitURLForm.fname.value==''){alert('You must write down your name!');objSubmitURLForm.fname.focus();return false}else{if (!checkEmail(objSubmitURLForm.femail.value)){alert('The e-mail address must be valid!');objSubmitURLForm.femail.focus();return false}else{if (objSubmitURLForm.fcode.value.length!=4){alert('The verifiaction code must have a length of four characters!');objSubmitURLForm.fcode.focus();return false}else{return true}}}}}}}}
