function BuyProductWithQuantity(idProduct,prefix,URL){BuyProductWithQuantity(idProduct,prefix,URL,null) } function BuyProductWithQuantity(idProduct,prefix,URL,countItems){var QuantityObjectId = prefix + idProduct;if ( URL.length == 0){URL = "ps_additem.aspx?idProduct=";} var QuantityObject = document.getElementById(QuantityObjectId);if (QuantityObject != null){var QuantityObjectValue = document.getElementById(QuantityObjectId).value;QuantityInt = parseInt (QuantityObjectValue);if (QuantityInt < 1 || QuantityInt > 100 || isNaN (QuantityInt)) QuantityInt = 1;} else{QuantityInt = parseInt(countItems);if (QuantityInt < 1 || QuantityInt > 100 || isNaN (QuantityInt)) QuantityInt = 1;} URL = URL + idProduct + "&quantity=" + QuantityInt;var SelectedOptions = document.getElementById("SelectedOptions");if(SelectedOptions != null){var SelectedOptionsValue = document.getElementById("SelectedOptions").value;URL = URL + "&options=";URL = URL + SelectedOptionsValue;} var query = window.location.search.substring(1);if(query.indexOf("idCartRow") != -1){URL = URL + "&modify=1";} window.location = URL } function BuyProductQty(idProduct,prefix,URL,evObj){if (evObj.keyCode!=13){return false;} else{BuyProductWithQuantity(idProduct,prefix,URL) } } function StartSearchMainControl(){var SearchTextObject = document.getElementById("SearchTextMainControl");if (SearchTextObject.value.length>0){URL = "ps_searchItem.aspx?SearchText=" + SearchTextObject.value;window.location = URL } } function OpenWindow(URL,WindowType){var wWidth = 600;var wHeight = 480;if ( WindowType == "TopBanner"){wWidth = 600;wHeight = 500;} if ( WindowType == "LeftBanner"){wWidth = 600;wHeight = 450;} if ( WindowType == "EditProduct"){wWidth = 480;wHeight = 320;} var poz_left = screen.availWidth / 2 - wWidth/2;var poz_top = screen.availHeight / 2 - wHeight/2;var params = "left="+poz_left+",top="+poz_top+",width="+wWidth+",height="+wHeight+",toolbar=0,resizable=1";window.open(URL,'petstore',params);} function EnterClickEvent(event,ButtonPrefix,idProduct){event = event || window.event;if (event.keyCode == 13){src = event.target;if (__nonMSDOMBrowser){src = event.target;} else{src = event.srcElement;} tagName = src.tagName.toLowerCase();if ((tagName != "a") && ((tagName != "input") || ((src.type != "submit") && (src.type != "reset") && (src.type != "image") && (src.type != "file")))){var ButtonTextId = ButtonPrefix + idProduct;document.getElementById(ButtonTextId).click();} return false;} return true;} function goCSRSearch(e,GetValue){e=e||window.event;var URLpath = window.location.href;if(e.keyCode == "13"){SearchText=GetValue;if (SearchText!=null && SearchText!=''){re = /[^\w '\-`]/g;SearchText = SearchText.replace(re,' ');} if (SearchText!=''){location.href = 'ps_CSRsearchItem.aspx?SearchText='+SearchText;} return false;} } function formatCurrency(num){num = num.toString().replace(/\$|\,/g,'');if(isNaN(num)) num = "0";sign = (num == (num = Math.abs(num)));num = Math.floor(num*100+0.50000000001);cents = num%100;num = Math.floor(num/100).toString();if(cents<10) cents = "0" + cents;for (var i = 0;i < Math.floor((num.length-(1+i))/3);i++) num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));return (((sign)?'':'-') + num + '.' + cents);} function checkCSRSearch(e,value){e=e||window.event;if(e.keyCode == "13"){if (value == ""){alert("Please input a search string!");return false;} } return true;} function CheckSearchString(idControl){var SearchText = "";if (idControl){SearchText = document.getElementById(idControl).value;} SearchText = Trim(SearchText);if (SearchText != null && SearchText != ''){re = /[^\w '\-`]/g;SearchText = SearchText.replace(re,' ');} if (SearchText == ""){alert("Please input a correct search string or choose a category.\nCharacters %,#,<,>,',/ and - cannot be used in your search string.");return false;} return true;} function CheckSearchForm(){var SearchText = document.getElementById(get_SearchTextMainControlClientID()).value;SearchText = Trim(SearchText);if (SearchText != null && SearchText != ''){re = /[^\w '\-`]/g;SearchText = SearchText.replace(re,' ');} var CaterogyParam = document.getElementById("idCategoryParam").value;if (SearchText == "" && CaterogyParam == ""){alert("Please input a correct search string or choose a category.\nCharacters %,#,<,>,',/ and - cannot be used in your search string.");return false;} return true;} function SearchBtn_onclick(){if (!CheckSearchForm()){return false;} var searchurl = "http://" + window.location.host + "/";searchurl = searchurl + "ps_searchItem.aspx?";searchurl = searchurl + "SearchText=";SearchText = document.getElementById(get_SearchTextMainControlClientID()).value;if (SearchText != null && SearchText != ''){re = /[^\w '\-`]/g;SearchText = SearchText.replace(re,' ');} searchurl = searchurl + SearchText;var categParam = document.getElementById("idCategoryParam").value;if (categParam){var categName = "";switch (categParam){case "DG": categName = "Dog_Suppies";break;case "CT": categName = "Cat_Supplies";break;case "AQ": categName = "Aquarium_Supplies";break;case "RP": categName = "Reptile_Supplies";break;case "BD": categName = "Bird_Supplies";break;case "SP": categName = "Small_Animal_Pet_Supplies";break;case "PD": categName = "Pond_Supplies";break;default:;} searchurl = searchurl + "&Category=";searchurl = searchurl + categName;searchurl = searchurl + "&IdCategory=";searchurl = searchurl + categParam;} var ua = window.navigator.userAgent;var msie = ua.indexOf("MSIE ");if (msie > 0){window.location.href = searchurl;} else{window.open(searchurl,target = "_self");} return false;} function RemoveCount(){var SearchText = document.getElementById(get_SearchTextMainControlClientID()).value;var CorrectText = SearchText;if (SearchText != null && SearchText != '' && SearchText.length > 0){var start = SearchText.indexOf('(') - 1;if (start > 0){CorrectText = SearchText.substring(0,start);document.getElementById(get_SearchTextMainControlClientID()).value = CorrectText;} } } var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);function KeyDownOnSearch(event){if (event.keyCode == 13){src = event.target;if (__nonMSDOMBrowser){src = event.target;} else{src = event.srcElement;} tagName = src.tagName.toLowerCase();if ((tagName != "a") && ((tagName != "input") || ((src.type != "submit") && (src.type != "reset") && (src.type != "image") && (src.type != "file")))){SearchBtn_onclick();} return false;} return true;} function Trim(TRIM_VALUE){if (TRIM_VALUE.length < 1){return "";} TRIM_VALUE = RTrim(TRIM_VALUE);TRIM_VALUE = LTrim(TRIM_VALUE);if (TRIM_VALUE == ""){return "";} else{return TRIM_VALUE;} } function RTrim(VALUE){var w_space = String.fromCharCode(32);var v_length = VALUE.length;var strTemp = "";if (v_length < 0){return "";} var iTemp = v_length - 1;while (iTemp > -1){if (VALUE.charAt(iTemp) == w_space){} else{strTemp = VALUE.substring(0,iTemp + 1);break;} iTemp = iTemp - 1;} //End While return strTemp;} function LTrim(VALUE){var w_space = String.fromCharCode(32);if (v_length < 1){return "";} var v_length = VALUE.length;var strTemp = "";var iTemp = 0;while (iTemp < v_length){if (VALUE.charAt(iTemp) == w_space){} else{strTemp = VALUE.substring(iTemp,v_length);break;} iTemp = iTemp + 1;} //End While return strTemp;} function KeyDownOnFreeNewsletter(event){if (event.keyCode == 13){window.location = 'ps_optNewsletterAddEmail.aspx?smd=1&email=' + document.getElementById('email').value;return false;} return true;}