
function checkRequire(obj){if(obj.value==""){obj.focus();return false;}
return true;}
function checkCompare(obj1,obj2){if(obj1.value!=obj2.value){obj1.focus();return false;}
return true;}
function checkIsNumber(obj){if(obj.value==""){obj.focus();return false;}
else{if(isNaN(obj.value)==true){obj.focus;return false;}}
return true;}
function checkIsPositiveNumber(obj){if(obj.value==""){obj.focus();return false;}
else{if((isNaN(obj.value)==false)&&(obj.value>0)){obj.focus;return true;}
else{return false;}}
return true;}
function isInteger(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(((c<"0")||(c>"9")))return false;}
return true;}
function IsInteger2(source){if(!ValidateRegular(source,"\\d*")){source.select();source.focus();return false;}
return true;}
function isDigit(c){if((c=='0')||(c=='1')||(c=='2')||(c=='3')||(c=='4')||(c=='5')||(c=='6')||(c=='7')||(c=='8')||(c=='9')){return true;}else{return false;}}
function isNum(argvalue){argvalue=argvalue.toString();if(argvalue.length==0)
return false;for(var n=0;n<argvalue.length;n++)
if(argvalue.substring(n,n+1)<"0"||argvalue.substring(n,n+1)>"9")
return false;return true;}
function isPosReal(s){var dot;s=trim(s);dot=0;for(i=0;i<s.length;i++)
if(!isDigit(s.charAt(i))){if(s.charAt(i)=='.'){dot++;if(i==s.length-1)return false;if(dot>1)return false;}
else return false;}
return true;}
function isPosInt(s){var n;n=s.length
if(n==0)return false;for(i=0;i<n;i++)
if(!isDigit(s.charAt(i)))return false;return true;}
function resetNumberTextBox(target,defaultValue){if(isNaN(target.value))
{target.value=defaultValue;}}
function trimLeft(s)
{var i;i=0;var n;n=s.length;while((i<n)&&(s.charAt(i)==' '))i++;s=s.substring(i);return(s);}
function trimRight(s){var n;n=s.length;var i;i=s.length-1;while((i>=0)&&(s.charAt(i)==' '))i--;s=s.substring(0,i+1);return(s);}
function trim(s){s=trimLeft(s);s=trimRight(s);return(s);}
function checkIsEmail(source){if(!ValidateRegular(source,"\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")){source.select();source.focus();return false;}
return true;}
function isEmail(strEmail){var intlen;var ctmp;strEmail=trim(strEmail);if(strEmail=='')return false;intlen=strEmail.length;if(intlen<5)return false;if(strEmail.indexOf('@')==-1)return false;if(strEmail.indexOf('.')==-1)return false;if(intlen-strEmail.lastIndexOf('.')-1>5)return false;if((strEmail.indexOf("_")!=-1)&&(strEmail.lastIndexOf("_")>strEmail.lastIndexOf("@")))return false;if(strEmail.lastIndexOf(".")<=strEmail.lastIndexOf("@")+1)return false;if(strEmail.indexOf("@")!=strEmail.lastIndexOf("@"))return false;if(intlen-1==strEmail.lastIndexOf('.'))return false;if(strEmail.charAt(strEmail.indexOf('@')+1)=='.')return false;if(strEmail.indexOf(" ")!=-1)return false;if(strEmail.indexOf("..")!=-1)return false;if(strEmail.indexOf(";")!=-1)return false;strEmail=strEmail.toLowerCase();for(intcnt=0;intcnt<intlen;intcnt++)
{ctmp=strEmail.charAt(intcnt)
if((!isDigit(ctmp))&&((ctmp>'z')||(ctmp<'a'))&&(ctmp!='-')&&(ctmp!='.')&&(ctmp!='@')&&(ctmp!='_'))return false;}
return true;}
function ValidateEmail(source){if(!ValidateRegular(source,"\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
{source.select();source.focus();return false;}
return true;}
function ValidateEmail2(num,source){if(num==2)
{if(source.value=="")
{alert('Please enter email address');source.focus();return false;}}
if(!ValidateRegular(source,"\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
{alert('Format email is invalid.');source.select();source.focus();return false;}
return true;}
function checkIsURL(source){if(!ValidateRegular(source,"(http://)?([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?")){source.select();source.focus();return false;}
return true;}
function ValidateURL(source)
{if(!ValidateRegular(source,"((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}"))
{source.select();source.focus();return false;}
return true;}
function URLEncode(str){var ms="%25#23 20?3F<3C>3E{7B}7D[5B]5D|7C^5E~7E`60+2B"
var msi=0
var i,c,rs,ts
while(msi<ms.length)
{c=ms.charAt(msi)
rs=ms.substring(++msi,msi+2)
msi+=2
i=0
while(true)
{i=str.indexOf(c,i)
if(i==-1)break
ts=str.substring(0,i)
str=ts+"%"+rs+str.substring(++i,str.length)}}
return str}
var dtCh="/";var minYear=1900;var maxYear=2100;function compareDate(start,end){var s=new Date(start);var e=new Date(end);var s_y=parseInt(s.getYear());var s_m=parseInt(s.getMonth());var s_d=parseInt(s.getDate());var e_y=parseInt(e.getYear());var e_m=parseInt(e.getMonth());var e_d=parseInt(e.getDate());if(s_y<=e_y){if(s_y==e_y){if(s_m<=e_m){if(s_m==e_m){if(s_d<=e_d){return true;}else{return false;}}
return true;}else{return false;}}
return true;}else{return false}}
function ValidateDate(objDate){if(isDate(objDate.value)==false){return false}
return true}
function isDate(dtStr){var daysInMonth=DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strMonth=dtStr.substring(0,pos1)
var strDay=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if(strDay.charAt(0)=="0"&&strDay.length>1)strDay=strDay.substring(1)
if(strMonth.charAt(0)=="0"&&strMonth.length>1)strMonth=strMonth.substring(1)
for(var i=1;i<=3;i++){if(strYr.charAt(0)=="0"&&strYr.length>1)strYr=strYr.substring(1)}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if(pos1==-1||pos2==-1){return false}
if(strMonth.length<1||month<1||month>12){return false}
if(strDay.length<1||day<1||day>31||(month==2&&day>daysInFebruary(year))||day>daysInMonth[month]){return false}
if(strYear.length!=4||year==0||year<minYear||year>maxYear){return false}
if(dtStr.indexOf(dtCh,pos2+1)!=-1||isInteger(stripCharsInBag(dtStr,dtCh))==false){return false}
return true}
function daysInFebruary(year){return(((year%4==0)&&((!(year%100==0))||(year%400==0)))?29:28);}
function DaysArray(n){for(var i=1;i<=n;i++){this[i]=31
if(i==4||i==6||i==9||i==11){this[i]=30}
if(i==2){this[i]=29}}
return this}
function ValidatePhone(source){if(!ValidateRegular(source,"((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}"))
{source.select();source.focus();return false;}
return true;}
function ValidatePhone2(num,source)
{if(num==2)
{if(source.value=="")
{alert('Please enter phone number!');source.focus();return false;}}
if(!ValidateRegular(source,"((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}"))
{alert('Phone number is invalid!\n Format phone:(xxx)xxx-xxxx');source.select();source.focus();return false;}
return true;}
function ValidateZipS(num,source)
{if(num==2)
{if(source.value=="")
{alert("Please enter zip code!");source.focus();return false;}}
if(!ValidateRegular(source,"\\d{5}(-\\d{4})?"))
{alert('Zip number is invalid!\n Format zip:xxxxx');source.select();source.focus();return false;}
return true;}
function ValidateFaxS(num,source)
{if(num==2)
{if(source.value=="")
{alert('Please enter fax number!');source.focus();return false;}}
if(!ValidateRegular(source,"((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}"))
{alert('Fax number is invalid!\n Format Fax:(xxx)xxx-xxxx');source.select();source.focus();return false;}
return true;}
function ValidateRegular(source,reg){var value=source.value;if(value=="")return true;var rx=new RegExp(reg);var matches=rx.exec(value);return(matches!=null&&value==matches[0]);}
function isImage(str){str=str.toLowerCase();var len=str.length;var pos=str.indexOf(".",0);var ext=str.substring(pos,len);if((ext==".jpg")||(ext==".gif")||(ext==".png")){return true;}
return false;}
function getFileName(str){var bpos
var filename
if((str=='')||(str.indexOf("\\")==-1))return(str);bpos=str.lastIndexOf("\\");filename=str.substring(bpos+1,str.length)
return(filename);}
function checkFile(strValue,strFileType)
{var strExtension=strValue.substr((strValue.lastIndexOf(".")+1),strValue.length).toLowerCase();var arrExtension=strFileType.split(",");var bFound=false;for(var i=0;i<arrExtension.length;i++)
{if(strExtension.toLowerCase()==arrExtension[i].toLowerCase())
{bFound=true;}}
return bFound;}
function NewWindow(sURL,width,hight){window.open(sURL,'NewWindow','scrollbars=no,status=no,width='+width+',height='+hight+',resizable=no');}
function openSearchWindow(file){var iWidth=500,iHeight=500;window.open(file,"Search","toolbar=no,scrollbars=yes,resizable=yes,width="+iWidth+",height="+iHeight).focus();}
function openCustomWindow(file,iWidth,iHeight){window.open(file,"Search","toolbar=no,scrollbars=yes,resizable=yes,width="+iWidth+",height="+iHeight).focus();}
function openNewWindow(file,Title){var iWidth=500,iHeight=600;window.open(file,Title,"toolbar=no,scrollbars=yes,resizable=yes,width="+iWidth+",height="+iHeight).focus();}
function openCalendarWindow(file,Title){var iWidth=500,iHeight=600;window.open(file,Title,"toolbar=no,scrollbars=yes,resizable=yes,width="+iWidth+",height="+iHeight).focus();}
function showFullImage(URL){fullSizeWin=window.open(URL,"_blank",'location=no,titlebar=no,scrollbars=yes,status=no,width=500,height=300,resizable=yes,toolbar=no,menubar=no');fullSizeWin.focus();}
function confirmRedirect(strMessage,strUrl){if(confirm(strMessage))
{window.location.href=strUrl;}}
function deleteMe(itemTitle,itemTitles){var count=0;var strAlert="";for(i=0;i<document.frmForm.elements.length;i++)
{e=document.frmForm.elements[i];if(e.name=="ckSelect[]"&&e.checked==true)
{count++;}}
if(count>0)
return confirm("You are deleteing "+count+" selected "+itemTitles+". Do you wish to continue?")
else
{alert("You must select at least one "+itemTitle+" to delete!");return false;}}
function confirmDel(theForm,subControl){var count=0;for(var i=0;i<theForm.elements.length;i++){var e=theForm.elements[i];if((e.name==subControl)&&(e.checked==true))count++;}
if(count==0){alert("Please choose at least one item to delete");return false;}else{return confirm("Are you sure want to delete these item(s)?");}}
function deleteMeWithAlert(itemTitle,itemTitles,itemFieldName,itemCountName,itemTitleSub)
{var count=0;var strAlert="";for(i=0;i<document.frmForm.elements.length;i++)
{e=document.frmForm.elements[i];if(e.name=="ckSelect[]"&&e.checked==true)
{var itemCount=document.getElementById(itemCountName+"_"+e.value).value;if(parseInt(itemCount,10)>0)
{var itemName=document.getElementById(itemFieldName+"_"+e.value).value;strAlert=strAlert+itemTitle+" ("+itemName+") already has "+itemTitleSub+". Please deselect it!\n"}
count++;}}
if(count>0)
if(strAlert!="")
{alert(strAlert);return false;}
else
{return confirm("You are sure to delete "+count+" selected "+itemTitles+". Do you wish to continue?")}
else
{alert("You must select at least one "+itemTitle+" to delete!");return false;}}
function deleteMeWithAlertEx(itemTitle,itemTitles,itemFieldName,itemCountName,itemTitleSub)
{var count=0;var strAlert="";for(i=0;i<document.frmForm.elements.length;i++)
{e=document.frmForm.elements[i];if(e.name=="ckSelect[]"&&e.checked==true)
{var itemCount=document.getElementById(itemCountName+"_"+e.value).value;if(parseInt(itemCount,10)>0)
{var itemName=document.getElementById(itemFieldName+"_"+e.value).value;strAlert=strAlert+itemTitle+" ("+itemName+") already has "+itemCount+" "+itemTitleSub+". Please deselect it!\n"}
count++;}}
if(count>0)
if(strAlert!="")
{alert(strAlert);return false;}
else
{return confirm("You are sure to delete "+count+" selected "+itemTitles+". Do you wish to continue?")}
else
{alert("You must select at least one "+itemTitle+" to delete!");return false;}}
function deleteMeWithAlertAttribute(itemTitle,itemTitles,itemFieldName,itemCountName,itemTitleSub){var count=0;var strAlert="";for(i=0;i<document.frmForm.elements.length;i++)
{e=document.frmForm.elements[i];if(e.name=="ckSelect[]"&&e.checked==true)
{var itemCount=document.getElementById(itemCountName+"_"+e.value).value;if(parseInt(itemCount,10)>0)
{var itemName=document.getElementById(itemFieldName+"_"+e.value).value;strAlert=strAlert+itemTitle+" ("+itemName+") is used for "+itemTitleSub+". Please deselect it!\n"}
count++;}}
if(count>0)
if(strAlert!="")
{alert(strAlert);return false;}
else
{return confirm("You are about to delete "+count+" selected "+itemTitles+". Do you wish to continue?")}
else
{alert("You must select at least one "+itemTitle+" to delete!");return false;}}
function bookmarksite(title,url){if(window.sidebar){window.sidebar.addPanel(title,url,"");}
else if(window.opera&&window.print){var elem=document.createElement('a');elem.setAttribute('href',url);elem.setAttribute('title',title);elem.setAttribute('rel','sidebar');elem.click();}
else if(document.all){window.external.AddFavorite(url,title);}}
function openBookmarkList(id){var el=GetObjectID(id);el.style.display='';}
function hideBookmarkList(id){var el=GetObjectID(id);el.style.display='none';}
function checkAll(coltrolName,target)
{var iIndex=1;for(i=0;i<document.frmForm.elements.length;i++)
{e=document.frmForm.elements[i];if((e.name==coltrolName)&&(e.disabled==false))
{e.checked=target.checked;var trRow=document.getElementById("trRow"+iIndex);if(target.checked)
{trRow.bgColor="#EFEFEF";}
else
{trRow.bgColor="#FFFFFF";}}
if((e.name==coltrolName))
{iIndex++;}}}
function checkSelect(target,iIndex)
{var trRow=document.getElementById("trRow"+iIndex);if(target.checked)
{trRow.bgColor="#EFEFEF";}
else
{trRow.bgColor="#FFFFFF";}}
function checkAllEx(coltrolName,target,checkColor,normalColor)
{var iIndex=1;for(i=0;i<document.frmForm.elements.length;i++)
{e=document.frmForm.elements[i];if((e.name==coltrolName)&&(e.disabled==false))
{e.checked=target.checked;var trRow=document.getElementById("trRow"+iIndex);if(target.checked)
{trRow.bgColor=checkColor;}
else
{trRow.bgColor=normalColor;}}
if((e.name==coltrolName))
{iIndex++;}}}
function checkSelectEx(target,iIndex,checkColor,normalColor)
{var trRow=document.getElementById("trRow"+iIndex);if(target.checked)
{trRow.bgColor=checkColor;}
else
{trRow.bgColor=normalColor;}}
function stripCharsInBag(s,bag){var i;var returnString="";for(i=0;i<s.length;i++){var c=s.charAt(i);if(bag.indexOf(c)==-1)returnString+=c;}
return returnString;}
function checkDeleteImage(obj1,obj2){if(obj1.checked==true)
{obj2.disabled=true;}
else
{obj2.disabled=false;}}
function IsCheckedRadio(source){if(source.length!=null){for(i=0;i<source.length;i++)
if(source[i].checked)
return true;}
else{if(source.checked)
return true;}
return false;}
function showmenu(flag){var menu=document.getElementById("pmenu");if(flag==1){menu.style.display="";}
else{menu.style.display="none";}}
function changeStatus(statusTitle,itemTitle){var count=0;for(i=0;i<document.frmForm.elements.length;i++)
{e=document.frmForm.elements[i];if(e.name=="ckSelect[]"&&e.checked==true)
count++;}
if(count>0){return true;}
else
{alert("You must select at least one "+itemTitle+" to set "+statusTitle+"!");return false;}}
function changeFeatured(statusTitle,itemTitle){var count=0;for(i=0;i<document.frmForm.elements.length;i++)
{e=document.frmForm.elements[i];if(e.name=="ckSelect[]"&&e.checked==true)
count++;}
if(count>0){return true;}
else
{alert("You must select at least one "+itemTitle+" to "+statusTitle+"!");return false;}}
function changeComboBox(target,queryKey,queryValue,strUrl){var strAppend="?";if(strUrl.indexOf("?")>0)
{strAppend="&";}
if(strUrl.indexOf(queryKey+"=")>0)
{strUrl=strUrl.replace(queryKey+"="+queryValue,queryKey+"="+target.value);}
else
{strUrl=strUrl+strAppend+queryKey+"="+target.value;}
window.location.href=strUrl;}