window.addEvent('domready', function(){ if (window.ie) { $('cmdBrowseBtn').setStyle('position', 'relative'); $('cmdBrowseBtn').addEvent('click', function(e) { new Event(e).stop(); $('fileRef').click(); }) } else { //$('fileRef').setStyle('cursor', 'hand'); } $('fileRef').addEvent('mouseover', function(e) { $('cmdBrowseBtn').addClass('browse-button-on'); $('cmdBrowseBtn').removeClass('browse-button'); }) $('fileRef').addEvent('mouseout', function(e) { $('cmdBrowseBtn').addClass('browse-button'); $('cmdBrowseBtn').removeClass('browse-button-on'); }) var sample_sheets_index = 0; var sample_dummies_index = 0; var sample_dummies_cover_details_slider = new Fx.Slide('sample-dummies-cover-detailsDIV', { duration: 250 }); sample_dummies_cover_details_slider.hide(); var sample_dummies_text_1_slider = new Fx.Slide('sample-dummies-text-1', { duration: 250}); var sample_dummies_text_2_slider = new Fx.Slide('sample-dummies-text-2', { duration: 250}); sample_dummies_text_2_slider.hide(); var sample_dummies_text_3_slider = new Fx.Slide('sample-dummies-text-3', { duration: 250}); sample_dummies_text_3_slider.hide(); var sample_dummies_text_4_slider = new Fx.Slide('sample-dummies-text-4', { duration: 250}); sample_dummies_text_4_slider.hide(); var sample_dummies_text_5_slider = new Fx.Slide('sample-dummies-text-5', { duration: 250}); sample_dummies_text_5_slider.hide(); //populate form if cookies. $('txtName').value = get_doggett_cookie('kwdoggett_name'); $('txtCompany').value = get_doggett_cookie('kwdoggett_company'); $('txtPhone').value = get_doggett_cookie('kwdoggett_phone'); $('txtEmail').value = get_doggett_cookie('kwdoggett_email'); //hook up sample dummies cover. _resetCoverOptions(); _resetCoverPages(); _resetCoverCategories(); _resetCoverBrands(); _resetCoverColours(); _resetCoverGSM(); _resetTextPages1(); _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); $('cmdBrowseBtn').addEvent('click', function(e) { new Event(e).stop(); }) $('cmdGoBackBottom').addEvent('click', function(e) { new Event(e).stop(); window.scrollTo(0, 120); $('txtComments').value = $('txtCommentsConfirmation').getValue(); $('order-form-container').setStyle('display', 'block'); $('confirmForm').setStyle('display', 'none'); }) $('cmdGoBack2').addEvent('click', function(e) { new Event(e).stop(); window.scrollTo(0, 120); $('txtComments').value = $('txtCommentsConfirmation').getValue(); $('order-form-container').setStyle('display', 'block'); $('confirmForm').setStyle('display', 'none'); }) $('cmdSubmitso').addEvent('click', function(e) { new Event(e).stop(); $('samplesForm').submit(); }) $('cmdSubmitSamples').addEvent('click', function(e) { new Event(e).stop(); var err = false; if (!err) { if ($('txtName').value.trim() == '') { err = true; $('txtName').focus(); alert('Please enter your name.'); } } if (!err) { if ($('txtCompany').value.trim() == '') { err = true; $('txtCompany').focus(); alert('Please enter your company.'); } } if (!err) { if ($('txtPhone').value.trim() == '') { err = true; $('txtPhone').focus(); alert('Please enter your phone number.'); } } if (!err) { if (!isMail($('txtEmail').getValue().trim())) { err = true; $('txtEmail').focus(); alert('Please enter your email address. Must be a valid email address.'); } } if (!err) { if ($('txtProject').getValue().trim() == '') { err = true; $('txtProject').focus(); alert('Please enter your project\'s name.'); } } if (!err) { if ($('txtClient').getValue().trim() == '') { err = true; $('txtClient').focus(); alert('Please enter your client\'s name.'); } } if (!err) { if ($('txtAppearanceDate').getValue().trim() == '') { err = true; $('txtAppearanceDate').focus(); alert('Please enter the appearance date.'); } } //check cover / text. if (!err) { window.scrollTo(0, 120); //toppage. $('preview-name').setHTML($('txtName').getValue()); $('preview-company').setHTML($('txtCompany').getValue()); $('preview-phone').setHTML($('txtPhone').getValue()); $('preview-email').setHTML($('txtEmail').getValue()); $('preview-project').setHTML($('txtProject').getValue()); $('preview-client').setHTML($('txtClient').getValue()); $('preview-appearance-date').setHTML($('txtAppearanceDate').getValue()); //TODO - sample dummies preview. var preview_sample_dummies = $('preview-sample-dummies'); preview_sample_dummies.setHTML(''); var preview_sample_dummies_container = new Element('div').setProperties({id: 'preview-sample-dummies-container'}).injectInside(preview_sample_dummies); var sample_dummies_header = false; if (!sample_dummies_header) { sample_dummies_header = true; new Element('p').addClass('confirmation-subheader').setHTML('Project specifications').injectInside(preview_sample_dummies_container); new Element('div').addClass('sample-order-confirmation-line').setHTML(' ').injectInside(preview_sample_dummies_container); } var table = new Element('table').setProperties({cellpadding: 0, cellspacing: 0, border: 0}).addClass('sample-order-preview-table').injectInside(preview_sample_dummies_container); var tbody = new Element('tbody').injectInside(table); //do cover. var cover_description = ''; if ($('cboCoverOption').getValue() == 'SC') { cover_description = 'Self Cover'; } else { if ($('cboCoverPagerName').getValue()) { cover_description = getBrandName($('cboCoverPagerName').getValue()); } if ($('cboCoverColor').getValue()) { if (cover_description) { cover_description += ', '; } cover_description += getColourAndFinishNames($('cboCoverColor').getValue()); } if ($('cboCoverGsm').getValue()) { if (cover_description) { cover_description += ', '; } cover_description += getGSM($('cboCoverGsm').getValue()) + 'gsm'; } if ($('cboCoverPage').getValue()) { if (cover_description) { cover_description += ', '; } cover_description += $('cboCoverPage').getValue(); } } var tr = new Element('tr').injectInside(tbody); new Element('td').setProperties({valign: 'top'}).addClass('label').injectInside(tr).setHTML('Cover'); new Element('td').setProperties({valign: 'top'}).addClass('content').injectInside(tr).setHTML(cover_description); if ($('cboTextPagerCat1')) { //do text. var text_description = ''; if ($('cboTextPagerName1').getValue()) { text_description = getBrandName($('cboTextPagerName1').getValue()); } if ($('cboTextColor1').getValue()) { if (text_description) { text_description += ', '; } text_description += getColourAndFinishNames($('cboTextColor1').getValue()); } if ($('cboTextGsm1').getValue()) { if (text_description) { text_description += ', '; } text_description += getGSM($('cboTextGsm1').getValue()) + 'gsm'; } if ($('cboTextPage1_other').getValue() || $('cboTextPage1').getValue()) { if (text_description) { text_description += ', '; } if ($('cboTextPage1_other').getValue()) { var temp_text_description = $('cboTextPage1_other').getValue(); var temp_text_last2 = temp_text_description.substr(temp_text_description.length-2, temp_text_description.length); if (temp_text_last2) { temp_text_last2 = temp_text_last2.toLowerCase(); } if (temp_text_last2 != 'pp') { temp_text_description = temp_text_description + 'pp'; } text_description += temp_text_description; } else { text_description += $('cboTextPage1').getValue(); } } var tr = new Element('tr').injectInside(tbody); new Element('td').setProperties({valign: 'top'}).addClass('label').injectInside(tr).setHTML('Text 1'); new Element('td').setProperties({valign: 'top'}).addClass('content').injectInside(tr).setHTML(text_description); } if ($('cboTextPagerCat2')) { //do text. var text_description = ''; if ($('cboTextPagerName2').getValue()) { text_description = getBrandName($('cboTextPagerName2').getValue()); } if ($('cboTextColor2').getValue()) { if (text_description) { text_description += ', '; } text_description += getColourAndFinishNames($('cboTextColor2').getValue()); } if ($('cboTextGsm2').getValue()) { if (text_description) { text_description += ', '; } text_description += getGSM($('cboTextGsm2').getValue()) + 'gsm'; } if ($('cboTextPage2_other').getValue() || $('cboTextPage2').getValue()) { if (text_description) { text_description += ', '; } if ($('cboTextPage2_other').getValue()) { var temp_text_description = $('cboTextPage2_other').getValue(); var temp_text_last2 = temp_text_description.substr(temp_text_description.length-2, temp_text_description.length); if (temp_text_last2) { temp_text_last2 = temp_text_last2.toLowerCase(); } if (temp_text_last2 != 'pp') { temp_text_description = temp_text_description + 'pp'; } text_description += temp_text_description; } else { text_description += $('cboTextPage2').getValue(); } } var tr = new Element('tr').injectInside(tbody); new Element('td').setProperties({valign: 'top'}).addClass('label').injectInside(tr).setHTML('Text 2'); new Element('td').setProperties({valign: 'top'}).addClass('content').injectInside(tr).setHTML(text_description); } if ($('cboTextPagerCat3')) { //do text. var text_description = ''; if ($('cboTextPagerName3').getValue()) { text_description = getBrandName($('cboTextPagerName3').getValue()); } if ($('cboTextColor3').getValue()) { if (text_description) { text_description += ', '; } text_description += getColourAndFinishNames($('cboTextColor3').getValue()); } if ($('cboTextGsm3').getValue()) { if (text_description) { text_description += ', '; } text_description += getGSM($('cboTextGsm3').getValue()) + 'gsm'; } if ($('cboTextPage3_other').getValue() || $('cboTextPage3').getValue()) { if (text_description) { text_description += ', '; } if ($('cboTextPage3_other').getValue()) { var temp_text_description = $('cboTextPage3_other').getValue(); var temp_text_last2 = temp_text_description.substr(temp_text_description.length-2, temp_text_description.length); if (temp_text_last2) { temp_text_last2 = temp_text_last2.toLowerCase(); } if (temp_text_last2 != 'pp') { temp_text_description = temp_text_description + 'pp'; } text_description += temp_text_description; } else { text_description += $('cboTextPage3').getValue(); } } var tr = new Element('tr').injectInside(tbody); new Element('td').setProperties({valign: 'top'}).addClass('label').injectInside(tr).setHTML('Text 3'); new Element('td').setProperties({valign: 'top'}).addClass('content').injectInside(tr).setHTML(text_description); } if ($('cboTextPagerCat4')) { //do text. var text_description = ''; if ($('cboTextPagerName4').getValue()) { text_description = getBrandName($('cboTextPagerName4').getValue()); } if ($('cboTextColor4').getValue()) { if (text_description) { text_description += ', '; } text_description += getColourAndFinishNames($('cboTextColor4').getValue()); } if ($('cboTextGsm4').getValue()) { if (text_description) { text_description += ', '; } text_description += getGSM($('cboTextGsm4').getValue()) + 'gsm'; } if ($('cboTextPage4_other').getValue() || $('cboTextPage4').getValue()) { if (text_description) { text_description += ', '; } if ($('cboTextPage4_other').getValue()) { var temp_text_description = $('cboTextPage4_other').getValue(); var temp_text_last2 = temp_text_description.substr(temp_text_description.length-2, temp_text_description.length); if (temp_text_last2) { temp_text_last2 = temp_text_last2.toLowerCase(); } if (temp_text_last2 != 'pp') { temp_text_description = temp_text_description + 'pp'; } text_description += temp_text_description; } else { text_description += $('cboTextPage4').getValue(); } } var tr = new Element('tr').injectInside(tbody); new Element('td').setProperties({valign: 'top'}).addClass('label').injectInside(tr).setHTML('Text 4'); new Element('td').setProperties({valign: 'top'}).addClass('content').injectInside(tr).setHTML(text_description); } if ($('cboTextPagerCat5')) { //do text. var text_description = ''; if ($('cboTextPagerName5').getValue()) { text_description = getBrandName($('cboTextPagerName5').getValue()); } if ($('cboTextColor5').getValue()) { if (text_description) { text_description += ', '; } text_description += getColourAndFinishNames($('cboTextColor5').getValue()); } if ($('cboTextGsm5').getValue()) { if (text_description) { text_description += ', '; } text_description += getGSM($('cboTextGsm5').getValue()) + 'gsm'; } if ($('cboTextPage5_other').getValue() || $('cboTextPage5').getValue()) { if (text_description) { text_description += ', '; } if ($('cboTextPage5_other').getValue()) { var temp_text_description = $('cboTextPage5_other').getValue(); var temp_text_last2 = temp_text_description.substr(temp_text_description.length-2, temp_text_description.length); if (temp_text_last2) { temp_text_last2 = temp_text_last2.toLowerCase(); } if (temp_text_last2 != 'pp') { temp_text_description = temp_text_description + 'pp'; } text_description += temp_text_description; } else { text_description += $('cboTextPage5').getValue(); } } var tr = new Element('tr').injectInside(tbody); new Element('td').setProperties({valign: 'top'}).addClass('label').injectInside(tr).setHTML('Text 5'); new Element('td').setProperties({valign: 'top'}).addClass('content').injectInside(tr).setHTML(text_description); } //ref file if ($('fileRefTXT').getValue()) { var preview_upl_and_comments_container = $('preview-upl-and-comments'); preview_upl_and_comments_container.setHTML(''); new Element('p').addClass('confirmation-subheader').setHTML('Reference File').injectInside(preview_upl_and_comments_container); new Element('div').addClass('sample-order-confirmation-line').setHTML(' ').injectInside(preview_upl_and_comments_container); var preview_upl_and_comments_container_div = new Element('div').setStyles({padding: '0px 0px 30px 0px'}).injectInside(preview_upl_and_comments_container); var preview_upl_and_comments_table = new Element('table').setProperties({cellpadding: 0, cellspacing: 0, border: 0}).addClass('sample-order-preview-table').injectInside(preview_upl_and_comments_container_div); var preview_upl_and_comments_tbody = new Element('tbody').injectInside(preview_upl_and_comments_table); var preview_upl_and_comments_tr = new Element('tr').injectInside(preview_upl_and_comments_tbody); new Element('td').setProperties({valign: 'top'}).addClass('label').injectInside(preview_upl_and_comments_tr).setHTML('File'); new Element('td').setProperties({valign: 'top'}).addClass('content').injectInside(preview_upl_and_comments_tr).setHTML($('fileRefTXT').getValue()); } //update comments box. $('txtCommentsConfirmation').value = $('txtComments').getValue(); //update deliveries text. $('order-form-container').setStyle('display', 'none'); $('confirmForm').setStyle('display', 'block'); //save forms in cookie. if ($('ckbRememberMe').getProperty('checked')) { save_doggett_cookie('kwdoggett_name', document.getElementById('txtName').value); save_doggett_cookie('kwdoggett_company', document.getElementById('txtCompany').value); save_doggett_cookie('kwdoggett_phone', document.getElementById('txtPhone').value); save_doggett_cookie('kwdoggett_email', document.getElementById('txtEmail').value); } else { delCookie('kwdoggett_name'); delCookie('kwdoggett_company'); delCookie('kwdoggett_phone'); delCookie('kwdoggett_email'); delCookie('kwdoggett_address1'); delCookie('kwdoggett_address2'); delCookie('kwdoggett_city'); delCookie('kwdoggett_state'); delCookie('kwdoggett_postcode'); } } }) function replaceNBSP(s) { return s.replace(' ', ''); } function _resetCoverOptions(selected_item) { //now create the select box for papers. $('cboCoverOptionDIV').setHTML(''); var select = new Element('select', {id: 'cboCoverOption', name: 'cboCoverOption'}).injectInside($('cboCoverOptionDIV')); //now fill it will all papers. var cbo = document.getElementById('cboCoverOption'); var index = 0; var selected_index = 0; for(var i=0; i < sampleDummiesCoverOptions.length; i++) { var newOpt = document.createElement('option'); newOpt.text = sampleDummiesCoverOptions[i]['name']; newOpt.value = sampleDummiesCoverOptions[i]['id']; var oldOpt = cbo.options[i]; if (sampleDummiesCoverOptions[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Select"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboCoverOption = new elSelect( {container: 'cboCoverOptionDIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboCoverOption_click} ); } function _resetCoverPages(selected_item) { //now create the select box for papers. $('cboCoverPageDIV').setHTML(''); var select = new Element('select', {id: 'cboCoverPage', name: 'cboCoverPage'}).injectInside($('cboCoverPageDIV')); //now fill it will all papers. var cbo = document.getElementById('cboCoverPage'); var index = 0; var selected_index = 0; for(var i=0; i < pages.length; i++) { var newOpt = document.createElement('option'); newOpt.text = pages[i]['id']; newOpt.value = pages[i]['id']; var oldOpt = cbo.options[i]; if (pages[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Pages"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboCoverPage = new elSelect( {container: 'cboCoverPageDIV', baseWidthClass: 'elSelect80wide'} ); } function _resetCoverCategories(selected_item) { //now create the select box for papers. $('cboCoverPagerCatDIV').setHTML(''); var select = new Element('select', {id: 'cboCoverPagerCat', name: 'cboCoverPagerCat'}).injectInside($('cboCoverPagerCatDIV')); //now fill it will all papers. var cbo = document.getElementById('cboCoverPagerCat'); var index = 0; var selected_index = 0; for(var i=0; i < categories.length; i++) { var newOpt = document.createElement('option'); newOpt.text = getCategoryName(categories[i]['id']); newOpt.value = categories[i]['id']; var oldOpt = cbo.options[i]; if (categories[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Category"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboCoverPagerCat = new elSelect( {container: 'cboCoverPagerCatDIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboCoverPagerCat_click} ); } function _resetCoverBrands(catid, selected_item) { //now create the select box for papers. $('cboCoverPagerNameDIV').setHTML(''); var select = new Element('select', {id: 'cboCoverPagerName', name: 'cboCoverPagerName'}).injectInside($('cboCoverPagerNameDIV')); //now fill it will all papers. var cbo = document.getElementById('cboCoverPagerName'); var index = 0; var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (catid && catid != 0) { for(var i=0; i < brandCats.length; i++) { //populate select with values from selected category. if(parseInt(brandCats[i]['catid']) == parseInt(catid)) { var newOpt = document.createElement('option'); newOpt.text = getBrandName(brandCats[i]['brandid']); newOpt.value = brandCats[i]['brandid']; var oldOpt = cbo.options[index]; if (brandCats[i]['brandid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } else { for(var i=0; i < brands.length; i++) { var newOpt = document.createElement('option'); newOpt.text = brands[i]['name']; newOpt.value = brands[i]['id']; var oldOpt = cbo.options[i]; if (brands[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } var newOpt = document.createElement('option'); newOpt.text = "Product"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboCoverPagerName = new elSelect( {container: 'cboCoverPagerNameDIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboCoverPagerName_click} ); } function _resetCoverColours(brandid, selected_item) { $('cboCoverColorDIV').setHTML(''); var select = new Element('select', {id: 'cboCoverColor', name: 'cboCoverColor'}).injectInside($('cboCoverColorDIV')); var cbo = document.getElementById('cboCoverColor'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = 'Colour / Finish'; newOpt.value = ''; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (brandid) { var index = 1; for(var i=0; i < brandColors.length; i++) { if(brandColors[i]['brandid'] == brandid) { var oldIndex = index; for(var k=0; k < brandFins.length; k++) { if(brandFins[k]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']) + " / " + getFinName(brandFins[k]['finid']); newOpt.value = brandColors[i]['colorid'] + ";" + brandFins[k]['finid'] ; var oldOpt = cbo.options[index]; if ((brandColors[i]['colorid'] + ";" + brandFins[k]['finid']) == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } if(index == oldIndex) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']); newOpt.value = brandColors[i]['colorid']; var oldOpt = cbo.options[index]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; } //now convert select box to alternative. var cboCoverColor = new elSelect( {container: 'cboCoverColorDIV', baseWidthClass: 'elSelect120wide', onChangeEventFunction: cboCoverColor_click} ); } function _resetCoverGSM(colorid_finish_id, selected_item) { $('cboCoverGsmDIV').setHTML(''); var select = new Element('select', {id: 'cboCoverGsm', name: 'cboCoverGsm'}).injectInside($('cboCoverGsmDIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboCoverGsm'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (colorid_finish_id) { //get color id. var temp = colorid_finish_id.split(';', 2); var colorid = temp[0]; //also get brand id. brandid = $('cboCoverPagerName').getValue(); var index = 1; for(var i=0; i < brandColorsGSMs.length; i++) { if(brandColorsGSMs[i]['colorid'] == colorid && brandColorsGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandColorsGSMs[i]['gsmid']); newOpt.value = brandColorsGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandColorsGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboCoverGsm = new elSelect( {container: 'cboCoverGsmDIV', baseWidthClass: 'elSelect56wide'} ); } function _resetCoverGSM__OLD(brandid, selected_item) { $('cboCoverGsmDIV').setHTML(''); var select = new Element('select', {id: 'cboCoverGsm', name: 'cboCoverGsm'}).injectInside($('cboCoverGsmDIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboCoverGsm'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (brandid) { var index = 1; for(var i=0; i < brandGSMs.length; i++) { if(brandGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandGSMs[i]['gsmid']); newOpt.value = brandGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboCoverGsm = new elSelect( {container: 'cboCoverGsmDIV', baseWidthClass: 'elSelect56wide'} ); } //populate papers select function cboCoverPagerCat_click(catid) { //show brands which relate to selected catid _resetCoverBrands(catid); //clear colours ddl _resetCoverColours(); //clear gsm ddl _resetCoverGSM(); } function cboCoverOption_click(option_id) { if (option_id == 'PC') { sample_dummies_cover_details_slider.slideIn(); } else { sample_dummies_cover_details_slider.slideOut(); } } function cboCoverPagerName_click(brandid) { //show colours which relate to selected brandid _resetCoverColours(brandid); //show gsm which relate to selected brandid //_resetCoverGSM(brandid); } function cboCoverColor_click(colorid) { _resetCoverGSM(colorid); } function _resetTextPages1(selected_item) { //now create the select box for papers. $('cboTextPage1DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPage1', name: 'cboTextPage1'}).injectInside($('cboTextPage1DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPage1'); var index = 0; var selected_index = 0; for(var i=0; i < textPages.length; i++) { var newOpt = document.createElement('option'); newOpt.text = textPages[i]['id']; newOpt.value = textPages[i]['id']; var oldOpt = cbo.options[i]; if (textPages[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Pages"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. new elSelect( {container: 'cboTextPage1DIV', baseWidthClass: 'elSelect80wide'} ); } function _resetTextCategories1(selected_item) { //now create the select box for papers. $('cboTextPagerCat1DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerCat1', name: 'cboTextPagerCat1'}).injectInside($('cboTextPagerCat1DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerCat1'); var index = 0; var selected_index = 0; for(var i=0; i < categories.length; i++) { var newOpt = document.createElement('option'); newOpt.text = getCategoryName(categories[i]['id']); newOpt.value = categories[i]['id']; var oldOpt = cbo.options[i]; if (categories[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Category"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerCat1 = new elSelect( {container: 'cboTextPagerCat1DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerCat1_click} ); } function _resetTextBrands1(catid, selected_item) { //now create the select box for papers. $('cboTextPagerName1DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerName1', name: 'cboTextPagerName1'}).injectInside($('cboTextPagerName1DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerName1'); var index = 0; var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (catid && catid != 0) { for(var i=0; i < brandCats.length; i++) { //populate select with values from selected category. if(parseInt(brandCats[i]['catid']) == parseInt(catid)) { var newOpt = document.createElement('option'); newOpt.text = getBrandName(brandCats[i]['brandid']); newOpt.value = brandCats[i]['brandid']; var oldOpt = cbo.options[index]; if (brandCats[i]['brandid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } else { for(var i=0; i < brands.length; i++) { var newOpt = document.createElement('option'); newOpt.text = brands[i]['name']; newOpt.value = brands[i]['id']; var oldOpt = cbo.options[i]; if (brands[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } var newOpt = document.createElement('option'); newOpt.text = "Product"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerName1 = new elSelect( {container: 'cboTextPagerName1DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerName1_click} ); } function _resetTextColours1(brandid, selected_item) { $('cboTextColor1DIV').setHTML(''); var select = new Element('select', {id: 'cboTextColor1', name: 'cboTextColor1'}).injectInside($('cboTextColor1DIV')); var cbo = document.getElementById('cboTextColor1'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = 'Colour / Finish'; newOpt.value = ''; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (brandid) { var index = 1; for(var i=0; i < brandColors.length; i++) { if(brandColors[i]['brandid'] == brandid) { var oldIndex = index; for(var k=0; k < brandFins.length; k++) { if(brandFins[k]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']) + " / " + getFinName(brandFins[k]['finid']); newOpt.value = brandColors[i]['colorid'] + ";" + brandFins[k]['finid'] ; var oldOpt = cbo.options[index]; if ((brandColors[i]['colorid'] + ";" + brandFins[k]['finid']) == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } if(index == oldIndex) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']); newOpt.value = brandColors[i]['colorid']; var oldOpt = cbo.options[index]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; } //now convert select box to alternative. var cboTextColor1 = new elSelect( {container: 'cboTextColor1DIV', baseWidthClass: 'elSelect120wide', onChangeEventFunction: cboTextColor1_click} ); } function _resetTextGSM1(colorid_finish_id, selected_item) { $('cboTextGsm1DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm1', name: 'cboTextGsm1'}).injectInside($('cboTextGsm1DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm1'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (colorid_finish_id) { //get color id. var temp = colorid_finish_id.split(';', 2); var colorid = temp[0]; //also get brand id. brandid = $('cboTextPagerName1').getValue(); var index = 1; for(var i=0; i < brandColorsGSMs.length; i++) { if(brandColorsGSMs[i]['colorid'] == colorid && brandColorsGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandColorsGSMs[i]['gsmid']); newOpt.value = brandColorsGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandColorsGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm1 = new elSelect( {container: 'cboTextGsm1DIV', baseWidthClass: 'elSelect56wide'} ); } function _resetTextGSM__OLD1(brandid, selected_item) { $('cboTextGsm1DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm1', name: 'cboTextGsm1'}).injectInside($('cboTextGsm1DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm1'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (brandid) { var index = 1; for(var i=0; i < brandGSMs.length; i++) { if(brandGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandGSMs[i]['gsmid']); newOpt.value = brandGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm1 = new elSelect( {container: 'cboTextGsm1DIV', baseWidthClass: 'elSelect56wide'} ); } function cboTextPagerCat1_click(catid) { //show brands which relate to selected catid _resetTextBrands1(catid); //clear colours ddl _resetTextColours1(); //clear gsm ddl _resetTextGSM1(); } function cboTextPagerName1_click(brandid) { //show colours which relate to selected brandid _resetTextColours1(brandid); //show gsm which relate to selected brandid //_resetTextGSM1(brandid); } function cboTextColor1_click(colorid) { _resetTextGSM1(colorid); } $('cmdAddMoreText1').addEvent('click', function(e) { new Event(e).stop(); var err = false; if (!err) { if ($('cboTextPagerName1').getValue() == '') { err = true; $('cboTextPagerName1DIV').addClass('elSelecterror'); alert('Please select a text product.'); } else { $('cboTextPagerName1DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextColor1').getValue() == '') { err = true; $('cboTextColor1DIV').addClass('elSelecterror'); alert('Please select a text colour / finish.'); } else { $('cboTextColor1DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextGsm1').getValue() == '') { err = true; $('cboTextGsm1DIV').addClass('elSelecterror'); alert('Please select a text GSM.'); } else { $('cboTextGsm1DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextPage1').getValue() == '' && $('cboTextPage1_other').getValue() == '') { err = true; $('cboTextPage1DIV').addClass('elSelecterror'); alert('Please select a text number of pages.'); } else { $('cboTextPage1DIV').removeClass('elSelecterror'); } } if (!err) { _resetTextPages2(); _resetTextCategories2(); _resetTextBrands2(); _resetTextColours2(); _resetTextGSM2(); sample_dummies_text_2_slider.slideIn(); $('cmdAddMoreText1').setStyle('visibility', 'hidden'); $('add-remove-divider-text-1').setStyle('visibility', 'hidden'); $('cmdRemoveText1').setStyle('visibility', 'visible'); } }) function _resetTextPages2(selected_item) { //now create the select box for papers. $('cboTextPage2DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPage2', name: 'cboTextPage2'}).injectInside($('cboTextPage2DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPage2'); var index = 0; var selected_index = 0; for(var i=0; i < textPages.length; i++) { var newOpt = document.createElement('option'); newOpt.text = textPages[i]['id']; newOpt.value = textPages[i]['id']; var oldOpt = cbo.options[i]; if (textPages[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Pages"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. new elSelect( {container: 'cboTextPage2DIV', baseWidthClass: 'elSelect80wide'} ); } function _resetTextCategories2(selected_item) { //now create the select box for papers. $('cboTextPagerCat2DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerCat2', name: 'cboTextPagerCat2'}).injectInside($('cboTextPagerCat2DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerCat2'); var index = 0; var selected_index = 0; for(var i=0; i < categories.length; i++) { var newOpt = document.createElement('option'); newOpt.text = getCategoryName(categories[i]['id']); newOpt.value = categories[i]['id']; var oldOpt = cbo.options[i]; if (categories[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Category"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerCat2 = new elSelect( {container: 'cboTextPagerCat2DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerCat2_click} ); } function _resetTextBrands2(catid, selected_item) { //now create the select box for papers. $('cboTextPagerName2DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerName2', name: 'cboTextPagerName2'}).injectInside($('cboTextPagerName2DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerName2'); var index = 0; var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (catid && catid != 0) { for(var i=0; i < brandCats.length; i++) { //populate select with values from selected category. if(parseInt(brandCats[i]['catid']) == parseInt(catid)) { var newOpt = document.createElement('option'); newOpt.text = getBrandName(brandCats[i]['brandid']); newOpt.value = brandCats[i]['brandid']; var oldOpt = cbo.options[index]; if (brandCats[i]['brandid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } else { for(var i=0; i < brands.length; i++) { var newOpt = document.createElement('option'); newOpt.text = brands[i]['name']; newOpt.value = brands[i]['id']; var oldOpt = cbo.options[i]; if (brands[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } var newOpt = document.createElement('option'); newOpt.text = "Product"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerName2 = new elSelect( {container: 'cboTextPagerName2DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerName2_click} ); } function _resetTextColours2(brandid, selected_item) { $('cboTextColor2DIV').setHTML(''); var select = new Element('select', {id: 'cboTextColor2', name: 'cboTextColor2'}).injectInside($('cboTextColor2DIV')); var cbo = document.getElementById('cboTextColor2'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = 'Colour / Finish'; newOpt.value = ''; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (brandid) { var index = 1; for(var i=0; i < brandColors.length; i++) { if(brandColors[i]['brandid'] == brandid) { var oldIndex = index; for(var k=0; k < brandFins.length; k++) { if(brandFins[k]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']) + " / " + getFinName(brandFins[k]['finid']); newOpt.value = brandColors[i]['colorid'] + ";" + brandFins[k]['finid'] ; var oldOpt = cbo.options[index]; if ((brandColors[i]['colorid'] + ";" + brandFins[k]['finid']) == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } if(index == oldIndex) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']); newOpt.value = brandColors[i]['colorid']; var oldOpt = cbo.options[index]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; } //now convert select box to alternative. var cboTextColor2 = new elSelect( {container: 'cboTextColor2DIV', baseWidthClass: 'elSelect120wide', onChangeEventFunction: cboTextColor2_click} ); } function _resetTextGSM2(colorid_finish_id, selected_item) { $('cboTextGsm2DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm2', name: 'cboTextGsm2'}).injectInside($('cboTextGsm2DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm2'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (colorid_finish_id) { //get color id. var temp = colorid_finish_id.split(';', 2); var colorid = temp[0]; //also get brand id. brandid = $('cboTextPagerName2').getValue(); var index = 1; for(var i=0; i < brandColorsGSMs.length; i++) { if(brandColorsGSMs[i]['colorid'] == colorid && brandColorsGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandColorsGSMs[i]['gsmid']); newOpt.value = brandColorsGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandColorsGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm2 = new elSelect( {container: 'cboTextGsm2DIV', baseWidthClass: 'elSelect56wide'} ); } function _resetTextGSM__OLD2(brandid, selected_item) { $('cboTextGsm2DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm2', name: 'cboTextGsm2'}).injectInside($('cboTextGsm2DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm2'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (brandid) { var index = 1; for(var i=0; i < brandGSMs.length; i++) { if(brandGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandGSMs[i]['gsmid']); newOpt.value = brandGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm2 = new elSelect( {container: 'cboTextGsm2DIV', baseWidthClass: 'elSelect56wide'} ); } function cboTextPagerCat2_click(catid) { //show brands which relate to selected catid _resetTextBrands2(catid); //clear colours ddl _resetTextColours2(); //clear gsm ddl _resetTextGSM2(); } function cboTextPagerName2_click(brandid) { //show colours which relate to selected brandid _resetTextColours2(brandid); //show gsm which relate to selected brandid //_resetTextGSM2(brandid); } function cboTextColor2_click(colorid) { _resetTextGSM2(colorid); } $('cmdAddMoreText2').addEvent('click', function(e) { new Event(e).stop(); var err = false; if (!err) { if ($('cboTextPagerName2').getValue() == '') { err = true; $('cboTextPagerName2DIV').addClass('elSelecterror'); alert('Please select a text product.'); } else { $('cboTextPagerName2DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextColor2').getValue() == '') { err = true; $('cboTextColor2DIV').addClass('elSelecterror'); alert('Please select a text colour / finish.'); } else { $('cboTextColor2DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextGsm2').getValue() == '') { err = true; $('cboTextGsm2DIV').addClass('elSelecterror'); alert('Please select a text GSM.'); } else { $('cboTextGsm2DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextPage2').getValue() == '' && $('cboTextPage2_other').getValue() == '') { err = true; $('cboTextPage2DIV').addClass('elSelecterror'); alert('Please select a text number of pages.'); } else { $('cboTextPage2DIV').removeClass('elSelecterror'); } } if (!err) { _resetTextPages3(); _resetTextCategories3(); _resetTextBrands3(); _resetTextColours3(); _resetTextGSM3(); sample_dummies_text_3_slider.slideIn(); $('cmdAddMoreText2').setStyle('visibility', 'hidden'); $('add-remove-divider-text-2').setStyle('visibility', 'hidden'); $('cmdRemoveText2').setStyle('visibility', 'visible'); } }) function _resetTextPages3(selected_item) { //now create the select box for papers. $('cboTextPage3DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPage3', name: 'cboTextPage3'}).injectInside($('cboTextPage3DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPage3'); var index = 0; var selected_index = 0; for(var i=0; i < textPages.length; i++) { var newOpt = document.createElement('option'); newOpt.text = textPages[i]['id']; newOpt.value = textPages[i]['id']; var oldOpt = cbo.options[i]; if (textPages[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Pages"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. new elSelect( {container: 'cboTextPage3DIV', baseWidthClass: 'elSelect80wide'} ); } function _resetTextCategories3(selected_item) { //now create the select box for papers. $('cboTextPagerCat3DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerCat3', name: 'cboTextPagerCat3'}).injectInside($('cboTextPagerCat3DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerCat3'); var index = 0; var selected_index = 0; for(var i=0; i < categories.length; i++) { var newOpt = document.createElement('option'); newOpt.text = getCategoryName(categories[i]['id']); newOpt.value = categories[i]['id']; var oldOpt = cbo.options[i]; if (categories[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Category"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerCat3 = new elSelect( {container: 'cboTextPagerCat3DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerCat3_click} ); } function _resetTextBrands3(catid, selected_item) { //now create the select box for papers. $('cboTextPagerName3DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerName3', name: 'cboTextPagerName3'}).injectInside($('cboTextPagerName3DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerName3'); var index = 0; var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (catid && catid != 0) { for(var i=0; i < brandCats.length; i++) { //populate select with values from selected category. if(parseInt(brandCats[i]['catid']) == parseInt(catid)) { var newOpt = document.createElement('option'); newOpt.text = getBrandName(brandCats[i]['brandid']); newOpt.value = brandCats[i]['brandid']; var oldOpt = cbo.options[index]; if (brandCats[i]['brandid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } else { for(var i=0; i < brands.length; i++) { var newOpt = document.createElement('option'); newOpt.text = brands[i]['name']; newOpt.value = brands[i]['id']; var oldOpt = cbo.options[i]; if (brands[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } var newOpt = document.createElement('option'); newOpt.text = "Product"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerName3 = new elSelect( {container: 'cboTextPagerName3DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerName3_click} ); } function _resetTextColours3(brandid, selected_item) { $('cboTextColor3DIV').setHTML(''); var select = new Element('select', {id: 'cboTextColor3', name: 'cboTextColor3'}).injectInside($('cboTextColor3DIV')); var cbo = document.getElementById('cboTextColor3'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = 'Colour / Finish'; newOpt.value = ''; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (brandid) { var index = 1; for(var i=0; i < brandColors.length; i++) { if(brandColors[i]['brandid'] == brandid) { var oldIndex = index; for(var k=0; k < brandFins.length; k++) { if(brandFins[k]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']) + " / " + getFinName(brandFins[k]['finid']); newOpt.value = brandColors[i]['colorid'] + ";" + brandFins[k]['finid'] ; var oldOpt = cbo.options[index]; if ((brandColors[i]['colorid'] + ";" + brandFins[k]['finid']) == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } if(index == oldIndex) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']); newOpt.value = brandColors[i]['colorid']; var oldOpt = cbo.options[index]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; } //now convert select box to alternative. var cboTextColor3 = new elSelect( {container: 'cboTextColor3DIV', baseWidthClass: 'elSelect120wide', onChangeEventFunction: cboTextColor3_click} ); } function _resetTextGSM3(colorid_finish_id, selected_item) { $('cboTextGsm3DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm3', name: 'cboTextGsm3'}).injectInside($('cboTextGsm3DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm3'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (colorid_finish_id) { //get color id. var temp = colorid_finish_id.split(';', 2); var colorid = temp[0]; //also get brand id. brandid = $('cboTextPagerName3').getValue(); var index = 1; for(var i=0; i < brandColorsGSMs.length; i++) { if(brandColorsGSMs[i]['colorid'] == colorid && brandColorsGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandColorsGSMs[i]['gsmid']); newOpt.value = brandColorsGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandColorsGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm3 = new elSelect( {container: 'cboTextGsm3DIV', baseWidthClass: 'elSelect56wide'} ); } function _resetTextGSM__OLD3(brandid, selected_item) { $('cboTextGsm3DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm3', name: 'cboTextGsm3'}).injectInside($('cboTextGsm3DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm3'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (brandid) { var index = 1; for(var i=0; i < brandGSMs.length; i++) { if(brandGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandGSMs[i]['gsmid']); newOpt.value = brandGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm3 = new elSelect( {container: 'cboTextGsm3DIV', baseWidthClass: 'elSelect56wide'} ); } function cboTextPagerCat3_click(catid) { //show brands which relate to selected catid _resetTextBrands3(catid); //clear colours ddl _resetTextColours3(); //clear gsm ddl _resetTextGSM3(); } function cboTextPagerName3_click(brandid) { //show colours which relate to selected brandid _resetTextColours3(brandid); //show gsm which relate to selected brandid //_resetTextGSM3(brandid); } function cboTextColor3_click(colorid) { _resetTextGSM3(colorid); } $('cmdAddMoreText3').addEvent('click', function(e) { new Event(e).stop(); var err = false; if (!err) { if ($('cboTextPagerName3').getValue() == '') { err = true; $('cboTextPagerName3DIV').addClass('elSelecterror'); alert('Please select a text product.'); } else { $('cboTextPagerName3DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextColor3').getValue() == '') { err = true; $('cboTextColor3DIV').addClass('elSelecterror'); alert('Please select a text colour / finish.'); } else { $('cboTextColor3DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextGsm3').getValue() == '') { err = true; $('cboTextGsm3DIV').addClass('elSelecterror'); alert('Please select a text GSM.'); } else { $('cboTextGsm3DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextPage3').getValue() == '' && $('cboTextPage3_other').getValue() == '') { err = true; $('cboTextPage3DIV').addClass('elSelecterror'); alert('Please select a text number of pages.'); } else { $('cboTextPage3DIV').removeClass('elSelecterror'); } } if (!err) { _resetTextPages4(); _resetTextCategories4(); _resetTextBrands4(); _resetTextColours4(); _resetTextGSM4(); sample_dummies_text_4_slider.slideIn(); $('cmdAddMoreText3').setStyle('visibility', 'hidden'); $('add-remove-divider-text-3').setStyle('visibility', 'hidden'); $('cmdRemoveText3').setStyle('visibility', 'visible'); } }) function _resetTextPages4(selected_item) { //now create the select box for papers. $('cboTextPage4DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPage4', name: 'cboTextPage4'}).injectInside($('cboTextPage4DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPage4'); var index = 0; var selected_index = 0; for(var i=0; i < textPages.length; i++) { var newOpt = document.createElement('option'); newOpt.text = textPages[i]['id']; newOpt.value = textPages[i]['id']; var oldOpt = cbo.options[i]; if (textPages[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Pages"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. new elSelect( {container: 'cboTextPage4DIV', baseWidthClass: 'elSelect80wide'} ); } function _resetTextCategories4(selected_item) { //now create the select box for papers. $('cboTextPagerCat4DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerCat4', name: 'cboTextPagerCat4'}).injectInside($('cboTextPagerCat4DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerCat4'); var index = 0; var selected_index = 0; for(var i=0; i < categories.length; i++) { var newOpt = document.createElement('option'); newOpt.text = getCategoryName(categories[i]['id']); newOpt.value = categories[i]['id']; var oldOpt = cbo.options[i]; if (categories[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Category"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerCat4 = new elSelect( {container: 'cboTextPagerCat4DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerCat4_click} ); } function _resetTextBrands4(catid, selected_item) { //now create the select box for papers. $('cboTextPagerName4DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerName4', name: 'cboTextPagerName4'}).injectInside($('cboTextPagerName4DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerName4'); var index = 0; var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (catid && catid != 0) { for(var i=0; i < brandCats.length; i++) { //populate select with values from selected category. if(parseInt(brandCats[i]['catid']) == parseInt(catid)) { var newOpt = document.createElement('option'); newOpt.text = getBrandName(brandCats[i]['brandid']); newOpt.value = brandCats[i]['brandid']; var oldOpt = cbo.options[index]; if (brandCats[i]['brandid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } else { for(var i=0; i < brands.length; i++) { var newOpt = document.createElement('option'); newOpt.text = brands[i]['name']; newOpt.value = brands[i]['id']; var oldOpt = cbo.options[i]; if (brands[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } var newOpt = document.createElement('option'); newOpt.text = "Product"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerName4 = new elSelect( {container: 'cboTextPagerName4DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerName4_click} ); } function _resetTextColours4(brandid, selected_item) { $('cboTextColor4DIV').setHTML(''); var select = new Element('select', {id: 'cboTextColor4', name: 'cboTextColor4'}).injectInside($('cboTextColor4DIV')); var cbo = document.getElementById('cboTextColor4'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = 'Colour / Finish'; newOpt.value = ''; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (brandid) { var index = 1; for(var i=0; i < brandColors.length; i++) { if(brandColors[i]['brandid'] == brandid) { var oldIndex = index; for(var k=0; k < brandFins.length; k++) { if(brandFins[k]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']) + " / " + getFinName(brandFins[k]['finid']); newOpt.value = brandColors[i]['colorid'] + ";" + brandFins[k]['finid'] ; var oldOpt = cbo.options[index]; if ((brandColors[i]['colorid'] + ";" + brandFins[k]['finid']) == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } if(index == oldIndex) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']); newOpt.value = brandColors[i]['colorid']; var oldOpt = cbo.options[index]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; } //now convert select box to alternative. var cboTextColor4 = new elSelect( {container: 'cboTextColor4DIV', baseWidthClass: 'elSelect120wide', onChangeEventFunction: cboTextColor4_click} ); } function _resetTextGSM4(colorid_finish_id, selected_item) { $('cboTextGsm4DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm4', name: 'cboTextGsm4'}).injectInside($('cboTextGsm4DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm4'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (colorid_finish_id) { //get color id. var temp = colorid_finish_id.split(';', 2); var colorid = temp[0]; //also get brand id. brandid = $('cboTextPagerName4').getValue(); var index = 1; for(var i=0; i < brandColorsGSMs.length; i++) { if(brandColorsGSMs[i]['colorid'] == colorid && brandColorsGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandColorsGSMs[i]['gsmid']); newOpt.value = brandColorsGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandColorsGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm4 = new elSelect( {container: 'cboTextGsm4DIV', baseWidthClass: 'elSelect56wide'} ); } function _resetTextGSM__OLD4(brandid, selected_item) { $('cboTextGsm4DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm4', name: 'cboTextGsm4'}).injectInside($('cboTextGsm4DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm4'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (brandid) { var index = 1; for(var i=0; i < brandGSMs.length; i++) { if(brandGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandGSMs[i]['gsmid']); newOpt.value = brandGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm4 = new elSelect( {container: 'cboTextGsm4DIV', baseWidthClass: 'elSelect56wide'} ); } function cboTextPagerCat4_click(catid) { //show brands which relate to selected catid _resetTextBrands4(catid); //clear colours ddl _resetTextColours4(); //clear gsm ddl _resetTextGSM4(); } function cboTextPagerName4_click(brandid) { //show colours which relate to selected brandid _resetTextColours4(brandid); //show gsm which relate to selected brandid //_resetTextGSM4(brandid); } function cboTextColor4_click(colorid) { _resetTextGSM4(colorid); } $('cmdAddMoreText4').addEvent('click', function(e) { new Event(e).stop(); var err = false; if (!err) { if ($('cboTextPagerName4').getValue() == '') { err = true; $('cboTextPagerName4DIV').addClass('elSelecterror'); alert('Please select a text product.'); } else { $('cboTextPagerName4DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextColor4').getValue() == '') { err = true; $('cboTextColor4DIV').addClass('elSelecterror'); alert('Please select a text colour / finish.'); } else { $('cboTextColor4DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextGsm4').getValue() == '') { err = true; $('cboTextGsm4DIV').addClass('elSelecterror'); alert('Please select a text GSM.'); } else { $('cboTextGsm4DIV').removeClass('elSelecterror'); } } if (!err) { if ($('cboTextPage4').getValue() == '' && $('cboTextPage4_other').getValue() == '') { err = true; $('cboTextPage4DIV').addClass('elSelecterror'); alert('Please select a text number of pages.'); } else { $('cboTextPage4DIV').removeClass('elSelecterror'); } } if (!err) { _resetTextPages5(); _resetTextCategories5(); _resetTextBrands5(); _resetTextColours5(); _resetTextGSM5(); sample_dummies_text_5_slider.slideIn(); $('cmdAddMoreText4').setStyle('visibility', 'hidden'); $('add-remove-divider-text-4').setStyle('visibility', 'hidden'); $('cmdRemoveText4').setStyle('visibility', 'visible'); } }) function _resetTextPages5(selected_item) { //now create the select box for papers. $('cboTextPage5DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPage5', name: 'cboTextPage5'}).injectInside($('cboTextPage5DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPage5'); var index = 0; var selected_index = 0; for(var i=0; i < textPages.length; i++) { var newOpt = document.createElement('option'); newOpt.text = textPages[i]['id']; newOpt.value = textPages[i]['id']; var oldOpt = cbo.options[i]; if (textPages[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Pages"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. new elSelect( {container: 'cboTextPage5DIV', baseWidthClass: 'elSelect80wide'} ); } function _resetTextCategories5(selected_item) { //now create the select box for papers. $('cboTextPagerCat5DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerCat5', name: 'cboTextPagerCat5'}).injectInside($('cboTextPagerCat5DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerCat5'); var index = 0; var selected_index = 0; for(var i=0; i < categories.length; i++) { var newOpt = document.createElement('option'); newOpt.text = getCategoryName(categories[i]['id']); newOpt.value = categories[i]['id']; var oldOpt = cbo.options[i]; if (categories[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } var newOpt = document.createElement('option'); newOpt.text = "Category"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerCat5 = new elSelect( {container: 'cboTextPagerCat5DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerCat5_click} ); } function _resetTextBrands5(catid, selected_item) { //now create the select box for papers. $('cboTextPagerName5DIV').setHTML(''); var select = new Element('select', {id: 'cboTextPagerName5', name: 'cboTextPagerName5'}).injectInside($('cboTextPagerName5DIV')); //now fill it will all papers. var cbo = document.getElementById('cboTextPagerName5'); var index = 0; var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (catid && catid != 0) { for(var i=0; i < brandCats.length; i++) { //populate select with values from selected category. if(parseInt(brandCats[i]['catid']) == parseInt(catid)) { var newOpt = document.createElement('option'); newOpt.text = getBrandName(brandCats[i]['brandid']); newOpt.value = brandCats[i]['brandid']; var oldOpt = cbo.options[index]; if (brandCats[i]['brandid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } else { for(var i=0; i < brands.length; i++) { var newOpt = document.createElement('option'); newOpt.text = brands[i]['name']; newOpt.value = brands[i]['id']; var oldOpt = cbo.options[i]; if (brands[i]['id'] == selected_item) { selected_index = i+1; } try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } var newOpt = document.createElement('option'); newOpt.text = "Product"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } cbo.selectedIndex = selected_index; //now convert select box to alternative. var cboTextPagerName5 = new elSelect( {container: 'cboTextPagerName5DIV', baseWidthClass: 'elSelect100wide', onChangeEventFunction: cboTextPagerName5_click} ); } function _resetTextColours5(brandid, selected_item) { $('cboTextColor5DIV').setHTML(''); var select = new Element('select', {id: 'cboTextColor5', name: 'cboTextColor5'}).injectInside($('cboTextColor5DIV')); var cbo = document.getElementById('cboTextColor5'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = 'Colour / Finish'; newOpt.value = ''; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; if (brandid) { var index = 1; for(var i=0; i < brandColors.length; i++) { if(brandColors[i]['brandid'] == brandid) { var oldIndex = index; for(var k=0; k < brandFins.length; k++) { if(brandFins[k]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']) + " / " + getFinName(brandFins[k]['finid']); newOpt.value = brandColors[i]['colorid'] + ";" + brandFins[k]['finid'] ; var oldOpt = cbo.options[index]; if ((brandColors[i]['colorid'] + ";" + brandFins[k]['finid']) == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } if(index == oldIndex) { var newOpt = document.createElement('option'); newOpt.text = getColorName(brandColors[i]['colorid']); newOpt.value = brandColors[i]['colorid']; var oldOpt = cbo.options[index]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; } //now convert select box to alternative. var cboTextColor5 = new elSelect( {container: 'cboTextColor5DIV', baseWidthClass: 'elSelect120wide', onChangeEventFunction: cboTextColor5_click} ); } function _resetTextGSM5(colorid_finish_id, selected_item) { $('cboTextGsm5DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm5', name: 'cboTextGsm5'}).injectInside($('cboTextGsm5DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm5'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (colorid_finish_id) { //get color id. var temp = colorid_finish_id.split(';', 2); var colorid = temp[0]; //also get brand id. brandid = $('cboTextPagerName5').getValue(); var index = 1; for(var i=0; i < brandColorsGSMs.length; i++) { if(brandColorsGSMs[i]['colorid'] == colorid && brandColorsGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandColorsGSMs[i]['gsmid']); newOpt.value = brandColorsGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandColorsGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm5 = new elSelect( {container: 'cboTextGsm5DIV', baseWidthClass: 'elSelect56wide'} ); } function _resetTextGSM__OLD5(brandid, selected_item) { $('cboTextGsm5DIV').setHTML(''); var select = new Element('select', {id: 'cboTextGsm5', name: 'cboTextGsm5'}).injectInside($('cboTextGsm5DIV')); var selected_index_counter = 0;//we need to use this rather than index as only some brands exist in the selected cat. var selected_index = 0; var cbo = document.getElementById('cboTextGsm5'); cbo.length = 0; var newOpt = document.createElement('option'); newOpt.text = "GSM"; newOpt.value = ""; var oldOpt = cbo.options[0]; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, 0); } if (brandid) { var index = 1; for(var i=0; i < brandGSMs.length; i++) { if(brandGSMs[i]['brandid'] == brandid) { var newOpt = document.createElement('option'); newOpt.text = getGSM(brandGSMs[i]['gsmid']); newOpt.value = brandGSMs[i]['gsmid']; var oldOpt = cbo.options[index]; if (brandGSMs[i]['gsmid'] == selected_item) { selected_index = selected_index_counter+1; } selected_index_counter++; try { cbo.add(newOpt, oldOpt); } catch(ex) { cbo.add(newOpt, index); } index++; } } } cbo.selectedIndex = selected_index; var cboTextGsm5 = new elSelect( {container: 'cboTextGsm5DIV', baseWidthClass: 'elSelect56wide'} ); } function cboTextPagerCat5_click(catid) { //show brands which relate to selected catid _resetTextBrands5(catid); //clear colours ddl _resetTextColours5(); //clear gsm ddl _resetTextGSM5(); } function cboTextPagerName5_click(brandid) { //show colours which relate to selected brandid _resetTextColours5(brandid); //show gsm which relate to selected brandid //_resetTextGSM5(brandid); } function cboTextColor5_click(colorid) { _resetTextGSM5(colorid); } $('cmdRemoveText1').addEvent('click', function(e) { new Event(e).stop(); //this moves the values up one row of selects. if ($('cboTextPagerCat2')) { _resetTextCategories1($('cboTextPagerCat2').getValue()); _resetTextBrands1($('cboTextPagerCat2').getValue(), $('cboTextPagerName2').getValue()); _resetTextColours1($('cboTextPagerName2').getValue(), $('cboTextColor2').getValue()); _resetTextGSM1($('cboTextPagerName2').getValue(), $('cboTextGsm2').getValue()); _resetTextPages1($('cboTextPage2').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //this moves the values up one row of selects. if ($('cboTextPagerCat3')) { _resetTextCategories2($('cboTextPagerCat3').getValue()); _resetTextBrands2($('cboTextPagerCat3').getValue(), $('cboTextPagerName3').getValue()); _resetTextColours2($('cboTextPagerName3').getValue(), $('cboTextColor3').getValue()); _resetTextGSM2($('cboTextPagerName3').getValue(), $('cboTextGsm3').getValue()); _resetTextPages2($('cboTextPage3').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //this moves the values up one row of selects. if ($('cboTextPagerCat4')) { _resetTextCategories3($('cboTextPagerCat4').getValue()); _resetTextBrands3($('cboTextPagerCat4').getValue(), $('cboTextPagerName4').getValue()); _resetTextColours3($('cboTextPagerName4').getValue(), $('cboTextColor4').getValue()); _resetTextGSM3($('cboTextPagerName4').getValue(), $('cboTextGsm4').getValue()); _resetTextPages3($('cboTextPage4').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //this moves the values up one row of selects. if ($('cboTextPagerCat5')) { _resetTextCategories4($('cboTextPagerCat5').getValue()); _resetTextBrands4($('cboTextPagerCat5').getValue(), $('cboTextPagerName5').getValue()); _resetTextColours4($('cboTextPagerName5').getValue(), $('cboTextColor5').getValue()); _resetTextGSM4($('cboTextPagerName5').getValue(), $('cboTextGsm5').getValue()); _resetTextPages4($('cboTextPage5').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //now remove ddls from the last row. var remove_row_number = 0; if ($('cboTextPagerCat5')) { if (remove_row_number == 0) { remove_row_number = 5; //clear divs. $('cboTextPagerCat5DIV').setHTML(''); $('cboTextPagerName5DIV').setHTML(''); $('cboTextColor5DIV').setHTML(''); $('cboTextGsm5DIV').setHTML(''); $('cboTextPage5DIV').setHTML(''); //now hide row sample_dummies_text_5_slider.slideOut(); //now change x button to add. $('cmdRemoveText4').setStyle('visibility', 'visible'); $('cmdAddMoreText4').setStyle('visibility', 'visible'); $('add-remove-divider-text-4').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat4')) { if (remove_row_number == 0) { remove_row_number = 4; //clear divs. $('cboTextPagerCat4DIV').setHTML(''); $('cboTextPagerName4DIV').setHTML(''); $('cboTextColor4DIV').setHTML(''); $('cboTextGsm4DIV').setHTML(''); $('cboTextPage4DIV').setHTML(''); //now hide row sample_dummies_text_4_slider.slideOut(); //now change x button to add. $('cmdRemoveText3').setStyle('visibility', 'visible'); $('cmdAddMoreText3').setStyle('visibility', 'visible'); $('add-remove-divider-text-3').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat3')) { if (remove_row_number == 0) { remove_row_number = 3; //clear divs. $('cboTextPagerCat3DIV').setHTML(''); $('cboTextPagerName3DIV').setHTML(''); $('cboTextColor3DIV').setHTML(''); $('cboTextGsm3DIV').setHTML(''); $('cboTextPage3DIV').setHTML(''); //now hide row sample_dummies_text_3_slider.slideOut(); //now change x button to add. $('cmdRemoveText2').setStyle('visibility', 'visible'); $('cmdAddMoreText2').setStyle('visibility', 'visible'); $('add-remove-divider-text-2').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat2')) { if (remove_row_number == 0) { remove_row_number = 2; //clear divs. $('cboTextPagerCat2DIV').setHTML(''); $('cboTextPagerName2DIV').setHTML(''); $('cboTextColor2DIV').setHTML(''); $('cboTextGsm2DIV').setHTML(''); $('cboTextPage2DIV').setHTML(''); //now hide row sample_dummies_text_2_slider.slideOut(); //now change x button to add. $('cmdRemoveText1').setStyle('visibility', 'hidden'); $('cmdAddMoreText1').setStyle('visibility', 'visible'); $('add-remove-divider-text-1').setStyle('visibility', 'visible'); } } }) $('cmdRemoveText2').addEvent('click', function(e) { new Event(e).stop(); //this moves the values up one row of selects. if ($('cboTextPagerCat3')) { _resetTextCategories2($('cboTextPagerCat3').getValue()); _resetTextBrands2($('cboTextPagerCat3').getValue(), $('cboTextPagerName3').getValue()); _resetTextColours2($('cboTextPagerName3').getValue(), $('cboTextColor3').getValue()); _resetTextGSM2($('cboTextPagerName3').getValue(), $('cboTextGsm3').getValue()); _resetTextPages2($('cboTextPage3').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //this moves the values up one row of selects. if ($('cboTextPagerCat4')) { _resetTextCategories3($('cboTextPagerCat4').getValue()); _resetTextBrands3($('cboTextPagerCat4').getValue(), $('cboTextPagerName4').getValue()); _resetTextColours3($('cboTextPagerName4').getValue(), $('cboTextColor4').getValue()); _resetTextGSM3($('cboTextPagerName4').getValue(), $('cboTextGsm4').getValue()); _resetTextPages3($('cboTextPage4').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //this moves the values up one row of selects. if ($('cboTextPagerCat5')) { _resetTextCategories4($('cboTextPagerCat5').getValue()); _resetTextBrands4($('cboTextPagerCat5').getValue(), $('cboTextPagerName5').getValue()); _resetTextColours4($('cboTextPagerName5').getValue(), $('cboTextColor5').getValue()); _resetTextGSM4($('cboTextPagerName5').getValue(), $('cboTextGsm5').getValue()); _resetTextPages4($('cboTextPage5').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //now remove ddls from the last row. var remove_row_number = 0; if ($('cboTextPagerCat5')) { if (remove_row_number == 0) { remove_row_number = 5; //clear divs. $('cboTextPagerCat5DIV').setHTML(''); $('cboTextPagerName5DIV').setHTML(''); $('cboTextColor5DIV').setHTML(''); $('cboTextGsm5DIV').setHTML(''); $('cboTextPage5DIV').setHTML(''); //now hide row sample_dummies_text_5_slider.slideOut(); //now change x button to add. $('cmdRemoveText4').setStyle('visibility', 'visible'); $('cmdAddMoreText4').setStyle('visibility', 'visible'); $('add-remove-divider-text-4').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat4')) { if (remove_row_number == 0) { remove_row_number = 4; //clear divs. $('cboTextPagerCat4DIV').setHTML(''); $('cboTextPagerName4DIV').setHTML(''); $('cboTextColor4DIV').setHTML(''); $('cboTextGsm4DIV').setHTML(''); $('cboTextPage4DIV').setHTML(''); //now hide row sample_dummies_text_4_slider.slideOut(); //now change x button to add. $('cmdRemoveText3').setStyle('visibility', 'visible'); $('cmdAddMoreText3').setStyle('visibility', 'visible'); $('add-remove-divider-text-3').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat3')) { if (remove_row_number == 0) { remove_row_number = 3; //clear divs. $('cboTextPagerCat3DIV').setHTML(''); $('cboTextPagerName3DIV').setHTML(''); $('cboTextColor3DIV').setHTML(''); $('cboTextGsm3DIV').setHTML(''); $('cboTextPage3DIV').setHTML(''); //now hide row sample_dummies_text_3_slider.slideOut(); //now change x button to add. $('cmdRemoveText2').setStyle('visibility', 'visible'); $('cmdAddMoreText2').setStyle('visibility', 'visible'); $('add-remove-divider-text-2').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat2')) { if (remove_row_number == 0) { remove_row_number = 2; //clear divs. $('cboTextPagerCat2DIV').setHTML(''); $('cboTextPagerName2DIV').setHTML(''); $('cboTextColor2DIV').setHTML(''); $('cboTextGsm2DIV').setHTML(''); $('cboTextPage2DIV').setHTML(''); //now hide row sample_dummies_text_2_slider.slideOut(); //now change x button to add. $('cmdRemoveText1').setStyle('visibility', 'hidden'); $('cmdAddMoreText1').setStyle('visibility', 'visible'); $('add-remove-divider-text-1').setStyle('visibility', 'visible'); } } }) $('cmdRemoveText3').addEvent('click', function(e) { new Event(e).stop(); //this moves the values up one row of selects. if ($('cboTextPagerCat4')) { _resetTextCategories3($('cboTextPagerCat4').getValue()); _resetTextBrands3($('cboTextPagerCat4').getValue(), $('cboTextPagerName4').getValue()); _resetTextColours3($('cboTextPagerName4').getValue(), $('cboTextColor4').getValue()); _resetTextGSM3($('cboTextPagerName4').getValue(), $('cboTextGsm4').getValue()); _resetTextPages3($('cboTextPage4').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //this moves the values up one row of selects. if ($('cboTextPagerCat5')) { _resetTextCategories4($('cboTextPagerCat5').getValue()); _resetTextBrands4($('cboTextPagerCat5').getValue(), $('cboTextPagerName5').getValue()); _resetTextColours4($('cboTextPagerName5').getValue(), $('cboTextColor5').getValue()); _resetTextGSM4($('cboTextPagerName5').getValue(), $('cboTextGsm5').getValue()); _resetTextPages4($('cboTextPage5').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //now remove ddls from the last row. var remove_row_number = 0; if ($('cboTextPagerCat5')) { if (remove_row_number == 0) { remove_row_number = 5; //clear divs. $('cboTextPagerCat5DIV').setHTML(''); $('cboTextPagerName5DIV').setHTML(''); $('cboTextColor5DIV').setHTML(''); $('cboTextGsm5DIV').setHTML(''); $('cboTextPage5DIV').setHTML(''); //now hide row sample_dummies_text_5_slider.slideOut(); //now change x button to add. $('cmdRemoveText4').setStyle('visibility', 'visible'); $('cmdAddMoreText4').setStyle('visibility', 'visible'); $('add-remove-divider-text-4').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat4')) { if (remove_row_number == 0) { remove_row_number = 4; //clear divs. $('cboTextPagerCat4DIV').setHTML(''); $('cboTextPagerName4DIV').setHTML(''); $('cboTextColor4DIV').setHTML(''); $('cboTextGsm4DIV').setHTML(''); $('cboTextPage4DIV').setHTML(''); //now hide row sample_dummies_text_4_slider.slideOut(); //now change x button to add. $('cmdRemoveText3').setStyle('visibility', 'visible'); $('cmdAddMoreText3').setStyle('visibility', 'visible'); $('add-remove-divider-text-3').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat3')) { if (remove_row_number == 0) { remove_row_number = 3; //clear divs. $('cboTextPagerCat3DIV').setHTML(''); $('cboTextPagerName3DIV').setHTML(''); $('cboTextColor3DIV').setHTML(''); $('cboTextGsm3DIV').setHTML(''); $('cboTextPage3DIV').setHTML(''); //now hide row sample_dummies_text_3_slider.slideOut(); //now change x button to add. $('cmdRemoveText2').setStyle('visibility', 'visible'); $('cmdAddMoreText2').setStyle('visibility', 'visible'); $('add-remove-divider-text-2').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat2')) { if (remove_row_number == 0) { remove_row_number = 2; //clear divs. $('cboTextPagerCat2DIV').setHTML(''); $('cboTextPagerName2DIV').setHTML(''); $('cboTextColor2DIV').setHTML(''); $('cboTextGsm2DIV').setHTML(''); $('cboTextPage2DIV').setHTML(''); //now hide row sample_dummies_text_2_slider.slideOut(); //now change x button to add. $('cmdRemoveText1').setStyle('visibility', 'hidden'); $('cmdAddMoreText1').setStyle('visibility', 'visible'); $('add-remove-divider-text-1').setStyle('visibility', 'visible'); } } }) $('cmdRemoveText4').addEvent('click', function(e) { new Event(e).stop(); //this moves the values up one row of selects. if ($('cboTextPagerCat5')) { _resetTextCategories4($('cboTextPagerCat5').getValue()); _resetTextBrands4($('cboTextPagerCat5').getValue(), $('cboTextPagerName5').getValue()); _resetTextColours4($('cboTextPagerName5').getValue(), $('cboTextColor5').getValue()); _resetTextGSM4($('cboTextPagerName5').getValue(), $('cboTextGsm5').getValue()); _resetTextPages4($('cboTextPage5').getValue()); } else { if (!$('cboTextPagerCat2')) { _resetTextCategories1(); _resetTextBrands1(); _resetTextColours1(); _resetTextGSM1(); _resetTextPages1(); } } //now remove ddls from the last row. var remove_row_number = 0; if ($('cboTextPagerCat5')) { if (remove_row_number == 0) { remove_row_number = 5; //clear divs. $('cboTextPagerCat5DIV').setHTML(''); $('cboTextPagerName5DIV').setHTML(''); $('cboTextColor5DIV').setHTML(''); $('cboTextGsm5DIV').setHTML(''); $('cboTextPage5DIV').setHTML(''); //now hide row sample_dummies_text_5_slider.slideOut(); //now change x button to add. $('cmdRemoveText4').setStyle('visibility', 'visible'); $('cmdAddMoreText4').setStyle('visibility', 'visible'); $('add-remove-divider-text-4').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat4')) { if (remove_row_number == 0) { remove_row_number = 4; //clear divs. $('cboTextPagerCat4DIV').setHTML(''); $('cboTextPagerName4DIV').setHTML(''); $('cboTextColor4DIV').setHTML(''); $('cboTextGsm4DIV').setHTML(''); $('cboTextPage4DIV').setHTML(''); //now hide row sample_dummies_text_4_slider.slideOut(); //now change x button to add. $('cmdRemoveText3').setStyle('visibility', 'visible'); $('cmdAddMoreText3').setStyle('visibility', 'visible'); $('add-remove-divider-text-3').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat3')) { if (remove_row_number == 0) { remove_row_number = 3; //clear divs. $('cboTextPagerCat3DIV').setHTML(''); $('cboTextPagerName3DIV').setHTML(''); $('cboTextColor3DIV').setHTML(''); $('cboTextGsm3DIV').setHTML(''); $('cboTextPage3DIV').setHTML(''); //now hide row sample_dummies_text_3_slider.slideOut(); //now change x button to add. $('cmdRemoveText2').setStyle('visibility', 'visible'); $('cmdAddMoreText2').setStyle('visibility', 'visible'); $('add-remove-divider-text-2').setStyle('visibility', 'visible'); } } if ($('cboTextPagerCat2')) { if (remove_row_number == 0) { remove_row_number = 2; //clear divs. $('cboTextPagerCat2DIV').setHTML(''); $('cboTextPagerName2DIV').setHTML(''); $('cboTextColor2DIV').setHTML(''); $('cboTextGsm2DIV').setHTML(''); $('cboTextPage2DIV').setHTML(''); //now hide row sample_dummies_text_2_slider.slideOut(); //now change x button to add. $('cmdRemoveText1').setStyle('visibility', 'hidden'); $('cmdAddMoreText1').setStyle('visibility', 'visible'); $('add-remove-divider-text-1').setStyle('visibility', 'visible'); } } }) }) //static js functions. function getCategoryName(catid) { for(var i = 0; i < categories.length; i++) { if(categories[i]['id'] == catid) return categories[i]['name']; } return null; } function getBrandName(brandid) { for(var i = 0; i < brands.length; i++) { if(brands[i]['id'] == brandid) return brands[i]['name']; } return null; } function getColorName(colorid) { for(var i = 0; i < colors.length; i++) { if(colors[i]['id'] == colorid) return colors[i]['name']; } return null; } function getFinName(finid) { for(var i = 0; i < finishs.length; i++) { if(finishs[i]['id'] == finid) return finishs[i]['name']; } return null; } function getGSM(gsmid) { for(var i = 0; i < gsms.length; i++) { if(gsms[i]['gsmid'] == gsmid) { return gsms[i]['gsm']; } } return null; } function getSize(sizeid) { for(var i = 0; i < sizes.length; i++) { if(sizes[i]['id'] == sizeid) { return sizes[i]['id']; } } return null; } function getBinding(bindingid) { for(var i = 0; i < binds.length; i++) { if(binds[i]['id'] == bindingid) { return binds[i]['name']; } } return null; } function getState(id) { for(var i = 0; i < states.length; i++) { if(states[i]['id'] == id) { return states[i]['name']; } } return null; } function getStatePhone(id) { for(var i = 0; i < states.length; i++) { if(states[i]['id'] == id) { return states[i]['phone']; } } return null; } function getColourAndFinishNames(id) { var a = id.split(';', 2); var colour = getColorName(a[0]); var finish = getFinName(a[1]); if (colour && finish) { return colour+' / '+finish; } else { return getColorName(id); } } function getPreDefinedWidthName(id) { for(var i = 0; i < preDefinedWidths.length; i++) { if(preDefinedWidths[i]['id'] == id) { return preDefinedWidths[i]['name']; } } return null; } function save_doggett_cookie(cookie_name, v) { setCookie(cookie_name, v, 300); } function get_doggett_cookie(cookie_name, form_element) { var z = getCookie(cookie_name) if (z != null && z != '') { return z; } else { return ''; } } function IsNumeric(sText) { var ValidChars = "0123456789."; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } function isMail(_email) { var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i return emailReg.test(_email); }