function rollover(image,source,folder,path,extension) { document.getElementById(image).src=path+'/'+folder+'/'+source+'_over.'+extension; } function rollout(image,source,folder,path,extension) { document.getElementById(image).src=path+'/'+folder+'/'+source+'.'+extension; } function rollover2(image,source,folder,path) { document.getElementById(image).src=path+'/'+'images/'+folder+'/'+source+'.gif'; } function rollout2(image,source,folder,path) { document.getElementById(image).src=path+'/'+'images/'+folder+'/'+source+'.gif'; } function preloadImages() { var d=document; if(d.images) { d.preload=new Array(); var i; var a=preloadImages.arguments; for(i=0; i 0) { document.getElementById('old_price').innerHTML = '£'+old_prices[ind]; document.getElementById('price').style.color = '#ff0000'; document.getElementById('price').innerHTML = '£'+prices[ind]; } else { document.getElementById('old_price').innerHTML = ''; document.getElementById('price').style.color = '#888'; document.getElementById('price').innerHTML = '£'+prices[ind]; } document.getElementById('colour').innerHTML = colours[ind]; document.getElementById('copy').innerHTML = descriptions[ind]; image_sku = new String(sku); image_sku = image_sku.replace("/",""); image_sku = image_sku.replace("_","W_"); document.getElementById('productImage').src='http://www.duchyoriginals.com/images/product/main/'+image_sku+'_1.jpg'; if(cross_sell_1[sku] || cross_sell_2[sku]) { document.getElementById('cross_sell_2_column').style.display = 'block'; } else { document.getElementById('cross_sell_2_column').style.display = 'none'; } document.getElementById('cross_sell_1_li').style.display = 'none'; document.getElementById('cross_sell_2_li').style.display = 'none'; if(cross_sell_1[sku]) { document.getElementById('cross_sell_1_li').style.display = 'block'; cs1 = cross_sell_1[sku]['sku']; cs1_image_sku = new String(cs1); cs1_image_sku = cs1_image_sku.replace("/",""); cs1_image_sku = cs1_image_sku.replace("_","W_"); document.getElementById('cross_sell_1_image').src='http://www.duchyoriginals.com/images/product/basket/'+cs1_image_sku+'.jpg'; cs1_style_name = cross_sell_1[sku]['style_name']; document.getElementById('cross_sell_1_style_name').innerHTML = cs1_style_name; cs1_product_name = cross_sell_1[sku]['name']; document.getElementById('cross_sell_1_product_name').innerHTML = ''+cs1_product_name+''; cs1_product_price = cross_sell_1[sku]['price']; document.getElementById('cross_sell_1_product_price').innerHTML = 'Price £'+cs1_product_price; cs1_product_link = cross_sell_1[sku]['url']; document.getElementById('cross_sell_1_product_link').href = cs1_product_link; } if(cross_sell_2[sku]) { document.getElementById('cross_sell_2_li').style.display = 'block'; cs2 = cross_sell_2[sku]['sku']; cs2_image_sku = new String(cs2); cs2_image_sku = cs2_image_sku.replace("/",""); cs2_image_sku = cs2_image_sku.replace("_","W_"); document.getElementById('cross_sell_2_image').src='http://www.duchyoriginals.com/images/product/basket/'+cs2_image_sku+'.jpg'; cs2_style_name = cross_sell_2[sku]['style_name']; document.getElementById('cross_sell_2_style_name').innerHTML = cs2_style_name; cs2_product_name = cross_sell_2[sku]['name']; document.getElementById('cross_sell_2_product_name').innerHTML = ''+cs2_product_name+''; cs2_product_price = cross_sell_2[sku]['price']; document.getElementById('cross_sell_2_product_price').innerHTML = 'Price £'+cs2_product_price; cs2_product_link = cross_sell_2[sku]['url']; document.getElementById('cross_sell_2_product_link').href = cs2_product_link; } if(availabilities[ind] > 0) { var stock_status = 'In stock'; } else { var stock_status = 'Out of stock'; } document.getElementById('stock_status').innerHTML = stock_status; currentQty = document.forms['product_form'].qty[document.forms['product_form'].qty.selectedIndex].value; document.forms['product_form'].qty.options.length = 0; if(availabilities[ind] > 0) { for(i=1; i<=availabilities[ind]; i++) { if(i < 10) { zero = '0'; } else { zero = ''; } document.forms['product_form'].qty[i-1] = new Option(zero+i,i); if(currentQty == i) { document.forms['product_form'].qty[i-1].selected = true; } } } else { document.forms['product_form'].qty[0] = new Option("00",0); } if(i > 1) { document.getElementById('bag_link').href = 'javascript:addToBag()'; } else { obj=document.getElementById('bag_link'); obj.removeAttribute('href'); //document.getElementById('bag_link').innerHTML = 'Add to Bag'; } for (var i=0;i<=1;i++) { var image_number = i+1; if(thumbs[ind][i]) { document.getElementById('thumb_2').style.display = 'inline'; document.getElementById('thumb_'+image_number).src = thumbs[ind][i]; document.getElementById('thumb_1').style.border = '1px solid #04CFDD'; document.getElementById('thumb_2').style.border = '1px solid #8F9190'; } else { document.getElementById('thumb_'+image_number).src = 'http://www.duchyoriginals.com/images/static/spacer.gif'; document.getElementById('thumb_2').style.display = 'none'; } } } function printColourName(colour) { if(colour != '') { document.getElementById('colour_name').innerHTML = styles[colour] + ' - ' + colours[colour]; } else { document.getElementById('colour_name').innerHTML = ''; } } function switch_graphic(image_number) { document.getElementById('flash_movie').style.display = 'none'; document.getElementById('productImage').style.display = 'block'; //var sku = document.getElementById('sku').value; image_sku = new String(sku); image_sku = image_sku.replace("/",""); image_sku = image_sku.replace("_","W_"); document.getElementById('productImage').src='http://www.duchyoriginals.com/images/product/main/'+image_sku+'_'+image_number+'.jpg'; document.getElementById('thumb_1').style.border = '1px solid #8F9190'; document.getElementById('thumb_2').style.border = '1px solid #8F9190'; document.getElementById('thumb_'+image_number).style.border = '1px solid #04CFDD'; } function switch_main_graphic(el,sku,image_number,number) { document.getElementById('flash_movie').style.display = 'none'; document.getElementById('productImage').style.display = 'block'; document.getElementById('copy').innerHTML = descriptions[sku]; if (currentEl && currentEl!=el) { currentEl.style.border = '1px solid #8F9190'; } image_sku = new String(sku); image_sku = image_sku.replace("/",""); image_sku = image_sku.replace("_","W_"); document.getElementById('productImage').src='http://www.duchyoriginals.com/images/product/main/'+image_sku+'_'+image_number+'.jpg'; document.getElementById('thumb_'+number).style.border = '1px solid #04CFDD'; currentEl = el; if(cross_sell_1[sku] || cross_sell_2[sku] || cross_sell_3[sku]) { document.getElementById('cross_sell_3_column').style.display = 'block'; } else { document.getElementById('cross_sell_3_column').style.display = 'none'; } document.getElementById('cross_sell_1_li').style.display = 'none'; document.getElementById('cross_sell_2_li').style.display = 'none'; document.getElementById('cross_sell_3_li').style.display = 'none'; if(cross_sell_1[sku]) { document.getElementById('cross_sell_1_li').style.display = 'block'; cs1 = cross_sell_1[sku]['sku']; cs1_image_sku = new String(cs1); cs1_image_sku = cs1_image_sku.replace("/",""); cs1_image_sku = cs1_image_sku.replace("_","W_"); document.getElementById('cross_sell_1_image').src='http://www.duchyoriginals.com/images/product/basket/'+cs1_image_sku+'.jpg'; cs1_style_name = cross_sell_1[sku]['style_name']; document.getElementById('cross_sell_1_style_name').innerHTML = cs1_style_name; cs1_product_name = cross_sell_1[sku]['name']; document.getElementById('cross_sell_1_product_name').innerHTML = ''+cs1_product_name+''; cs1_product_price = cross_sell_1[sku]['price']; document.getElementById('cross_sell_1_product_price').innerHTML = 'Price £'+cs1_product_price; cs1_product_link = cross_sell_1[sku]['url']; document.getElementById('cross_sell_1_product_link').href = cs1_product_link; } if(cross_sell_2[sku]) { document.getElementById('cross_sell_2_li').style.display = 'block'; cs2 = cross_sell_2[sku]['sku']; cs2_image_sku = new String(cs2); cs2_image_sku = cs2_image_sku.replace("/",""); cs2_image_sku = cs2_image_sku.replace("_","W_"); document.getElementById('cross_sell_2_image').src='http://www.duchyoriginals.com/images/product/basket/'+cs2_image_sku+'.jpg'; cs2_style_name = cross_sell_2[sku]['style_name']; document.getElementById('cross_sell_2_style_name').innerHTML = cs2_style_name; cs2_product_name = cross_sell_2[sku]['name']; document.getElementById('cross_sell_2_product_name').innerHTML = ''+cs2_product_name+''; cs2_product_price = cross_sell_2[sku]['price']; document.getElementById('cross_sell_2_product_price').innerHTML = 'Price £'+cs2_product_price; cs2_product_link = cross_sell_2[sku]['url']; document.getElementById('cross_sell_2_product_link').href = cs2_product_link; } if(cross_sell_3[sku]) { document.getElementById('cross_sell_3_li').style.display = 'block'; cs3 = cross_sell_3[sku]['sku']; cs3_image_sku = new String(cs3); cs3_image_sku = cs3_image_sku.replace("/",""); cs3_image_sku = cs3_image_sku.replace("_","W_"); document.getElementById('cross_sell_3_image').src='http://www.duchyoriginals.com/images/product/basket/'+cs3_image_sku+'.jpg'; cs3_style_name = cross_sell_3[sku]['style_name']; document.getElementById('cross_sell_3_style_name').innerHTML = cs3_style_name; cs3_product_name = cross_sell_3[sku]['name']; document.getElementById('cross_sell_3_product_name').innerHTML = ''+cs3_product_name+''; cs3_product_price = cross_sell_3[sku]['price']; document.getElementById('cross_sell_3_product_price').innerHTML = 'Price £'+cs3_product_price; cs3_product_link = cross_sell_3[sku]['url']; document.getElementById('cross_sell_3_product_link').href = cs3_product_link; } window.scrollTo(0,0); // To take you top of the page } function addToBag() { document.getElementById('productImage').style.display = 'none'; document.getElementById('flash_movie').style.display = 'block'; var path = "flash/bag.swf"; var so = new SWFObject(path, "mymovie", "240", "240", "7", ""); so.addParam("wmode", "white"); so.write("flash_movie"); var qty = document.getElementById('qty').value updateBag(sku, qty); } function addToBagSummary(sku) { document.getElementById('productImage').style.display = 'none'; document.getElementById('flash_movie').style.display = 'block'; document.getElementById('copy').innerHTML = descriptions[sku]; var path = "flash/bag.swf"; var so = new SWFObject(path, "mymovie", "240", "240", "7", ""); so.addParam("wmode", "white"); so.write("flash_movie"); var qty = document.getElementById('qty_'+sku).value updateBag(sku, qty); window.scrollTo(0,0); // To take you top of the page } function updateBag(sku, quantity) { sku = escape(sku); xmlhttp=setHTTPObject(); var url = "http://www.duchyoriginals.com/shop/basket.php?action=add&sku="+sku+"&quantity="+quantity; xmlhttp.open("GET", url, false); xmlhttp.send(null); getContent(url,"bagCount"); } function copyAddress() { if (document.getElementById('different_delivery').checked) { document.getElementById('d_salutation').value = document.getElementById('b_salutation').value; document.getElementById('d_first_name').value = document.getElementById('b_first_name').value; document.getElementById('d_last_name').value = document.getElementById('b_last_name').value; document.getElementById('d_telephone').value = document.getElementById('b_telephone').value; document.getElementById('d_address_line_1').value = document.getElementById('b_address_line_1').value; document.getElementById('d_address_line_2').value = document.getElementById('b_address_line_2').value; document.getElementById('d_town_city').value = document.getElementById('b_town_city').value; document.getElementById('d_county_state').value = document.getElementById('b_county_state').value; document.getElementById('d_postcode_zip').value = document.getElementById('b_postcode_zip').value; document.getElementById('d_country').value = document.getElementById('b_country').value; } else { //document.getElementById('d_salutation').value = ""; document.getElementById('d_first_name').value = ""; document.getElementById('d_last_name').value = ""; document.getElementById('d_telephone').value = ""; document.getElementById('d_address_line_1').value = ""; document.getElementById('d_address_line_2').value = ""; document.getElementById('d_town_city').value = ""; document.getElementById('d_county_state').value = ""; document.getElementById('d_postcode_zip').value = ""; //document.getElementById('d_country').value = ""; } } function compareStartAndEndDates() { var start_date_month = document.getElementById('start_date_month').value-1; var start_date_year = document.getElementById('start_date_year').value; var startDate = new Date(); startDate.setFullYear(start_date_year,start_date_month,1); var end_date_month = document.getElementById('end_date_month').value-1; var end_date_year = document.getElementById('end_date_year').value; var endDate = new Date(); endDate.setFullYear(end_date_year,end_date_month,1); if (startDate>=endDate) { alert('End date must be greater than start date'); return false; } else { return true; } } function emailCheckForMultipleEmails (emailStr) { var emailError = null; var emailPat=/^(.+)@(.+)$/; var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"; var validChars="\[^\\s" + specialChars + "\]"; var quotedUser="(\"[^\"]*\")"; var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; var atom=validChars + '+'; var word="(" + atom + "|" + quotedUser + ")"; var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); var matchArray=emailStr.match(emailPat); if (matchArray==null) { emailError = "Email address seems incorrect (check @ and .'s)"; return emailError; } var user=matchArray[1]; var domain=matchArray[2]; if (user.match(userPat)==null) { emailError = "The username doesn't seem to be valid."; return emailError } var IPArray=domain.match(ipDomainPat); if (IPArray!=null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { emailError = "Destination IP address is invalid!"; return emailError; } } return null; } var domainArray=domain.match(domainPat); if (domainArray==null) { emailError = "The domain name doesn't seem to be valid."; return emailError; } var atomPat=new RegExp(atom,"g") var domArr=domain.match(atomPat) var len=domArr.length if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) { emailError = "The address must end in a three-letter domain, or two letter country."; return emailError } if (len<2) { emailError = "This address is missing a hostname."; return emailError } return null; } function emailCheck (emailStr) { var emailPat=/^(.+)@(.+)$/ //var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]\\/\\?\\!\\£\\$\\%\\&\\#\\~\\*\\'\\|\\`\\=\\¬\\¦\\}\\{\\+\\^" //var validChars="\[\\s" + specialChars + "\]" var validChars="[a-zA-Z0-9_-]" var quotedUser="(\"[^\"]*\")" var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/ var atom=validChars + '+' var word="(" + atom + "|" + quotedUser + ")" var userPat=new RegExp("^" + word + "(\\." + word + ")*$") var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$") var matchArray=emailStr.match(emailPat) if (matchArray==null) { alert("Email address seems incorrect (check @ and .'s)") return false } var user=matchArray[1] var domain=matchArray[2] if (user.match(userPat)==null) { alert("Email address doesn't seem to be valid.") return false } var IPArray=domain.match(ipDomainPat) if (IPArray!=null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { alert("Email address has an invalid destination IP.") return false } } return true } var domainArray=domain.match(domainPat) if (domainArray==null) { alert("Email address has an invalid domain name") return false } var atomPat=new RegExp(atom,"g") var domArr=domain.match(atomPat) var len=domArr.length if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4) { alert("Email address must end in a three-letter or four-letter domain, or two letter country.") return false } if (len<2) { var errStr="Email address doesn't have a hostname." alert(errStr) return false } return true; } // ############## Adding to basket process #################### function setHTTPObject() { var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } } return xmlhttp; } var queue = new Array(); function getContent(url, target) { queue.push(new Array(url,target)); processQueue(); } var url; var target; var busy; var xmlhttp; function processQueue() { if(busy) return; if(queue.length == 0) return; busy = true; var item = queue.pop(); url = item[0]; target = item[1]; xmlhttp=setHTTPObject(); xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { document.getElementById(target).innerHTML = xmlhttp.responseText; busy = false; processQueue(); } } xmlhttp.send(null); } function removeFromBag(sku) { xmlhttp=setHTTPObject(); var url = "http://www.duchyoriginals.com/shop/basket.php?action=remove_from_basket&type=specific_quantity&sku="+sku+"&quantity=0"; xmlhttp.open("GET", url, false); xmlhttp.send(null); getContent(url,"bagCount"); } // ############## End of adding to basket process #################### function delIngredientStore(el_id) { var selectedList=document.getElementById("inop_"+el_id); var selIndex = selectedList.selectedIndex; if(selIndex < 0) return; selectedList.options[selIndex]=null; selectIngredientNone(selectedList); getIngredientStore(el_id); } function addIngredientStore(el_id) { var selectedList=document.getElementById("inop_"+el_id); var inpTXT=document.getElementById("outop_txt_"+el_id); var inpNUM=document.getElementById("outop_num_"+el_id); var prod=inpTXT.value,quant=inpNUM.value; while(prod.search(/\t/)!=-1) prod=prod.replace(/\t/,""); while(quant.search(/\t/)!=-1) quant=quant.replace(/\t/,""); if(quant=="" || prod==""){ inpTXT.value=prod; inpNUM.value=quant; alert("Please fill in both fields"); return; } var newOption=document.createElement('option'); var optionLabel=document.createTextNode(prod+"\t"+quant); newOption.setAttribute('value',prod+"\t"+quant); newOption.appendChild(optionLabel); selectedList.appendChild(newOption); inpTXT.value=""; inpNUM.value=""; getIngredientStore(el_id); } function selectIngredientNone(list) { list.selectedIndex = -1; } function getIngredientStore(el_id) { var optionList=document.getElementById("inop_"+el_id).options; var data=''; var len=optionList.length; for(i=0; i0)?"\n":"")+optionList.item(i).value; document.getElementById("datop_"+el_id).value=data; } // SEARCH FOCUS function searchfocus(inputField, focus){ if (focus){ if(inputField.value=="Search..."){ inputField.value = "" ; inputField.className = "" ; } } else { if(inputField.value=="Search..." || inputField.value=="") { inputField.value = "Search..." ; inputField.className = "searchgrey" ; } } }