
function selectCountry(form){if(shipaddress_country!=""&&form.shipaddress_country){selectLen=form.shipaddress_country.length;for(i=0;i<=(selectLen-1);i++){if(form.shipaddress_country.options[i].value==shipaddress_country){form.shipaddress_country.options[i].selected=true;break;}}}
checkCountry(form,'shipaddress_state');if(shipaddress_state!=""&&form.shipaddress_state){selectLen=form.shipaddress_state.length;for(i=0;i<=(selectLen-1);i++){if(form.shipaddress_state.options[i].value==shipaddress_state){form.shipaddress_state.options[i].selected=true;break;}}}}
function checkCountry(form,fldname){var CountryIndex;var CountryValue;var stateField;var postalCodeField;var postalCodeId;var countyField;var countyId;if(fldname=="shipaddress_country"&&form.shipaddress_country){CountryIndex=form.shipaddress_country.selectedIndex;CountryValue=form.shipaddress_country.options[CountryIndex].value;stateField="shipaddress_state";postalCodeField="shipaddress_postalcode";postalCodeId="shippostalcode";countyField="shipaddress_county";countyId="shipcounties";}
if(fldname=="billaddress_country"&&form.billaddress_country){CountryIndex=form.billaddress_country.selectedIndex;CountryValue=form.billaddress_country.options[CountryIndex].value;stateField="billaddress_state";postalCodeField="billaddress_postalcode";postalCodeId="billpostalcode";countyField="billaddress_county";countyId="billcounties";}
var PostalCodeCountries=new Array('US','CA','JP');if(CountryValue=="US"){clearStates(form,stateField);addStates(form,stateField);showField(form,'vat',false);showField(form,'billaddress_areacode',true);showField(form,'shipaddress_areacode',true);if(typeof(counties)!='undefined'&&typeof(form.elements[countyField])!='undefined'){addCounties(form,fldname);}}
else{if(CountryValue=="CA"){clearStates(form,stateField);addProvinces(form,stateField);showField(form,'vat',false);showField(form,'billaddress_areacode',true);showField(form,'shipaddress_areacode',true);}
else{if(eval(hideareacode)){if(fldname=='billaddress_country'){showField(form,'billaddress_areacode',false);if(typeof(form.elements['billaddress_phone'])!='undefined'){form.elements['billaddress_phone'].size=15;form.elements['billaddress_phone'].maxlength=15;}}
if(fldname=='shipaddress_country'){showField(form,'shipaddress_areacode',false);if(typeof(form.elements['shipaddress_phone'])!='undefined'){form.elements['shipaddress_phone'].size=15;form.elements['shipaddress_phone'].maxlength=15;}}}
if(typeof(form.elements[stateField])!='undefined'){clearStates(form,stateField);var noState=new Option("","",false,false);form.elements[stateField].options[0]=noState;}
if(typeof(form.elements[postalCodeField])!='undefined'){}
showField(form,'vat',true);}
clearCounties(form,countyField);showField(form,countyId,false);}
if(eval(form.elements[postalCodeField])){for(i=0;i<=PostalCodeCountries.length-1;i++){if(PostalCodeCountries[i]==CountryValue){showField(form,postalCodeId,true);break;}
else{showField(form,postalCodeId,false);}}}
if(eval(form.shipping_method)){loadShippingMethods(form);}}
function checkState(form){var taxField="shipaddress_state";var orderFormStateField="shipaddress_state";var CountryIndex=form.shipaddress_country.selectedIndex;var CountryValue=form.shipaddress_country.options[CountryIndex].value;var CountryText=form.shipaddress_country.options[CountryIndex].text;var taxFieldValue="";var taxFieldType=form.elements[taxField].type;var fieldValues=new Array();if(taxFieldType=="select-one"){var taxIndex=form.elements[taxField].selectedIndex;fieldValues=form.elements[taxField].options[taxIndex].value.split('|');taxFieldValue=fieldValues[0];}
else{fieldValues=form.elements[taxField].value.split('|');taxFieldValue=fieldValues[0];}
if((CountryValue=="US")&&((taxFieldValue=="")||(taxFieldValue=="INVALID"))){alert("\nSince you selected "+CountryText+" for your country, you"+"\nmust select your ship to state to continue.\n");form.elements[taxField].focus();return false;}
if((CountryValue=="CA")&&((taxFieldValue=="")||(taxFieldValue=="INVALID"))){alert("\nSince you selected "+CountryText+" for your country, you"+"\nmust select your ship to province to continue.\n");form.elements[taxField].focus();return false;}
if(CountryValue!="US"&&CountryValue!="CA"){if(eval(form.elements['vat_number'])){if(form.elements['vat_number'].value!=""){var vatNum=form.elements['vat_number'].value;if(!validateVatNumFmt(CountryValue,vatNum)){return false;}}}}
return true;}
function clearStates(form,fld){if(typeof(form.elements[fld])!='undefined'){selectLen=form.elements[fld].length;for(i=(selectLen-1);i>=0;i--){form.elements[fld].options[i]=null;}}}
function clearCounties(form,fld){if(typeof(form.elements[fld])!='undefined'&&form.elements[fld].type=='select-one'){selectLen=form.elements[fld].length;for(i=(selectLen-1);i>=0;i--){form.elements[fld].options[i]=null;}
var noCounty=new Option("Out of state","out_of_state",false,false);form.elements[fld].options[0]=noCounty;}}
function addCounties(form,fld){var stateIndex;var stateValue;var CountyField;var CountyId;if(fld=="billaddress_state"){stateIndex=form.billaddress_state.selectedIndex;stateValue=form.billaddress_state.options[stateIndex].value;CountyField="billaddress_county";CountyId="billcounties";}
if(fld=="shipaddress_state"){stateIndex=form.shipaddress_state.selectedIndex;stateValue=form.shipaddress_state.options[stateIndex].value;CountyField="shipaddress_county";CountyId="shipcounties";}
if(typeof(counties)!='undefined'&&eval(counties[stateValue])&&typeof(form.elements[fld])!='undefined'){clearCounties(form,CountyField);if(counties[stateValue].length>0){for(i=0;i<=counties[stateValue].length-1;i++){if(counties[stateValue][i]!=""){var str=counties[stateValue][i];var newCounty=new Option(str,str,false,false);form.elements[CountyField].options[i]=newCounty;}}
showField(form,CountyId,true);}}
else{if(typeof(form.elements[CountyField])!='undefined'){clearCounties(form,CountyField);showField(form,CountyId,false);}}}
function showField(form,whichEl,show){if(whichEl=="vat"&&form.shipaddress_country){var VATCountries=new Array('AT','BE','DK','FI','FR','DE','EL','IE','IT','LU','NL','PT','ES','SE','GB');var CountryIndex=form.shipaddress_country.selectedIndex;var CountryValue=form.shipaddress_country.options[CountryIndex].value;for(i=0;i<=VATCountries.length-1;i++){if(VATCountries[i]==CountryValue){show=true;break;}
else{show=false;}}}
if(document.all){whichEl=document.all[whichEl];}
else{whichEl=document.getElementById(whichEl);}
if(whichEl){if(show){whichEl.style.display="";}
else{whichEl.style.display="none";}}}
function addProvinces(form,fld){var Provinces=new Array();Provinces[0]="Alberta|Alberta";Provinces[1]="British Columbia|British Columbia";Provinces[2]="Labrador|Labrador";Provinces[3]="Manitoba|Manitoba";Provinces[4]="Native Reservations|Native Reservations";Provinces[5]="Nunavut|Nunavut";Provinces[6]="New Brunswick|New Brunswick";Provinces[7]="Newfoundland|Newfoundland";Provinces[8]="North West Territories|North West Territories";Provinces[9]="Nova Scotia|Nova Scotia";Provinces[10]="Ontario|Ontario";Provinces[11]="Prince Edward Island|Prince Edward Island";Provinces[12]="Quebec|Quebec";Provinces[13]="Saskatchewan|Saskatchewan";Provinces[14]="Yukon|Yukon";for(i=0;i<=Provinces.length-1;i++){if(Provinces[i]!=null){var pro=Provinces[i].split('|');var newProvince=new Option(pro[1],pro[0],false,false);form.elements[fld].options[i]=newProvince;}}}
function addStates(form,fld){var States=new Array();States[0]="|- Select State -";States[1]="AL|Alabama";States[2]="AK|Alaska";States[3]="AZ|Arizona";States[4]="AR|Arkansas";States[5]="CA|California";States[6]="CO|Colorado";States[7]="CT|Connecticut";States[8]="DE|Delaware";States[9]="DC|District of Columbia";States[10]="FL|Florida";States[11]="GA|Georgia";States[12]="GU|Guam";States[13]="HI|Hawaii";States[14]="ID|Idaho";States[15]="IL|Illinois";States[16]="IN|Indiana";States[17]="IA|Iowa";States[18]="KS|Kansas";States[19]="KY|Kentucky";States[20]="LA|Louisiana";States[21]="ME|Maine";States[22]="MD|Maryland";States[23]="MA|Massachusetts";States[24]="MI|Michigan";States[25]="MN|Minnesota";States[26]="MS|Mississippi";States[27]="MO|Missouri";States[28]="MT|Montana";States[29]="NE|Nebraska";States[30]="NV|Nevada";States[31]="NH|New Hampshire";States[32]="NJ|New Jersey";States[33]="NM|New Mexico";States[34]="NY|New York";States[35]="NC|North Carolina";States[36]="ND|North Dakota";States[37]="OH|Ohio";States[38]="OK|Oklahoma";States[39]="OR|Oregon";States[40]="PA|Pennsylvania";States[41]="PR|Puerto Rico";States[42]="RI|Rhode Island";States[43]="SC|South Carolina";States[44]="SD|South Dakota";States[45]="TN|Tennessee";States[46]="TX|Texas";States[47]="UT|Utah";States[48]="VT|Vermont";States[49]="VA|Virginia";States[50]="VI|Virgin Islands";States[51]="WA|Washington";States[52]="WV|West Virginia";States[53]="WI|Wisconsin";States[54]="WY|Wyoming";for(i=0;i<=States.length-1;i++){if(States[i]!=null){var values=States[i].split('|');var newState=new Option(values[1],values[0],false,false);form.elements[fld].options[i]=newState;}}}
function clearMethods(form){selectLen=form.shipping_method.length;for(i=(selectLen-1);i>=0;i--){form.shipping_method.options[i]=null;}}
function loadShippingMethods(form){clearMethods(form);var CountryIndex=form.shipaddress_country.selectedIndex;var CountryValue=form.shipaddress_country.options[CountryIndex].value;if(!eval(methods[CountryValue])){CountryValue="INT";}
if(eval(methods[CountryValue])){for(i=0;i<=methods[CountryValue].length-1;i++){if(methods[CountryValue][i]!=""){var values=methods[CountryValue][i].split(':');var newMethod=new Option(values[0]+" - "+values[1],values[0],false,false);form.shipping_method.options[i]=newMethod;}}}
form.shipping_method.options[0].selected=true;}
function validateVatNumFmt(country,vatNum){vatNum=vatNum.toLowerCase();VATRATES=new Array();VATRATES['AT']="9,[u]\\d{8}";VATRATES['BE']="9,\\d{9}";VATRATES['DK']="8,\\d{8}";VATRATES['FI']="8,\\d{8}";VATRATES['FR']="11,\\d{11}:[a-hj-np-z]\\d{10}:\\d[a-hj-np-z]\\d{9}:[a-hj-np-z][a-hj-np-z]\\d{9}";VATRATES['DE']="9,\\d{9}";VATRATES['EL']="8,\\d{8}";VATRATES['IE']="8,\\d{7}[a-z]:\\d[a-z]\\d{5}[a-z]";VATRATES['IT']="11,\\d{11}";VATRATES['LU']="8,\\d{8}";VATRATES['NL']="12,\\d{9}[b]\\d\\d";VATRATES['PT']="9,\\d{9}";VATRATES['ES']="9,[a-z]\\d{9}:\\d{9}[a-z]:[a-z]\\d{8}[a-z]";VATRATES['SE']="12,\\d{10}01";VATRATES['GB']="9,\\d{9}";if(VATRATES[country]==null){return true;}
var len=VATRATES[country].split(',')[0];var pattern=VATRATES[country].split(',')[1];if(vatNum.length>len){var tooLong=(vatNum.length-len);alert("Your VAT Number is "+tooLong+" characters too long?");return false;}
if(vatNum.length<len){var tooShort=(len-vatNum.length);alert("Your VAT Number is "+tooShort+" characters too short?");return false;}
var match=false;if(pattern.match(/\:/g)){var patterns=new Array();patterns=pattern.split(':');for(k=0;k<patterns.length;k++){if(vatNum.match(patterns[k])){alert(vatNum.match(patterns[k]));match=true;break;}}}
else{if(vatNum.match(pattern)){match=true;}}
if(match){return true;}
else{alert("Your VAT number "+vatNum+" is invalid for "+country);return false;}
return false;}
function testRequiredFields(form){if(typeof(requiredFields)!='undefined'){for(j=0;j<requiredFields.length;j++){var bCountry=null;if(requiredFields[j].substring(0,4)=="ship"&&typeof(form.shipaddress_country)!='undefined'){var sCountryIdx=form.shipaddress_country.selectedIndex;var bCountry=form.shipaddress_country.options[sCountryIdx].value;}
else if(typeof(form.billaddress_country)!='undefined'){var bCountryIdx=form.billaddress_country.selectedIndex;var bCountry=form.billaddress_country.options[bCountryIdx].value;}
if((bCountry!="CA"&&bCountry!="US")&&(requiredFields[j]=='billaddress_areacode'||requiredFields[j]=='shipaddress_areacode')){continue;}
if(typeof(form.elements[requiredFields[j]])!='undefined'){var label="";for(i=0;i<requiredFields[j].length;i++){character=requiredFields[j].charAt(i);if("_".indexOf(character)!=-1){label+=" ";}
else{label+=character;}}
var requiredValue="";if(form.elements[requiredFields[j]].type=="text"){requiredValue=form.elements[requiredFields[j]].value;}
if(form.elements[requiredFields[j]].type=="select-one"){var sIndex=form.elements[requiredFields[j]].selectedIndex;requiredValue=form.elements[requiredFields[j]].options[sIndex].value;}
if(form.elements[requiredFields[j]].type=="radio"){for(i=0;i<form.elements[requiredFields[j]].length;i++){if(form.elements[requiredFields[j]][i].checked){requiredValue=form.elements[requiredFields[j]][i].value;break;}}}
if(form.elements[requiredFields[j]].type=="checkbox"){if(form.elements[requiredFields[j]].checked){requiredValue=form.elements[requiredFields[j]].value;}}
requiredValue=requiredValue.replace(/^\s*|\s*$/g,"");if(requiredValue==""||requiredValue.toLowerCase()=="invalid"){if(form.elements[requiredFields[j]].type=="text"){alert("You forgot to fill in the \""+label+"\" field.\n"+"This field is required before processing your order.");}
else{alert("You forgot to make a selection for the \""+label+"\" field.\n"+"This field is required before processing your order.");}
form.elements[requiredFields[j]].focus();return false;}
var testField=requiredFields[j].substring(12);if(requiredFields[j]=="card_number"){if(requiredValue!=""){var cleanFld=strip(requiredValue);form.elements[requiredFields[j]].value=cleanFld;}}
if(testField=="email"){if(!emailCheck(requiredValue)){alert("Please enter a valid email address");form.elements[requiredFields[j]].select();return false;}}
if((bCountry=="US"||bCountry=="CA")&&testField=="areacode"){var areacode=strip(requiredValue);if(areacode.length<3||areacode.length>3||parseInt(areacode)==0){alert("Please enter a valid "+label);form.elements[requiredFields[j]].select();return false;}}
if((bCountry=="US"||bCountry=="CA")&&testField=="phone"){var phone=strip(requiredValue);if(phone.length<7||phone.length>7||parseInt(phone)==0){alert("Please enter a valid "+label);form.elements[requiredFields[j]].select();return false;}}
if((bCountry=="CA"||bCountry=="US")&&testField=="postalcode"){if(!isZip(requiredValue)&&bCountry=="US"){alert("Please enter a valid "+label);form.elements[requiredFields[j]].select();return false;}
requiredValue=requiredValue.replace(' ','');if(bCountry=="CA"&&(requiredValue.length<6||requiredValue.length>6)){alert("Please enter a valid "+label);form.elements[requiredFields[j]].select();return false;}}}}}
convertApostrophies(form);return true;}
function convertApostrophies(form){for(j=0;j<form.elements.length;j++){if(form.elements[j].type=="text"){var strText=form.elements[j].value;form.elements[j].value=strText.replace("'","`");}}}
function checkRequiredFields(form){var Required=testRequiredFields(form);if(!Required){return false;}
if(typeof(form.sameasbilling)!='undefined'&&!form.sameasbilling.checked&&form.shipaddress_addr1.value==""){form.sameasbilling.checked=true;shipsame(form);}
if(typeof(form.card_number)!='undefined'){var Payment=checkCard(form);if(!Payment){return false;}
var Expire=checkExpireDate(form);if(!Expire){return false;}}
else{return true;}}
function checkCard(form){var cardNumField="card_number";var cardField=form.elements[cardNumField];var entry=form.elements[cardNumField].value;if(entry==""){alert('You did not enter a valid credit card number\n'+'Please check your entry and try again.');cardField.focus();return false;}
var strippedEntry=strip(entry);if((!isCreditCard(strippedEntry))||(strippedEntry.length==0)){alert('The credit card number you entered could not be validated.\n'+'Please check the number and try again.');cardField.focus();cardField.select();return false;}
if(!checkCardType(form)){return false;}
return true;}
function checkCardType(form){var typeField="credit_card_type";var typeIndex=form.elements[typeField].selectedIndex;var typeFieldValue=form.elements[typeField].options[typeIndex].value;var numField="card_number";var numFieldValue=form.elements[numField].value;var num=numFieldValue.substring(0,1);var blnOK=true;if((typeFieldValue.toLowerCase()=="american express")&&(num!=3)){blnOK=false;}
if((typeFieldValue.toLowerCase()=="american_express")&&(num!=3)){blnOK=false;}
if((typeFieldValue.toLowerCase()=="amex")&&(num!=3)){blnOK=false;}
if((typeFieldValue.toLowerCase()=="visa")&&(num!=4)){blnOK=false;}
if((typeFieldValue.toLowerCase()=="mastercard")&&(num!=5)){blnOK=false;}
if((typeFieldValue.toLowerCase()=="discover")&&(num!=6)){blnOK=false;}
if(!blnOK){alert("The credit card number that you entered does not match the card type that you selected from the available card types that we offer.\n\n"+"Please select the correct card type for the credit card.");form.elements[typeField].focus();return false;}
return true;}
function checkExpireDate(form){var monthIndex=form.elements['expire_month'].selectedIndex;var expireMonth=form.elements['expire_month'].options[monthIndex].value-1;var yearIndex=form.elements['expire_year'].selectedIndex;var expireYear=form.elements['expire_year'].options[yearIndex].value;var now=new Date();var today=new Date(now.getYear(),now.getMonth(),now.getDate());var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);var expireDay=monthDays[expireMonth];var expire=new Date(expireYear,expireMonth,expireDay);if(expire<today){alert("The expiration date you selected is invalid.\n\n"+"Please select a valid expiration date for the credit card.");form.elements['expire_month'].focus();return false;}
return true;}
function isCreditCard(st){if(st.length>19)
return(false);sum=0;mul=1;l=st.length;for(i=0;i<l;i++){digit=st.substring(l-i-1,l-i);tproduct=parseInt(digit,10)*mul;if(tproduct>=10)
sum+=(tproduct%10)+1;else
sum+=tproduct;if(mul==1)
mul++;else
mul--;}
if((sum%10)==0)
return(true);else
return(false);}
function strip(val){val=""+val;if(!val)
return"";var result="";for(i=0;i<val.length;i++){character=val.charAt(i);if("0123456789".indexOf(character)!=-1)
result+=character;}
return result;}
function shipsame(form){if(form.sameasbilling.checked){form.shipaddress_companyname.value=form.billaddress_companyname.value;form.shipaddress_firstname.value=form.billaddress_firstname.value
form.shipaddress_lastname.value=form.billaddress_lastname.value;form.shipaddress_addr1.value=form.billaddress_addr1.value;form.shipaddress_addr2.value=form.billaddress_addr2.value;form.shipaddress_city.value=form.billaddress_city.value;form.shipaddress_postalcode.value=form.billaddress_postalcode.value;form.shipaddress_areacode.value=form.billaddress_areacode.value;form.shipaddress_phone.value=form.billaddress_phone.value;form.shipaddress_email.value=form.billaddress_email.value;if(form.billaddress_country.type=="select-one"){var bCountryIdx=form.billaddress_country.selectedIndex;form.shipaddress_country.options[bCountryIdx].selected=true;}
else{form.shipaddress_country.value=form.billaddress_country.value;}
if(typeof(form.shipaddress_county)!='undefined'&&typeof(form.billaddress_county)!='undefined'){if(form.shipaddress_county.type=='select-one'){var bCountyIdx=form.billaddress_county.selectedIndex;form.shipaddress_county.options[bCountyIdx].selected=true;}
else{form.shipaddress_county.value=form.billaddress_county.value;}}
checkCountry(form,'shipaddress_country');if(form.billaddress_state.type=="select-one"){var bStateIdx=form.billaddress_state.selectedIndex;form.shipaddress_state.options[bStateIdx].selected=true;}
else{form.shipaddress_state.value=form.billaddress_state.value;}}
else{form.shipaddress_companyname.value="";form.shipaddress_firstname.value="";form.shipaddress_lastname.value="";form.shipaddress_addr1.value="";form.shipaddress_addr2.value="";form.shipaddress_city.value="";form.shipaddress_postalcode.value="";form.shipaddress_areacode.value="";form.shipaddress_phone.value="";form.shipaddress_email.value="";selectBoxes(form,true);}}
function selectBoxes(form,shipOnly){if(!shipOnly){for(j=0;j<=form.elements['billaddress_country'].length-1;j++){if(form.elements['billaddress_country'].options[j].value==selectedBillCountry){form.elements['billaddress_country'].options[j].selected=true;break;}}
checkCountry(form,'billaddress_country');}
if(form.elements['shipaddress_country']){for(j=0;j<=form.elements['shipaddress_country'].length-1;j++){if(form.elements['shipaddress_country'].options[j].value==selectedShipCountry){form.elements['shipaddress_country'].options[j].selected=true;break;}}
checkCountry(form,'shipaddress_country');}
if(selectedBillState=="INVALID"&&(selectedShipState!="INVALID"||selectedShipState!="")){selectedBillState=selectedShipState;}
if(!shipOnly){if(typeof(form.elements['billaddress_state'])!='undefined'){for(j=0;j<=form.elements['billaddress_state'].length-1;j++){if(form.elements['billaddress_state'].options[j].value==selectedBillState){form.elements['billaddress_state'].options[j].selected=true;addCounties(form,'billaddress_state');break;}}}}
if(typeof(form.elements['shipaddress_state'])!='undefined'){for(j=0;j<=form.elements['shipaddress_state'].length-1;j++){if(form.elements['shipaddress_state'].options[j].value==selectedShipState){form.elements['shipaddress_state'].options[j].selected=true;addCounties(form,'shipaddress_state');break;}}}}
function selectExpireDate(form){var date=new Date();var month=date.getMonth();var yy=date.getYear();var year=(yy<1000)?yy+1900:yy;if(form.elements['expire_month']){form.elements['expire_month'].options[month].selected=true;}
if(form.elements['expire_year']){for(j=0;j<=form.elements['expire_year'].length-1;j++){if(form.elements['expire_year'].options[j].value==year){form.elements['expire_year'].options[j].selected=true;break;}}}}
function submitAddressChange(form,field){if(document.forms['addrform'].elements['csid']){var fldIndex=form.elements[field].selectedIndex;var csid=form.elements[field].options[fldIndex].value;document.forms['addrform'].elements['csid'].value=csid;document.forms['addrform'].submit();}}
function submitShipMethodChange(form,field){if(document.forms['shipform'].elements['shipping_method']){var fldIndex=form.elements[field].selectedIndex;var selectedMethod=form.elements[field].options[fldIndex].value;document.forms['shipform'].elements['shipping_method'].value=selectedMethod;document.forms['shipform'].submit();}}
function submitPaymentChange(form,field){if(document.forms['payform'].elements['payment_method']){var fldIndex=form.elements[field].selectedIndex;var csid=form.elements[field].options[fldIndex].value;document.forms['payform'].elements['payment_method'].value=csid;document.forms['payform'].submit();}}
function disable(form,el){}
function isZip(s){reZip=new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);if(!reZip.test(s)){return false;}
return true;}
function emailCheck(str){var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if(str.indexOf(at)==-1){return false;}
if(str.indexOf(at)==-1||str.indexOf(at)==0||str.indexOf(at)==lstr){return false;}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr){return false;}
if(str.indexOf(at,(lat+1))!=-1){return false;}
if(str.substring(lat-1,lat)==dot||str.substring(lat+1,lat+2)==dot){return false;}
if(str.indexOf(dot,(lat+2))==-1){return false;}
if(str.indexOf(" ")!=-1){return false;}
return true;}
function Node(id,pid,name,url,title,target,icon,iconOpen,open){this.id=id;this.pid=pid;this.name=name;this.url=url;this.title=title;this.target=target;this.icon=icon;this.iconOpen=iconOpen;this._io=open||false;this._is=false;this._ls=false;this._hc=false;this._ai=0;this._p;};function dTree(objName){this.config={target:null,folderLinks:true,useSelection:true,useCookies:true,useLines:true,useIcons:true,useStatusText:false,closeSameLevel:false,inOrder:false}
this.icon={root:'images/menu/empty.gif',folder:'images/menu/folder.gif',folderOpen:'images/menu/folderopen.gif',node:'images/menu/page.gif',empty:'images/menu/empty.gif',line:'images/menu/line.gif',join:'images/menu/join.gif',joinBottom:'images/menu/joinbottom.gif',plus:'images/menu/plus.gif',plusBottom:'images/menu/plusbottom.gif',minus:'images/menu/minus.gif',minusBottom:'images/menu/minusbottom.gif',nlPlus:'images/menu/nolines_plus.gif',nlMinus:'images/menu/nolines_minus.gif'};this.obj=objName;this.aNodes=[];this.aIndent=[];this.root=new Node(-1);this.selectedNode=null;this.selectedFound=false;this.completed=false;};dTree.prototype.add=function(id,pid,name,url,title,target,icon,iconOpen,open){this.aNodes[this.aNodes.length]=new Node(id,pid,name,url,title,target,icon,iconOpen,open);};dTree.prototype.openAll=function(){this.oAll(true);};dTree.prototype.closeAll=function(){this.oAll(false);};dTree.prototype.toString=function(){var str='<div class="dtree">\n';if(document.getElementById){if(this.config.useCookies)this.selectedNode=this.getSelected();str+=this.addNode(this.root);}else str+='Browser not supported.';str+='</div>';if(!this.selectedFound)this.selectedNode=null;this.completed=true;return str;};dTree.prototype.addNode=function(pNode){var str='';var n=0;if(this.config.inOrder)n=pNode._ai;for(n;n<this.aNodes.length;n++){if(this.aNodes[n].pid==pNode.id){var cn=this.aNodes[n];cn._p=pNode;cn._ai=n;this.setCS(cn);if(!cn.target&&this.config.target)cn.target=this.config.target;if(cn._hc&&!cn._io&&this.config.useCookies)cn._io=this.isOpen(cn.id);if(!this.config.folderLinks&&cn._hc)cn.url=null;if(this.config.useSelection&&cn.id==this.selectedNode&&!this.selectedFound){cn._is=true;this.selectedNode=n;this.selectedFound=true;}
str+=this.node(cn,n);if(cn._ls)break;}}
return str;};dTree.prototype.node=function(node,nodeId){var str='<div class="dTreeNode">'+this.indent(node,nodeId);if(this.config.useIcons){if(!node.icon)node.icon=(this.root.id==node.pid)?this.icon.root:((node._hc)?this.icon.folder:this.icon.node);if(!node.iconOpen)node.iconOpen=(node._hc)?this.icon.folderOpen:this.icon.node;if(this.root.id==node.pid){node.icon=this.icon.root;node.iconOpen=this.icon.root;}
else{str+='<img id="i'+this.obj+nodeId+'" src="'+((node._io)?node.iconOpen:node.icon)+'" alt="" />';}}
if(node.url){str+='<a id="s'+this.obj+nodeId+'" class="'+((this.config.useSelection)?((node._is?'nodeSel':'node')):'node')+'" href="'+node.url+'"';if(node.title)str+=' title="'+node.title+'"';if(node.target)str+=' target="'+node.target+'"';if(this.config.useStatusText)str+=' onmouseover="window.status=\''+node.name+'\';return true;" onmouseout="window.status=\'\';return true;" ';if(this.config.useSelection&&((node._hc&&this.config.folderLinks)||!node._hc))
str+=' onclick="javascript: '+this.obj+'.s('+nodeId+');"';str+='>';}
else if((!this.config.folderLinks||!node.url)&&node._hc&&node.pid!=this.root.id)
str+='<a href="javascript: '+this.obj+'.o('+nodeId+');" class="node">';str+=node.name;if(node.url||((!this.config.folderLinks||!node.url)&&node._hc))str+='</a>';str+='</div>';if(node._hc){str+='<div id="d'+this.obj+nodeId+'" class="clip" style="display:'+((this.root.id==node.pid||node._io)?'block':'none')+';">';str+=this.addNode(node);str+='</div>';}
this.aIndent.pop();return str;};dTree.prototype.indent=function(node,nodeId){var str='';if(this.root.id!=node.pid){for(var n=0;n<this.aIndent.length;n++)
str+='<img src="'+((this.aIndent[n]==1&&this.config.useLines)?this.icon.line:this.icon.empty)+'" alt="" />';(node._ls)?this.aIndent.push(0):this.aIndent.push(1);if(node._hc){str+='<a href="javascript: '+this.obj+'.o('+nodeId+');"><img id="j'+this.obj+nodeId+'" src="';if(!this.config.useLines)str+=(node._io)?this.icon.nlMinus:this.icon.nlPlus;else str+=((node._io)?((node._ls&&this.config.useLines)?this.icon.minusBottom:this.icon.minus):((node._ls&&this.config.useLines)?this.icon.plusBottom:this.icon.plus));str+='" alt="" /></a>';}else str+='<img src="'+((this.config.useLines)?((node._ls)?this.icon.joinBottom:this.icon.join):this.icon.empty)+'" alt="" />';}
return str;};dTree.prototype.setCS=function(node){var lastId;for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n].pid==node.id)node._hc=true;if(this.aNodes[n].pid==node.pid)lastId=this.aNodes[n].id;}
if(lastId==node.id)node._ls=true;};dTree.prototype.getSelected=function(){var sn=this.getCookie('cs'+this.obj);return(sn)?sn:null;};dTree.prototype.s=function(id){if(!this.config.useSelection)return;var cn=this.aNodes[id];if(cn._hc&&!this.config.folderLinks)return;if(this.selectedNode!=id){if(this.selectedNode||this.selectedNode==0){eOld=document.getElementById("s"+this.obj+this.selectedNode);eOld.className="node";}
eNew=document.getElementById("s"+this.obj+id);eNew.className="nodeSel";this.selectedNode=id;if(this.config.useCookies)this.setCookie('cs'+this.obj,cn.id);}};dTree.prototype.o=function(id){var cn=this.aNodes[id];this.nodeStatus(!cn._io,id,cn._ls);cn._io=!cn._io;if(this.config.closeSameLevel)this.closeLevel(cn);if(this.config.useCookies)this.updateCookie();};dTree.prototype.oAll=function(status){for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n]._hc&&this.aNodes[n].pid!=this.root.id){this.nodeStatus(status,n,this.aNodes[n]._ls)
this.aNodes[n]._io=status;}}
if(this.config.useCookies)this.updateCookie();};dTree.prototype.openTo=function(nId,bSelect,bFirst){if(!bFirst){for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n].id==nId){nId=n;break;}}}
var cn=this.aNodes[nId];if(cn.pid==this.root.id||!cn._p)return;cn._io=true;cn._is=bSelect;if(this.completed&&cn._hc)this.nodeStatus(true,cn._ai,cn._ls);if(this.completed&&bSelect)this.s(cn._ai);else if(bSelect)this._sn=cn._ai;this.openTo(cn._p._ai,false,true);};dTree.prototype.closeLevel=function(node){for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n].pid==node.pid&&this.aNodes[n].id!=node.id&&this.aNodes[n]._hc){this.nodeStatus(false,n,this.aNodes[n]._ls);this.aNodes[n]._io=false;this.closeAllChildren(this.aNodes[n]);}}}
dTree.prototype.closeAllChildren=function(node){for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n].pid==node.id&&this.aNodes[n]._hc){if(this.aNodes[n]._io)this.nodeStatus(false,n,this.aNodes[n]._ls);this.aNodes[n]._io=false;this.closeAllChildren(this.aNodes[n]);}}}
dTree.prototype.nodeStatus=function(status,id,bottom){eDiv=document.getElementById('d'+this.obj+id);eJoin=document.getElementById('j'+this.obj+id);if(this.config.useIcons){eIcon=document.getElementById('i'+this.obj+id);eIcon.src=(status)?this.aNodes[id].iconOpen:this.aNodes[id].icon;}
eJoin.src=(this.config.useLines)?((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):((status)?this.icon.nlMinus:this.icon.nlPlus);eDiv.style.display=(status)?'block':'none';};dTree.prototype.clearCookie=function(){var now=new Date();var yesterday=new Date(now.getTime()-1000*60*60*24);this.setCookie('co'+this.obj,'cookieValue',yesterday);this.setCookie('cs'+this.obj,'cookieValue',yesterday);};dTree.prototype.setCookie=function(cookieName,cookieValue,expires,path,domain,secure){document.cookie=escape(cookieName)+'='+escape(cookieValue)
+(expires?'; expires='+expires.toGMTString():'')
+(path?'; path='+path:'')
+(domain?'; domain='+domain:'')
+(secure?'; secure':'');};dTree.prototype.getCookie=function(cookieName){var cookieValue='';var posName=document.cookie.indexOf(escape(cookieName)+'=');if(posName!=-1){var posValue=posName+(escape(cookieName)+'=').length;var endPos=document.cookie.indexOf(';',posValue);if(endPos!=-1)cookieValue=unescape(document.cookie.substring(posValue,endPos));else cookieValue=unescape(document.cookie.substring(posValue));}
return(cookieValue);};dTree.prototype.updateCookie=function(){var str='';for(var n=0;n<this.aNodes.length;n++){if(this.aNodes[n]._io&&this.aNodes[n].pid!=this.root.id){if(str)str+='.';str+=this.aNodes[n].id;}}
this.setCookie('co'+this.obj,str);};dTree.prototype.isOpen=function(id){var aOpen=this.getCookie('co'+this.obj).split('.');for(var n=0;n<aOpen.length;n++)
if(aOpen[n]==id)return true;return false;};if(!Array.prototype.push){Array.prototype.push=function array_push(){for(var i=0;i<arguments.length;i++)
this[this.length]=arguments[i];return this.length;}};if(!Array.prototype.pop){Array.prototype.pop=function array_pop(){lastElement=this[this.length-1];this.length=Math.max(this.length-1,0);return lastElement;}};function GoTo(thisURL){location=thisURL;}
function OpenWindow(thisURL,x,y){alert(thisURL);var gWin;if(x==undefined){gWin=window.open(thisURL,'GraphicWindow','resizable=0','scrollbars=0');}
else{gWin=window.open(thisURL,'GraphicWindow','width='+x+',height='+y+',resizable=0,scrollbars=0');}}
function popup(img,h,w,title){var sWidth=screen.width/2-w;var win=window.open("","graphics","top=100,left="+sWidth+",scrollbars=0,resizable=1");win.resizeTo(w,h+100);win.document.open("text/html","replace");win.document.write("<html><head><title>"+title+"</title></head><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>");win.document.write("<img src="+img+" width="+w+" height="+h+"><br>");win.document.write("<form><div align=center><input type=button name=Close value=\"Close Window\" onclick=window.close()></div></form>");win.document.write("</body></html>");win.status="Zoom Image of "+title;win.focus();}
function qtyCheck(form){var qtySelected=parseInt(0);for(i=0;i<form.elements.length;i++){var fieldName=form.elements[i].name;if(fieldName.substring(0,8).toLowerCase()=="quantity"){var fieldValue=parseInt(form.elements[i].value);if(fieldValue>0){qtySelected+=parseInt(fieldValue);var id=fieldName.substring(9,fieldName.length);var availFld="available|"+id;var minField="minimum|"+id;var nameFld="name|"+id;var productName=form.elements[nameFld].value
var pattern=/\s{2,}/g;var pName=productName.replace(pattern,"");if(eval(form.elements[availFld])){var qtyAvailable=parseInt(form.elements[availFld].value);if(fieldValue>qtyAvailable){if(qtyAvailable<=0){alert("Sorry, the '"+pName+"' is not available at this time.");}
else{alert("There are only "+qtyAvailable+" of the '"+pName+"s' available.\n\n"+"Please reduce the quantity so it is equal to or fewer than "+qtyAvailable+" item(s).");}
form.elements[i].value="";form.elements[i].focus();return false;}}
if(eval(form.elements[minField])){var qtyMinimum=parseInt(form.elements[minField].value);if(fieldValue<qtyMinimum){alert("You must purchase a minimum of "+qtyMinimum+" '"+pName+"s'.");form.elements[i].value="";form.elements[i].focus();return false;}}}}}
if(qtySelected==0){alert("You have not entered a quantity of an item to add to the cart.");return false;}
return true;}
function checkInputs(form,sku){var isInventoried=false;var inventoryFld="item."+sku+".inventory";var inventoryQty=0;var minimumQty=0;if(typeof(form.elements[inventoryFld])!='undefined'){isInventoried=true;inventoryQty=form.elements[inventoryFld].value;var minFld="item."+sku+".minimum";if(typeof(form.elements[minFld])!='undefined'){minimumQty=form.elements[minFld].value;}}
var qtyFld="item."+sku+".quantity";var qtySelected=parseInt(0);if(form.elements[qtyFld].type=="select-one"){var qIndex=form.elements[qtyFld].selectedIndex;qtySelected=parseInt(form.elements[qtyFld].options[qIndex].value);}
else{qtySelected=parseInt(form.elements[qtyFld].value);}
if(isNaN(qtySelected)||qtySelected<1){alert("You have not entered a valid quantity for this item?");form.elements[qtyFld].value="";form.elements[qtyFld].focus();return false;}
if(isInventoried&&(qtySelected>inventoryQty)){alert("You entered a quantity for this item that is greater than the available quantity ("+inventoryQty+")");form.elements[qtyFld].value="";form.elements[qtyFld].focus();return false;}
if(minimumQty>0&&(qtySelected<minimumQty)){alert("You must purchase a minimum of "+minimumQty+" items");form.elements[qtyFld].value="";form.elements[qtyFld].focus();return false;}
var optionFld="option."+sku+".";var nameLen=sku.length+8;var Options=new Array();for(i=0;i<form.elements.length;i++){var fieldName=form.elements[i].name;var fieldType=form.elements[i].type;if(typeof(fieldName)!='undefined'&&fieldName.substring(0,nameLen)==optionFld){var fldValue=null;if(fieldType=="select-one"){var selectedIndex=form.elements[fieldName].selectedIndex;fldValue=form.elements[fieldName].options[selectedIndex].value;}
if(fieldType=="text"){fldValue=form.elements[fieldName].value;}
if(fieldType=='radio'){var isChecked=false;for(j=0;j<form.elements[fieldName].length;j++){if(form.elements[fieldName][j].checked==true){isChecked=true;break;}}
if(!isChecked){var parts=fieldName.split('.');fldValue="invalid|"+parts[2];}}
if(fldValue&&fldValue.substring(0,7).toLowerCase()=="invalid"){testFlds=fldValue.split('|');var optionName=testFlds[1];var message="You must select an option for '"+optionName+"' before you can add this item to your cart.";alert(message);if(fieldType=="radio"){form.elements[fieldName][0].focus();}
else{form.elements[fieldName].focus();}
return false;}
else{if(fldValue){var flds=fldValue.split('|');Options.push(flds[0]);}}}}
if(Options.length>0){var strOptions=Options.join(':');return checkInventoryOptions(form,qtyFld,qtySelected,sku,strOptions);}
return true;}
function showIt(whichEl,classEL){if(document.all){whichEl=document.all[whichEl];classEL=document.all[classEL];}
else{whichEl=document.getElementById(whichEl);classEL=document.getElementById(classEL);}
whichEl.style.display=(whichEl.style.display=="none")?"":"none";classEL.className=(classEL.className=="subListItem")?"subListItemClicked":"subListItem";}
function inventoryList(){this.length=0;this.items=new Array();this.getItem=function(in_key){return this.items[in_key];}
this.setItem=function(in_key,in_value){if(typeof(in_value)!='undefined'){if(typeof(this.items[in_key])=='undefined'){this.length++;}
this.items[in_key]=in_value;}
return in_value;}
this.hasItem=function(in_key){return typeof(this.items[in_key])!='undefined';}}
function checkInventoryOptions(form,qtyFld,qtySelected,sku,strOptions){if(inventory.length>0&&inventory.hasItem(sku)){for(j=0;j<inventory.items[sku].length;j++){var min=inventory.items[sku][j][1];var available=inventory.items[sku][j][2];if(inventory.items[sku][j][0]!=""&&strOptions&&inventory.items[sku][j][0]==strOptions){if(qtySelected>available){var qtyToEnter=parseInt(available)+1;alert("The available quantity for this item with the selected options is ("+available+")\n\n"+"Enter a quantity lower than "+qtyToEnter+" or select different options to try again.");form.elements[qtyFld].value="";form.elements[qtyFld].focus();return false;}
if(min>0&&qtySelected<min){alert("You must purchase a minimum of ("+min+") items with the selected options");form.elements[qtyFld].value="";form.elements[qtyFld].focus();return false;}}}}
return true;}
function displayInventoryCount(form,sku){if(inventory.length>0&&inventory.hasItem(sku)){var optionFld="option."+sku+".";var nameLen=sku.length+8;var Options=new Array();for(i=0;i<form.elements.length;i++){var fieldName=form.elements[i].name;var fieldType=form.elements[i].type;if(typeof(fieldName)!='undefined'&&fieldName.substring(0,nameLen)==optionFld){var fldValue=null;if(fieldType=="select-one"){var selectedIndex=form.elements[fieldName].selectedIndex;fldValue=form.elements[fieldName].options[selectedIndex].value;}
if(fieldType=="text"){fldValue=form.elements[fieldName].value;}
if(fieldType=='radio'){for(j=0;j<form.elements[fieldName].length;j++){if(form.elements[fieldName][j].checked==true){var values=form.elements[fieldName][j].value.split('|');fldValue=values[0];break;}}}
if(fldValue){var flds=fldValue.split('|');Options.push(flds[0]);}}}
if(Options.length>0){var strOptions=Options.join(':');for(j=0;j<inventory.items[sku].length;j++){var min=0;var available=0;if(inventory.items[sku][j][0]!=""&&strOptions&&inventory.items[sku][j][0]==strOptions){min=inventory.items[sku][j][1];available=inventory.items[sku][j][2];if(parseInt(min)>0){var minFld=sku+'.minimum';var minDiv=document.getElementById(minFld);if(typeof(minDiv)!='undefined'){minDiv.innerHTML="<p><b>Minimum Purchase Quantity:</b> "+min;}}
if(parseInt(available)>0){var availableFld=sku+'.available';var availableDiv=document.getElementById(availableFld);if(typeof(availableDiv)!='undefined'){availableDiv.innerHTML="<p><b>Available Quantity:</b> "+available;}}}}}}}
jQuery.noConflict()
var jquerypopupmenu={arrowpath:'arrow.gif',popupmenuoffsets:[0,0],animspeed:200,showhidedelay:[150,150],startzindex:1000,builtpopupmenuids:[],positionul:function($,$ul,e){var istoplevel=$ul.hasClass('jqpopupmenu')
var docrightedge=$(document).scrollLeft()+$(window).width()-40
var docbottomedge=$(document).scrollTop()+$(window).height()-40
if(istoplevel){var x=e.pageX+this.popupmenuoffsets[0]
var y=e.pageY+this.popupmenuoffsets[1]
x=(x+$ul.data('dimensions').w>docrightedge)?docrightedge-$ul.data('dimensions').w:x
y=(y+$ul.data('dimensions').h>docbottomedge)?docbottomedge-$ul.data('dimensions').h:y}
else{var $parentli=$ul.data('$parentliref')
var parentlioffset=$parentli.offset()
var x=$ul.data('dimensions').parentliw
var y=0
x=(parentlioffset.left+x+$ul.data('dimensions').w>docrightedge)?x-$ul.data('dimensions').parentliw-$ul.data('dimensions').w:x
y=(parentlioffset.top+$ul.data('dimensions').h>docbottomedge)?y-$ul.data('dimensions').h+$ul.data('dimensions').parentlih:y}
$ul.css({left:x,top:y})},showbox:function($,$popupmenu,e){clearTimeout($popupmenu.data('timers').hidetimer)
$popupmenu.data('timers').showtimer=setTimeout(function(){$popupmenu.show(jquerypopupmenu.animspeed)},this.showhidedelay[0])},hidebox:function($,$popupmenu){clearTimeout($popupmenu.data('timers').showtimer)
$popupmenu.data('timers').hidetimer=setTimeout(function(){$popupmenu.hide(100)},this.showhidedelay[1])},buildpopupmenu:function($,$menu,$target){$menu.css({display:'block',visibility:'hidden',zIndex:this.startzindex}).addClass('jqpopupmenu').appendTo(document.body)
$menu.bind('mouseenter',function(){clearTimeout($menu.data('timers').hidetimer)})
$menu.bind('mouseleave',function(){jquerypopupmenu.hidebox($,$menu)})
$menu.data('dimensions',{w:$menu.outerWidth(),h:$menu.outerHeight()})
$menu.data('timers',{})
var $lis=$menu.find("ul").parent()
$lis.each(function(i){var $li=$(this).css({zIndex:1000+i})
var $subul=$li.find('ul:eq(0)').css({display:'block'})
$subul.data('dimensions',{w:$subul.outerWidth(),h:$subul.outerHeight(),parentliw:this.offsetWidth,parentlih:this.offsetHeight})
$subul.data('$parentliref',$li)
$subul.data('timers',{})
$li.data('$subulref',$subul)
$li.children("a:eq(0)").append('<img src="'+jquerypopupmenu.arrowpath+'" class="rightarrowclass" style="border:0;" />')
$li.bind('mouseenter',function(e){var $targetul=$(this).css('zIndex',++jquerypopupmenu.startzindex).addClass("selected").data('$subulref')
if($targetul.queue().length<=1){clearTimeout($targetul.data('timers').hidetimer)
$targetul.data('timers').showtimer=setTimeout(function(){jquerypopupmenu.positionul($,$targetul,e)
$targetul.show(jquerypopupmenu.animspeed)},jquerypopupmenu.showhidedelay[0])}})
$li.bind('mouseleave',function(e){var $targetul=$(this).data('$subulref')
clearTimeout($targetul.data('timers').showtimer)
$targetul.data('timers').hidetimer=setTimeout(function(){$targetul.hide(100).data('$parentliref').removeClass('selected')},jquerypopupmenu.showhidedelay[1])})})
$menu.find('ul').andSelf().css({display:'none',visibility:'visible'})
$menu.data('$targetref',$target)
this.builtpopupmenuids.push($menu.get(0).id)},init:function($,$target,$popupmenu){if(this.builtpopupmenuids.length==0){$(document).bind("click",function(e){if(e.button==0){$('.jqpopupmenu').find('ul').andSelf().hide()}})}
if(jQuery.inArray($popupmenu.get(0).id,this.builtpopupmenuids)==-1)
this.buildpopupmenu($,$popupmenu,$target)
if($target.parents().filter('ul.jqpopupmenu').length>0)
return
$target.bind("mouseenter",function(e){$popupmenu.css('zIndex',++jquerypopupmenu.startzindex)
jquerypopupmenu.positionul($,$popupmenu,e)
jquerypopupmenu.showbox($,$popupmenu,e)})
$target.bind("mouseleave",function(e){jquerypopupmenu.hidebox($,$popupmenu)})}}
jQuery.fn.addpopupmenu=function(popupmenuid){var $=jQuery
return this.each(function(){var $target=$(this)
jquerypopupmenu.init($,$target,$('#'+popupmenuid))})};jQuery(document).ready(function($){var $anchors=$('*[data-popupmenu]')
$anchors.each(function(){$(this).addpopupmenu(this.getAttribute('data-popupmenu'))})})
function ddlistmenu(id,className){var menu=document.createElement('ul')
if(id)
menu.id=id
if(className)
menu.className=className
this.menu=menu}
ddlistmenu.prototype={addItem:function(url,text,target){var li=document.createElement('li')
li.innerHTML='<a href="'+url+'" target="'+target+'">'+text+'</a>'
this.menu.appendChild(li)
this.li=li
return this},addSubMenu:function(){var s=new ddlistmenu(null,null)
this.li.appendChild(s.menu)
return s}}
var thumbnailviewer={enableTitle:true,enableAnimation:true,definefooter:'<div class="footerbar">CLOSE X</div>',defineLoading:'<img src="images/loading.gif" height="16" width="16" /> Loading Image...',scrollbarwidth:16,opacitystring:'filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity: 0.1; opacity: 0.1',targetlinks:[],createthumbBox:function(){document.write('<div id="thumbBox" onClick="thumbnailviewer.closeit()"><div id="thumbImage"></div>'+this.definefooter+'</div>')
document.write('<div id="thumbLoading">'+this.defineLoading+'</div>')
this.thumbBox=document.getElementById("thumbBox")
this.thumbImage=document.getElementById("thumbImage")
this.thumbLoading=document.getElementById("thumbLoading")
this.standardbody=(document.compatMode=="CSS1Compat")?document.documentElement:document.body},centerDiv:function(divobj){var ie=document.all&&!window.opera
var dom=document.getElementById
var scroll_top=(ie)?this.standardbody.scrollTop:window.pageYOffset
var scroll_left=(ie)?this.standardbody.scrollLeft:window.pageXOffset
var docwidth=(ie)?this.standardbody.clientWidth:window.innerWidth-this.scrollbarwidth
var docheight=(ie)?this.standardbody.clientHeight:window.innerHeight
var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)?this.standardbody.offsetHeight:this.standardbody.scrollHeight
var objwidth=divobj.offsetWidth
var objheight=divobj.offsetHeight
var topposition=(docheight>objheight)?scroll_top+docheight/2-objheight/2+"px":scroll_top+10+"px"
divobj.style.left=docwidth/2-objwidth/2+"px"
divobj.style.top=Math.floor(parseInt(topposition))+"px"
divobj.style.visibility="visible"},showthumbBox:function(){thumbnailviewer.thumbLoading.style.visibility="hidden"
this.centerDiv(this.thumbBox)
if(this.enableAnimation){this.currentopacity=0.1
this.opacitytimer=setInterval("thumbnailviewer.opacityanimation()",20)}},loadimage:function(link){if(this.thumbBox.style.visibility=="visible")
this.closeit()
var imageHTML='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />'
if(this.enableTitle&&link.getAttribute("title"))
imageHTML+='<br />'+link.getAttribute("title")
this.centerDiv(this.thumbLoading)
this.thumbImage.innerHTML=imageHTML
this.featureImage=this.thumbImage.getElementsByTagName("img")[0]
if(this.featureImage.complete)
thumbnailviewer.showthumbBox()
else{this.featureImage.onload=function(){thumbnailviewer.showthumbBox()}}
if(document.all&&!window.createPopup)
this.featureImage.src=link.getAttribute("href")
this.featureImage.onerror=function(){thumbnailviewer.thumbLoading.style.visibility="hidden"}},setimgopacity:function(value){var targetobject=this.featureImage
if(targetobject.filters&&targetobject.filters[0]){if(typeof targetobject.filters[0].opacity=="number")
targetobject.filters[0].opacity=value*100
else
targetobject.style.filter="alpha(opacity="+value*100+")"}
else if(typeof targetobject.style.MozOpacity!="undefined")
targetobject.style.MozOpacity=value
else if(typeof targetobject.style.opacity!="undefined")
targetobject.style.opacity=value
else
this.stopanimation()},opacityanimation:function(){this.setimgopacity(this.currentopacity)
this.currentopacity+=0.1
if(this.currentopacity>1)
this.stopanimation()},stopanimation:function(){if(typeof this.opacitytimer!="undefined")
clearInterval(this.opacitytimer)},closeit:function(){this.stopanimation()
this.thumbBox.style.visibility="hidden"
this.thumbImage.innerHTML=""
this.thumbBox.style.left="-2000px"
this.thumbBox.style.top="-2000px"},cleanup:function(){this.thumbLoading=null
if(this.featureImage)this.featureImage.onload=null
this.featureImage=null
this.thumbImage=null
for(var i=0;i<this.targetlinks.length;i++)
this.targetlinks[i].onclick=null
this.thumbBox=null},dotask:function(target,functionref,tasktype){var tasktype=(window.addEventListener)?tasktype:"on"+tasktype
if(target.addEventListener)
target.addEventListener(tasktype,functionref,false)
else if(target.attachEvent)
target.attachEvent(tasktype,functionref)},init:function(){if(!this.enableAnimation)
this.opacitystring=""
var pagelinks=document.getElementsByTagName("a")
for(var i=0;i<pagelinks.length;i++){if(pagelinks[i].getAttribute("rel")&&pagelinks[i].getAttribute("rel")=="thumbnail"){pagelinks[i].onclick=function(){thumbnailviewer.stopanimation()
thumbnailviewer.loadimage(this)
return false}
this.targetlinks[this.targetlinks.length]=pagelinks[i]}}
this.dotask(window,function(){if(thumbnailviewer.thumbBox.style.visibility=="visible")thumbnailviewer.centerDiv(thumbnailviewer.thumbBox)},"resize")}}
thumbnailviewer.createthumbBox()
thumbnailviewer.dotask(window,function(){thumbnailviewer.init()},"load")
thumbnailviewer.dotask(window,function(){thumbnailviewer.cleanup()},"unload")
var arrowimages={down:['downarrowclass','nav/down.gif',23],right:['rightarrowclass','nav/right.gif']}
var jqueryslidemenu={animateduration:{over:200,out:100},buildmenu:function(menuid,arrowsvar){jQuery(document).ready(function($){var $mainmenu=$("#"+menuid+">ul")
var $headers=$mainmenu.find("ul").parent()
$headers.each(function(i){var $curobj=$(this)
var $subul=$(this).find('ul:eq(0)')
this._dimensions={w:this.offsetWidth,h:this.offsetHeight,subulw:$subul.outerWidth(),subulh:$subul.outerHeight()}
this.istopheader=$curobj.parents("ul").length==1?true:false
$subul.css({top:this.istopheader?this._dimensions.h+"px":0})
$curobj.children("a:eq(0)").css(this.istopheader?{paddingRight:arrowsvar.down[2]}:{}).append('<img src="'+(this.istopheader?arrowsvar.down[1]:arrowsvar.right[1])
+'" class="'+(this.istopheader?arrowsvar.down[0]:arrowsvar.right[0])
+'" style="border:0;" />')
$curobj.hover(function(e){var $targetul=$(this).children("ul:eq(0)")
this._offsets={left:$(this).offset().left,top:$(this).offset().top}
var menuleft=this.istopheader?0:this._dimensions.w
menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())?(this.istopheader?-this._dimensions.subulw+this._dimensions.w:-this._dimensions.w):menuleft
if($targetul.queue().length<=1)
$targetul.css({left:menuleft+"px",width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)},function(e){var $targetul=$(this).children("ul:eq(0)")
$targetul.slideUp(jqueryslidemenu.animateduration.out)})})
$mainmenu.find("ul").css({display:'none',visibility:'visible'})})}}
jqueryslidemenu.buildmenu("myslidemenu",arrowimages)
