/* +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= (c) InFX Solutions 2010 +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 */if(typeof(_infx)=="undefined")var _infx={};_infx.popups=function(params){this.bgcolor='#aaaaaa';for(var p in params){this[p]=params[p];}
this.maskerobj=null;this.frame=null;this.dialogue=null;this.y_with_scroll=null;this.x_with_scroll=null;this.rtnEl=function(id){return document.getElementById(id);}
this.create_masker=function(){this.maskerobj=this.rtnEl('masker');if(!this.maskerobj){this.maskerobj=document.createElement("div");this.maskerobj.setAttribute("id","masker");this.maskerobj.style.backgroundColor=this.bgcolor;if(this.frame){this.frame.appendChild(this.maskerobj);}else{document.body.appendChild(this.maskerobj);}}}
this.create_popup=function(){this.frame=this.rtnEl('popup_frame');this.dialogue=this.rtnEl('popup_dialog');if(!this.frame){this.frame=document.createElement("div");this.frame.setAttribute("id","popup_frame");document.body.appendChild(this.frame);}
if(!this.dialogue){this.dialogue=document.createElement("span");this.dialogue.setAttribute("id","popup_dialog");this.frame.appendChild(this.dialogue);}}
this.switch_masker=function(onoff){if(this.maskerobj==null){this.create_masker();}
if(this.maskerobj){this.setOpacity(this.maskerobj,70);this.maskerobj.style.visibility=(onoff==1)?'visible':'hidden';this.getPageSizeWithScroll();if(document.all){this.maskerobj.style.height=this.y_with_scroll;this.maskerobj.style.width=this.x_with_scroll;}else{this.maskerobj.style.height=(this.y_with_scroll)+'px';this.maskerobj.style.width=(this.x_with_scroll-((this.y_max_scroll>0)?0:15))+'px';}}}
this.switch_popup=function(onoff,inner_html){if(this.frame==null||this.dialogue==null){this.create_popup();}
if(this.frame&&this.dialogue){this.frame.style.visibility=(onoff==1)?'visible':'hidden';this.dialogue.innerHTML=inner_html;this.popup_form=this.rtnEl('popup_form');if(inner_html!=''&&this.popup_form){if(document.all){this.page_offset=document.documentElement.scrollTop||(document.body.scrollTop||0);this.window_height=document.documentElement.clientHeight;this.window_width=document.documentElement.clientWidth;}else{this.page_offset=window.pageYOffset||(document.body.scrollTop||0);this.window_height=window.innerHeight;this.window_width=window.innerWidth;}
this.dialogue_height=this.popup_form.clientHeight;this.dialogue_width=this.popup_form.clientWidth;var top=parseInt((this.window_height/2)-(this.dialogue_height/2))+this.page_offset;var left=parseInt((this.window_width/2)-(this.dialogue_width/2));if(document.all){this.popup_form.style.pixelTop=top;this.popup_form.style.pixelLeft=left;}else{this.popup_form.style.top=top+'px';this.popup_form.style.left=left+'px';}}}}
this.getPageSizeWithScroll=function(){this.x_max_scroll=0;if(window.innerHeight){this.y_with_scroll=window.innerHeight+window.scrollMaxY;this.x_with_scroll=window.innerWidth+window.scrollMaxX;this.x_max_scroll=window.scrollMaxX;}else if(document.body.scrollHeight>document.body.offsetHeight){this.y_with_scroll=document.body.scrollHeight;this.x_with_scroll=document.body.scrollWidth;}else{this.y_with_scroll=document.body.offsetHeight;this.x_with_scroll=document.body.offsetWidth;}
}
this.setOpacity=function(obj,opacity){opacity=(opacity==100)?99.999:opacity;obj.style.filter="alpha(opacity:"+opacity+")";obj.style.KHTMLOpacity=opacity/100;obj.style.MozOpacity=opacity/100;obj.style.opacity=opacity/100;}
this.fadeUp=function(obj_id,opacity,limit,fade_speed){if(!limit)limit=100;var obj=this.rtnEl(obj_id);if(obj){if(opacity<=limit){this.setOpacity(obj,opacity);opacity+=2.5;window.setTimeout("_infx.popup.fadeUp('"+obj_id+"',"+opacity+","+limit+","+fade_speed+");",fade_speed);}}}
this.fadeDown=function(obj_id,opacity,limit,fade_speed){var obj=this.rtnEl(obj_id);if(obj){this.setOpacity(obj,opacity);if(opacity>=limit){opacity-=2.5;window.setTimeout("_infx.popup.fadeDown('"+obj_id+"',"+opacity+","+limit+","+fade_speed+");",fade_speed);}}}
this.masker=function(onoff){this.switch_masker(onoff);}
this.layer=function(onoff,inner_html){this.switch_popup(onoff,inner_html);this.switch_masker(onoff);}
this.loading=function(onoff){this.switch_masker(onoff);this.maskerobj.innerHTML=(onoff)?"<div id='loading_frame' style=''><img src='/images/ajax-loader.gif' style='visibility:visible;'>&nbsp;</div>":"";}}
_infx.popup=new _infx.popups();if(typeof(_infx)=="undefined")var _infx={};_infx.cookie=function(){var info={};function read(){var nameEQ=info.name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function write(){if(info.days){var date=new Date();date.setTime(date.getTime()+(info.days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=info.name+"="+info.value+expires+"; path=/";}
return{create:function(jsonobj){info=jsonobj;write();},read:function(name){info.name=name;return read();},clear:function(name){info={name:name,value:'',days:-1};write();}};}();function ajax_request(site_url,callback){var http_request=false;if(window.XMLHttpRequest){http_request=new XMLHttpRequest();if(http_request.overrideMimeType){http_request.overrideMimeType('text/html');}}else if(window.ActiveXObject){try{http_request=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{http_request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
if(!http_request){alert('You are probably using the last version of Internet Explorer for the Mac which has been discontinued.');return false;}
http_request.onreadystatechange=function(){ajax_process_response(http_request,site_url,callback);};http_request.open('GET',site_url,true);http_request.send(null);}
function ajax_post_request(site_url,params,callback){var http_request=false;if(window.XMLHttpRequest){http_request=new XMLHttpRequest();if(http_request.overrideMimeType){http_request.overrideMimeType('text/html');}}else if(window.ActiveXObject){try{http_request=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{http_request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
if(!http_request){alert('You are probably using the last version of Internet Explorer for the Mac which has been discontinued.');return false;}
var parameters=make_url_params(params,0);http_request.onreadystatechange=function(){ajax_process_response(http_request,site_url,callback);};http_request.open('POST',site_url,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Content-length",parameters.length);http_request.setRequestHeader("Connection","close");http_request.send(parameters);}
function ajax_process_response(http_request,site_url,callback){if(http_request.readyState==4){if(http_request.status==200){if(http_request.responseText=='done'){window.location.href=unescape(window.location.pathname);}else{eval(callback);}}else{return false;}}}
function ajax_submit_form(json){var frmObj=rtnEl(json.frmname);if(frmObj){for(var n in json){var obj=frmObj[n];if(obj){obj.value=json[n];}}
var params={};var elements=frmObj.elements;for(var x=0;x<elements.length;x++){var el=elements[x];params[el.name]=el.value;}
if(json.val_list){if(verifylist(frmObj,json.val_list,json.error_panel)){ajax_post_request(json.script,params,json.callback);}}else{ajax_post_request(json.script,params,json.callback);}}else{alert("Can't find form with name "+json.frmname);}}
function ajax_fill_data(fill_id,returned){if(document.getElementById(fill_id)){document.getElementById(fill_id).innerHTML=returned;}}
function ajax_populate_form(fill_id,form_id,returned){if(document.getElementById(fill_id)){document.getElementById(fill_id).innerHTML=returned;if(document.forms[form_id]){document.forms[form_id].submit();}}}
function ajax_request_form(fill_id,type){ajax_request("/cgi-bin/payment-control.pl?ac=ajax_form&type="+type,"ajax_populate_form('"+fill_id+"','dynamic_form',http_request.responseText);");}
function make_url_params(params_obj,first){var s='';for(p in params_obj){var sep=(first||first==null)?'?':'&';first=0;s+=sep+p+'='+encodeURI(params_obj[p]);};return s;}var system='/cgi-bin/ecommerce/system.pl';var search_script='/cgi-bin/ecommerce/search.pl';var product_script='/cgi-bin/ecommerce/product.pl';var event_script='/cgi-bin/ecommerce/event.pl';var advert_widget='/cgi-bin/infxwidgets/widget-adverts.pl';var basket_widget='/cgi-bin/infxwidgets/widget-basket.pl';var login_widget='/cgi-bin/infxwidgets/widget-login.pl';var profile_widget='/cgi-bin/infxwidgets/widget-profile.pl';var review_widget='/cgi-bin/infxwidgets/widget-review.pl';var payment_control='/cgi-bin/payment-control.pl';var newsletter_signup='/cgi-bin/newsletter.pl';var send_info='/cgi-bin/send-info.pl';var system_state='';var basket_state='';var last_search='';var search_timeout;var ticket_array={};var concession_array={};var multi_add_items=new Array();function rtnEl(id){return document.getElementById(id);}
function submit_form(json){var frmObj=rtnEl(json.frmname);if(frmObj){for(var n in json){var obj=rtnEl(n);if(obj){obj.value=json[n];}else if(n!='frmname'&&n!='val_list'&&n!='error_panel'){alert("Can't Set "+n+" in "+json.frmname+" to "+json[n]);}}
if(json.val_list){if(verifylist(frmObj,json.val_list,json.error_panel))frmObj.submit();}else{frmObj.submit();}}else{alert("Can't find form with name "+json.frmname);}}
function dynamicaly_post_form(json){var frmObj=document.createElement('form');frmObj.setAttribute('action',json.action);frmObj.setAttribute('method','POST');frmObj.name='dynamic_form';frmObj.id='dynamic_form';for(var p in json.elements){var obj=rtnEl(json.elements[p]);if(obj){var input=document.createElement("input");input.name=obj.name;if(json.override){input.setAttribute('value',((json.override[obj.name])?json.override[obj.name]:obj.value));}else{input.setAttribute('value',obj.value);}
input.setAttribute('type','hidden');frmObj.appendChild(input);}}
document.body.appendChild(frmObj);document.forms['dynamic_form'].submit();}
function signup_for_newsletter(type,message){if(rtnEl('signup_name')){rtnEl('signup_name').value=(rtnEl('signup_name').value=='Your Name')?"":rtnEl('signup_name').value;}
if(rtnEl('signup_email')){rtnEl('signup_email').value=(rtnEl('signup_email').value=='your@email.com')?"":rtnEl('signup_email').value;}
if(validate_single_field(rtnEl('signup_email'),{'signup_email':'email'})){var name=(rtnEl('signup_name'))?rtnEl('signup_name').value:rtnEl('signup_email').value;var json={ac:'subscribe',json:1,name:name,email:rtnEl('signup_email').value,signup_type:type,successtext:escape(message)};ajax_post_request(newsletter_signup,json,"newsletter_callback('newsletter_signup',http_request.responseText);");}}
function newsletter_callback(id,jsonstr){var json;eval("json = "+jsonstr+";");if(rtnEl(id))rtnEl(id).innerHTML="<b>"+json.title+"</b><br/>"+json.message;}
function send_page_to_a_friend(message){if(rtnEl('friend_email')){rtnEl('friend_email').value=(rtnEl('friend_email').value=='friends.name@email.com'||rtnEl('friend_email').value=='their-name@email.com')?"":rtnEl('friend_email').value;}
if(validate_single_field(rtnEl('friend_email'),{'friend_email':'email'})){var json={ac:'send_to_a_friend',friends_email:rtnEl('friend_email').value,recommended_page:location.href,successtext:message};ajax_post_request(send_info,json,"ajax_fill_data('send_to_a_friend',http_request.responseText);");}}
function findPos(obj){var curleft=curtop=0;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}while(obj=obj.offsetParent);}
return[curleft,curtop];}
function keyCheck(e,checkcode){var keycode=(window.event)?event.keyCode:e.keyCode;return(keycode==checkcode)?true:false;}
function join_objects(){for(var x=1;x<arguments.length;x++){for(var p in arguments[x]){arguments[0][p]=arguments[x][p];}}}
function BC_datachange(obj,lcb_fieldname){if(rtnEl('datachange'))rtnEl('datachange').value=1;rtnEl(lcb_fieldname).value='';}
function toggle_panels(id_list,force){var id_array=id_list.split(',');for(var x=0;x<id_array.length;x++){toggle_panel(id_array[x],force);}}
function toggle_panel(id,force){var obj=rtnEl(id);if(obj)obj.style.display=(obj.style.display=='none'||force==1)?'block':'none';}
function toggle_panel_visibility(id,force){var obj=rtnEl(id);if(obj)obj.style.visibility=(obj.style.visibility=='hidden'||force==1)?'show':'hidden';}
function panel_control(id,display){var obj=rtnEl(id);if(obj)obj.style.display=display;}
function load_page(href){var check=location.href;check=check.replace(location.protocol+"//"+location.host,"");if(href!=check&&location.href!=href)location.href=href;}
function login_refresh(){_infx.popup.layer(0,'');window.location.reload(true);}
function login_popup(json){if(json.ac!=''){ajax_post_request(login_widget,json,"popup_callback(http_request.responseText)");}}
function profile_popup(json){if(json.ac!=''){if(json.sendform)add_form_to_json(json,json.sendform);ajax_post_request(profile_widget,json,"popup_callback(http_request.responseText)");}}
function popup_callback(jsonstr){var json;eval("json = "+jsonstr+";");if(json.ac=='display_dialog'){_infx.popup.layer(1,json.dialog_html);}else if(json.ac=='refresh'){window.location.reload(true);}else if(json.ac=='safe_refresh'){var href=location.href;href=href.replace(/#.*$/,'');href=href.replace(/\?.*$/,'');location.href=href+'?time='+(new Date()).getTime();}}
function option_list_popup(json){if(json.ac!=''){ajax_post_request(product_script,json,"option_list_callback(http_request.responseText)");}}
function option_list_callback(jsonstr){var json;eval("json = "+jsonstr+";");if(json.ac=='display_dialog'){_infx.popup.layer(1,json.dialog_html);}}
function add_form_to_json(json,formid){var frmobj=rtnEl(formid);var elements=frmobj.getElementsByTagName('input');for(var x=0;x<elements.length;x++){json[elements[x].id]=elements[x].value;}
var selectors=frmobj.getElementsByTagName('select');for(var x=0;x<selectors.length;x++){json[selectors[x].id]=selectors[x].value;}}
function write_review_popup(json){if(json.ac!=''){ajax_post_request(review_widget,json,"write_review_callback(http_request.responseText)");}}
function write_review_callback(jsonstr){var json;eval("json = "+jsonstr+";");if(json.ac=='display_dialog'){_infx.popup.layer(1,json.dialog_html);$('input[@type=radio].star').rating();}else if(json.ac=='refresh'){window.location.reload(true);}}
function quote_request(json){if(json.ac!=''){ajax_post_request(product_script,json,"quote_request_callback(http_request.responseText)");}}
function quote_request_callback(jsonstr){var json;eval("json = "+jsonstr+";");if(json.ac=='display_dialog'){_infx.popup.layer(1,json.dialog_html);}}
function control_payment_gateways(json){var payment_type=rtnEl('payment_type');if((json.type==''||json.type==undefined)&&payment_type)json.type=payment_type.value;else payment_type.value=json.type;if(json.highlight==1){var payment_method_fieldset=rtnEl('payment_method');var options=payment_method_fieldset.getElementsByTagName('div');for(var x=0;x<options.length;x++){options[x].className=(options[x].id=='payment_gateway_'+json.type)?'option_on':'option_off';}}
if(json.reset_selector==1){var card_select=rtnEl('select_card_detail_id');if(card_select)card_select.selectedIndex=0;}
if(json.submit==1){_infx.popup.masker(1);ajax_request_form('dynamic_form_div',json.type);}else if(json.load_form){var params={};params.ac='load_form';params.form_type=json.load_form;params.type=json.type;if(rtnEl('mode')){params.mode=rtnEl('mode').value;}
ajax_post_request(payment_control,params,"callback_fill_payment_form('"+json.type+"','"+json.highlight+"',http_request.responseText);");}else{if(json.type=='paypal'||json.type=='google'){var payment_form_div=rtnEl('payment_form');payment_form_div.innerHTML='';}
if(json.highlight==1){display_checkout_button(json.type);}}}
function display_checkout_button(type){var checkout_button=rtnEl('checkout_button');if(checkout_button){var checkout_button_text=rtnEl('checkout_button_text');if(checkout_button_text)checkout_button_text.innerHTML=((type=='paypal')?'Checkout with Paypal':((type=='google')?"Checkout with Google":"Checkout"));if(type!='')checkout_button.onclick=function(){submit_form({'frmname':'main_form','val_list':validate,'ac':'process_payment','ac_type':'save_client'});}
else	checkout_button.onclick=function(){}
checkout_button.title=((type=='')?'Please select a payment method before clicking on checkout.':'Click here to continue.');_infx.popup.setOpacity(checkout_button,((type!='')?100:40));if(checkout_button.style)checkout_button.style.cursor=((type!='')?'pointer':'default');}}
function callback_fill_payment_form(type,highlight,jsonstr){var json;eval("json = "+jsonstr+";");ajax_fill_data('payment_form',json.html);if(highlight==1){display_checkout_button(type);}
_infx.popup.loading(0);}
function search_control(json){if(json.searchtxt!=''){json.searchtxt=unescape(json.searchtxt);if(json.searchtxt!=last_search||(json['search._start']||json['search._limit'])){if(rtnEl('search_spinner'))rtnEl('search_spinner').style.visibility=(json.searchtxt!='')?'visible':'hidden';last_search=json.searchtxt;json.mode='ajax';ajax_post_request(search_script,json,"display_search_results('search_results',http_request.responseText);");}}else{display_search_results('search_results','');}}
function display_search_results(fill_id,jsonstr){var json;if(jsonstr=='')return;eval("json = "+jsonstr+";");if(document.getElementById(fill_id)){if(rtnEl('search_spinner'))rtnEl('search_spinner').style.visibility='hidden';document.getElementById(fill_id).innerHTML=json.content+json.hidden;}}
function modify_basket_item(json){json.ac='modify_item';var validate={};validate[json.validate]='numeric';delete json.validate;var container_div;if(json.element_container!=''){container_div=rtnEl(json.element_container);}
if(!container_div)container_div=rtnEl('detail');if(container_div&&json.ignore!='options'){var elements=container_div.getElementsByTagName('select');for(var x=0;x<elements.length;x++){json[elements[x].id]=elements[x].value;}}
if(validate_single_field(rtnEl(json.validate),validate)){_infx.popup.layer(0,'');mini_basket_spinner(1);ajax_post_request(basket_widget,json,"basket_callback(http_request.responseText);");}}
function modify_basket_quantity(json){json.ac='modify_quantity';var validate={};validate[json.validate]='numeric';if(validate_single_field(rtnEl(json.validate),validate)){mini_basket_spinner(1);delete json.validate;if(json.mini){ajax_post_request(basket_widget,json,'mini_basket_control(\''+json.mode+'\');');}else{ajax_post_request(basket_widget,json,'update_basket();');}}}
function remove_promo_code(json){json.ac='remove_promo_code';var confirm=window.confirm('Do you really want to remove this promotional code from your order?');if(confirm)ajax_post_request(basket_widget,json,'update_basket();');}
function add_promo_code(json){json.ac='add_promo_code';var validate={};validate[json.validate]='text';if(validate_single_field(rtnEl(json.validate),validate)){if(json.popup_message){ajax_post_request(basket_widget,json,'promo_callback_with_popup_message(http_request.responseText);');}else{ajax_post_request(basket_widget,json,'promo_callback(http_request.responseText);');}}}
function promo_callback(jsonstr){var json;eval("json = "+jsonstr+";");update_basket();display_message(json.message,json.message_style);}
function promo_callback_with_popup_message(jsonstr){var json;eval("json = "+jsonstr+";");update_basket();_infx.popup.layer(1,"<div id='popup_form' style='width:450px;padding:0px;'><div class='close' onmousedown=\"_infx.popup.layer(0,'');\" title='Close this popup'>&nbsp;<\/div><h2 style='margin:0px;'>Add Promo Code<\/h2><div id='message' style='margin:0px;background-color:"+json.message_style+";width:437px;'>"+json.message+"<\/div><div class='clear'><\/div><\/div>");}
function remove_basket_item(json){json.ac='remove_from_basket';if(json.mini){mini_basket_spinner(1);ajax_post_request(basket_widget,json,'mini_basket_control(\''+json.mode+'\');');}else{mini_basket_spinner(1);ajax_post_request(basket_widget,json,'update_basket();');}}
function collect_items(json){var obj=rtnEl(json.target);if(obj){var cnt=0;var elements=obj.getElementsByTagName('input');for(var x=0;x<elements.length;x++){if(elements[x].name.indexOf("qty_")!=-1){var bits=elements[x].name.match(/.*qty_(.*)$/);if(elements[x].value>0&&bits[1]){var options=rtnEl('option_string_'+bits[1]).value.split(',');var json={'quantity':elements[x].value,'product_id':json.product_id,'ignore_options':1};for(var y=0;y<options.length;y++){var obits=options[y].split('=');json['option_'+obits[0]]=obits[1];}
multi_add_items.push(json);cnt++;}}}
if(cnt==0)alert('Please ensure you have entered a quantity into at least one of the boxes.');}}
function multiple_add_to_basket(){if(multi_add_items.length>0){mini_basket_spinner(1);var item=multi_add_items.shift();item.multiple_add=1;add_to_basket(item);}else{mini_basket_control(basket_state);}}
function add_to_basket(json){json.ac='add_to_basket';json.mode=basket_state;var validate={};validate[json.validate]='numeric';if(rtnEl('minibasket')&&rtnEl('basket'))alert('Hmmmm we have both basket types on this page.. Should only ever have one!');if(rtnEl('minibasket')){json.mini=1;}
var option_div=rtnEl('options_'+json.product_id);if(option_div&&json.ignore_options!=1){var elements=option_div.getElementsByTagName('select');for(var x=0;x<elements.length;x++){json[elements[x].id]=elements[x].value;}}
if(validate_single_field(rtnEl(json.validate),validate)){delete json.validate;_infx.popup.layer(0,'');ajax_post_request(basket_widget,json,'basket_callback(http_request.responseText);');}}
function basket_callback(jsonstr){var json;eval("json = "+jsonstr+";");if(json.message&&json.message!=''&&json.ac!='add_next_item'){_infx.popup.layer(1,"<div id='popup_form' style='width:460px;padding-top:8px;'><div class='"+((json.message_class)?json.message_class:"add_to_basket_message")+"'>"+json.message+"</div></div>");window.setTimeout(function(){_infx.popup.layer(0,'');},((json.message_delay&&json.message_delay!='')?json.message_delay:1000));}
if(json.ac=='display_options'){_infx.popup.layer(1,json.option_html);}else if(json.ac=='display_event_options'){_infx.popup.layer(1,json.event_option_html);if(json.event_javascript!='')eval(json.event_javascript);}else if(json.ac=='update_mini_basket'){mini_basket_control(json.mode);}else if(json.ac=='add_next_item'){multiple_add_to_basket();}else if(json.ac=='update_basket'){update_basket();}else if(json.ac=='checkout_redirect'){location.href='/checkout/';}}
function mini_basket_control(mode){var json={};json.ac=(mode=='expand')?'mini_basket_expand':'mini_basket';basket_state=mode;mini_basket_spinner(1);ajax_post_request(basket_widget,json,"basket_control_callback('minibasket','"+mode+"',http_request.responseText);");}
function mini_basket_spinner(onoff){var obj=rtnEl('mini_basket_spinner');if(obj)obj.style.display=(onoff==1)?'block':'none';if(rtnEl('basket_open'))rtnEl('basket_open').style.display=(onoff!=1)?'block':'none';}
function basket_control_callback(fill_id,mode,returned){ajax_fill_data(fill_id,returned);if(mode=='expand'){_infx.popup.fadeUp(fill_id,70,95,100);}else{_infx.popup.fadeDown(fill_id,95,70,100);}}
function flash_basket(id){setTimeout(function(){_infx.popup.fadeUp(id,70,95,100);},50);setTimeout(function(){_infx.popup.fadeDown(id,95,70,100);},750);}
function update_basket(){var json={};json.ac='basket';ajax_post_request(basket_widget,json,"main_basket_callback('basket',http_request.responseText);");}
function main_basket_callback(fill_id,returned){var checkout_form=rtnEl('form');if(returned.indexOf("<!--[EMPTY BASKET]-->")!=-1){if(checkout_form)checkout_form.style.display='none';}else{if(checkout_form)checkout_form.style.display='block';}
ajax_fill_data(fill_id,returned);}
function delay_submit_search(value){var ac='search';if(search_timeout)clearTimeout(search_timeout);value=escape(value);if(arguments[1]!=null){ac=arguments[1];}
search_timeout=setTimeout(function(){search_control({'searchtxt':value,'ac':ac});},750);}
function close_search(value){ajax_fill_data('search_results','');}
function update_dyn_date(field,selects){var obj=rtnEl(field);if(obj){var select_array=selects.split(',');var s1=rtnEl(select_array[0]);var s2=rtnEl(select_array[1]);obj.value=s1.value+'/'+s2.value;}}
function change_card_detail(json){if(json.card_detail_id!=-1){var params={};params.ac='load_form';params.form_type='card';params.mode=system_state;params['F_card_detail.id']=json.card_detail_id;ajax_post_request(payment_control,params,"callback_change_card_detail('payment_form',http_request.responseText);");}else{var obj=rtnEl('payment_type');if(obj)obj.value='';control_payment_gateways({'type':'','highlight':1});var payment_form_div=rtnEl('payment_form');if(payment_form_div)payment_form_div.innerHTML='';}}
function callback_change_card_detail(target_id,jsonstr){var json;eval("json = "+jsonstr+";");control_payment_gateways({'type':json.type,'highlight':1});ajax_fill_data(target_id,json.html);}
function copy_billing_to_delivery(){var delivery_fieldset=rtnEl('delivery_address');var elements=delivery_fieldset.getElementsByTagName('input');for(var x=0;x<elements.length;x++){var delivery_id=elements[x].id;if(delivery_id=='F_delivery_address.delivery_name'){var tobj=rtnEl('F_client.title');var fnobj=rtnEl('F_client.forename');var snobj=rtnEl('F_client.surname');if(tobj&&fnobj&&snobj)elements[x].value=((tobj.value==-1)?"":tobj.value)+" "+fnobj.value+" "+snobj.value;}else if(delivery_id!='F_delivery_address.id'&&delivery_id!='F_delivery_address.delivery_country_id'){var billing_id=delivery_id.replace('_delivery_address','_client');billing_id=billing_id.replace('delivery_','billing_');var obj=rtnEl(billing_id);if(obj)elements[x].value=obj.value;}}
var selectors=delivery_fieldset.getElementsByTagName('select');for(var x=0;x<selectors.length;x++){var delivery_id=selectors[x].id;if(delivery_id!='select_delivery_address_id'){var billing_id=delivery_id.replace('_delivery_address','_client');billing_id=billing_id.replace('delivery_','billing_');var obj=rtnEl(billing_id);var changed=0;var options=selectors[x].options;for(var y=0;y<options.length;y++){if(options[y].value==obj.value){var old_val=selectors[x].value;options[y].selected=true;if(selectors[x].onchange&&options[y].value!=-1&&old_val!=obj.value)selectors[x].onchange();changed=1;}}
if(!changed)alert("Sorry not all fields could be copied.");}}
var updated_obj=rtnEl('F_delivery_address.updated');if(updated_obj)updated_obj.value='';}
function update_state(json){json.ac='basket';ajax_post_request(basket_widget,json,"main_basket_callback('basket',http_request.responseText);");}
function update_delivery_charge(json){json.ac='basket';ajax_post_request(basket_widget,json,"main_basket_callback('basket',http_request.responseText);");_infx.popup.layer(1,"<div id='popup_form' style='width:650px;height:25px;padding-top:8px;'><div class='information_message'>Your changes may of affected the delivery charge please check before proceeding</div></div>");window.setTimeout(function(){_infx.popup.layer(0,'');},2000);}
function change_delivery_address(json){json.ac='ajax_change_delivery_address';json.dataview=(json.profile)?2:1;ajax_post_request(system,json,"callback_delivery_address('"+((json.profile)?'profile_delivery_address':'delivery_address')+"','"+json.profile+"',http_request.responseText);");}
function set_default_delivery_address(json){json.ac='set_default_delivery_address';ajax_post_request(profile_widget,json,"profile_popup({'ac':'delivery_addresses_dialog'});");}
function remove_delivery_address(json){json.ac='remove_delivery_address';ajax_post_request(profile_widget,json,"profile_popup({'ac':'delivery_addresses_dialog'});");}
function callback_delivery_address(target_id,profile,jsonstr){var json;eval("json = "+jsonstr+";");ajax_fill_data(target_id,json.html);if(profile!='true')_infx.popup.loading(0);}
var current_option;function change_product_option(json){if(typeof pMatchPictureOption=='function')pMatchPictureOption(json.product_id);if(json.ac=='update_stock'&&!rtnEl('stock_level_'+json.product_id))return;if(json.ac=='update_stock'||json.ac=='update_price'){var option_div=rtnEl('options_'+json.product_id);if(option_div){var elements=option_div.getElementsByTagName('select');for(var x=0;x<elements.length;x++){json[elements[x].id]=elements[x].value;}}}
if(json.option_select_div){current_option=json.option_select_div;delete json.option_select_div;}
ajax_post_request(product_script,json,"callback_change_product_option(http_request.responseText);");}
function callback_change_product_option(jsonstr){var json;eval("json = "+jsonstr+";");for(var p in json){if(p.indexOf("option_select_")!=-1){if(current_option)current_option.innerHTML=json[p];}else{ajax_fill_data(p,json[p]);}}}
function display_message(text,bgcolor){var mobj=rtnEl('message');if(mobj){mobj.style.display='block';mobj.innerHTML=text;mobj.style.backgroundColor=bgcolor;}}
function email(name,domain,suffix,text){var address=name+"\u0040"+domain+"."+suffix;var url="mailto:"+address;document.write("<a href=\""+url+"\">"+((!text)?address:text)+"</a>");}
function switch_advert_category(type,amount,target,category,control_type){var json={};json.type=type;json.dir=(type=='smallads')?'/dyn/_smallads/':'/dyn/_mainads/';json.amount=amount;json.category=category;json.control_type=control_type;json.ajax=1;ajax_post_request(advert_widget,json,"advert_callback('"+target+"',http_request.responseText);");}
function advert_callback(target,jsonstr){var json;eval("json = "+jsonstr+";");ajax_fill_data(json.control_type,json.control_html);ajax_fill_data(target,json.content);}
function checkout_form_control(config){var element;var state_or_county_input=((config.type=='delivery')?'delivery_state_or_county_input':'billing_state_or_county_input');if(config.ac=='change_state'){if(config.type=='delivery')update_delivery_charge({'delivery_state':config.state_id});}else if(config.ac=='change_country'){var dyn_element_prefix=((config.type=='delivery')?"F_delivery_address":"F_client");var tab_index=((config.type=='delivery')?"108":"133");if(config.country_id==13||config.country_id==38||config.country_id==226){if(config.country_id==13){element=rtnEl(((config.type=='delivery')?'delivery_post_code_text':'billing_post_code_text'));if(element)element.innerHTML='Postcode';}else if(config.country_id==38){element=rtnEl(((config.type=='delivery')?'delivery_post_code_text':'billing_post_code_text'));if(element)element.innerHTML='Postal Code';}else if(config.country_id==226){element=rtnEl(((config.type=='delivery')?'delivery_post_code_text':'billing_post_code_text'));if(element)element.innerHTML='Zip Code';}
var ajax_json={};ajax_json.ac='ajax_drop_down';ajax_json.drop_down_type='state';ajax_json.country_id=config.country_id;ajax_json.tab_index=tab_index;ajax_json.form_type=config.type;ajax_json.element_name=dyn_element_prefix+"."+((config.type=='delivery')?"delivery_state_id":"billing_state_id");ajax_post_request(payment_control,ajax_json,"checkout_form_callback('"+state_or_county_input+"',http_request.responseText);");}else{element=rtnEl(((config.type=='delivery')?'delivery_post_code_text':'billing_post_code_text'));if(element)element.innerHTML='Postcode';element=rtnEl(state_or_county_input);if(element){var dyn_element_name=((config.type=='delivery')?"delivery_county":"billing_county");element.innerHTML="<label for='County'>County <span class='astrix'>*</span></label><br /><input class='textbox' name='"+dyn_element_prefix+"."+dyn_element_name+"' id='"+dyn_element_prefix+"."+dyn_element_name+"' tabindex='"+tab_index+"' onchange=\"BC_datachange(this,'"+dyn_element_prefix+".updated');\" value=''/>";}}
if(config.type=='delivery')update_delivery_charge({'delivery_country':config.country_id});}}
function checkout_form_callback(target,jsonstr){var json;eval("json = "+jsonstr+";");if(json.success){ajax_fill_data(target,json.prefix+json.html);}}
function stop_propagation(event){if(!event)var event=window.event;event.cancelBubble=true;if(event.stopPropagation)event.stopPropagation();return false;}
function remove_link_focus(){for(var i=0;i<document.links.length;i++)document.links[i].onfocus=blur_link;}
function blur_link(){if(this.blur)this.blur();}
function BC_cbxv(obj,nm,offval,onval){var ipobj=gfindobj(obj,nm);var cbobj=gfindobj(obj,"CB_"+nm);if(!cbobj||!ipobj)return 0;if(cbobj.checked){ipobj.value=onval;}else{ipobj.value=offval;}
return 1;}
function gfindobj(obj,reqid){for(var p in obj.childNodes){var cobj=obj.childNodes[p];if(cobj&&cobj.id!=null){if(cobj.id==reqid)return cobj;}
if(cobj&&(cobj.childNodes)&&(cobj.childNodes.length>0)){var ob=gfindobj(cobj,reqid);if(ob)return ob;}}
return null;}
function toggle_filter_display(element,id,type){var target=rtnEl(id);if(type=='options'){target.style.display=(target.style.display!='none')?'none':'inline';element.innerHTML=(target.style.display=='none')?'More...':'Less';}else if(type=='rows'){var morerowtxt=rtnEl('morerowtxt');target.style.display=(target.style.display!='none')?'none':'inline';morerowtxt.innerHTML=(target.style.display=='none')?'More rows':'Less rows';}}
function format_currency(expr){return format_currency_commas(format_decimal_places(expr,2));}
function format_currency_commas(nStr){nStr+='';x=nStr.split('.');x1=x[0];x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2');}
return x1+x2;}
function format_decimal_places(expr,decplaces){var str=""+Math.round(eval(expr)*Math.pow(10,decplaces));while(str.length<=decplaces){str="0"+str;}
var decpoint=str.length-decplaces
var decimal=".";if(decplaces==0){decimal="";}
return str.substring(0,decpoint)+decimal+str.substring(decpoint,str.length);}
if(window.attachEvent){window.attachEvent('onload',remove_link_focus);}
else{window.addEventListener('load',remove_link_focus,false);}
var useBSNns;if(useBSNns)
{if(typeof(bsn)=="undefined")
bsn={}
var _bsn=bsn;}
else
{var _bsn=this;}
_bsn.Crossfader=function(divs,fadetime,delay)
{this.nAct=-1;this.aDivs=divs;for(var i=0;i<divs.length;i++){if(document.getElementById(divs[i]))document.getElementById(divs[i]).style.opacity=0;if(document.getElementById(divs[i]))document.getElementById(divs[i]).style.position="absolute";if(document.getElementById(divs[i]))document.getElementById(divs[i]).style.filter="alpha(opacity=0)";if(document.getElementById(divs[i]))document.getElementById(divs[i]).style.visibility="hidden";}
this.nDur=fadetime;this.nDelay=delay;this.bPlay=1;this.queue=-1;this.nDelayCnt=0;var p=this;this.nID1=setInterval(function(){p._timer()},this.nDelay/100);this._newfade();}
_bsn.Crossfader.prototype._timer=function()
{if(this.bPlay)this.nDelayCnt++;if(this.nDelayCnt>100&&!this.fading){this._newfade();}}
_bsn.Crossfader.prototype._selectfade=function(idx)
{this.queue=idx;this.nDelayCnt=101;this.bPlay=0;this.nDur=100;}
_bsn.Crossfader.prototype._newfade=function()
{this.nDelayCnt=0;this.nOldAct=this.nAct;this.nAct++;if(this.queue>-1){this.nAct=this.queue;this.queue=-1;}
if(!this.aDivs[this.nAct])this.nAct=0;if(this.nAct==this.nOldAct)
return false;if(document.getElementById(this.aDivs[this.nAct]))document.getElementById(this.aDivs[this.nAct]).style.visibility="visible";this.nInt=50;this.nTime=0;var p=this;this.fading=1;this.nID2=setInterval(function(){p._fade()},this.nInt);}
_bsn.Crossfader.prototype._play=function()
{this.bPlay=1;this.nDelayCnt=100;}
_bsn.Crossfader.prototype._fade=function()
{this.nTime+=this.nInt;var ieop=Math.round(this._easeInOut(this.nTime,0,1,this.nDur)*100);var op=ieop/100;if(document.getElementById(this.aDivs[this.nAct]))document.getElementById(this.aDivs[this.nAct]).style.opacity=op;if(document.getElementById(this.aDivs[this.nAct]))document.getElementById(this.aDivs[this.nAct]).style.filter="alpha(opacity="+ieop+")";if(this.nOldAct>-1)
{if(document.getElementById(this.aDivs[this.nOldAct]))document.getElementById(this.aDivs[this.nOldAct]).style.opacity=1-op;if(document.getElementById(this.aDivs[this.nOldAct]))document.getElementById(this.aDivs[this.nOldAct]).style.filter="alpha(opacity="+(100-ieop)+")";}
if(this.nTime>=this.nDur)
{clearInterval(this.nID2);this.fading=0;if(this.nOldAct>-1)
if(document.getElementById(this.aDivs[this.nOldAct]))document.getElementById(this.aDivs[this.nOldAct]).style.visibility="hidden";if(this.queue>-1){this._selectfade(this.queue);this.queue=-1;}
var p=this;this.nDelayCnt=0;}}
_bsn.Crossfader.prototype._easeInOut=function(t,b,c,d)
{return c/2*(1-Math.cos(Math.PI*t/d))+b;}
var widget_script='/cgi-bin/infxwidgets/widget-node-navigation.pl';var timeouts=new Array();timeouts['product_navigation']=null;timeouts['product_finder']=null;timeouts['product_breadcrumb']=null;timeouts['product_breadcrumb_open']=null;function truncate(s,l){if(s.length>l){s=s.substring(0,l-3)
for(var j=s.length;j>0;j--){if(s.charAt(j)==";")j=-1
if(s.charAt(j)=="&")return s.substring(0,j)+"...";}
return s+"...";}
return s;}
function create_menu(json,node_id,whatisit,first){var cat=_ext.JSON.decode(json);var string=(first)?"<ul id='"+whatisit+"_ul_"+node_id+"'>":"<ul id='"+whatisit+"_ul_"+node_id+"' class='sub'>";for(var p in cat){var mover="onmouseover=do_menu('"+cat[p].id+"',1,"+cat[p].leaf+",'"+whatisit+"')";var mout="onmouseout=do_menu('"+cat[p].id+"',0,"+cat[p].leaf+",'"+whatisit+"')";var sub_div="<div class='sub' id='"+whatisit+"_"+cat[p].id+"'><\/div>";var text_div="<div "+mover+" "+mout+" onclick='navigate_menu("+_ext.JSON.encode(cat[p])+");'>"+truncate(cat[p].text,25)+"<\/div>";var cls=(p!=(cat.length-1))?"border":"";if(!parseInt(cat[p].leaf)){string+="<li id='"+whatisit+"_li_"+cat[p].id+"' class='folder "+cls+"'>"+sub_div+""+text_div+"<\/li>";}else{string+="<li id='"+whatisit+"_li_"+cat[p].id+"' class='file "+cls+"'>";string+="<div "+mover+" "+mout+" onclick='navigate_menu("+_ext.JSON.encode(cat[p])+");'>";string+=truncate(cat[p].text,25);string+="<\/div>";string+="<\/li>";}}
string+="<\/ul>";rtnEl(whatisit+'_'+node_id).innerHTML=string;if(cat.length>0){rtnEl(whatisit+'_'+node_id).style.visibility="visible";rtnEl(whatisit+'_ul_'+node_id).style.visibility="visible";}}
function do_menu(node_id,isover,isleaf,whatisit){if(isover){timeout_menu_types(0,whatisit);var li_el=rtnEl(whatisit+'_li_'+node_id);alter_class(li_el,'hilite','add');var el=rtnEl(whatisit+'_'+node_id);if(el){el.style.display='inline';if(el.innerHTML==""){ajax_post_request(widget_script,{'menu_node':node_id},"create_menu(http_request.responseText,'"+node_id+"','"+whatisit+"',0);");}else{hide_grand_children(node_id,whatisit);if(el.childNodes[0].childNodes.length>0){rtnEl(whatisit+'_ul_'+node_id).style.visibility="visible";rtnEl(whatisit+'_ul_'+node_id).style.display="block";}}
}
hide_brother_children(node_id,whatisit);}else{timeout_menu_types(1,whatisit);}}
function hide_grand_children(node_id,whatisit){div_node=rtnEl(whatisit+'_'+node_id);if(div_node.childNodes[0]){for(var i=0;i<div_node.childNodes[0].childNodes.length;i++){var el=div_node.childNodes[0].childNodes[i];alter_class(el,'hilite','remove');if(el.childNodes[1]){el.childNodes[0].style.visibility="hidden";el.childNodes[0].style.display="none";}}}}
function hide_brother_children(node_id,whatisit){li_node=rtnEl(whatisit+'_li_'+node_id);div_parent=li_node.parentNode.parentNode;for(var i=0;i<div_parent.childNodes[0].childNodes.length;i++){var el=div_parent.childNodes[0].childNodes[i];if(el.id!=whatisit+'_li_'+node_id){alter_class(el,'hilite','remove');if(el.childNodes[1]){el.childNodes[0].style.visibility="hidden";el.childNodes[0].style.display='none';}}}}
function find_breadcrumb(breadcrumb_node){ajax_post_request(widget_script,{'breadcrumb_node':breadcrumb_node},"create_breadcrumb(http_request.responseText,"+breadcrumb_node+",'product_breadcrumb',0);");}
function create_breadcrumb(json,node_id,whatisit){var s=_ext.JSON.decode(json);var string="<ul>";string+="<li class='top'><a href='/index.shtml'>Home</a><\/li> ";while(s.child){string+=" <span class='divider'>&#187;</span> <div class='menu' id='"+whatisit+"_"+s.id+"'><\/div> <li id='"+whatisit+"_li_"+s.id+"' onmouseover=\"delayed_display_menu('"+s.id+"',1,'"+whatisit+"',2000);\" onmouseout=delayed_display_menu('"+s.id+"',0,'"+whatisit+"',0) class='top'><a href='#navigate-to' onmousedown='navigate_menu("+_ext.JSON.encode(s)+");'>"+s.name+"</a><\/li>";s=s.child;}
string+="<\/ul>";rtnEl('product_breadcrumb').innerHTML=string;}
function delayed_display_menu(node_id,over,whatisit,delay){if(timeouts['product_breadcrumb_open'])clearTimeout(timeouts['product_breadcrumb_open']);if(over){timeouts['product_breadcrumb_open']=setTimeout("display_menu('"+node_id+"',"+over+",'"+whatisit+"')",delay);}else{display_menu(node_id,over,whatisit);}}
function display_menu(node_id,over,whatisit){timeout_menu_types(0,whatisit);var el=rtnEl(whatisit+'_li_'+node_id);if(over){alter_class(el,'hilite','add');alter_class(el,'active','add');if(rtnEl(whatisit+'_'+node_id)){if(rtnEl(whatisit+'_'+node_id).innerHTML==""){ajax_post_request(widget_script,{'first_menu_node':node_id},"create_menu(http_request.responseText,'"+node_id+"','"+whatisit+"',1);");}
close_menu(node_id,whatisit);hide_grand_children(node_id,whatisit);}}else{alter_class(el,'hilite','remove');alter_class(el,'active','add');timeout_menu_types(1,whatisit);}}
function create_finder(finder_node,over){var whatisit="product_finder";if(over){timeout_menu_types(0,whatisit);var mycontainer=rtnEl(whatisit);if(!rtnEl(whatisit+"_"+finder_node)){var myfirstul=document.createElement("div");myfirstul.setAttribute("id",whatisit+"_"+finder_node);mycontainer.appendChild(myfirstul);ajax_post_request(widget_script,{'menu_node':finder_node},"create_menu(http_request.responseText,'"+finder_node+"','"+whatisit+"',1);");}
else{rtnEl(whatisit+"_"+finder_node).style.display="inline";hide_grand_children(finder_node,whatisit);}}else{timeout_menu_types(1,whatisit);}}
function navigation(parent_node,option,type){var callback_function=(option)?"create_menu":"create_navigation";var whatisit=(type)?type:"product_navigation";var mycontainer=rtnEl(whatisit);if(!rtnEl(whatisit+"_"+parent_node)){var myfirstdiv=document.createElement("div");myfirstdiv.setAttribute("id",whatisit+"_"+parent_node);mycontainer.appendChild(myfirstdiv);ajax_post_request(widget_script,{'menu_node':parent_node},callback_function+"(http_request.responseText,'"+parent_node+"','"+whatisit+"',1);");}}
function create_navigation(json,node_id,whatisit){var cat=_ext.JSON.decode(json);var string;string="<ul id='"+whatisit+"_ul_"+node_id+"'>";for(var p in cat){var click="onclick='navigate_menu("+_ext.JSON.encode(cat[p])+");'";var mover="onmouseover=navigation_hilite('"+cat[p].id+"',1,'"+whatisit+"')";var mout="onmouseout=navigation_hilite('"+cat[p].id+"',0,'"+whatisit+"')";var text_div="<div "+click+" "+mover+" "+mout+">"+truncate(cat[p].text,25)+"<\/div>";var cls=(p!=(cat.length-1))?"border":"";string+=(!parseInt(cat[p].leaf))?"<li id='"+whatisit+"_li_"+cat[p].id+"' class='folder "+cls+"'>"+text_div+"<\/li>":"<li id='"+whatisit+"_li_"+cat[p].id+"' class='file "+cls+"'><div "+mover+" "+mout+" onclick='navigate_menu("+_ext.JSON.encode(cat[p])+");'>"+truncate(cat[p].text,25)+"<\/div><\/li>";string+="";}
string+="<\/ul>";rtnEl(whatisit+'_'+node_id).innerHTML=string;if(cat.length>0){rtnEl(whatisit+'_'+node_id).style.visibility="visible";rtnEl(whatisit+'_ul_'+node_id).style.visibility="visible";}}
function navigation_hilite(node_id,over,whatisit){alter_class(rtnEl(whatisit+"_li_"+node_id),'hilite',(over)?'add':'remove');}
function close_menu(node_id,whatisit){var container=rtnEl(whatisit);for(var i=0;i<container.childNodes[0].childNodes.length;i++){var el=container.childNodes[0].childNodes[i];if(el.tagName){if(el.tagName.toLowerCase()=='div'){el.style.display=(el.id!=whatisit+'_'+node_id)?'none':'inline';}
else if(el.tagName.toLowerCase()=='li'){if(el.id!=whatisit+'_li_'+node_id){alter_class(el,'active','remove');}}}}}
function alter_class(element,classname,action){if(element){var classRegEx=new RegExp(" "+classname,"g");element.className=element.className.replace(classRegEx,"");if(action=='add')element.className+=" "+classname;}}
function close_menu_types(node_id,whatisit){if(whatisit.indexOf('finder')!=-1){var obj=rtnEl(whatisit+"_0");if(obj)obj.style.display="none";}else if(whatisit.indexOf('navigation')!=-1){var container=rtnEl(whatisit);var ul_elements=container.getElementsByTagName('ul');for(var x=0;x<ul_elements.length;x++){if(x==0){var li_elements=ul_elements[x].getElementsByTagName('li');for(var y=0;y<li_elements.length;y++){alter_class(li_elements[y],'hilite','remove');}}else{ul_elements[x].style.display='none';}}
}else if(whatisit.indexOf('breadcrumb')!=-1){close_menu(node_id,whatisit);}}
function debug(text){var panel=rtnEl('debug_panel');panel.innerHTML+=text+"<br>";}
function timeout_menu_types(set,whatisit){if(!set){clearTimeout(timeouts[whatisit]);timeouts[whatisit]=null;}else{timeouts[whatisit]=setTimeout("close_menu_types('ul_0','"+whatisit+"');",1000);}}
function navigate_menu(node){if(typeof(node.post)=='object'){var form=document.createElement("form");form.action=node.action;form.method='post';form.id=_ext.id();for(var p in node.post){var el=document.createElement("input");el.type="hidden";el.name=p;el.value=(_ext.isObject(node.post[p]))?_ext.JSON.encode(node.post[p]):node.post[p];form.appendChild(el);}
document.body.appendChild(form);form.submit();}else{if(node.link!=null&&node.link!='')location.href=node.link;}}
var errorTxt="Some of the fields below are required or the information given is not valid, for further information move your mouse over the highlighted boxes below.";var urlRegxp=/^((http|https):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i
var emailRegxp=/^([\w_-]+)(\.[\w_-]+)*@([\w_-]+)(\.[\w_-]*){0,1}(\.[a-zA-Z]{2,4}){1,2}$/;var pcodeRegxp=/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {0,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/i;var dateRegxp=/^([0-9]){1,2}[\/|:|-]{1}([0-9]){1,2}[\/|:|-]([0-9]){4}$/;var dateTimeRegxp=/^([0-9]){1,2}[\/|:|-]{1}([0-9]){1,2}[\/|:|-]([0-9]){4} [0-9]{2}:{1}[0-9]{2}$/;var carddateRegxp=/^([0-9]){1,2}[\/|:|-]{1}([0-9]){1,2}$/;var passwordRegxp=/^[a-zA-Z0-9]{6,20}$/;var timeRegxp=/^[0-9]{2}:{1}[0-9]{2}$/;var usernameReqxp=/[a-zA-Z0-9]{3,20}/;var secureusernameReqxp=/^[a-zA-Z0-9\-]{6,20}$/;var currencyRegxp=/^\d+(\.\d{1,2})?$/;var telnoRegxp=/^(^[0-9\+ \-\)\(]+)$/
var numericRegxp=/^([0-9]+)$/;var notblankRegxp=/[a-zA-Z_0-9]+/;var ignoretagsRegxp=/fieldset/i;var validate={};function verifylist(formobj,chklist){var fail=0;var debug=0;var result_array=new Array();for(var i=0;i<formobj.length;i++){var e=formobj.elements[i];if(ignoretagsRegxp.test(e.tagName)==true||e.tagName=='')continue;var valobj={};var robj={};robj.debug='';var val=chklist[e.name];if(typeof val=='string'){valobj.type=val;}else{valobj=val;}
robj.debug+="Field: "+e.name;if(valobj){robj.element=e;robj.alt_tag='';robj.good=0;robj.type=valobj.type;robj.debug+=" ("+valobj.type+")";if((isdisplayed(e)&&e.type!='hidden')||valobj.hidden){robj.debug+=" Visible";validate_field_value(robj,valobj);}else{robj.debug+=" Invisible";robj.good=1;}
result_array.push(robj);}else{robj.debug+=" (NOT IN CHECKLIST)\n";}}
var debugTxt="";for(var x=0;x<result_array.length;x++){var robj=result_array[x];if(robj.type=='radio'){var nm=robj.element.name;for(var y=0;y<result_array.length;y++){var chk_robj=result_array[y];if(chk_robj.element.name==nm){if(robj.good==1||chk_robj.good==1){robj.good=1;chk_robj.good=1;}}}}
if(robj.good)robj.debug+=" - GOOD\n";else robj.debug+="\n  "+robj.alt_tag+" - ERROR\n";if(robj.good==0){hilite_error(robj);fail=1;}else if(robj.good==1){clear_error(robj);}
debugTxt+=robj.debug;}
if(debug)alert(debugTxt);display_error_dialogue(errorTxt,fail,1);return(fail)?false:true;}
function validate_single_field(e,chklist){if(!e)return 1;var valobj={};var val=chklist[e.name];if(typeof val=='string'){valobj.type=val;}else{valobj=val;}
var robj={};robj.element=e;robj.alt_tag='';robj.good=0;robj.type=valobj.type;if(valobj){if(isdisplayed(e)){validate_field_value(robj,valobj);}else{robj.good=1;}}
if(robj.good==0)hilite_error(robj);else if(robj.good==1)clear_error(robj);return robj.good;}
function validate_field_value(robj,valobj){var value='';if(valobj.type!="wordcount"&&valobj.type!="text"&&valobj.type!="postcode"&&valobj.type!="datetime"){value=robj.element.value.replace(/ /g,'');if(valobj.type=="currency"){value=value.replace(/[^0-9]*/g,'');}else if(valobj.type!="email"&&valobj.type!="numeric"&&valobj.type!="meters"){value=value.replace(/\./g,'');value=value.replace(/\,/g,'');}}else{value=robj.element.value;}
value=trim(value);if(valobj.type=="text"){if((valobj.optional==1)&&(value=='')||(value!="")&&(!isBlank(value))){robj.good=1;}else{robj.alt_tag="This is a required field";}}
else if(valobj.type=="payment_type"){if(value!=''){robj.good=1;}else{alert('Please select a payment method before clicking on checkout.');}}
else if(valobj.type=="username"){if(usernameReqxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Username must be between 3 - 20 characters long and contain only letters and numbers.";}}
else if(valobj.type=="secure_username"){if(secureusernameReqxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Username must be between 6 - 20 characters long and contain only letters, numbers and hyphens.";}}
else if(valobj.type=="password"){if(passwordRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Password must be between 6 - 20 characters long and contain only letters and numbers.";}}
else if(valobj.type=="checkbox"){robj.good=1;}
else if(valobj.type=="select-one"){if(robj.element.value!="-1"||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Please select a value from the pulldown menu";robj.good=0;}}
else if(valobj.type=="radio"){if(robj.element.checked||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Please select at least one of these options";}}
else if(valobj.type=="agree"){if(robj.element.checked){robj.good=1;}else{robj.alt_tag="Please tick to agree";}}
else if(valobj.type=="date"){if(dateRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Date format must be eg. dd/mm/yyyy";}}
else if(valobj.type=="datetime"){if(dateTimeRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Date time format must be eg. dd/mm/yyyy hh:mm";}}
else if(valobj.type=="card_date"){if(carddateRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Please make a selection from this drop down.";}}
else if(valobj.type=="time"){if(timeRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Time format must be in 24hr format eg. 16:00";}}
else if(valobj.type=="numeric"){if(numericRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Value entered should only contain digits eg. 1234";}}
else if(valobj.type=="csv"){if((numericRegxp.test(value)==true&&(value.length==3||value.length==4))||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Your security code should be either 3 or 4 digits.";}}
else if(valobj.type=="card_number"){if(numericRegxp.test(value)==true&&(value.length>=12&&value.length<=19)||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Please ensure you have entered your card number correctly.";}}
else if(valobj.type=="meters"){if(numericRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Fabrics can only be purchased in whole meters.";}}
else if(valobj.type=="currency"){if(currencyRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Must contain a positive currency value eg. 10.99";}}
else if(valobj.type=="postcode"){if(pcodeRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Ensure postcode is valid eg. BN27 2GH";}}
else if(valobj.type=="telephone"){value=value.replace(/ /g,'');if(telnoRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Ensure this is a valid phone number.";}}
else if(valobj.type=="http"){if(urlRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Please ensure you have entered a valid web address.";}}
else if(valobj.type=="email"){if(emailRegxp.test(value)==true||(valobj.optional==1&&value=='')){robj.good=1;}else{robj.alt_tag="Ensure this is a valid email address eg. somebody@domain.co.uk";}}
else if(valobj.type=="cm"||(valobj.optional==1&&value=='')){value=value.replace(/cm/,'');if(numericRegxp.test(value)==true){robj.good=1;}else{robj.alt_tag="This should be a value in cm eg. 100cm";}}
else{alert('Element ('+robj.element.name+') has unknown validation type! ('+valobj.type+')');robj.good=1;}
if(valobj.change_case){if(valobj.change_case=='upper'){value=value.toUpperCase();}else if(valobj.change_case=='lower'){value=value.toLowerCase();}else if(valobj.change_case=='capitalise'){value='Coming soon to a validate script near you';}}
if(valobj.minimum!=null){if(value>=valobj.minimum){robj.alt_tag="Entered value is below the minimum of "+valobj.minimum;robj.good=0;}}
if(valobj.maximum!=null){if(value<=valobj.maximum){robj.alt_tag="Entered value is above the maximum of "+valobj.maximum;robj.good=0;}}
if(valobj.round_up){value=parseInt((value*valobj.round_up)/valobj.round_up);}
if(valobj.round_down){value=(value/valobj.round_down)*valobj.round_down;}
if(valobj.expiry_date){var today=new Date();var mnth=rtnEl('dyn_expiry_month');var year=rtnEl('dyn_expiry_year');today.setDate(1);if(mnth.value!=-1&&year.value!=-1){var checkdate=new Date();checkdate.setFullYear(parseInt('20'+year.value),(mnth.value-1),2);if(checkdate>today){clear_error({'element':mnth,'alt_tag':''});clear_error({'element':year,'alt_tag':''});}else{var errstr="This card has expired please ensure you have entered the information correctly.";hilite_error({'element':mnth,'alt_tag':errstr});hilite_error({'element':year,'alt_tag':errstr});robj.good=0;}}}
if(valobj.start_date){var today=new Date();var mnth=rtnEl('dyn_start_month');var year=rtnEl('dyn_start_year');today.setDate(2);if(mnth.value!=-1&&year.value!=-1){var checkdate=new Date();checkdate.setFullYear(parseInt('20'+year.value),(mnth.value-1),1);if(checkdate<today){clear_error({'element':mnth,'alt_tag':''});clear_error({'element':year,'alt_tag':''});}else{var errstr="This card is not active yet please ensure you have entered the information correctly.";hilite_error({'element':mnth,'alt_tag':errstr});hilite_error({'element':year,'alt_tag':errstr});robj.good=0;}}}
if(valobj.conf_email){var errstr="Please ensure both email address fields match before continuing";var confObj=rtnEl(valobj.conf_email);if(confObj){var test=(value==confObj.value)?1:0;if(test){clear_error({'element':confObj,'alt_tag':''});}else{robj.alt_tag=(robj.good)?errstr:robj.alt_tag;hilite_error({'element':confObj,'alt_tag':errstr});robj.good=0;}}else{alert("No email confirmation email field with id: "+valobj.conf_email);}}
if(valobj.checkifblank){if(robj.good==0){var cobj={};cobj.element=rtnEl(valobj.checkifblank.name);cobj.alt_tag='';cobj.good=0;cobj.type=valobj.checkifblank.type;var cvalobj={}
cvalobj.type=valobj.checkifblank.type;if(cobj.element){validate_field_value(cobj,cvalobj);}else{cobj.good=0;}
robj.good=cobj.good;}}
if(valobj.onerrorhilite){var elements=valobj.onerrorhilite.split(',');for(var x=0;x<elements.length;x++){var obj=rtnEl(elements[x]);if(robj.good){clear_error({'element':obj,'alt_tag':''});}else{hilite_error({'element':obj,'alt_tag':robj.alt_tag});}}}
robj.element.value=value;}
function clear_error(robj){if(robj.type='radio'&&rtnEl(robj.element.name+"_div"))robj.element=rtnEl(robj.element.name+"_div");if(robj.element.style)robj.element.style.backgroundColor="";if(robj.element.style)robj.element.style.color="";robj.element.backgroundColor="";robj.element.color="";robj.element.title=(robj.alt_tag)?robj.alt_tag:"";robj.element.alt=(robj.alt_tag)?robj.alt_tag:"";}
function hilite_error(robj){if(robj.type='radio'&&rtnEl(robj.element.name+"_div"))robj.element=rtnEl(robj.element.name+"_div");if(robj.element.style)robj.element.style.backgroundColor="#AD3D36";if(robj.element.style)robj.element.style.color="#ffffff";robj.element.backgroundColor="#AD3D36";robj.element.color="#ffffff";robj.element.title=(robj.alt_tag)?robj.alt_tag:"";robj.element.alt=(robj.alt_tag)?robj.alt_tag:"";if(robj.element.attachEvent){robj.element.attachEvent('onchange',function(){clear_error({'element':this});});}
else{robj.element.addEventListener('change',function(){clear_error({'element':this});},false);}}
function display_error_dialogue(error,fail,scroll){var errorDivObj=rtnEl('message');if(errorDivObj){var display=(fail)?'block':'none';errorDivObj.style.display=display;errorDivObj.innerHTML=error;}
if(scroll)window.scrollTo(0,0);}
function trim(s){s=s.replace(/ $/g,'');s=s.replace(/^ /g,'');return s;}
function isBlank(s){if(s==''){return true}
return!notblankRegxp.test(s);}
function isdisplayed(node){var n=0;var fnd=0;while(fnd==0){if(n>1){node=node.parentNode;}
if(node){if(node.style){if(node.style.display){if(node.style.display=='block'){fnd=0;}
if(node.style.display=='none'){fnd=1;}}}}else{fnd=3;}
if(n>20){return true;}
n++;}
if(fnd==1){return false;}
if(fnd==0||fnd==3){return true;}}
if(typeof(_ext)=="undefined")var _ext={};var idSeed=0;_ext.toString=Object.prototype.toString;_ext.apply=function(o,c){if(o&&c&&typeof c=='object'){for(var p in c){o[p]=c[p];}}}
_ext.Element=function(element,forceNew){var dom=typeof element=="string"?document.getElementById(element):element,id;if(!dom)return null;id=dom.id;if(!forceNew&&id&&_ext.Element.cache[id]){return _ext.Element.cache[id];}
this.dom=dom;this.id=id||_ext.id(dom);};_ext.Element.cache={};_ext.apply(_ext,{id:function(el,prefix){return(el=_ext.getDom(el)||{}).id=el.id||(prefix||"ext-gen")+(++idSeed);},get:function(el){var ex,elm,id;if(!el){return null;}
if(typeof el=="string"){if(!(elm=document.getElementById(el))){return null;}
if(ex=_ext.Element.cache[el]){ex.dom=elm;}else{ex=_ext.Element.cache[el]=new _ext.Element(elm);}
return ex;}else if(el.tagName){if(!(id=el.id)){id=_ext.id(el);}
if(ex=_ext.Element.cache[id]){ex.dom=el;}else{ex=_ext.Element.cache[id]=new _ext.Element(el);}
return ex;}else if(el instanceof _ext.Element){if(el!=docEl){el.dom=document.getElementById(el.id)||el.dom;_ext.Element.cache[el.id]=el;}
return el;}else if(el.isComposite){return el;}else if(_ext.isArray(el)){return _ext.Element.select(el);}else if(el==document){if(!docEl){var f=function(){};f.prototype=_ext.Element.prototype;docEl=new f();docEl.dom=document;}
return docEl;}
return null;},getDom:function(el){if(!el||!document)return null;return el.dom?el.dom:(_ext.isString(el)?document.getElementById(el):el);},getBody:function(){return _ext.get(document.body||document.documentElement);},isArray:function(v){return _ext.toString.apply(v)==='[object Array]';},isString:function(v){return typeof v==='string';},isObject:function(v){return v&&typeof v=="object";},isFunction:function(v){return _ext.toString.apply(v)==='[object Function]';},isNumber:function(v){return typeof v==='number'&&isFinite(v);},USE_NATIVE_JSON:false});_ext.JSON=new(function(){var useHasOwn=!!{}.hasOwnProperty,isNative=function(){var useNative=null;return function(){if(useNative===null){useNative=_ext.USE_NATIVE_JSON&&window.JSON&&JSON.toString()=='[object JSON]';}
return useNative;};}(),pad=function(n){return n<10?"0"+n:n;},doDecode=function(json){return eval("("+json+')');},doEncode=function(o){if(typeof o=="undefined"||o===null){return"null";}else if(_ext.isArray(o)){return encodeArray(o);}else if(Object.prototype.toString.apply(o)==='[object Date]'){return _ext.JSON.encodeDate(o);}else if(typeof o=="string"){return encodeString(o);}else if(typeof o=="number"){return isFinite(o)?String(o):"null";}else if(typeof o=="boolean"){return String(o);}else{var a=["{"],b,i,v;for(i in o){if(!useHasOwn||o.hasOwnProperty(i)){v=o[i];switch(typeof v){case"undefined":case"function":case"unknown":break;default:if(b){a.push(',');}
a.push(doEncode(i),":",v===null?"null":doEncode(v));b=true;}}}
a.push("}");return a.join("");}},m={"\b":'\\b',"\t":'\\t',"\n":'\\n',"\f":'\\f',"\r":'\\r','"':'\\"',"\\":'\\\\'},encodeString=function(s){if(/["\\\x00-\x1f]/.test(s)){return'"'+s.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
c=b.charCodeAt();return"\\u00"+
Math.floor(c/16).toString(16)+
(c%16).toString(16);})+'"';}
return'"'+s+'"';},encodeArray=function(o){var a=["["],b,i,l=o.length,v;for(i=0;i<l;i+=1){v=o[i];switch(typeof v){case"undefined":case"function":case"unknown":break;default:if(b){a.push(',');}
a.push(v===null?"null":_ext.JSON.encode(v));b=true;}}
a.push("]");return a.join("");};this.encodeDate=function(o){return'"'+o.getFullYear()+"-"+
pad(o.getMonth()+1)+"-"+
pad(o.getDate())+"T"+
pad(o.getHours())+":"+
pad(o.getMinutes())+":"+
pad(o.getSeconds())+'"';};this.encode=function(){var ec;return function(o){if(!ec){ec=isNative()?JSON.stringify:doEncode;}
return ec(o);};}();this.decode=function(){var dc;return function(json){if(!dc){dc=isNative()?JSON.parse:doDecode;}
return dc(json);};}();})();
