function funCheckNumeric(strInput)
{if(strInput==""||(strInput!=""&&isNaN(strInput)))
strOutput=0;else
strOutput=strInput;return strOutput;}
function funGetFileExtension(strInputFile)
{var Extension="";if(trimAll(strInputFile)!="")
{Filelength=strInputFile.length;indexofDot=strInputFile.indexOf(".");Extension=strInputFile.substring(indexofDot+1,Filelength);}
return Extension;}
function validUsCanadaZip(zip,coutnry)
{if(coutnry=="CA")
{zip=zip.toUpperCase();if(zip.match(/^[A-Z][0-9][A-Z][0-9][A-Z][0-9]$/))
{return true;}
else if(zip.match(/^[A-Z][0-9][A-Z].[0-9][A-Z][0-9]$/))
{return true;}
else
{return false;}}
else if(coutnry=="US")
{if(zip.match(/^[0-9]{5}$/))
{return true;}
else if(zip.match(/^[0-9]{9}$/))
{return true;}
else
{return false;}}
else
{return true;}}
function findPosY(obj){var curTop=0;if(obj.offsetParent){while(obj.offsetParent){curTop+=obj.offsetTop;obj=obj.offsetParent;}}else if(obj.y){curTop+=obj.y;}
return curTop;}
function findPosX(obj){var curLeft=0;if(obj.offsetParent){while(obj.offsetParent){curLeft+=obj.offsetLeft;obj=obj.offsetParent;}}else if(obj.x){curLeft+=obj.x;}
return curLeft;}
function funChrArraySearch(arrInput,strElmnttoSrch)
{var BoolElmntExist=false;for(elmnt=0;elmnt<arrInput.length;elmnt++)
{if(arrInput[elmnt]==strElmnttoSrch)
{BoolElmntExist=true;break;}}
return BoolElmntExist;}
function funIsValidDate(strDate)
{var validate=false;if(trimAll(strDate)!="")
{var arrDate=strDate.split('/');if(arrDate.length==3)
{var month=trimAll(arrDate[0]);var date=trimAll(arrDate[1]);var year=trimAll(arrDate[2]);if(isNaN(month)||isNaN(date)||isNaN(year)||month.length!=2||date.length!=2||year.length!=4)
validate=false;else
{month=parseFloat(month);date=parseFloat(date);year=parseFloat(year);if(month>0&&month<=12&&date>0&&date<=31&&year>2006)
validate=true;}}}
else
validate=true;return validate;}
function validateString(strValue){var objRegExp=/(^[a-zA-Z]+$)/;return objRegExp.test(strValue);}
function validateNumeric(strValue){var objRegExp=/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;return objRegExp.test(strValue);}
function validateInteger(strValue){var objRegExp=/(^-?\d\d*$)/;return objRegExp.test(strValue);}
function validateNotEmpty(strValue){var strTemp=strValue;strTemp=trimAll(strTemp);if(strTemp.length>0){return true;}
return false;}
function validateEmail(strValue){var objRegExp=/^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,6}(\.[a-z]{2}){0,2})$/i;return objRegExp.test(strValue);}
function rightTrim(strValue){var objRegExp=/^([\w\W]*)(\b\s*)$/;if(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,'$1');}
return strValue;}
function leftTrim(strValue){var objRegExp=/^(\s*)(\b[\w\W]*)$/;if(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,'$2');}
return strValue;}
function trimAll(strValue){var objRegExp=/^(\s*)$/;if(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,'');if(strValue.length==0)
return strValue;}
objRegExp=/^(\s*)([\W\w]*)(\b\s*$)/;if(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,'$2');}
return strValue;}
function validateCurrency(strValue){var objRegExp=/(^\$\d{1,3}(,\d{3})*\.\d{2}$)|(^\(\$\d{1,3}(,\d{3})*\.\d{2}\)$)/;return objRegExp.test(strValue);}
function validateTime(strValue){var objRegExp=/^([1-9]|1[0-2]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/;return objRegExp.test(strValue);}
function validateState(strValue){var objRegExp=/^(AK|AL|AR|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MI|MN|MO|MS|MT|NB|NC|ND|NH|NJ|NM|NV|NY|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY)$/i;return objRegExp.test(strValue);}
function validateSSN(strValue){var objRegExp=/^\d{3}\-\d{2}\-\d{4}$/;return objRegExp.test(strValue);}
function validateUSPhone(strValue){var objRegExp=/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;return objRegExp.test(strValue);}
function validateUSZip(strValue){var objRegExp=/(^\d{5}$)|(^\d{5}-\d{4}$)/;return objRegExp.test(strValue);}
function validateUrl(strValue)
{var objRegExp=/^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.|http:\/\/|https:\/\/){1}([\w]+)(.[\w]+){1,2}$/;return objRegExp.test(strValue);}
function replace(argvalue,x,y){if((x==y)||(parseInt(y.indexOf(x))>-1)){errmessage="replace function error: \n";errmessage+="Second argument and third argument could be the same ";errmessage+="or third argument contains second argument.\n";errmessage+="This will create an infinite loop as it's replaced globally.";alert(errmessage);return false;}
while(argvalue.indexOf(x)!=-1){var leading=argvalue.substring(0,argvalue.indexOf(x));var trailing=argvalue.substring(argvalue.indexOf(x)+x.length,argvalue.length);argvalue=leading+y+trailing;}
return argvalue;}
function validateUSDate(strValue){var objRegExp=/^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
if(!objRegExp.test(strValue))
return false;else{var arrayDate=strValue.split(RegExp.$1);var intDay=parseInt(arrayDate[1],10);var intYear=parseInt(arrayDate[2],10);var intMonth=parseInt(arrayDate[0],10);if(intMonth>12||intMonth<1){return false;}
var arrayLookup={'01':31,'03':31,'04':30,'05':31,'06':30,'07':31,'08':31,'09':30,'10':31,'11':30,'12':31}
if(arrayLookup[arrayDate[0]]!=null){if(intDay<=arrayLookup[arrayDate[0]]&&intDay!=0)
return true;}
var booLeapYear=(intYear%4==0&&(intYear%100!=0||intYear%400==0));if(((booLeapYear&&intDay<=29)||(!booLeapYear&&intDay<=28))&&intDay!=0)
return true;}
return false;}
function validateValue(strValue,strMatchPattern){var objRegExp=new RegExp(strMatchPattern);return objRegExp.test(strValue);}
function removeCurrency(strValue){var objRegExp=/\(/;var strMinus='';if(objRegExp.test(strValue)){strMinus='-';}
objRegExp=/\)|\(|[,]/g;strValue=strValue.replace(objRegExp,'');if(strValue.indexOf('$')>=0){strValue=strValue.substring(1,strValue.length);}
return strMinus+strValue;}
function addCurrency(strValue){var objRegExp=/-?[0-9]+\.[0-9]{2}$/;if(objRegExp.test(strValue)){objRegExp.compile('^-');strValue=addCommas(strValue);if(objRegExp.test(strValue)){strValue='($'+strValue.replace(objRegExp,'')+')';}
else{strValue='$'+strValue;}
return strValue;}
else
return strValue;}
function removeCommas(strValue){var objRegExp=/,/g;return strValue.replace(objRegExp,'');}
function addCommas(strValue){var objRegExp=new RegExp('(-?[0-9]+)([0-9]{3})');while(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,'$1,$2');}
return strValue;}
function removeCharacters(strValue,strMatchPattern){var objRegExp=new RegExp(strMatchPattern,'gi');return strValue.replace(objRegExp,'');}
function is_valid_credit_card_number(cardNumber,cardType)
{var isValid=false;var ccCheckRegExp=/[^\d ]/;isValid=!ccCheckRegExp.test(cardNumber);if(isValid)
{var cardNumbersOnly=cardNumber.replace(/ /g,"");var cardNumberLength=cardNumbersOnly.length;var lengthIsValid=false;var prefixIsValid=false;var prefixRegExp;switch(cardType)
{case"mastercard","MasterCard":lengthIsValid=(cardNumberLength==16);prefixRegExp=/^5[1-5]/;break;case"visa","Visa":lengthIsValid=(cardNumberLength==16||cardNumberLength==13);prefixRegExp=/^4/;break;case"amex","Amex":lengthIsValid=(cardNumberLength==15);prefixRegExp=/^3(4|7)/;break;case"discover","Discover":lengthIsValid=(cardNumberLength==16);prefixRegExp=/^6011/;break;default:prefixRegExp=/^$/;alert("Card type not found");}
prefixIsValid=prefixRegExp.test(cardNumbersOnly);isValid=prefixIsValid&&lengthIsValid;}
if(isValid)
{var numberProduct;var numberProductDigitIndex;var checkSumTotal=0;for(digitCounter=cardNumberLength-1;digitCounter>=0;digitCounter--)
{checkSumTotal+=parseInt(cardNumbersOnly.charAt(digitCounter));digitCounter--;numberProduct=String((cardNumbersOnly.charAt(digitCounter)*2));for(var productDigitCounter=0;productDigitCounter<numberProduct.length;productDigitCounter++)
{checkSumTotal+=parseInt(numberProduct.charAt(productDigitCounter));}}
isValid=(checkSumTotal%10==0);}
return isValid;}
function IsNumeric(sText)
{var ValidChars="0123456789.,";var IsNumber=true;var Char;for(i=0;i<sText.length&&IsNumber==true;i++)
{Char=sText.charAt(i);if(ValidChars.indexOf(Char)==-1)
{IsNumber=false;}}
return IsNumber;}
function fun_checkMultipleselectdropdown_values(formname,ctrlname,selectedCountrynames)
{with(document.forms[formname])
{if(selectedCountrynames!="")
{for(var i=1;i<elements[ctrlname].options.length;i++)
{optionValue=elements[ctrlname].options[i].value;if(selectedCountrynames.indexOf(optionValue)>=0)
elements[ctrlname].options[i].selected=true;}}}}
function fun_checkall(formname,parent_ctrlname,child_ctrlname,numofrows)
{with(document.forms[formname])
{if(elements[parent_ctrlname].checked==true)
{for(chkbx=1;chkbx<=numofrows;chkbx++)
{chkbx_id=child_ctrlname+chkbx;elements[chkbx_id].checked=true;}}
else
{for(chkbx=1;chkbx<=numofrows;chkbx++)
{chkbx_id=child_ctrlname+chkbx;elements[chkbx_id].checked=false;}}}}
function pagetransfer(pagenumber,formname)
{with(document.forms[formname])
{target="";hdn_page.value=pagenumber;hdn_mode.value="paging";submit();}}
function fun_find_checkedbox(formname,ctrlname,numofrows)
{with(document.forms[formname])
{chkd=false;for(chkbx=1;chkbx<=numofrows;chkbx++)
{chkbx_id=ctrlname+chkbx;if((elements[chkbx_id].checked==true))
{chkd=true;break;}}}
return chkd;}
function fun_DeleteMessages(formname,ctrlname,numofrows)
{if(fun_find_checkedbox(formname,ctrlname,numofrows)==false)
{alert("Please select the messages to delete");return false;}
else if(confirm("Are you sure want to delete this messages?"))
{document.forms[formname].hdn_mode.value="delete";document.forms[formname].submit();}}
function enter_key_for_change_pwd_page(e)
{if(e.keyCode==13)
{if(navigator.appName=="Netscape")
{e.preventDefault();}
else
e.keyCode=0;change_pwd_validation();}}
function change_pwd_validation()
{with(document.change_password_frm)
{if(old_pwd.value=="")
{alert("Enter your current password.");old_pwd.focus();return false;}
else if(new_pwd.value=="")
{alert("Enter your new password.");new_pwd.focus();return false;}
else if(new_pwd.value.length<4||new_pwd.value.length>10)
{alert("The password should contains 4 to 10 characters.");new_pwd.focus();return false;}
else if(confirm_pwd.value=="")
{alert("Confirm your password.");confirm_pwd.focus();return false;}
else if(confirm_pwd.value!=new_pwd.value)
{alert("Confirm password doesn't match with the new password.");confirm_pwd.focus();return false;}
else
{hdn_mode.value="change_password";submit();}}}
function fun_manageSeminar(formname)
{with(document.forms[formname])
{alert(formname);var numOfDimensions=hidd_num_dimensions.value;if(trimAll(drpdwn_category.value)=="")
{alert("Please select category name.");drpdwn_category.focus();return false;}
else if(trimAll(txt_seminartitle.value)=="")
{alert("Please enter the title.");txt_seminartitle.focus();return false;}
imgvalue=trimAll(txt_SeminarImage.value);if((imgvalue)!="")
{var ary=imgvalue.split(".");var ext=ary[ary.length-1].toLowerCase();if((ext=="jpeg")||(ext=="jpg")||(ext=="gif"))
{}
else
{alert("You have selected a "+ext+" file, please Select Image file of type jpg,jpeg or gif");txt_ProductImage.focus();return false;}}
submit();return true;}}
function funPrintReport(formename)
{with(document.forms[formename])
{var orderid=hdn_orderid.value;window.open("printreport.php?orderId="+orderid,"PrintDetails","top=0,left=0,width=600,height=600,resizable=yes,scrollbars=yes,top=100,left=100");}}
function printpreview()
{document.getElementById("btn_close").style.display="none";document.getElementById("btn_print").style.display="none";window.print();}
function printpreview_mail()
{document.getElementById("btn_print").style.display="none";window.print();}
function enter_key_for_forget_pwd_page(e,formname)
{if(e.keyCode==13)
{if(navigator.appName=="Netscape")
{e.preventDefault();}
else
e.keyCode=0;forget_pwd_validation(formname);}}
function forget_pwd_validation(formname)
{with(document.forms[formname])
{if(trimAll(txt_UserEmail.value)=="")
{alert("Please enter your email");txt_UserEmail.focus();return false;}
else if(!(validateEmail(trimAll(txt_UserEmail.value))))
{alert("Please enter valid email address!");txt_UserEmail.focus();return false;}
else
{hdn_mode.value="submit";submit();}}}
function enter_key_for_user_registration_page(e,formname)
{if(e.keyCode==13)
{if(navigator.appName=="Netscape")
{e.preventDefault();}
else
e.keyCode=0;validate_register(formname);}}
function validate_register(formname)
{with(document.forms[formname])
{var usrPass=TxtPassword.value;var userpasslength=usrPass.length;if(trimAll(TxtEmail.value)=="")
{alert("Please enter Email Address");TxtEmail.focus();return false;}
else if(!(validateEmail(trimAll(TxtEmail.value))))
{alert("Please enter valid email address!");TxtEmail.focus();return false;}
else if(trimAll(TxtPassword.value)=="")
{alert("Please enter password");TxtPassword.focus();return false;}
else if(userpasslength<4||userpasslength>10)
{alert("The password should contains 4 to 10 characters");TxtPassword.focus();return false;}
else if(trimAll(TxtRetypePassword.value)=="")
{alert("Please re-enter password for confirmation");TxtRetypePassword.focus();return false;}
else if(trimAll(TxtPassword.value)!=trimAll(TxtRetypePassword.value))
{alert("Password and confirm password not matched.");TxtRetypePassword.focus();return false;}
else if(trimAll(drpdwn_country.value)=="")
{alert("Please select country.");drpdwn_country.focus();return false;}
else if(trimAll(drpdwn_country.value)=="US"&&trimAll(TxtZipcode.value)=="")
{alert("Please enter Zip Code.");TxtZipcode.focus();return false;}
else if(trimAll(drpdwn_hearFrom.value)=="Affiliate")
{if(trimAll(TxtRefCode.value)=="")
{alert("Please enter reference code.");TxtRefCode.focus();return false;}}
HiddenMode.value="register";submit();return true;}}
function enter_key_for_login_page(e,formname,logintype)
{if(e.keyCode==13)
{if(navigator.appName=="Netscape")
{e.preventDefault();}
else
e.keyCode=0;login_validation(formname,logintype);}}
function login_validation(formname,logintype)
{with(document.forms[formname])
{hdn_logintype.value=logintype;if(logintype=="user")
{if(trimAll(txtuser_email.value)=="")
{alert("Please enter email address.");txtuser_email.focus();return false;}
else if(!(validateEmail(trimAll(txtuser_email.value))))
{alert("Please enter valid email address!");txtuser_email.focus();return false;}
else if(trimAll(txtuser_pass.value)=="")
{alert("Please enter password.");txtuser_pass.focus();return false;}
else
{hdn_mode.value="login";submit();return true;}}
else if(logintype=="affiliate")
{if(trimAll(txtaff_email.value)=="")
{alert("Please enter email address.");txtaff_email.focus();return false;}
else if(!(validateEmail(trimAll(txtaff_email.value))))
{alert("Please enter valid email address!");txtaff_email.focus();return false;}
else if(trimAll(txtaff_pass.value)=="")
{alert("Please enter password.");txtaff_pass.focus();return false;}
else
{hdn_mode.value="login";submit();return true;}}}}
function enter_key_for_adminlogin_page(e,formname)
{if(e.keyCode==13)
{if(navigator.appName=="Netscape")
{e.preventDefault();}
else
e.keyCode=0;adminlogin_validation(formname);}}
function adminlogin_validation(formname)
{with(document.forms[formname])
{if(trimAll(txtbx_username.value)=="")
{alert("Please enter username.");txtbx_username.focus();return false;}
else if(txtbx_pass.value=="")
{alert("Please enter password.");txtbx_pass.focus();return false;}
else
{hdn_mode.value="login";submit();return true;}}}
function funadminpagetransfer(pagenumber,formname)
{with(document.forms[formname])
{HdnPage.value=pagenumber;HiddenMode.value="paging";submit();}}
function enter_key_for_edit_profile_page(e,formname)
{if(e.keyCode==13)
{if(navigator.appName=="Netscape")
{e.preventDefault();}
else
e.keyCode=0;validate_edit_profile(formname);}}
function validate_edit_profile(formname)
{with(document.forms[formname])
{if(trimAll(TxtEmail.value)=="")
{alert("Please enter email address");TxtEmail.focus();return false;}
else if(!(validateEmail(trimAll(TxtEmail.value))))
{alert("Please enter valid email address");TxtEmail.focus();return false;}
else if(trimAll(TxtFirstName.value)=="")
{alert("Please enter first name");TxtFirstName.focus();return false;}
else if(trimAll(TxtLastName.value)=="")
{alert("Please enter last name");TxtLastName.focus();return false;}
else if(trimAll(TxtAddress1.value)=="")
{alert("Please enter Address1");TxtAddress1.focus();return false;}
else if(trimAll(TxtCity.value)=="")
{alert("Please enter city");TxtCity.focus();return false;}
else if(trimAll(drpdwn_country.value)=="")
{alert("Please select country");drpdwn_country.focus();return false;}
else if(trimAll(drpdwn_country.value)=="US"&&trimAll(TxtState.value)=="")
{alert("Please select state");TxtState.focus();return false;}
else if(trimAll(drpdwn_country.value)!="US"&&trimAll(txt_Shipstate.value)=="")
{alert("Please enter the state");txt_Shipstate.focus();return false;}
else if(trimAll(drpdwn_country.value)=="US"&&trimAll(TXtZipcode.value)=="")
{alert("Please enter Zip Code");TXtZipcode.focus();return false;}
else if(trimAll(TxtPhoneNumber.value)=="")
{alert("Please enter phone number");TxtPhoneNumber.focus();return false;}
else if(trimAll(TxtPhoneNumber.value)!=""&&!checkPhone(trimAll(TxtPhoneNumber.value)))
{TxtPhoneNumber.focus();return false;}
else if(trimAll(TxtPhoneNumber.value)!=""&&trimAll(TxtPhoneNumber.value).length!=10)
{alert("Please enter 10 digit phone number");TxtPhoneNumber.focus();return false;}
if(document.getElementById("lbl_cardnumTxtBx").style.display=="")
{if(trimAll(txt_CreditCardNum.value)=="")
{alert("Please enter credit card number");txt_CreditCardNum.focus();return false;}
else if(!(validateNumeric(txt_CreditCardNum.value)))
{alert("Card number should be numeric");txt_CreditCardNum.focus();return false;}
else if(trimAll(txt_CreditCardNum.value)!="")
{var ccNumb=txt_CreditCardNum.value;var valid="0123456789";var len=ccNumb.length;var iCCN=parseInt(ccNumb);var sCCN=ccNumb.toString();sCCN=sCCN.replace(/^\s+|\s+$/g,'');var iTotal=0;var bNum=true;var bResult=false;var temp;var calc;if(len>=13&&len<=16)
{for(var i=len;i>0;i--)
{calc=parseInt(iCCN)%10;calc=parseInt(calc);iTotal+=calc;i--;iCCN=iCCN/10;calc=parseInt(iCCN)%10;calc=calc*2;switch(calc)
{case 10:calc=1;break;case 12:calc=3;break;case 14:calc=5;break;case 16:calc=7;break;case 18:calc=9;break;default:calc=calc;}
iCCN=iCCN/10;iTotal+=calc;}
if(!((iTotal%10)==0))
{alert("Please enter valid credit card number");txt_CreditCardNum.focus();return false;}}
else
{alert("Please enter valid credit card number");txt_CreditCardNum.focus();return false;}}}
if(trimAll(SelcardType.value)=="")
{alert("Please select credit card type");SelcardType.focus();return false;}
else if(trimAll(SelExpiryMonth.value)=="")
{alert("Please select card Expiration month");SelExpiryMonth.focus();return false;}
else if(trimAll(SelExpiryYear.value)=="")
{alert("Please select card Expiration year");SelExpiryYear.focus();return false;}
else if(trimAll(TxtBillingAddress1.value)=="")
{alert("Please enter billing address");TxtBillingAddress1.focus();return false;}
else if(trimAll(TxtBillingCity.value)=="")
{alert("Please enter billing city");TxtBillingCity.focus();return false;}
else if(trimAll(drpdwn_billing_country.value)=="")
{alert("Please select billing country");drpdwn_billing_country.focus();return false;}
else if(trimAll(drpdwn_billing_country.value)=="US"&&trimAll(TxtBillingState.value)=="")
{alert("Please select billing state");TxtBillingState.focus();return false;}
else if(trimAll(drpdwn_billing_country.value)=="US"&&trimAll(TxtBillingZipcode.value)=="")
{alert("Please select billing Zip Code");TxtBillingZipcode.focus();return false;}
else if(trimAll(drpdwn_billing_country.value)!="US"&&trimAll(txt_Blngstate.value)=="")
{alert("Please select enter billing state");txt_Blngstate.focus();return false;}
else if(trimAll(TxtBillingPhoneNumber.value)=="")
{alert("Please enter billing phone number");TxtBillingPhoneNumber.focus();return false;}
else if(trimAll(TxtBillingPhoneNumber.value)!=""&&!checkPhone(trimAll(TxtBillingPhoneNumber.value)))
{TxtBillingPhoneNumber.focus();return false;}
else if(trimAll(TxtBillingPhoneNumber.value)!=""&&trimAll(TxtBillingPhoneNumber.value).length!=10)
{alert("Please enter 10 digit phone number");TxtBillingPhoneNumber.focus();return false;}
HiddenMode.value="edit";submit();return true;}}
function funEnterKeyForAdminEditProfile(e,formname)
{if(e.keyCode==13)
{if(navigator.appName=="Netscape")
{e.preventDefault();}
else
e.keyCode=0;funValidateEditProfileAdminSide(formname);}}
function funValidateEditProfileAdminSide(formname)
{with(document.forms[formname])
{var show_card=document.getElementById("hdn_showCard").value;var edit_card=document.getElementById("hdn_editCard").value;if(trimAll(TxtEmail.value)=="")
{alert("Please enter email address!");TxtEmail.focus();return false;}
if(!(validateEmail(trimAll(TxtEmail.value))))
{alert("Please enter valid email address!");TxtEmail.focus();return false;}
if(trimAll(drpdwn_country.value)=="")
{alert("Please select country !");drpdwn_country.focus();return false;}
if(trimAll(drpdwn_country.value)=="US"&&trimAll(TXtZipcode.value)=="")
{alert("Please enter zipcode!");TXtZipcode.focus();return false;}
if(show_card=="yes"||edit_card=="yes")
{if(edit_card=="yes")
{if(trimAll(TxtCreditCardNumber.value)!="")
{if(!(validateNumeric(TxtCreditCardNumber.value)))
{alert("Card number should be numeric");TxtCreditCardNumber.focus();return false;}
var ccNumb=TxtCreditCardNumber.value;var valid="0123456789";var len=ccNumb.length;var iCCN=parseInt(ccNumb);var sCCN=ccNumb.toString();sCCN=sCCN.replace(/^\s+|\s+$/g,'');var iTotal=0;var bNum=true;var bResult=false;var temp;var calc;if(len>=13&&len<=16)
{for(var i=len;i>0;i--)
{calc=parseInt(iCCN)%10;calc=parseInt(calc);iTotal+=calc;i--;iCCN=iCCN/10;calc=parseInt(iCCN)%10;calc=calc*2;switch(calc)
{case 10:calc=1;break;case 12:calc=3;break;case 14:calc=5;break;case 16:calc=7;break;case 18:calc=9;break;default:calc=calc;}
iCCN=iCCN/10;iTotal+=calc;}
if(!((iTotal%10)==0))
{alert("Please enter valid credit card number");TxtCreditCardNumber.focus();return false;}}
else
{alert("Please enter valid credit card number");TxtCreditCardNumber.focus();return false;}}}}
HiddenMode.value="edit";return true;}}
function func_shipping_details(formname)
{with(document.forms[formname])
{if(ChkBillingSame.checked==true)
{TxtBillingAddress1.value=trimAll(TxtAddress1.value);TxtBillingAddress2.value=trimAll(TxtAddress2.value);TxtBillingCity.value=trimAll(TxtCity.value);TxtBillingState.value=trimAll(TxtState.value);drpdwn_billing_country.value=trimAll(drpdwn_country.value);TxtBillingZipcode.value=trimAll(TXtZipcode.value);TxtBillingPhoneNumber.value=trimAll(TxtPhoneNumber.value);}
else if(ChkBillingSame.checked==false)
{TxtBillingAddress1.value="";TxtBillingAddress2.value="";TxtBillingCity.value="";TxtBillingState.value="";drpdwn_billing_country.value="";TxtBillingZipcode.value="";TxtBillingPhoneNumber.value="";}}}
function funsharephotos(formname,page_from,ChkBxCtrlNmPrfx,CtrlNmNumofChkBxs)
{with(document.forms[formname])
{numofChkBxs=parseInt(elements[CtrlNmNumofChkBxs].value);if(fun_find_checkedbox(formname,ChkBxCtrlNmPrfx,numofChkBxs)==false)
{if(page_from=="galleries")
alert("Please select the gallery to share");else
alert("Please select the album or photos to share");}
else
{hdn_mode.value="share";hdn_return.value=page_from;action="sharephotos.php";submit();}}}
function sortbyname(formname,type,order)
{with(document.forms[formname])
{HiddenSort.value="yes";HiddenSortBy.value=type;HiddenSortingOrder.value=order;submit();}}
function funResetPass(formname)
{with(document.forms[formname])
{if(txt_pwd.value=="")
{alert("Enter your new password.");txt_pwd.focus();return false;}
else if(txt_pwd.value.length<4||txt_pwd.value.length>10)
{alert("The password should contains 4 to 10 characters.");txt_pwd.focus();return false;}
else if(txt_confirmpwd.value=="")
{alert("Confirm your password.");txt_confirmpwd.focus();return false;}
else if(txt_confirmpwd.value!=txt_pwd.value)
{alert("Confirm password doesn't match with the new password.");txt_confirmpwd.focus();return false;}
else
{hdn_mode.value="change_password";return true;}}}
function funRedirectAdminPage()
{window.close();window.opener.document.location.href="admin_home.php";}
function funFrameOver(ctrlid)
{document.getElementById(ctrlid).className="FramebckrndOver";}
function funFrameOut(ctrlid)
{document.getElementById(ctrlid).className="FramebckrndOut";}
function funFindRadioBtnSelctn(formname,CtrlNm,NumOfCtrls)
{var Chkd=false;with(document.forms[formname])
{for(var rdbtn=0;rdbtn<NumOfCtrls;rdbtn++)
{if(elements[CtrlNm][rdbtn].checked==true)
{Chkd=true;break;}}}
return Chkd}
function funGalRedirectAdminSide(strSrvr)
{var strUrl="galleries.php";if(strSrvr=="live")
{strUrl="http://www.scandigital.com/admin/galleries.php";}
document.location.href=strUrl;}
function funShowOverImg_old(strid,strType)
{if(strType=="mouseover")
{document.getElementById("OutTbl_"+strid).style.display="none";document.getElementById("OverTbl_"+strid).style.display="";}
else
{document.getElementById("OutTbl_"+strid).style.display="";document.getElementById("OverTbl_"+strid).style.display="none";}}
function funShowOverImg(strid,strType)
{arrDivIds=new Array("dv_top","dv_btm","dv_lft","dv_rgtht","dv_btmleft","dv_btmrght","dv_topleft","dv_toprght");arrDivClasses=new Array("t","b","l","r","bl","br","tl","tr");var strClsName="Out_";if(strType=="mouseover")
strClsName="Over_";for(dv=0;dv<arrDivIds.length;dv++)
{ctrlname=arrDivIds[dv]+strid;document.getElementById(ctrlname).className=strClsName+arrDivClasses[dv];}}
function funCountryChange(formname,DrpdwnCtrlName,ZipCaptnCtrlName)
{with(document.forms[formname])
{var strCaption="Postal Code:";if(trimAll(document.getElementById(DrpdwnCtrlName).value)=="US")
{strCaption="Zip Code:";if(DrpdwnCtrlName=="drpdwn_country")
{document.getElementById("TxtState").style.display="";document.getElementById("txt_Shipstate").style.display="none";}
else if(DrpdwnCtrlName=="drpdwn_billing_country")
{document.getElementById("TxtBillingState").style.display="";document.getElementById("txt_Blngstate").style.display="none";}}
else
{if(DrpdwnCtrlName=="drpdwn_country")
{document.getElementById("TxtState").style.display="none";document.getElementById("txt_Shipstate").style.display="";}
else if(DrpdwnCtrlName=="drpdwn_billing_country")
{document.getElementById("TxtBillingState").style.display="none";document.getElementById("txt_Blngstate").style.display="";}}
document.getElementById(ZipCaptnCtrlName).innerHTML=strCaption+"&nbsp;";if(DrpdwnCtrlName=="drpdwn_ShpngCountry")
{funFillBillingAddress(6);funCountryChange(formname,'drpdwn_BlngCountry','td_BlngPostalCode');}}}
function funcValidateCreditCardNum(CreditCardNum)
{var ccNumb=CreditCardNum;var valid="0123456789";var len=ccNumb.length;var iCCN=parseInt(ccNumb);var sCCN=ccNumb.toString();sCCN=sCCN.replace(/^\s+|\s+$/g,'');var iTotal=0;var bNum=true;var bResult=false;var temp;var calc;if(len>=13&&len<=16)
{for(var i=len;i>0;i--)
{calc=parseInt(iCCN)%10;calc=parseInt(calc);iTotal+=calc;i--;iCCN=iCCN/10;calc=parseInt(iCCN)%10;calc=calc*2;switch(calc)
{case 10:calc=1;break;case 12:calc=3;break;case 14:calc=5;break;case 16:calc=7;break;case 18:calc=9;break;default:calc=calc;}
iCCN=iCCN/10;iTotal+=calc;}
if(!((iTotal%10)==0))
{return false;}}
else
{return false;}}
function enter_key_for_authenlogin_page(e,formname)
{if(e.keyCode==13)
{if(navigator.appName=="Netscape")
{e.preventDefault();}
else
e.keyCode=0;authenlogin_validation(formname);}}
function authenlogin_validation(formname)
{with(document.forms[formname])
{if(trimAll(txt_authen_user.value)=="")
{alert("Please enter username.");txt_authen_user.focus();return false;}
else if(txt_authen_pass.value=="")
{alert("Please enter password.");txt_authen_pass.focus();return false;}
else
{hdn_mode.value="login";submit();return true;}}}
function CheckSpecialCharacters(StrName)
{var flag=0;var SpecialCharArray=new Array("<",">","=","/","$","?","\\");for(i=0;i<SpecialCharArray.length;i++)
{var ArrayName=SpecialCharArray[i].toLowerCase();if(StrName.indexOf(ArrayName)>=0)
{flag=1;break;}}
if(flag==1)
{return true;}}
function funPlayAudio(formname,intAudioId)
{with(document.forms[formname])
{window.open('play_audio.php?AudioId='+intAudioId,'playaudio','top=40,left=60,width=300,height=275,resizable=yes,scrollbars=yes');}}
function funValidateMemoryMakers()
{with(document.forms['frmMemoryMakers'])
{if(trimAll(txt_fname.value)=="")
{alert("Please enter first name");txt_fname.focus();return false;}
else if(trimAll(txt_lname.value)=="")
{alert("Please enter last name");txt_lname.focus();return false;}
else if(trimAll(txt_Email.value)==""||!(validateEmail(trimAll(txt_Email.value))))
{alert("Please enter valid email address");txt_Email.focus();return false;}
else if(trimAll(txt_address1.value)=="")
{alert("Please enter your address");txt_address1.focus();return false;}
else if(trimAll(txt_City.value)=="")
{alert("Please enter city");txt_City.focus();return false;}
else if(trimAll(drpdwn_Country.value)=="US"&&trimAll(drpdwn_state.value)=="")
{alert("Please select state");drpdwn_state.focus();return false;}
else if(trimAll(drpdwn_Country.value)=="")
{alert("Please select country");drpdwn_Country.focus();return false;}
else if(trimAll(txt_Zip.value)=="")
{alert("Please enter postal code");txt_Zip.focus();return false;}
else if(trimAll(txt_Phone.value)=="")
{alert("Please enter phone");txt_Phone.focus();return false;}
else
{windowName="newpopup";action="show-upslabel.php";target=windowName;open('',windowName,'top=0,left=0,width=920,height=900,resizable=yes,scrollbars=yes');submit();}}}
function funPagingMoveTenRec(pg,formname,val)
{with(document.forms[formname])
{if(val=="single")
{HdnPage.value=pg;HiddenMode.value="paging";submit();}
else if(val=="Last")
{HdnPage.value=pg;hdn_strtpg.value=pg-1;HiddenMode.value="paging";submit();}
else if(val=="ten")
{if((pg%15==0||(pg/15)>1)&&pg>15)
{var pgval=Math.floor(pg/15);var pg=pgval*15;HdnPage.value=pg;}
else
HdnPage.value=pg;HiddenMode.value="paging";submit();}}}
function funPagingMoveSingleRec(formname,pagenumber)
{with(document.forms[formname])
{HdnPage.value=pagenumber;HiddenMode.value="paging";submit();}}
function validateAlphaNumeric(strValue)
{var objRegExp=/(^[a-zA-Z0-9]+$)/;return objRegExp.test(strValue);}
function fungetnewsletter()
{initLytebox();document.getElementById("newsletter").onclick();}
function funLyteboxOpen(ctrlid,mode,orderId,ctrl)
{initLytebox();document.getElementById(ctrlid).href="edit_process_comments.php?mode="+mode+"&orderId="+orderId+"&ctrlname="+ctrl;document.getElementById(ctrlid).onclick();}
function funSaveProcessCommentsValue(formname,colname,orderId,ctrl)
{with(document.forms[formname])
{try
{var strValue=trimAll(document.getElementById(ctrl).value);var changestr=strValue.replace(/#/gi,"<~>");changestr=changestr.replace(/&/gi,"<~~>");changestr=changestr.replace(/\+/gi,"<@@>");changestr=changestr.replace(/=/gi,"<@>");changestr=changestr.replace(/%/gi,"<9>");document.getElementById("disp_load").style.display="";var strPostRegData="mode=save&orderId="+orderId+"&ctrlvalue="+changestr+"&colname="+colname;url="ajx_save_process_comments.php";if(url.substring(0,4)!='http')
{url=base_url+url;}
http_req=null;if(window.XMLHttpRequest)http_req=new XMLHttpRequest();else if(window.ActiveXObject)http_req=new ActiveXObject("Microsoft.XMLHTTP");if(http_req)
{http_req.onreadystatechange=function()
{if(http_req.readyState==4)
{var strResponseTxt=http_req.responseText;document.getElementById("disp_load").style.display="none";if(strResponseTxt=="yes")
{alert("Comments has been saved successfully");}}};http_req.open("POST",url,true);http_req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");http_req.send(strPostRegData);}}
catch(err)
{alert(err);}}}
function checkPhone(phoneno)
{try
{var ValidChars="0123456789";var IsNumber=true;var Char;for(i=0;i<phoneno.length&&IsNumber==true;i++)
{Char=phoneno.charAt(i);if(ValidChars.indexOf(Char)==-1)
{IsNumber=false;break;}}
if(IsNumber==false)
{alert("Only numeric digits allowed for your phone number");return false;}
else
{return true;}}
catch(err)
{}}
