1function Sale( price, name, start, end ) 2{ 3 this.price = price; 4 this.name = name; 5 this.start = start; 6 this.end = end; 7 8} 9 10function Product( id, title, summary, pic, price, qty, hash, adjustedPrice ) 11{ 12 this.id = id; 13 this.title = title; 14 this.summary = summary; 15 this.pic = pic; 16 this.price = price; 17 this.qty = qty; 18 this.optionList = new Array(); 19 this.configList = new Array(); 20 this.hash = hash; 21 this.adjustedPrice = adjustedPrice; 22 this.sale = null; 23} 24 25Product.prototype.addOption = function(id, price, name, lbl, type) 26{ 27 this.optionList[this.optionList.length] = new ProductOptions(id, price, name, lbl, type ); 28} 29 30Product.prototype.addSale = function(price, name, start, end) 31{ 32 this.sale = new Sale( price, name, start, end ); 33} 34 35Product.prototype.addConfig = function(id, title, qty, price) 36{ 37 this.configList[this.configList.length] = new ProductConfig(id, title, qty, price ); 38} 39 40function ProductOptions( id, price, name, lbl, type ) 41{ 42 this.id = id; 43 this.price = price; 44 this.name = name; 45 this.label = lbl; 46 this.type = type; 47} 48 49function ProductConfig( id, title, qty, price ) 50{ 51 this.id = id; 52 this.title = title; 53 this.qty = qty; 54 this.price = price; 55} 56 57function formatCurrency(strValue) 58{ 59 strValue = strValue.toString().replace(/\$|\,/g,""); 60 dblValue = parseFloat(strValue); 61 62 blnSign = (dblValue == (dblValue = Math.abs(dblValue))); 63 dblValue = Math.floor(dblValue*100+0.50000000001); 64 intCents = dblValue%100; 65 strCents = intCents.toString(); 66 dblValue = Math.floor(dblValue/100).toString(); 67 68 if(intCents<10) 69 strCents = "0" + strCents; 70 71 for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++) 72 dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+","+ 73 dblValue.substring(dblValue.length-(4*i+3)); 74 75 return (((blnSign)?"":"-") + "$" + dblValue + "." + strCents); 76} 77 78function Tax( name, amount ) 79{ 80 this.name = name; 81 this.amount = amount; 82} 83 84function validate(noClassChange) 85{ 86 var err = false; 87 88 // First name 89 if( document.getElementById("first_name").value == "" ) 90 { 91 if( !noClassChange ) showError("first_name"); 92 err = true; 93 } else 94 hideError("first_name"); 95 96 // Last name 97 if( document.getElementById("last_name").value == "" ) 98 { 99 if( !noClassChange ) showError("last_name"); 100 err = true; 101 } else 102 hideError("last_name"); 103 104 // Address 105 if( document.getElementById("address").value == "" ) 106 { 107 if( !noClassChange ) showError("address"); 108 err = true; 109 } else 110 hideError("address"); 111 112 // City 113 if( document.getElementById("city").value == "" ) 114 { 115 if( !noClassChange ) showError("city"); 116 err = true; 117 } else 118 hideError("city"); 119 120 // Postal Code 121 if( document.getElementById("postal_code").value == "" ) 122 { 123 if( !noClassChange ) showError("postal_code"); 124 err = true; 125 } else 126 hideError("postal_code"); 127 128 // Phone number 129 if( document.getElementById("phone").value == "" ) 130 { 131 if( !noClassChange ) showError("phone"); 132 err = true; 133 } else 134 hideError("phone"); 135 136 if( document.getElementById("province").selectedIndex == 0 ) 137 { 138 err = true; 139 if( !noClassChange ) showError( "province" ); 140 } else { 141 hideError( "province" ); 142 } 143 144 if( document.getElementById("country").selectedIndex == 0 ) 145 { 146 err = true; 147 if( !noClassChange ) showError( "country" ); 148 } else { 149 hideError( "country" ); 150 } 151 152 153 // Email 154 if( document.getElementById("email") && document.getElementById("email").value == "" ) 155 { 156 if( !noClassChange ) showError("email"); 157 err = true; 158 } else 159 hideError("email"); 160 161 162 return !err; 163} 164 165function getStyle(oElm, strCssRule){ 166 var strValue = ""; 167 if(document.defaultView && document.defaultView.getComputedStyle){ 168 strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); 169 } 170 else if(oElm.currentStyle){ 171 strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){ 172 return p1.toUpperCase(); 173 }); 174 strValue = oElm.currentStyle[strCssRule]; 175 } 176 return strValue; 177} 178 179function toggleDisplay($id, $display) 180{ 181 if ($display==null) $display = 'block'; 182 183 document.getElementById($id).style.display = 184 (getStyle(document.getElementById($id), 'display') == 'none') ? $display : 'none'; 185} 186 187function swapOptions($fromSelectID, $toSelectID, $swapButton, $func) 188{ 189 opts = document.getElementById($fromSelectID); 190 size = opts.options.length; 191 selCats = document.getElementById($toSelectID); 192 offset = 0; 193 194 for( i = opts.selectedIndex; i < size; i++ ) 195 { 196 if( opts.options[i - offset].selected ) 197 { 198 sLength = selCats.options.length; 199 200 201 newCat = new Option(); 202 newCat.text = opts.options[i - offset].text; 203 newCat.value = opts.options[i - offset].value; 204 205 selCats.options[sLength] = newCat; 206 207 opts.options[i - offset] = null; 208 offset++; 209 } 210 } 211 212 if($swapButton != null) 213 document.getElementById($swapButton).disabled = selCats.options.length == 0; 214} 215 216function removeOptions($selectID, $buttonID, $func) 217{ 218 select = document.getElementById($selectID); 219 size = select.options.length; 220 offset = 0; 221 222 if (select.selectedIndex != -1) 223 { 224 for( i = select.selectedIndex; i < size; i++ ) 225 if( select.options[i - offset].selected ) 226 { 227 select.options[i - offset] = null; 228 offset++; 229 } 230 } 231 232 // sets the button to disabled if there are no options to remove 233 if ($buttonID != null) 234 document.getElementById($buttonID).disabled = select.options.length == 0; 235} 236 237function moveOption ($selectID, $buttonID, $func) 238{ 239 select = document.getElementById($selectID); 240 if (select.selectedIndex != -1) 241 { 242 if ($func == 'down') 243 { 244 if (select.selectedIndex != select.options.length - 1) 245 var i = select.selectedIndex + 1; 246 else 247 return; 248 } 249 else 250 { 251 if (select.selectedIndex != 0) 252 var i = select.selectedIndex - 1; 253 else 254 return; 255 } 256 var swapOption = new Object(); 257 swapOption.text = select.options[select.selectedIndex].text; 258 swapOption.value = select.options[select.selectedIndex].value; 259 swapOption.selected = select.options[select.selectedIndex].selected; 260 swapOption.defaultSelected = select.options[select.selectedIndex].defaultSelected; 261 var anIndex = select.selectedIndex; 262 for (var property in swapOption) 263 select.options[anIndex][property] = select.options[i][property]; 264 for (var property in swapOption) 265 select.options[i][property] = swapOption[property]; 266 } 267 268 // sets the button to disabled if there are no options to remove 269 if ($buttonID != null) 270 document.getElementById($buttonID).disabled = select.options.length == 0; 271} 272 273function checkValue($id,$regExp,$msg) 274{ 275 $obj = document.getElementById($id); 276 277 if($obj.value.match( $regExp ) != null) return true; 278 //else if($orelse != null) eval($orelse); 279 280 alert($msg); $obj.select(); $obj.focus(); 281 return false;
282} 283 284function compareValue($compare, $compareTo, $comparator, $msg) 285{ 286 $c = document.getElementById($compare); 287 $c2 = document.getElementById($compareTo); 288 289 compareFunc = new Function("return (" + $c.value + $comparator + $c2.value + ") ? true : false;"); 290 291 if(compareFunc()) return true 292 293 //else 294 alert($msg); 295 return false; 296}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.