////////////////////////////////////////// // COPYRIGHT 2005 - M.H. & G.O. FOR CVP // ////////////////////////////////////////// //var form = ""; var buka = ""; var whereto = ""; var debugmode = "no"; var blahka =""; var delay_timeout =1000; var ajax_target = ""; var ajax_destination =""; function isdefined(variable) { return (typeof(window[variable]) == "undefined")? false: true; } function do_nothing(){ } function loading() { scroll(0,0); var temp = '

Loading



Please click here if it takes more than 5 seconds
' document.getElementById("content").innerHTML = temp; } function loading2(productID) { scroll(0,0); var temp = '

Loading



Please click here if it takes more than 5 seconds
' document.getElementById("content").innerHTML = temp; } function createXMLHttpRequest() { var ua; if(window.XMLHttpRequest) { try { ua = new XMLHttpRequest(); } catch(e) { ua = false; } } else if(window.ActiveXObject) { try { ua = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { ua = false; } } return ua; } var req = createXMLHttpRequest(); function sendRequest(id, pid) { req.open('get', 'basket_functions_ajax.php?do=' + id + 'pid=' + pid); req.onreadystatechange = handleResponse; req.send(null); } ////////////////////////////////////////////////////////////////////////////////////////////// function abort_the_bastard() { req.abort(); } function show_finance_option(finance_productID,order_zone,order_total,order_total_ex) { if (req.readyState > 0 && req.readyState < 4) req.abort(); // kill if 1,2,3 req.open('get', 'checkout_finance_ajax.php?finance_productID='+finance_productID+'&order_zone='+order_zone+'&order_total='+order_total+'&order_total_ex='+order_total_ex); req.onreadystatechange = handleResponse; req.send(null); } function update_header_basket() { abort_the_bastard(); req.open('get', 'header_basket.php?from=ajax', true); req.onreadystatechange = handleResponse; req.send(null); if (debugmode == 'yes') { alert('updating header basket'); } } function update_basket2() { // alert("fuckit"); req.open('get', 'basket_functions_ajax.php?do=update_small_basket', true); whereto= "yourbasket22"; req.onreadystatechange = handleResponse; req.send(null); } function show_bank(card) { abort_the_bastard(); req.open('get', 'bin_finder.php?do=find_bank&bin='+card); //, true whereto= "card"; req.onreadystatechange = handleResponse; req.send(null); } function check_company(postcode,company_number){ req.open('get', 'companies_house_parse2.php?comppostcode='+postcode+'&compnumber='+company_number); whereto= "company"; req.onreadystatechange = handleResponse; req.send(null); } function check_company3(postcode,company_number){ req.open('get', 'companies_house_parse3.php?comppostcode='+postcode+'&compnumber='+company_number); whereto= "company"; req.onreadystatechange = handleResponse; req.send(null); } function check_postcode(p) { var postcodeRegEx = /(^[A-Z]{1,2}[0-9]{1,2})([0-9][A-Z]{2}$)/i; var post=p.toUpperCase(); document.cvp.company_postcode.value=post.replace(postcodeRegEx,"$1 $2");; } function cvp_suggest(query,thediv){ ajax_target = thediv; req.open('get', 'cvp_search_suggest.php?q='+query+'&thediv='+thediv); req.onreadystatechange = handleResponse; req.send(null); } function check_search_content() { var content=document.searchy.q.value; if(content=='') { hide('livesearch'); } else { show('livesearch'); } } function cvp_mainsuggest(query,thediv){ ajax_target = 'mainsuggest'; req.open('get', 'cvp_search_suggest.php?q='+query+'&thediv='+thediv); req.onreadystatechange = handleResponse; req.send(null); } function check_search_content2() { var content=document.catsearch.q.value; if(content=='') { hide('mainsearch'); } else { show('mainsearch'); } } function yes_i_meant(suggestion,divname) { document.searchy.q.value=suggestion; var content=document.searchy.q.value; cvp_suggest(content,divname); } function check_vat(vat_number){ req.open('get', 'check_vat_ajax.php?vat_number='+vat_number); whereto= "vat_check"; req.onreadystatechange = handleResponse; req.send(null); } function gobasket(parameter){ /* THIS IS USED by add_to_basket */ if (isdefined(parameter)){ window.location=('checkout.secure.php?parameter=' + parameter); } else { window.location=('checkout.secure.php'); } } function gobasketop(productID){ /* THIS IS USED by add_to_basket */ if (isdefined(productID)){ window.location=('relatedISAPI.dll.php?pD=' + productID); } else { window.location=('relatedISAPI.dll.php'); } } function gocheckout(){ window.location='checkout.secure.php'; } function goquote(parameter){ if (isdefined(parameter)){ window.location=('view_quote.php?parameter=' + parameter); } else { window.location=('view_quote.php'); } } function gosubmitquote(){ window.location='submit_quote.php'; } function checkAll(field) { for (i = 0; i < field.length; i++) field[i].checked = true ; } function uncheckAll(field) { for (i = 0; i < field.length; i++) field[i].checked = false ; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// function add_to_basket(productID, qty) { var what = 'blahka = check_if_loaded(\'basket\');' loading(); abort_the_bastard() req.open('get', 'basket_functions_ajax.php?do=add_to_basket&productID='+productID+'@'+qty); req.onreadystatechange = handleResponse; req.send(null); if (debugmode == 'yes') { alert('adding to basket'); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// REMEMBER addbasket from now on function addbasket(productID, qty) { var what = 'blahka = check_if_loaded(\'basket\');' loading2(productID); abort_the_bastard() req.open('get', 'basket_functions_ajax.php?do=add_to_basket&productID='+productID+'@'+qty); // +'@X' the X triggers off the optional instead of the checkout immed. req.onreadystatechange = handleResponse; req.send(null); if (debugmode == 'yes') { alert('adding to basket'); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// function add_promo_to_basket(productID, qty, promoID) { loading(); abort_the_bastard(); req.open('get', 'basket_functions_ajax.php?do=add_promo_to_basket&productID='+productID+'@'+product_name+'@'+price+'@'+qty+'@'+promoID); req.onreadystatechange = handleResponse; req.send(null); setTimeout('gobasket();',delay_timeout); if (debugmode == 'yes') { alert('adding to basket'); } } //////////////////////////////////////////////////// function add_optional_to_basket(productID, qty) { // qty = document.add.quantity.options[document.add.quantity.selectedIndex].value abort_the_bastard() req.open('get', 'basket_functions_ajax.php?do=add_optional_to_basket&productID='+productID+'@'+qty); req.onreadystatechange = handleResponse; document.getElementById('bbutton'+productID).innerHTML = 'Remove item'; req.send(null); } function remove_optional_from_basket(productID) { req.open('get', 'basket_functions_ajax.php?do=remove_optional_from_basket&productID='+productID); req.onreadystatechange = handleResponse; document.getElementById('bbutton'+productID).innerHTML = 'Add to basket'; req.send(null); } function remove_from_basket(id) { // id=refID loading(); abort_the_bastard() req.open('get', 'basket_functions_ajax.php?do=remove_from_basket&refID='+id); req.onreadystatechange = do_nothing; req.send(null); setTimeout('gocheckout();',delay_timeout); } function updatequantity(id,qty) { // id=refID and manot need quantity if use document.form.quantity.options[etc loading(); abort_the_bastard() req.open('get', 'basket_functions_ajax.php?do=update_quantity&refID='+id+'&quantity='+qty); req.onreadystatechange = do_nothing; req.send(null); setTimeout('gocheckout();',delay_timeout); } function update_shipping(shippingID, orderID) { loading(); abort_the_bastard() req.open('get', 'basket_functions_ajax.php?do=update_shipping&shippingID='+shippingID+'&orderID='+orderID); req.onreadystatechange = do_nothing; req.send(null); setTimeout('gocheckout();',delay_timeout); if (debugmode == 'yes') { alert('updating shipping'); } } function update_postcode(postcode) { abort_the_bastard() req.open('get', 'basket_functions_ajax.php?do=update_postcode&postcode='+postcode); req.onreadystatechange = do_nothing; req.send(null); window.location='checkout.secure.php'; } function show_basket() { loading(); abort_the_bastard() req.open('get', 'basket_functions_ajax.php?do=show_basket'); req.onreadystatechange = do_nothing; req.send(null); setTimeout('gobasket();',delay_timeout); if (debugmode == 'yes') { alert('showing basket'); } } function checkout() { loading(); abort_the_bastard() req.open('get', 'basket_functions_ajax.php?do=checkout'); req.onreadystatechange = do_nothing; req.send(null); setTimeout('gocheckout();',delay_timeout); if (debugmode == 'yes') { alert('checkout'); } } ///////////////////////////////////////////////////////////////////////////////// QUOTE RELATED function show_small_quotation() { req.open('get', 'quote_functions_ajax.php?do=show_small_quotation', true); //req2.open('get', 'basket2.php'); if (debugmode == 'yes') { alert('Showing small quotation'); } // req.onreadystatechange = handleResponse; // req.send(null); } function show_quotation() { loading(); req.open('get', 'quote_functions_ajax.php?do=show_quotation'); //req.open('get', 'basket2.php'); if (debugmode == 'yes') { alert('Showing quotation'); } req.onreadystatechange = do_nothing; req.send(null); setTimeout('goquote();',delay_timeout); } function submit_quote() { loading(); req.open('get', 'quote_functions_ajax.php?do=submit_quote'); req.onreadystatechange = do_nothing; req.send(null); setTimeout('gosubmitquotequote();',delay_timeout); } function remove_from_quotation(id) { // id=refID loading(); req.open('get', 'quote_functions_ajax.php?do=remove_from_quotation&refID='+id); req.onreadystatechange = do_nothing; req.send(null); setTimeout('goquote();',delay_timeout); } function optional_quote(productID, product_name, price, qty, parentID, czeked) { var kontrola = czeked; if (kontrola == true){ add_optional_to_quotation(productID, product_name, price, qty, parentID); //setTimeout('show_small_quotation()',2000); } else { req.open('get', 'quote_functions_ajax.php?do=remove_optional_from_quotation&productID='+productID); req.onreadystatechange = do_nothing; req.send(null); // setTimeout('show_small_quotation()',2000); } } function add_optional_to_quotation(productID, product_name, price, qty, parentID) { // qty = document.add.quantity.options[document.add.quantity.selectedIndex].value req.open('get', 'quote_functions_ajax.php?do=add_optional_to_quotation&productID='+productID+'@'+product_name+'@'+price+'@'+qty+'&parentID='+parentID); req.onreadystatechange = do_nothing; req.send(null); } function add_to_quotation(productID, product_name, qty) { loading(); // qty = document.add.quantity.options[document.add.quantity.selectedIndex].value abort_the_bastard(); req.open('get', 'quote_functions_ajax.php?do=add_to_quotation&productID='+productID+'@'+product_name+'@'+qty); if (debugmode == 'yes') { alert('quote_functions_ajax.php?do=add_to_quotation&productID='+productID+'@'+product_name+'@'+qty); } req.onreadystatechange = do_nothing; req.send(null); setTimeout('goquote();',delay_timeout); } function updateqquantity(id,qty) { loading(); // id=refID and manot need quantity if use document.form.quantity.options[etc /* var qty = document.('form'+'id').('qty'+'id').value */ req.open('get', 'quote_functions_ajax.php?do=update_quantity&refID='+id+'&quantity='+qty); req.onreadystatechange = do_nothing; req.send(null); setTimeout('goquote();',delay_timeout); } function gimme_subcategories(categoryID){ req.open('get', 'gimme_subcategories.php?categoryID='+categoryID); req.onreadystatechange = handleResponse; req.send(null); } function gimme_package_details(url,div, mode){ if (mode == 'on'){ //'brief_package_info.php?packageID=$pak_proID' //'package_details$packageonpage$tabulator' ajax_target = 'package_details'; ajax_destination = 'package_details' + div; document.getElementById('package_title'+ div).href = "javascript:gimme_package_details('"+ url +"','"+ div +"','off');"; document.getElementById('plusminus'+div).innerHTML = ''; req.open('get', url); req.onreadystatechange = handleResponse; req.send(null); } else { ajax_target = 'package_details'; ajax_destination = 'package_details' + div; document.getElementById('package_title'+ div).href = "javascript:gimme_package_details('"+ url +"','"+ div +"','on');"; document.getElementById('plusminus'+div).innerHTML = ''; url2 = url + '&mode=brief'; req.open('get', url2); req.onreadystatechange = handleResponse; req.send(null); } } function show_stock_level(orderwise_code) { req.open('get', 'orderwise.web.api.php?orderwise_code='+orderwise_code); req.onreadystatechange = handleResponse; req.send(null) } function show_quantity_mic(productID) { req.open('get', 'show_the_quantity.php?do=show_public_quantity&productID='+productID); //req.open('get', 'basket2.php'); req.onreadystatechange = handleResponse; req.send(null); } function hide_quantity_mic(productID) { req.open('get', 'show_the_quantity.php?do=hide_public_quantity&productID='+productID); //req.open('get', 'basket2.php'); req.onreadystatechange = handleResponse; req.send(null); } function handleResponse() { if(req.readyState == 4){ var response = req.responseText; var update = new Array(); if(response.indexOf('||' != -1)) { update = response.split('||'); contentreturned = update[0]; variant = update[1]; if (debugmode == 'yes') { alert('variant: '+ variant); alert('contentreturned: ' + contentreturned); } if (variant == 'header_basket') { document.getElementById("header_basket").innerHTML = contentreturned; if (debugmode == 'yes') { alert('header_basket'); } } else if (variant == 'quotation'){ document.getElementById("yourquote22").innerHTML = contentreturned; if (debugmode == 'yes') { alert('yourquote22'); } } else if (variant == 'stock_status'){ document.getElementById("stock_status").innerHTML = contentreturned; } else if (variant == 'stock_checker'){ document.getElementById("stock_check_div").innerHTML = contentreturned; } else if (ajax_target =='livesearch') /* variant == 'livesearch' || */ { document.getElementById("livesearch").innerHTML = contentreturned; ajax_target = ''; } else if (ajax_target =='mainsearch') { document.getElementById("mainsearch").innerHTML = contentreturned; ajax_target = ''; } else if (variant == 'gimme_subcategories') { document.getElementById("gimme_subcategories").innerHTML = contentreturned; } else if (variant == 'menuajax') { alert(contentreturned); } else if(ajax_target == 'package_details'){ document.getElementById(ajax_destination).innerHTML = contentreturned; ajax_destination = ""; } else if (variant == 'quotationno'){ /* document.getElementById("yourquote22").innerHTML = "";*/ if (debugmode == 'yes') { alert('dont display, empty quote'); } } else if (variant == 'menu'){ document.getElementById("masterdiv").innerHTML = contentreturned; if (debugmode == 'yes') { alert('masterdiv'); } } else if (variant == 'vat_check'){ if(contentreturned=='no'){ document.getElementById('vat_reg_number').style.backgroundColor='#FF7D7D'; document.company_form.vat_check_button.value='Check'; } else if(contentreturned=='yes'){ document.getElementById('vat_reg_number').style.backgroundColor='#CCFFBB'; document.company_form.vat_check_button.value='Valid'; document.company_form.vat_check_button.disabled=true; // document.company_form.vat_reg_number_hidden.value = document.getElementById('vat_reg_number').value; // document.getElementById('vat_reg_number').disabled=true; } else { document.getElementById('vat_reg_number').style.backgroundColor='#ffffff'; document.company_form.vat_check_button.value='Check'; } //document.getElementById("vat_check").innerHTML = contentreturned; if (debugmode == 'yes') { alert('vat_check'); } } else if (variant == 'company'){ if(contentreturned=='no'){ document.getElementById('company_reg_number').style.backgroundColor='#FF7D7D'; document.company_form.company_check_button.value='Check'; } else if(contentreturned=='yes'){ document.getElementById('company_reg_number').style.backgroundColor='#CCFFBB'; document.company_form.company_check_button.value='Valid'; document.company_form.company_check_button.disabled=true; // document.getElementById('company_reg_number').disabled=true; } else { document.getElementById('company_reg_number').style.backgroundColor='#ffffff'; document.company_form.company_check_button.value='Check'; } //document.getElementById("company").innerHTML = contentreturned; if (debugmode == 'yes') { alert('company'); } } else if (variant == 'card'){ document.getElementById("card").innerHTML = contentreturned; if (debugmode == 'yes') { alert('card'); } } else if (variant == 'finance_div') { document.getElementById("finance_div").innerHTML = contentreturned; } else if (variant == 'add2berror') { gobasket(contentreturned); if (debugmode == 'yes') { alert('gobasket should launch now'); } } else if (variant == 'add2ops') { gobasketop(contentreturned); } else if (variant == 'add2qerror') { setTimeout('goquote(contentreturned);',delay_timeout); if (debugmode == 'yes') { alert('masterdiv'); } } else { if (variant != '' || ajax_target != '') { } else { document.getElementById("content").innerHTML = contentreturned; if (debugmode == 'yes') { alert('writing to content'); } } //blahka=''; } } } //alert("loading: " + req.readyState); } function handleEnter (field, event) { var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if (keyCode == 13) { var i; for (i = 0; i < field.form.elements.length; i++) if (field == field.form.elements[i]) break; i = (i + 1) % field.form.elements.length; field.form.elements[i].focus(); return false; } else return true; } function leftmenu_switch(divid, iState) { if (iState == '') { if (document.getElementById(divid).style.display == "block") { iState = 1; } else { iState = 0; } } // alert('set_menu.php?do=' + divid + '&what=' + iState); document.getElementById(divid).style.display = iState ? "none" : "block"; req.open('get', 'set_menu.php?do=' + divid + '&what=' + iState); req.onreadystatechange = do_nothing; req.send(null); var a = divid + "a"; document.getElementById(a).style.backgroundImage = iState ? "url('images/layout/play_off.gif')" : "url('images/layout/play_on.gif')"; }