var allowed_char_types=[32,37,33,40,41,44,46,48,49,50,51,52,53,54,55,56,57,64,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,125];var allowed_tel_types=[32,40,41,48,49,50,51,52,53,54,55,56,57];var allowed_num_types=[48,49,50,51,52,53,54,55,56,57];function checkinputnumericandextra(tmpnum)
{var stringholder='';for(x=0;x<tmpnum.length;x++)
{if((tmpnum.charCodeAt(x)>=48)&&(tmpnum.charCodeAt(x)<=58))
{stringholder=stringholder+tmpnum.charAt(x);}}
return stringholder;}
function checkinputnumeric(tmpnum)
{var checkinputnumeric_result=true
for(x=0;x<tmpnum.length;x++)
{if((tmpnum.charCodeAt(x)>=48)&&(tmpnum.charCodeAt(x)<=57))
{}else
{var checkinputnumeric_result=false;}}
return checkinputnumeric_result;}
function checkforvalidkeyword(tmpstring)
{var newstring="";var usedyet="false";for(x=0;x<tmpstring.length;x++)
{if((tmpstring.charCodeAt(x)>=97)&&(tmpstring.charCodeAt(x)<=122))
{newstring=newstring+tmpstring.charAt(x);}
if((tmpstring.charCodeAt(x)>=65)&&(tmpstring.charCodeAt(x)<=90))
{newstring=newstring+tmpstring.charAt(x);}
if((tmpstring.charCodeAt(x)>=48)&&(tmpstring.charCodeAt(x)<=57))
{newstring=newstring+tmpstring.charAt(x);}
if(usedyet=="false")
{if(tmpstring.charCodeAt(x)==32)
{newstring=newstring+tmpstring.charAt(x);usedyet="true";}}}
return newstring;}
function checkforinvalidcharsimple(tmpstring)
{var newstring="";for(x=0;x<tmpstring.length;x++)
{if((tmpstring.charCodeAt(x)>=32)&&(tmpstring.charCodeAt(x)<=126))
{newstring=newstring+tmpstring.charAt(x);}}
return newstring;}
function checkforinvalidcharname_nospace(tmpstring)
{var newstring="";for(x=0;x<tmpstring.length;x++)
{if((tmpstring.charCodeAt(x)>=97)&&(tmpstring.charCodeAt(x)<=122))
{newstring=newstring+tmpstring.charAt(x);}
if((tmpstring.charCodeAt(x)>=65)&&(tmpstring.charCodeAt(x)<=90))
{newstring=newstring+tmpstring.charAt(x);}}
return newstring;}
function checkforinvalidcharname(tmpstring)
{var newstring="";for(x=0;x<tmpstring.length;x++)
{if((tmpstring.charCodeAt(x)>=97)&&(tmpstring.charCodeAt(x)<=122))
{newstring=newstring+tmpstring.charAt(x);}
if((tmpstring.charCodeAt(x)>=65)&&(tmpstring.charCodeAt(x)<=90))
{newstring=newstring+tmpstring.charAt(x);}
if(tmpstring.charCodeAt(x)==32)
{newstring=newstring+tmpstring.charAt(x);}}
return newstring;}
function checkforinvalidchartel2(tmpstring)
{var newstring="";for(x=0;x<tmpstring.length;x++)
{if((tmpstring.charCodeAt(x)>=48)&&(tmpstring.charCodeAt(x)<=57))
{newstring=newstring+tmpstring.charAt(x);}
if((tmpstring.charCodeAt(x)>=40)&&(tmpstring.charCodeAt(x)<=41))
{newstring=newstring+tmpstring.charAt(x);}
if(tmpstring.charCodeAt(x)==32)
{newstring=newstring+tmpstring.charAt(x);}}
return newstring;}
function checkforinvalidchartel(tmpstring)
{var telvalid="false";var newstring="";tmpstring=tmpstring.toLowerCase();for(x=0;x<tmpstring.length;x++)
{var telvalid="false";if((tmpstring.charCodeAt(x)>=32)&&(tmpstring.charCodeAt(x)<=126))
{for(y=0;y<allowed_tel_types.length;y++)
{if(tmpstring.charCodeAt(x)==allowed_tel_types[y])
{var telvalid="true";}}}
if(telvalid=="false")return false;;}
return true;}
function checkforinvalidcharcomp(tmpstring)
{var newstring="";tmpstring=tmpstring.toLowerCase();for(x=0;x<tmpstring.length;x++)
{if((tmpstring.charCodeAt(x)>=32)&&(tmpstring.charCodeAt(x)<=126))
{for(y=0;y<allowed_char_types.length;y++)
{if(tmpstring.charCodeAt(x)==allowed_char_types[y])
{newstring=newstring+tmpstring.charAt(x);}}}}
return newstring;}
function extremetrim(tmpstring)
{var newstring="";for(x=0;x<tmpstring.length;x++)
{if(tmpstring.charAt(x)==" ")
{newstring=newstring+tmpstring.charAt(x);while(tmpstring.charAt(x+1)==" ")
{x++;}}else
{newstring=newstring+tmpstring.charAt(x);}}
return newstring;}
function removeallspaces(tmpstring)
{var newstring="";for(x=0;x<tmpstring.length;x++)
{if(tmpstring.charAt(x)==" ")
{}else
{newstring=newstring+tmpstring.charAt(x);}}
return newstring;}
function convertlowercase(tmpstring)
{return tmpstring.toLowerCase();}
function addhttp(tmpstring)
{tmpstring=tmpstring.toLowerCase();if(tmpstring.slice(0,3)=="www")
{tmpstring="http://"+tmpstring;}
return tmpstring;}
function convertwordcase(tmpstring)
{var newstring="";tmpstring=extremetrim(tmpstring);tmpstring=tmpstring.toLowerCase();for(x=0;x<tmpstring.length;x++)
{if(x==0)
{newstring=newstring+tmpstring.charAt(x).toUpperCase();}else
{if(tmpstring[x-1]==" ")
{newstring=newstring+tmpstring.charAt(x).toUpperCase();}else
{newstring=newstring+tmpstring.charAt(x);}}}
return newstring;}
function checkukpostcode(tmppc)
{var reg=new RegExp("^(([A-Z]{1,2}[0-9][0-9A-Z]{0,1})\ ([0-9][A-Z]{2}))|(GIR\ 0AA)$","i");if(reg.test(tmppc))
{return true;}else
{return false;}}
function splitpostcode(tmpstr)
{if(tmpstr.charCodeAt(tmpstr.length-4)!=32)
{switch(tmpstr.length)
{case 5:tmpstr=tmpstr.slice(0,2)+" "+tmpstr.slice(2,5);break;case 6:tmpstr=tmpstr.slice(0,3)+" "+tmpstr.slice(3,6);break;case 7:tmpstr=tmpstr.slice(0,4)+" "+tmpstr.slice(4,7);break;default:}}
return tmpstr;}
function checkusazipcode(tmppc)
{var reg=new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);if(reg.test(tmppc))
{return true;}else
{return false;}}
function checkauscode(tmppc)
{var reg=new RegExp("^([N][S][W]|[A][C][T]|[V][I][C]|[Q][L][D]|[S][A]|[W][A]|[T][A][S]|[N][T])([ ])([0-9]{4})$");if(reg.test(tmppc))
{return true;}else
{return false;}}
function checkwebaddress(tmpwa)
{tmpwa=addhttp(tmpwa.toLowerCase());var reg=new RegExp("^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~])*[^\.\,\)\(\s]$","i");if(reg.test(tmpwa))
{return true;}else
{return false;}}
function checkemailaddress(tmpem)
{var reg=new RegExp("^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,6}$","i");if(reg.test(tmpem))
{return true;}else
{return false;}}
function ltrim(str){for(var k=0;k<str.length&&isWhitespace(str.charAt(k));k++);return str.substring(k,str.length);}
function rtrim(str){for(var j=str.length-1;j>=0&&isWhitespace(str.charAt(j));j--);return str.substring(0,j+1);}
function trimwhitespace(str){return ltrim(rtrim(str));}
function isWhitespace(charToCheck){var whitespaceChars=" \t\n\r\f";return(whitespaceChars.indexOf(charToCheck)!=-1);}
function check_duplicate(img_name,varvalue,vartype)
{switch(vartype)
{case'picture_gallery':var $vaddress="include/checkduplicateuser.php?gallery_name=";break;default:if(vartype=="name")
{var $vaddress="include/checkduplicateuser.php?usrnm=";}else
{var $vaddress="include/checkduplicateemail.php?emailad=";}}
GDownloadUrl($vaddress+varvalue,function(data){var xml=GXml.parse(data);var checkresult=xml.documentElement.getElementsByTagName("result");for(var i=0;i<checkresult.length;i++)
{var varres=checkresult[i].getAttribute("res");if(varres=="pass")
{document.getElementById(img_name).src="images/ok.gif";document.getElementById(img_name).alt="Ok";document.getElementById(img_name).title="Ok";}else
{document.getElementById(img_name).src="images/error.gif";document.getElementById(img_name).alt="Error";document.getElementById(img_name).title="Error";}}});if(varvalue==""){document.getElementById(img_name).src="images/error.gif"}}
function check_not_blank(img_name,varvalue,vartype)
{if(vartype=="name")
{var $vaddress="include/checkduplicateuser.php?usrnm=";}else
{var $vaddress="include/checkduplicateemail.php?emailad=";}
GDownloadUrl($vaddress+varvalue,function(data){var xml=GXml.parse(data);var checkresult=xml.documentElement.getElementsByTagName("result");for(var i=0;i<checkresult.length;i++)
{var varres=checkresult[i].getAttribute("res");if(varres=="pass")
{document[img_name].src="images/ok.gif";document[img_name].alt="Ok";document[img_name].title="Ok";}else
{document[img_name].src="images/error.gif";document[img_name].alt="Error";document[img_name].title="Error";}}});if(varvalue==""){document[img_name].src="images/error.gif"}}
function checkpostcode(cntycode,postcode)
{var postcode_valid=false;switch(cntycode)
{case'gb':postcode_valid=checkukpostcode(postcode);break;case'us':postcode_valid=checkusazipcode(postcode);break;case'au':postcode_valid=checkauscode(postcode);break;default:postcode_valid=false;}
return postcode_valid;}
function adjustpostcode(cntycode,postcode)
{var newpostcode='';switch(cntycode)
{case'gb':for(var x=0;x<postcode.length;x++)
{newpostcode=newpostcode+postcode.charAt(x);if(postcode.length==5){if(x==1)newpostcode=newpostcode+' ';}
if(postcode.length==6){if(x==2)newpostcode=newpostcode+' ';}
if(postcode.length==7){if(x==3)newpostcode=newpostcode+' ';}}
break;case'us':for(var x=0;x<postcode.length;x++)
{newpostcode=newpostcode+postcode.charAt(x);}
break;case'au':for(var x=0;x<postcode.length;x++)
{newpostcode=newpostcode+postcode.charAt(x);if(postcode.length==6){if(x==1)newpostcode=newpostcode+' ';}
if(postcode.length==7){if(x==2)newpostcode=newpostcode+' ';}}
newpostcode=newpostcode.toUpperCase();break;default:newpostcode=postcode;}
return newpostcode;}
function checkimage(tmpholder)
{var fileokay=false;tmpholder=tmpholder.toLowerCase();for(var i=0;i<allowed_pic_types.length;i++)
{if(tmpholder.substring(tmpholder.length-3,tmpholder.length)==allowed_pic_types[i])
{fileokay=true;}
if(tmpholder.substring(tmpholder.length-4,tmpholder.length)==allowed_pic_types[i])
{fileokay=true;}}
if(fileokay==false)
{alert("The file you selected is not a valid type(JPG,JPEG,GIF,PNG)");}else
{}}