
var siteurl='http://www.mtbeautiful.co.nz';var secureurl='';function confirmdelete(){if(confirm("Are you sure you want to delete this?")==true){return true;}else{return false;}}
function xyz(c,a,b,s){var s=(s==null)?true:s;var o='';var m='';var m2=':otliam';for(i=0;i<=b.length;i++){o=b.charAt(i)+o;}
b=o;for(i=0;i<=m2.length;i++){m=m2.charAt(i)+m;}
if(!s){m='';}
return m+a+unescape('%'+'4'+'0')+b+'.'+c;}
function validate(val,type){if(type=='email'){return val.match(/^(?:^[A-Z0-9._%-]+@[A-Z0-9.-]+\.(?:[A-Z]{2}|com|org|net|biz|info|name|aero|biz|info|jobs|museum|name)$)$/i);}else if(type=='url'){return val.match(/^(?:\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])$/i);}else if(type=='integer'){return val.match(/^-?[0-9]+$/i);}}
function validateEmail(str){var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if(str.indexOf(at)==-1){return false}
if(str.indexOf(at)==-1||str.indexOf(at)==0||str.indexOf(at)==lstr){return false}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr){return false}
if(str.indexOf(at,(lat+1))!=-1){return false}
if(str.substring(lat-1,lat)==dot||str.substring(lat+1,lat+2)==dot){return false}
if(str.indexOf(dot,(lat+2))==-1){return false}
if(str.indexOf(" ")!=-1){return false}
return true}
function showhide(region){if(document.getElementById){if(document.getElementById(region).style.display=='none'){document.getElementById(region).style.display='block';}else{document.getElementById(region).style.display='none';}}else{alert('Sorry, your browser doesn\'t support this');}}
function showregion(region){if(document.getElementById){document.getElementById(region).style.display='block';}else{alert('Sorry, your browser doesn\'t support this');}}
function hideregion(region){if(document.getElementById){document.getElementById(region).style.display='none';}else{alert('Sorry, your browser doesn\'t support this');}}
function setCookie(name,value,expires,path,domain,secure){document.cookie=name+"="+escape(value)+
((expires)?"; expires="+expires.toGMTString():"")+
((path)?"; path="+path:"")+
((domain)?"; domain="+domain:"")+
((secure)?"; secure":"");}
function getCookie(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null;}else{begin+=2;}
var end=document.cookie.indexOf(";",begin);if(end==-1){end=dc.length;}
return unescape(dc.substring(begin+prefix.length,end));}
function deleteCookie(name,path,domain){if(getCookie(name)){document.cookie=name+"="+
((path)?"; path="+path:"")+
((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}}
function isNull(a){return typeof a=='object'&&!a;}
function nl2br(myString){return myString.replace(/\n/g,'<br />\n');}
$(document).ready(function(){$('input.post_redirect_submit').mouseover(function(){window.status=this.title;return true;});$('input.post_redirect_submit').mouseout(function(){window.status='Done';return true;});});function frajax(action,a,b,c,d,e,f,g,h,i,j){var url=siteurl;var r=/(http|https):\/\/.*/;var m=r.exec(window.location);if(m!=null&&m.length>1){if(m[1]=='https'){url=secureurl;}}
url+='/actions/'+action+'.php?';if(a){url+='arg1='+encodeURIComponent(a);}
if(b){url+='&arg2='+encodeURIComponent(b);}
if(c){url+='&arg3='+encodeURIComponent(c);}
if(d){url+='&arg4='+encodeURIComponent(d);}
if(e){url+='&arg5='+encodeURIComponent(e);}
if(f){url+='&arg6='+encodeURIComponent(f);}
if(g){url+='&arg7='+encodeURIComponent(g);}
if(h){url+='&arg8='+encodeURIComponent(h);}
if(i){url+='&arg9='+encodeURIComponent(i);}
if(j){url+='&arg10='+encodeURIComponent(j);}
document.getElementById('frajax-iframe').src=url;return false;}
$(document).ready(function(){$('input.quantity').change(function(){var id=$(this).attr('id');var code=id.replace(/quantity\[(.*?)\]/ig,"$1");$.getJSON('json/jojo_cart_change_quantity.php',{qty:$(this).val(),code:code},change_quantity_callback);});$('input.quantity').bind('focus',function(){if($(this).val()=='0'){$(this).val('');}});});function change_quantity_callback(data)
{$('#row_'+data.code+' td.cart-linetotal span.linetotal').html(data.linetotal.toFixed(2));$('#row_'+data.code+' input.quantity').val(data.quantity);$('#subtotal').html(data.subtotal.toFixed(2));$('#total').html(data.total.toFixed(2));}
function updateCountry(country,section){if(!country){return;}
$.getJSON(siteurl+'/json/jojo_cart_country_hasstates.php',{c:country},function(data){if(data){updateCountryStates(country,section);}else{updateCountryCities(country,section);$('#'+section+'_state').attr('disabled',true);}});}
function updateCountryCities(country,section){$.getJSON(siteurl+'/json/jojo_cart_country_cities.php',{c:country},function(data){target=$('#'+section+'_city');if(!data.length){var textbox=document.createElement('input');$(textbox).attr('id',target.attr('id'));$(textbox).attr('name',target.attr('name'));if(target.val()){$(textbox).val(target.val());}
target.replaceWith(textbox);}else{var selectbox=document.createElement('select');$(selectbox).attr('id',target.attr('id'));$(selectbox).attr('name',target.attr('name'));option=new Option('','');selectbox.options.add(option);for(i=0;i<data.length;i++){option=new Option(data[i],data[i]);selectbox.options.add(option);}
if(target.val()){$(selectbox).val(target.val());}
target.replaceWith(selectbox);}});}
function updateStateCities(country,state,section){if(!country||!state){return;}
$.getJSON(siteurl+'/json/jojo_cart_state_cities.php',{c:country,s:state},function(data){target=$('#'+section+'_city');if(!data.length){var textbox=document.createElement('input');$(textbox).attr('id',target.attr('id'));$(textbox).attr('name',target.attr('name'));if(target.val()){$(textbox).val(target.val());}
target.replaceWith(textbox);}else{var selectbox=document.createElement('select');$(selectbox).attr('id',target.attr('id'));$(selectbox).attr('name',target.attr('name'));option=new Option('','');selectbox.options.add(option);for(i=0;i<data.length;i++){option=new Option(data[i],data[i]);selectbox.options.add(option);}
if(target.val()){$(selectbox).val(target.val());}
target.replaceWith(selectbox);}});}
function updateCountryStates(country,section){$.getJSON(siteurl+'/json/jojo_cart_country_states.php',{c:country},function(data){target=$('#'+section+'_state');if(!data.length){var textbox=document.createElement('input');$(textbox).attr('id',target.attr('id'));$(textbox).attr('name',target.attr('name'));if(target[0].tagName=='INPUT'&&target.val()){$(textbox).val(target.val());}
target.replaceWith(textbox);}else{var selectbox=document.createElement('select');$(selectbox).attr('id',target.attr('id'));$(selectbox).attr('name',target.attr('name'));option=new Option('','');selectbox.options.add(option);for(i=0;i<data.length;i++){option=new Option(data[i]['state'],data[i]['statecode']);selectbox.options.add(option);}
$(selectbox).bind('change',function(){updateStateCities(country,$(this).val(),section);});if(target.val()){$(selectbox).val(target.val());}
target.replaceWith(selectbox);updateStateCities(country,$(selectbox).val(),section)}
target=$('#'+section+'_city');var textbox=document.createElement('input');$(textbox).attr('id',target.attr('id'));$(textbox).attr('name',target.attr('name'));if(target.val()){$(textbox).val(target.val());}
target.replaceWith(textbox);});}
function copyShippingToBilling(){$('#billing_firstname').val($('#shipping_firstname').val());$('#billing_lastname').val($('#shipping_lastname').val());$('#billing_email').val($('#shipping_email').val());$('#billing_address1').val($('#shipping_address1').val());$('#billing_address2').val($('#shipping_address2').val());$('#billing_suburb').val($('#shipping_suburb').val());$('#billing_city').val($('#shipping_city').val());$('#billing_state').val($('#shipping_state').val());$('#billing_postcode').val($('#shipping_postcode').val());$('#billing_country').val($('#shipping_country').val());updateCountry($('#billing_country').val(),'billing');}
function showUpdate(){$("#updatelink").show();$("#checkout").hide();}
function cartWidgetSubmit(e){data=$('.cartwidget input, .cartwidget select').serializeArray();if(e.explicitOriginalTarget)submitValue=e.explicitOriginalTarget.id;else if(e.relatedTarget)submitValue=e.relatedTarget.id;else submitValue=document.activeElement.id;if(submitValue=='add'){data[data.length]={name:submitValue,value:"Add to cart"};}else{data[data.length]={name:'update',value:"Update"};}
jojo_cart_widget_update(data);return false;}
function cartWidgetEmpty(e){$(this).html('Emptying...');data=$('.cartwidget input, .cartwidget select').serializeArray();data[data.length]={name:'empty',value:"Empty cart"};jojo_cart_widget_update(data);return false;}
function cartWidgetUpdate(e){$(this).html('Updating cart...');data=$('.cartwidget input, .cartwidget select').serializeArray();data[data.length]={name:'update',value:"Update"};$.get(this.href,{},function(){jojo_cart_widget_update(data);});return false;}
function jojo_cart_widget_update(data){$('.shoppingcart').html('<img src="images/ajax-loader.gif" alt="Updating"/>');$.post('json/jojo_cart_widget.php',data,function(data){if(!$('.shoppingcart').length){window.location.href=window.location.href;}
$('.shoppingcart').html(data);$('.cartwidget').unbind('submit');$('.cartwidget').bind('submit',cartWidgetSubmit);$('#emptycart').bind('click',cartWidgetEmpty);$('#updatecart').bind('click',cartWidgetUpdate);$("#updatelink").hide();},"json");}
$(document).ready(function(){if($('.shoppingcart')){$("#updatelink").hide();$('#emptycart').bind('click',cartWidgetEmpty);$('#updatecart').bind('click',cartWidgetUpdate)
$('.cartwidget').bind('submit',cartWidgetSubmit);}});$(document).ready(function(){$('.buynowbutton').bind('click',function(e){var data={};data[$('input',this).attr('name')]='go';jojo_cart_widget_update(data);return false;});});$(document).ready(function(){hideDivs();$("#peoplelink3").bind('click',function(){Shadowbox.open({type:'iframe',content:this.href+'/?shadowbox=true',width:430,height:460},{overlayColor:'#fff',overlayOpacity:0.7});return false;});$("#peoplelink1, #peoplelink2, #peoplelink4, #peoplelink5, #peoplelink6,"+"#mountainlink, #gullylink, #familyvineyard").bind('click',function(){Shadowbox.open({type:'iframe',content:this.href+'/?shadowbox=true',width:430,height:430},{overlayColor:'#fff',overlayOpacity:0.7});return false;});$("#big-map").bind('click',function(){Shadowbox.open({type:'iframe',content:this.href+'/?shadowbox=true',width:872,height:610},{overlayColor:'#fff',overlayOpacity:0.7});return false;});$("#handwrittinglink").bind('click',function(){Shadowbox.open({type:'iframe',content:this.href+'/?shadowbox=true',width:495,height:600},{overlayColor:'#fff',overlayOpacity:0.7});return false;});$("#capsulelink").bind('click',function(){Shadowbox.open({type:'iframe',content:this.href+'/?shadowbox=true',width:495,height:490},{overlayColor:'#fff',overlayOpacity:0.7});return false;});$("#satellitemaplink").bind('click',function(){Shadowbox.open({type:'iframe',content:this.href+'/?shadowbox=true',width:670,height:600},{overlayColor:'#fff',overlayOpacity:0.7});return false;});$("#maplink, #maplink2").bind('click',function(){Shadowbox.open({type:'iframe',content:this.href+'/?shadowbox=true',width:550,height:610},{overlayColor:'#fff',overlayOpacity:0.7});return false;});});function splash(){var fadetime=600;$('#splash1').fadeIn(fadetime,function(){$('#splash7').fadeIn(fadetime,function(){$('#splash3').fadeIn(fadetime,function(){$('#splash5').fadeIn(fadetime,function(){$('#splash8').fadeIn(fadetime,function(){$('#splash6').fadeIn(fadetime,function(){$('#splash4').fadeIn(fadetime,function(){$('#splash2').fadeIn(fadetime,function(){setTimeout(function(){window.location.href=siteurl+'/home';},1500);});});});});});});});});}
function showDiv(id){if($(id).is(':hidden')){$("div.hide").hide();$(id).show();}else{$(id).hide();}}
function hideDivs(){$("div.hide").hide();}
function hideableContent(){$('#content  h3').each(function(intIndex){var id=$(this).text().replace(' ','-').toLowerCase();$(this).wrapInner('<a href="#" onclick="showDiv(\'#'+id+'\');return false;"></a>');$(this).next('div').addClass('hide').attr('id',id);});}