function sort_by(key,order){var type_of_page=$("#type_of_page").html();if($("#"+key).children(".arrow_up").attr("class")==null){$("#"+key).children(".arrow").addClass("arrow_up");$("#"+key).children(".arrow").removeClass("arrow");var order="asc"}else{$("#"+key).children(".arrow_up").addClass("arrow");$("#"+key).children(".arrow_up").removeClass("arrow_up");var order="desc"}var results_param="";$("#results_parameters").children("div").each(function(){results_param+="&parameter_"+$(this).children(".param_key").text()+"=";results_param+=$(this).children(".param_value").text()});$(".loader").show();var html=$.ajax({type:"POST",url:http_host+"/ajax/ajax_load_search_compare_results.php",data:"order_by="+key+"&asc_desc="+order+"&type_of_page="+type_of_page+results_param,success:function(){$(".loader").hide()},error:function(){$(".loader").hide()},async:false}).responseText;$("#search_compare_results").html(html);$("#"+key).parent(".sortable").children("a").each(function(){$(this).removeClass("active")});$("#"+key).addClass("active");call_back_list();count=0}function load_search_compare_results(pageid,nb_products){var type_of_page=$("#type_of_page").html();var results_param="";$("#results_parameters").children("div").each(function(){results_param+="&parameter_"+$(this).children(".param_key").text()+"=";results_param+=$(this).children(".param_value").text()});var key="";var order="";if($("div .sortable").children(".active").length!=0){key="&order_by="+$("div .sortable").children(".active").attr("id");if($("div .sortable").children(".active").children(".arrow_up").length!=0){order="&asc_desc=asc"}else{order="&asc_desc=desc"}}$(".loader").show();var html=$.ajax({type:"POST",url:http_host+"/ajax/ajax_load_search_compare_results.php",data:"pageid="+pageid+"&nb_products="+nb_products+"&type_of_page="+type_of_page+key+order+results_param,success:function(){$(".loader").hide()},error:function(){$(".loader").hide()},async:false}).responseText;$("#search_compare_results").html(html);count=0}var count=0;function select_checkbox(id){var tmp_count=0;$(".check").each(function(){if($(this).is(':checked')==true){tmp_count++}});if($("#checkbox_"+id).is(':checked')==true){count++;if(count>3){window.alert('You have selected '+count+' products and the limit is 3.');$("#checkbox_"+id).attr("checked",false);tmp_count--}else{$("#li_"+id).addClass("selected")}}else{$("#li_"+id).removeClass("selected")}if($("#checkbox_"+id).is(':checked')==false){count--;$("#checkbox_"+id).attr("checked",false)}if(count!=tmp_count){count=0;$(".check").each(function(){if($(this).is(':checked')==true){count++;if(count>3){window.alert('You have selected '+count+' products and the limit is 3.');$("#checkbox_"+id).attr("checked",false);count--;$("#checkbox_"+id).parent("li").removeClass("selected")}else{if($(this).parent("li").hasClass("selected")==false){$(this).parent("li").addClass("selected")}}}else{$(this).parent("li").removeClass("selected")}})}}function control_compare_plans(){if(count>1){$("#search_compare_form").submit()}else{count=0;$(".check").each(function(){if($(this).is(':checked')==true){count++;$(this).parent("li").addClass("selected")}});if(count<2){alert('You need to select at least two products to compare')}else{$("#search_compare_form").submit()}}}function show_hide_browse_nav(alias){$("#browse").children().find(".active").each(function(){$(this).removeClass("active")});$("#nav_"+alias).addClass("active");$(".browse_links").each(function(){$(this).css({display:"none"})});$("#browse_links_"+alias).css({display:"block"})}function submit_search_tool(){$(".comparison").each(function(){var tmp1=$(this).text();var tmp2=$(this).parent().parent().children().find(".upd").text();if($(this).parent().children(".comparison_unit").length!=0){tmp2=(tmp2+$(this).parent().children(".comparison_unit").text())}$(this).parent().children("input").val(tmp1+tmp2)});$("#search_tool").submit()}function radio_checkbox(id1,id2){if($("#"+id2).is(':checked')==true){$("#"+id2).attr("checked",false)}}function plan_enquire_now(){var error=0;var set_focus="";$("#submit_button").attr("disabled",true);var product_id=$("#product_id").val();var name=$("#name").val();if(name==""){error=1;$("#p_name").addClass("error");if(set_focus==""){set_focus='name'}}var email=$("#email").val();var valid=Validate_Email_Address(email);if(valid==false){error=1;$("#p_email").addClass("error");if(set_focus==""){set_focus='email'}}var phone=$("#phone").val();if(phone==""){error=1;$("#p_phone").addClass("error");if(set_focus==""){set_focus='phone'}}var location_id=$("#location_id").val();if(location_id==""){error=1;$("#p_location").addClass("error");if(set_focus==""){set_focus='location_id'}}var message=$("#message").val();if(message==""){error=1;$("#p_message").addClass("error");if(set_focus==""){set_focus='message'}}if($('#special_offers').is(':checked')==false){var special_offers='0'}else{var special_offers='1'}if(error==1){$("#submit_button").attr("disabled",false);if(set_focus!=""){$("#"+set_focus).focus()}}else{var html=$.ajax({type:"POST",url:http_host+"/ajax/ajax_plan_enquire_now.php",data:"name="+name+"&email="+email+"&phone="+phone+"&message="+message+"&product_id="+product_id+"&location_id="+location_id+"&special_offers="+special_offers,async:false}).responseText;$("#enquire_now").html(html)}}function check_captcha_contactus(){var captcha_code=$("#captcha_code").val();var sid=$("#session_id").val();var reload_form=$("#reload_form").val();if(reload_form!="1"){var html=$.ajax({type:"POST",url:http_host+"/ajax/ajax_check_captcha.php",data:"captcha_code="+captcha_code+"&SID="+sid,async:false}).responseText;check_captcha_response_contactus(html)}else{$("#submit_btn").attr("disabled",true);send_contact()}}function check_captcha_advertise(){var captcha_code=$("#captcha_code").val();var sid=$("#session_id").val();var reload_form=$("#reload_form").val();if(reload_form!="1"){var html=$.ajax({type:"POST",url:http_host+"/ajax/ajax_check_captcha.php",data:"captcha_code="+captcha_code+"&SID="+sid,async:false}).responseText;check_captcha_response_advertise(html)}else{$("#submit_btn").attr("disabled",true);send_advertise()}}function align_section(section_class){var height_section_one=0;$.each($('.'+section_class),function(){var height=parseInt($(this).css('height').replace("px",""));if(height>height_section_one){height_section_one=height}});$('.'+section_class).css('height',height_section_one+'px')}function align_section_ref(section_class,ref_class){var height_section_one=0;$.each($('.'+section_class),function(){if($(this).hasClass(ref_class)){if($(this).css('height')!="auto"){height_section_one=parseInt($(this).css('height').replace("px",""))}}});if(height_section_one!=0){$('.'+section_class).css('height',height_section_one+'px')}}function check_captcha_response_contactus(responseText){if(responseText=="true"){$("#submit_btn").attr("disabled",true);send_contact()}else{$("#p_captcha").addClass("error");$("#submit_btn").attr("disabled",false)}}function check_captcha_response_advertise(responseText){if(responseText=="true"){$("#submit_btn").attr("disabled",true);send_advertise()}else{$("#p_captcha").addClass("error");$("#submit_btn").attr("disabled",false)}}function send_contact(){var error=0;var set_focus="";var div_id="contact_us";var name;if((name=$("#name_contact").val())==""){error=1;$('#p_name_contact').addClass("error");if(set_focus==""){set_focus='name_contact'}}var phone;if((phone=$("#phone_contact").val())==""){error=1;$('#p_phone_contact').addClass("error");if(set_focus==""){set_focus='phone_contact'}}var email;email=$("#email_contact").val();valid=Validate_Email_Address(email);if(valid==false){error=1;$('#p_email_contact').addClass("error");if(set_focus==""){set_focus='email_contact'}}var subject=$("#subject_contact").val();var message;message=$("#comment_contact").val();if(error==1){$("#submit_btn").attr("disabled",false)}else{var html=$.ajax({type:"POST",url:http_host+"/ajax/ajaxSendMail.php",data:"name="+escape(name)+"&email="+escape(email)+"&phone="+escape(phone)+"&subject="+escape(subject)+"&message="+escape(message)+"&page=contact",async:false}).responseText;$("#contact_us").html(html)}}function send_advertise(){var error=0;var set_focus="";var div_id="advertise";var name;if((name=$("#name_contact").val())==""){error=1;$('#p_name_contact').addClass("error");if(set_focus==""){set_focus='name_contact'}}var phone;if((phone=$("#phone_contact").val())==""){error=1;$('#p_phone_contact').addClass("error");if(set_focus==""){set_focus='phone_contact'}}var email;email=$("#email_contact").val();valid=Validate_Email_Address(email);if(valid==false){error=1;$('#p_email_contact').addClass("error");if(set_focus==""){set_focus='email_contact'}}var message;message=$("#comment_contact").val();if(error==1){$("#submit_button").attr("disabled",false);if(set_focus!=''){$("#"+set_focus).focus()}}else{var html=$.ajax({type:"POST",url:http_host+"/ajax/ajaxSendMail.php",data:"name="+escape(name)+"&email="+escape(email)+"&phone="+escape(phone)+"&message="+escape(message)+"&page=advertise",async:false}).responseText;$("#advertise").html(html)}}function Validate_String(string,return_invalid_chars){valid_chars='1234567890-_.^~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';invalid_chars='';if(string==null||string=='')return(true);for(index=0;index<string.length;index++){char=string.substr(index,1);if(valid_chars.indexOf(char)==-1){if(invalid_chars.indexOf(char)==-1){if(invalid_chars=='')invalid_chars+=char;else invalid_chars+=', '+char}}}if(return_invalid_chars==true&&invalid_chars!=''){last_comma=invalid_chars.lastIndexOf(',');if(last_comma!=-1)invalid_chars=invalid_chars.substr(0,$last_comma)+' and '+invalid_chars.substr(last_comma+1,invalid_chars.length);return(invalid_chars)}else return(invalid_chars=='')}function Validate_Email_Address(email_address){at=email_address.indexOf('@');dot=email_address.indexOf('.');if(at==-1||dot==-1||dot==0||dot==email_address.length-1)return(false);user_name=email_address.substr(0,at);domain_name=email_address.substr(at+1,email_address.length);if(Validate_String(user_name)===false||Validate_String(domain_name)===false)return(false);return(true)}function deleteProduct(e){var product_div=$(e).parent().parent();var id=product_div.attr('id');$('#plan_info_'+id).children('.pink').find('.added').hide();$('#plan_info_'+id).children('.pink').find('.add_shortlist').show();var html=$.ajax({type:"POST",url:http_host+"/ajax/ajax_shortlist_cookie.php",data:"action=shortlist_unset_cookie&product_id="+id,async:false}).responseText;if(html=='ok_unset'){$(product_div).slideUp('',function(){$(this).remove();if($('.li_added').length==0){$('#form_tool').hide();$('.shortlist_sent').hide();$('.email_shortlist').hide();$('.shortlist_info').hide().fadeIn()}})}}function call_back_list(){$('.li_added').each(function(){var li_id=$(this).attr('id');$('#plan_info_'+li_id).children('.pink').find('.add_shortlist').hide();$('#plan_info_'+li_id).children('.pink').find('.added').show()})}function add_to_shortlist(e){if($('.li_added').length==0){$('.email_shortlist').fadeIn();$('.shortlist_info').hide()}$(e).hide();$(e).next('.added').show();var product_id=$(e).parent().parent().parent().attr('id');var html=$.ajax({type:"POST",url:http_host+"/ajax/ajax_shortlist_cookie.php",data:"action=shortlist_cookie&product_id="+product_id,async:false}).responseText;if(html=='ok'){var resp=$.ajax({type:"POST",url:http_host+"/ajax/ajax_get_product_details.php",data:"action=new&product_id="+product_id,async:false}).responseText;$(resp).appendTo($('.shortlist ul').find('li').end()).hide().slideDown()}return false}function check_contract(product_id,id,page,flag){var toCheck=false;var contract_length;var active_bundle_option="";var inactive_bundle_option="";var counter_active=0;var counter_inactive=0;if($("#chk_contract_"+product_id+"_"+id).is(':checked')==false){toCheck=false;contract_length=0}else{toCheck=true;contract_length=$("#chk_contract_"+product_id+"_"+id).val()}$("#chk_contract_"+product_id+"_"+id).parent().parent(".contract").children().children(".chk_contract").each(function(){$(this).attr("checked",false)});$("#chk_contract_"+product_id+"_"+id).attr("checked",toCheck);if(toCheck==false){if($("#chk_contract_"+product_id+"_"+contract_length).attr("id")==null){var tmp=new Array();var last=$("#chk_contract_"+product_id+"_"+id).parent().parent(".contract").children().children(".chk_contract:last").attr("id");if(last=="chk_contract_"+product_id+"_"+id){$("#chk_contract_"+product_id+"_"+id).parent().parent(".contract").children().children(".chk_contract:last").parent().prev().children(".chk_contract").attr("checked",true);contract_length=$("#chk_contract_"+product_id+"_"+id).parent().parent(".contract").children().children(".chk_contract:last").parent().prev().children(".chk_contract").val()}else{$("#"+last).attr("checked",true);contract_length=$("#"+last).val()}}else{contract_length=0}}if(page!="search_compare"){$("#chk_contract_"+product_id+"_"+id).parent().parent(".contract").parent(".more_on").children(".bundle").children().children(".chk_bundle").each(function(){if($(this).is(':checked')==true){counter_active++;active_bundle_option+="&active_bundle_option_"+counter_active+"="+$(this).val()}else{counter_inactive++;inactive_bundle_option+="&inactive_bundle_option"+counter_inactive+"="+$(this).val()}})}else{$("#chk_contract_"+product_id+"_"+id).parent().parent(".contract").parent(".disc").children(".bundle").children().children(".chk_bundle").each(function(){if($(this).is(':checked')==true){counter_active++;active_bundle_option+="&active_bundle_option_"+counter_active+"="+$(this).val()}else{counter_inactive++;inactive_bundle_option+="&inactive_bundle_option"+counter_inactive+"="+$(this).val()}})}$(".loader").show();var html=$.ajax({type:"POST",url:http_host+"/ajax/ajax_load_search_compare_results_plan.php",data:"product_id="+product_id+active_bundle_option+inactive_bundle_option+"&contract_length="+contract_length+"&page="+page+"&flag="+flag,success:function(){call_back_list();$(".loader").hide()},error:function(){$(".loader").hide()},async:false}).responseText;if(page=="plan_details"){$("#product_info_"+product_id).html(html)}else if(page=="detail_compare"){$("#detail_compare_"+product_id).html(html)}else if(page=="search_compare"){$("#li_"+product_id).html(html)}call_back_list()}function check_bundle(product_id,id,page,flag){var active_bundle_option="";var inactive_bundle_option="";var counter_active=0;var counter_inactive=0;var contract_length="";$("#chk_bundle_"+product_id+"_"+id).parent().parent(".bundle").children().children(".chk_bundle").each(function(){if($(this).is(':checked')){counter_active++;active_bundle_option+="&active_bundle_option_"+counter_active+"="+$(this).val()}else{counter_inactive++;inactive_bundle_option+="&inactive_bundle_option"+counter_inactive+"="+$(this).val()}});if(page!="search_compare"){$("#chk_bundle_"+product_id+"_"+id).parent().parent(".bundle").parent(".more_on").children(".contract").children().children(".chk_contract").each(function(){if($(this).is(':checked')==true){contract_length=$(this).val()}})}else{$("#chk_bundle_"+product_id+"_"+id).parent().parent(".bundle").parent(".disc").children(".contract").children().children(".chk_contract").each(function(){if($(this).is(':checked')==true){contract_length=$(this).val()}})}$(".loader").show();var html=$.ajax({type:"POST",url:http_host+"/ajax/ajax_load_search_compare_results_plan.php",data:"product_id="+product_id+active_bundle_option+inactive_bundle_option+"&contract_length="+contract_length+"&page="+page+"&flag="+flag,success:function(){$(".loader").hide()},error:function(){$(".loader").hide()},async:false}).responseText;if(page=="plan_details"){$("#product_info_"+product_id).html(html)}else if(page=="detail_compare"){$("#detail_compare_"+product_id).html(html)}else if(page=="search_compare"){$("#li_"+product_id).html(html)}call_back_list()}function display_terms(alias){var terms=window.open(http_host+"/terms-and-conditions/"+alias+".pdf","terms","width=600,height=400,top=200,left=200,toolbar=no,menubar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no");if(window.focus){terms.focus()}}$(document).ready(function(){if($(".top_banner").children("a").length==0&&$(".top_banner").children("object").length==0){$("body").addClass("no_banner")}if($('.shortlist').length>0){var resp=$.ajax({type:"POST",url:http_host+"/ajax/ajax_get_product_details.php",data:"action=load",async:false}).responseText;if(resp!=''){$('.shortlist ul').slideDown(500,function(){$(this).append(resp);if($('.li_added').length>0){call_back_list();$('.email_shortlist').fadeIn();$('.shortlist_info').hide()}})}else{$('.shortlist_info').fadeIn()}}$("#search_more_option").click(function(){if($("#search_tool_more_option").css("display")=="none"){$("#search_tool_more_option").show();$("#search_more_option").html("&lt; less options")}else{$("#search_tool_more_option").hide();$("#search_more_option").html("more options &gt;")}return false});$("#home_page_search_more_option").click(function(){if($(this).html()=='more options &gt;'){$(".tool").css('width','940px').hide().fadeIn();$("#home_page_search_more_option").html("&lt; less options")}else{$(".tool").css('width','290px').hide().fadeIn();$("#home_page_search_more_option").html("more options &gt;")}return false});$(".close_button").click(function(){$(".tool").css('width','290px').hide().fadeIn();$("#home_page_search_more_option").html("more options &gt;")});$(".locationAjaxPostcode ").each(function(){$(this).autocomplete(http_host+"/ajax/ajaxGetLocation.php",{delay:2,selectFirst:true,max:20,minChars:4,cacheLength:100,parse:function(data){tmp=$.evalJSON(data);parsed_data=[];for(i=0;i<tmp.length;i++){obj=tmp[i];parsed_data[i]={data:obj,value:obj.id,result:obj.name}}return parsed_data},formatItem:function(row,i,max){return row.name},formatMatch:function(row,i,max){return row.name},formatResult:function(row){return row.name}});$(this).result(function(event,data,formatted){$(this).parent().children(".hidden_location").val(data["id"])})});$(".slider").each(function(){$(this).slider({max:$(this).parent().children("input").attr("value"),min:parseInt($(this).parent().children(".min").html()),step:parseInt($(this).parent().children(".step").html()),value:parseInt($(this).parent().parent().children().find(".upd").html()),slide:function(e,ui){$(this).parent().parent().children().find(".upd").html(ui.value);if(ui.value==0){$(this).parent().parent().children(".display_1").css({display:"none"});$(this).parent().parent().children(".display_2").css({display:"block"});$(this).parent().parent().children(".display_3").css({display:"none"})}else{$(this).parent().parent().children(".display_1").css({display:"block"});$(this).parent().parent().children(".display_2").css({display:"none"});$(this).parent().parent().children(".display_3").css({display:"none"})}if(ui.value==$(this).slider('option','min')){if($(this).parent().parent().children().hasClass("display_3")){$(this).parent().parent().children(".display_1").css({display:"none"});$(this).parent().parent().children(".display_2").css({display:"none"});$(this).parent().parent().children(".display_3").css({display:"block"})}}}})});$('#form_tool').submit(function(){$.error=0;$.set_focus='';$("#submit_tool").attr("disabled",true);var name=$('#name_tool').val();if(name==''){$.error=1;$('#name_tool').addClass("error");if($.set_focus==""){$.set_focus='name_tool'}}var mail=$('#email_tool').val();if(mail==''){$.error=1;$('#email_tool').addClass("error");if($.set_focus==""){$.set_focus='email_tool'}}else{valid=Validate_Email_Address(mail);if(valid==false){$.error=1;$('#email_tool').addClass("error");$.set_focus='email_tool'}}var msg=$('#message_tool').val();if(msg==''){$.error=1;$('#message_tool').addClass("error");if($.set_focus==""){$.set_focus='message_tool'}}if($.error==1){if($.set_focus!=''){$("#"+$.set_focus).focus()}}else{var resp=$.ajax({type:"POST",url:http_host+"/ajax/ajax_send_shortlist.php",data:"action=send_shortlist&name="+name+"&mail="+mail+"&msg="+msg,async:false}).responseText;if(resp=='ok'){$('.shortlist_sent').fadeIn();$('#form_tool').hide();$('#name_tool').val('');$('#email_tool').val('');$('#message_tool').val('')}else if(resp=='black_listed'){$(".shortlist_black_list").fadeIn();$('#form_tool').hide();$('#email_tool').val('')}else{}}$("#submit_tool").attr("disabled",false);return false});$('.email_shortlist').click(function(){$(this).fadeOut(300,function(){$(this).hide()});$('.email_form').fadeIn();$('#form_tool').fadeIn();return false});$('.email_shortlist_click').click(function(){$(this).parent().hide();$('#form_tool').fadeIn();return false});$(".product_special").css({display:"block"});var handle;$(".hover_box").hover(function(){if($(this).attr("title").length!=0){$(this).attr("t",$(this).attr("title"));$(this).attr("title","");$(this).attr("alt","");if(!handle){handle=$('<div style="position:absolute" class="tooltip"></div>').appendTo($(this)).hide()}}handle.html($(this).attr("t")).fadeIn('fast')},function(){handle.hide()})});
