var fontLengthFront=10; var fontLengthBack=8; var strErrorPreview = "You have to update your preview first"; var strErrorRemoveBack = "Are you sure you want to remove the back of this design?"; var strDefaultsFront = "WARNING!\nYou have left some of our example text on your design.\nPlease remove any text not required and preview again."; var strLetterheadLaserWarning = "PLEASE NOTE: Letterhead quantities of 25, 50, 100, 250 and 500 are not guaranteed for use on a laser printer."; var strLeaveWarning = "You are about to leave the designer interface.\nYour work has been saved.\nYou can retrieve your work by clicking view recent items at the top of the screen."; var strInvalidFileTypeFront = "You need to select a file for the front of the design first"; var strInvalidFileTypeBack = "You need to select a file for the back of the design first"; var strSelectFileFront = "You need to select a file for the front of the design first"; var strSelectFileBack = "You need to select a file for the back of the design first"; var strAutoSave = "Auto save in progress..."; var strAutoSaveComplete = "Auto save complete!"; var strFront = "Front"; var strFrontAndBack = "Front and back"; document.domain = "smileprint.com"; window.onunload = DCDisplaySavedMessage; // Define global variables var g_frm = document.card_form; var g_timer; // Used to timer how long preview takes to return var g_sfront = "front"; var g_sback = "back"; var g_ipreviewcount = 0; var g_activecontent, g_activestage; var g_priceselect; var g_seenselectback = false; var fontLength=fontLengthFront; var colorTarget, fontTarget, backpreviewTarget; // Function called when updating a preview from printra function DCPreview(side){ timer = new Date().getTime(); // Get timer for preview timings DCSaveForm(); // Save the entered values into cookie DCSetPreviewImages(side, DCGetBuildingImage(), true); // Set off the relevant building images g_frm.action = "/import/"; g_frm.kinds.value = g_frm["kinds_"+side].value; g_frm.side.value = side; g_frm.target = 'frame_'+side; if(side==g_sfront) g_frm.url.value = ""; else g_frm.urlback.value = ""; g_frm.submit(); } // Returns a path to the animated building gif function DCGetBuildingImage() { var imagetype = 0; // This is to decide what type of upload gif to show, either normal, upload logo, or upload whole if(g_frm.enctype=="multipart/form-data") imagetype = g_frm.isupload.value; return "http://www.smileprint.com:80/images/buildingimage/uk"+g_frm.baseproductid.value+imagetype+g_frm.o.value+".gif"; } // This is the call back function from printra's import2.cgi programs function ShowProof(side){ var oFrame = window["frame_"+side]; if(side==g_sfront){ g_frm.url.value = oFrame.i_ImgUrl; g_frm.token.value = oFrame.i_token; if(g_frm.uploaded_logo) g_frm.uploaded_logo.value = oFrame.i_uploaded_logo; if(g_frm.uploaded_bg) g_frm.uploaded_bg.value = oFrame.i_uploaded_bg; if(g_frm.uploaded_eps) g_frm.uploaded_eps.value = oFrame.i_uploaded_eps; setTimeout("DCSetPreviewImages('"+side+"', '"+g_frm.url.value+"', false)", 100); } else { g_frm.token_back.value = oFrame.i_token g_frm.urlback.value = oFrame.i_ImgUrl; // The current serve stationery is used by styles that return a back and a front if(g_frm.uploaded_logo_pc) g_frm.uploaded_logo_pc.value = oFrame.i_uploaded_logo_pc; if(g_frm.uploaded_eps2) g_frm.uploaded_eps2.value = oFrame.i_uploaded_eps2; setTimeout("DCSetPreviewImages('"+side+"', '"+g_frm.urlback.value+"', false)", 100); } DCSetAllowFinish(true); DCSetUpdateImage(true); if(oFrame.i_uploaded_logo!="" && g_frm.isupload.value!=0){ // Create a cookie to store the path to any uploaded file var now = new Date(); now.setTime(now.getTime() + 14 * 24 * 60 * 60 * 1000); // 14 days in advance DCSetCookie('upload'+side, oFrame.i_uploaded_logo, now, '/'); if(document.getElementById("uploadfld").style.display=='block') DCSwapUploadFields(); } g_ipreviewcount++; g_timer = new Date().getTime() - g_timer; g_frm.encoding = "application/x-www-form-urlencoded"; DCSaveWork(true); } // Sets whether basket should update the image of this item function DCSetUpdateImage(b){ if(b) g_frm.updateimage.value = "True"; else g_frm.updateimage.value = ""; } // This saves every update to an item to facillitate recent items function DCSaveWork(){ window.status = strAutoSave; if(g_frm.itemqty.value=="") g_frm.itemqty.value = g_frm.itemqty_single.options[1]; g_frm.timer.value = g_timer; g_frm.action = "/savework.php"; g_frm.target = "util"; g_frm.submit(); setTimeout("DCAutoSave()", 1000); } // All this does is play with window.status function DCAutoSave(){ window.status = strAutoSaveComplete; setTimeout("DCClearStatus()", 4000); } // All this does is play with window.status function DCClearStatus(){ window.status = ""; } ////////////////////////////////////////////////////////////////////////////////////////////// // Utlity functions function DCCheckDefaultsHaveChanged() { // This is to stop people leaving defaults such as Your Name in the fields var fld; if(g_frm.isprivate.value==0) { // dont do this check if private design for (var loop=0; loop < g_frm.elements.length; loop++) { fld = g_frm.elements[loop]; if(fld.type == 'text' || fld.type == 'textarea') { if(fld.value != "" && fld.value == fld.defaultValue && fld.getAttribute('validateFront')=="Yes") { fld.focus(); fld.select(); alert(strDefaultsFront); return false; } } } } return true; } function DCSetPreviewImages(side, image, building) { resizewidth = g_frm.resizewidth.value; resizeheight = g_frm.resizeheight.value; if(side==g_sfront) { // Set front images if(document.images['_img']) document.images["_img"].src = image; if(building) return; // Only do one image if building if(document.images["_imgacceptterms"]) document.images["_imgacceptterms"].src = image; if(document.images['_imgapproval']) { document.images["_imgapproval"].src = image; document.images["_imgapproval"].src = "/getexternalimage.php?url="+escape(image)+"&w="+resizewidth+"&h="+resizeheight; } } else { // Set back images DCChangeAllImagesWithClass("_imgback", image); if(building) return; // Only do one image if building if(document.images["_imgbackacceptterms"]) document.images["_imgbackacceptterms"].src = image; if(document.images["_imgbackapproval"]) { if(document.images["_imgbackapproval"]) document.images["_imgbackapproval"].src = image; if(document.images["_imgbackapproval"]) document.images["_imgbackapproval"].src = "/getexternalimage.php?url="+escape(image)+"&w="+resizewidth+"&h="+resizeheight; } } } function DCSetAllowFinish(b){ // Sets whether user can proceed adding this design to basket if(b) g_frm.allowfinish.value = "True"; else g_frm.allowfinish.value = ""; } function MJSetAllowFinish(b){ // Delete this when everything is migrated over to this file if(b) g_frm.allowfinish.value = "True"; else g_frm.allowfinish.value = ""; } function DCGetAllowFinish(){ return (g_frm.allowfinish.value!=""); } function DCSaveForm() { // Saves the form values in a cookie if they have changed. var now = new Date(); var str, fld; now.setTime(now.getTime() + 14 * 24 * 60 * 60 * 1000); // Set now variable to 14 days in advance for (var loop=0; loop < g_frm.elements.length; loop++) { fld = g_frm.elements[loop]; if((fld.type == 'text' || fld.type == 'textarea') && (fld.defaultValue!=fld.value || g_frm.basketitemid.value!=""||g_frm.preview.value==1)) str += ';' + fld.name + '=' + fld.value; } DCSetCookie("designer", str, now, '/'); } function DCLoadForm() { // Loads the form values from cookie var strCookie = DCGetCookie("designer"); if(strCookie) { var arrValues = strCookie.split(";"); var arrNameValue; for(var i = 0; i0) { alert(strLeaveWarning); } } function DCValidateFront(isedit) { if(!DCGetAllowFinish()){ alert(strErrorPreview); try { g_frm.preview.focus() }catch (e){ return; } return; } if(!isedit && g_frm.preview.value==0 && g_frm.isprivate.value==0) { // Single sided items call this function first, doubles call DoneEditingFront if(!DCCheckDefaultsHaveChanged()) return false; } return true; } function DCQuantityChange() { // This is called when the quantity select is changed DCFinishingOptionChange(g_frm.finishingside.value); DCMaterialOptionChange(); DCCuttingOptionChange(); } function DCMaterialOptionChange() { var omaterialoption = g_frm.materialoptionid; // Check to see if there is options as there might not be a select to work with if(omaterialoption.type!="select-one") return; // Get any preselected materialoption var selectedmaterialoptionid = omaterialoption.selectedIndex; if(omaterialoption.selectedIndex!=-1) selectedmaterialoptionid = omaterialoption.options[omaterialoption.selectedIndex].value; // Get the current value so it isnt lost when changing qty var iqty = getFormFieldValue(g_priceselect); var optionselected = false; var doublesided = g_frm.doublesided.value; // Need to repopulate the material option select based on the quantity omaterialoption.options.length = 0; // clear the material select to start with for(i=0;i0) price = price*((100-discount)/100); if(price==0) pricestr = ''; else pricestr = ' - '+symbol+formatNumber(price,2).toString(); if(selectedmaterialoptionid==-1 && misdefault==1) selectedmaterialoptionid = materialoptionid; omaterialoption.options[i] = new Option(mname+pricestr, materialoptionid); } if(selectedmaterialoptionid!=-1) omaterialoption.value = selectedmaterialoptionid; DCFinishingOptionChange(g_frm.finishingside.value); // Need to update finishing options as they rely on what material has been selected } function DCFinishingOptionChange(finishingside) { var ofinishingsides = g_frm.finishingside; var ofinishingsidesdiv = document.getElementById("finishingsidesdiv"); var iqty = getFormFieldValue(g_priceselect); var finishingoptionid, fname, fsymbol, fisdefault, basefinishingoptionid; var ofinishingoption = g_frm.finishingoptionid; // check to see if there is finishing options as there will be a select if so if(ofinishingoption.type!="select-one") return; // Get any preselected finishingoption var selectedfinishingoptionid = ofinishingoption.selectedIndex; if(selectedfinishingoptionid!=-1) selectedfinishingoptionid = ofinishingoption.options[ofinishingoption.selectedIndex].value; // Get the current value so it isnt lost when changing qty // Get any preselected materialoption var omaterialoption = g_frm.materialoptionid; if(omaterialoption.type=="select-one") { var selectedmaterialoptionid = omaterialoption.selectedIndex; if(omaterialoption.selectedIndex!=-1) selectedmaterialoptionid = omaterialoption.options[omaterialoption.selectedIndex].value; // Get the current value so it isnt lost when changing qty } ofinishingsidesdiv.style.display = "none"; // Start by hiding the Sides select ofinishingoption.options.length = 0; // clear the material select to start with x=0; for(i=0;i0) { frontprice = frontprice*((100-discount)/100); frontbackprice = frontbackprice*((100-discount)/100); } frontprice = formatNumber(frontprice,2); frontbackprice = formatNumber(frontbackprice,2); ofinishingsides.options.length = 0; // clear the select ofinishingsides.options[0] = new Option(strFront+' - '+symbol+frontprice, 0); ofinishingsides.options[1] = new Option(strFrontAndBack+' - '+symbol+frontbackprice,1); ofinishingsidesdiv.style.display = "block"; ofinishingsides.value = finishingside; } } ofinishingoption.options[x] = new Option(fname, finishingoptionid); x++; } if(selectedfinishingoptionid!=-1) ofinishingoption.value = selectedfinishingoptionid; } function DCCuttingOptionChange() { var ocuttingoption = g_frm.cuttingoptionid; // Check to see if there is options as there might not be a select to work with if(ocuttingoption.type!="select-one") return; // Get any preselected materialoption var selectedcuttingoptionid = ocuttingoption.selectedIndex; if(ocuttingoption.selectedIndex!=-1) selectedcuttingoptionid = ocuttingoption.options[ocuttingoption.selectedIndex].value; // Get the current value so it isnt lost when changing qty var iqty = getFormFieldValue(g_priceselect); var optionselected = false; // Need to repopulate the option select based on the quantity ocuttingoption.options.length = 0; // clear the select to start with for(i=0;i0) price = price*((100-discount)/100); if(price==0) pricestr = ''; else pricestr = ' - '+symbol+formatNumber(price,2).toString(); if(selectedcuttingoptionid==-1 && cisdefault==1) selectedcuttingoptionid = cuttingoptionid; ocuttingoption.options[i] = new Option(cname+pricestr, cuttingoptionid); } if(selectedcuttingoptionid!=-1) ocuttingoption.value = selectedcuttingoptionid; // Show/Hide corner options // 1. Get the isnone property of the selected cutting option for(i=0;i