var opt = [];
var res;
var cur=[];
var tt=[];
var all=[];
var s=[];

var aaa = '';




var g_desc=' | ';

var show;
var accordion;

var selected_address;


function modal_overlay(callback) {
	
	var overlay = new Element('div', {
		'id':'modal_overlay',
		'styles': {
			'background-color': '#333333',	// light dark color or png image
			'position': 'absolute',
			'top': '0px',
			'left': '0px',
			'width': window.getScrollWidth() + 'px',
			'height':window.getScrollHeight() + 'px'
		}
	});
	overlay.setOpacity('.75');
	overlay.injectInside(document.body);

	if (callback) {
		callback();
	}

}




function validate_value(el) {
	
	if (el.value) {
		el.setStyles({'background-color':'#ffffff'});
		return true;
	}
	else {
		el.setStyles({'background-color':'#ff8d8d'});
		return false;
	}
}


function validate(arr) {
all_valid =  true;
arr.each( function(item_data) {



if (  item_data.getTag() == 'input' && item_data.type=='checkbox' ) {



	if ( item_data.hasClass('mnd') && !item_data.checked ) { 
		if ( item_data.getParent().hasClass('invalid'))
		item_data.getParent().setStyles({'background-color':'#ff8d8d'});
	
       		all_valid = false;		
	}
	else if ( item_data.hasClass('mnd')  && item_data.checked  ) { 
		
		if ( item_data.getParent().hasClass('invalid'))
		item_data.getParent().setStyles({'background-color':'#ffffff'});
	}
	
}

if ( item_data.getTag() == 'select' ||  item_data.getTag() == 'input' ||  item_data.getTag() == 'textarea'  ) {

	if ( item_data.hasClass('mnd') && item_data.value.replace(/\s/g,'').length == 0) { 
		item_data.setStyles({'background-color':'#ff8d8d'});	
       		all_valid = false;		
	}
	
	else if ( item_data.hasClass('nr') ) {
	
		var vmin  =  item_data.getProperty('class').split(' ').filter( function(item){return item.match('min')})[0].replace('min:','').toFloat();
		var vmax  =  item_data.getProperty('class').split(' ').filter( function(item){return item.match('max')})[0].replace('max:','').toFloat();
		
		if ( item_data.value.toString().match(/^\d+$/)==null  || ( vmin && item_data.value < vmin ) || ( vmax && item_data.value > vmax ) ) {
			item_data.setStyles({'background-color':'#ff8d8d'});
			// item_data.value="[%Numbers only please%]";
			item_data.addEvent('click',function() { this.value='';});
			all_valid  = false;		
			
		}
		

	}
	
	else if ( item_data.hasClass('non_zero') && item_data.value == 0   ) {
		
		item_data.setStyles({'background-color':'#ff8d8d'});
		// item_data.value="[%Numbers > 0 please%]";
		item_data.addEvent('click',function() { this.value='';});
		all_valid  = false;		

	}
	
	

	else if ( item_data.hasClass('time') && item_data.value.toString().match(/^([0-1][0-9]|[2][0-3])(:([0-5][0-9])){1,2}$/)==null   ) {
		item_data.setStyles({'background-color':'#ff8d8d'});
		item_data.value="[%hh:mm%]";
		item_data.addEvent('click',function() { this.value='';});
		all_valid  = false;		

	}


	else {
		item_data.setStyles({'background-color':'#ffffff'});
	}

}

});


if ( !all_valid ) {	alert("Please complete all mandatory fields( in red )");return false}
else {
	return true;
	}
}





function set_opt() {
tt=[];

    res.each( function( item) {
	if ( $type(item) != 'function') {
	    item.val.each ( function(val) {
		
                    if ( !tt[val.variation_name] ) tt[val.variation_name] = [];    
		    if ( !tt[val.variation_name].contains(val.variation_value) ) tt[val.variation_name].push(val.variation_value);
		
	    })
	}
    })


set_interface();

}


function get_all() {
all=[];

if (opt.length >0 ) {
    opt.each( function( item) {
	if ( $type(item) != 'function') {
	    item.val.each ( function(val) {
		
                    if ( !all[val.variation_name] ) all[val.variation_name] = [];    
		    if ( !all[val.variation_name].contains(val.variation_value) ) all[val.variation_name].push(val.variation_value);
		
	    })
	}
    })
}

}


function get_price() {
	

	// var currency_id = 	Cookie.get('currency');
	
    $('price_'+currency_id).setText('Select an option');
    $('price_nonvat_'+currency_id).setText('Select an option');

    $('prod_var_id').setProperty('value','');
s=[];

// g_desc=' | ';

$$('select').each(function(it){
var ob={};
ob.variation_name = it.name;
ob.variation_value = it.value;
// g_desc=g_desc+ob['variation_name']+' : '+ob['variation_value']+' | ';
s.push( ob );



})


opt.each( function( item) {

if ( $type(item) != 'function') {

if  ( item.val.every( function(val) {
        return (	s.some(function(sval) {
                    if (sval['variation_name'] == val.variation_name && sval['variation_value'] == val.variation_value)
                        return true;
                    else
                        return false;
                })	
        );

	    })   ) {


			if ( curr_symbol ) {
			    $('price_'+currency_id).setText (curr_symbol+" "+item['price_'+currency_id] );
			    $('price_nonvat_'+currency_id).setText (curr_symbol+" "+item['price_nonvat_'+currency_id] );
			}
			else {
			    $('price_'+currency_id).setText (currency_id+" "+item['price_'+currency_id] );
			    $('price_nonvat_'+currency_id).setText (currency_id +" "+item['price_nonvat_'+currency_id]);
			}



   	$('prod_var_id').setProperty('value',item.prod_var_id);

	check_stock(item.prod_var_id);
   	// $('g_price').setProperty('value', item.price );
	// $('g_desc').setProperty('value',g_desc);



        }

	}

});


}



function check_stock(prod_id) {

	for ( vs=0 ; vs< vars_stock.length ; vs++) {
		if (vars_stock[vs].prod_var_id == prod_id ) {

			if (parseInt(vars_stock[vs].prod_stock) > 0 && parseInt(vars_stock[vs].prod_stock) <= parseInt(vars_stock[vs].prod_stock_limit) ){
				$('order_product')  	&& $('order_product').setText('');
				$('prod_outstock_text') && $('prod_outstock_text').setText('');
				$('prod_low_warn_text') && $('prod_low_warn_text').setText(prod_low_warn_text_js);
				prod_stock = vars_stock[vs].prod_stock;
				
				
			}
			else if (vars_stock[vs].prod_stock == 0) {
				$('order_product')  	&& $('order_product').setText('');
				$('prod_outstock_text') && $('prod_outstock_text').setText(prod_outstock_text);
				$('prod_low_warn_text') && $('prod_low_warn_text').setText('');
				
			}		
			else {
				$('order_product')  	&& $('order_product').setText(order_product);
				$('prod_outstock_text') && $('prod_outstock_text').setText('');
				$('prod_low_warn_text') && $('prod_low_warn_text').setText('');
				prod_stock = vars_stock[vs].prod_stock;
				
			}
		}
	}
}




function get_opt(sel) {
cur['sel'] = sel.id;
cur['val'] = sel.value;

if (!sel.value) {res = opt}
else {

res = opt.filter(function(item, index){

 if (   item.val.filter( function(val,index){
        return val.variation_value==sel.value;
        }).length > 0
) {
return item;
}
 


});
}

set_opt();




}



function srt(a,b){
		if(a.value == b.value){
			return 0;
		}
		return (a.value < b.value) ? -1 : 1;
};


function set_interface() {

    for (v in tt) {
        if ($type(tt[v])!='function') {
           var sel = new Element('select').setProperties({'id':v,'name':v,'class':'mnd'}).setStyles({'display':'block','width':100,'text-align':'left'}).addEvent('change', function() {get_opt(this);});
            var o = new Element('option').setText('Select...').setProperties({'value':''}).injectInside(sel);

// tt[v].sort(srt);

          tt[v].each( function(item){
                var o = new Element('option').setProperties({'value':item}).setText(item).injectInside(sel);
                if ( v == cur['sel'] && item == cur['val']) {

                    o.setProperties({'selected':true});
                }
            });

         if ( v != cur['sel'] ) {
            sv = $(v).value;    
            sel.getElements('option').each( function(op){
                if (op.value == sv) op.selected=true;
				else op.selected=false;
            })
            $(v).replaceWith(sel);

         }
         else {

           var sel = new Element('select').setProperties({'id':v,'name':v,'class':'mnd'}).setStyles({'display':'block','width':100,'text-align':'left'}).addEvent('change', function() {get_opt(this);});
            var o = new Element('option').setText('Select...').setProperties({'value':'','selected':true}).injectInside(sel);

// all[v].sort(srt);

          all[v].each( function(item){
                var o = new Element('option').setProperties({'value':item}).setText(item).injectInside(sel);
                if ( v == cur['sel'] && item == cur['val']) {
                    o.setProperties({'selected':true});
                }
            });

              $(v).replaceWith(sel);
              }
        }

    }

get_price();
};





function ch_g(frm) {


document.getElementById('g_quant').value = frm.value

if (frm.value < 5) document.getElementById('uk_delivery').value=3.95;
if (frm.value > 4 && frm.value < 11 ) document.getElementById('uk_delivery').value=6.95;
if (frm.value > 10) document.getElementById('uk_delivery').value=8.95;



if (frm.value > 2) {
	document.getElementById('int_delivery').value=(frm.value-2)*3+6;
};

;return true;

}



function set_cart_currency(curr_id) {
	Cookie.set('currency',curr_id);
	$('currency_select').setStyle('display','none');
	$$('[class^=price_curr_]').each( function(item) {item.addClass('hidden')} );
	$$('.price_curr_'+curr_id).each(  function(item) {item.removeClass('hidden')} )

}



function set_currency(curr_id) {
	Cookie.set('currency',curr_id);
	$('currency_select').setStyle('display','none');
	$$('[class^=price_curr_]').each( function(item) {item.addClass('hidden')} );
	$$('.price_curr_'+curr_id).each(  function(item) {item.removeClass('hidden')} )
	
	get_price();

}



function check_promocode(code) {
	new Ajax('check_promocode.php?promocode='+code, { method: 'get',evalScripts:true,
	onComplete:	 function(response) {
		
		if ( response) {

			response = Json.evaluate(response);
			disc = response.real_total.toFloat() - response.total.toFloat();
			old_total = $('total').value.toFloat();
			$('discount').setHTML('Discount: &pound; '+disc.toFixed(2));
			$$('.total').each(function(t) {
				t.setText((old_total-disc.toFixed(2)).toFixed(2));
			})


		}
		else {
			$('discount').setText('');
			$$('.total').each(function(t) {
				t.setText(old_total.toFixed(2));
			})
		}
	}
	}).request();	
}




window.addEvent('domready', function() {
	var promo_tm;

	if ( $('promocode') ) {
		$('promocode').addEvent('keyup', function() {
			$clear(promo_tm);
			promo_tm = (function() {check_promocode($('promocode').value)}).delay(500);
		}).addEvent('keydown', function() {
			$clear(promo_tm);
		})
	}


if (opened == "all-closed") start='all-closed';
else start='';
	
// if ( Cookie.get('opened') != "all-closed") start = ''; else start='all-closed';



accordion = new Accordion('a.atStart', 'div.atStart', {
	'start':start,
	opacity: false,

	onActive: function(toggler, element){
		toggler.setStyle('text-decoration', 'underline');
	},
 
	onBackground: function(toggler, element){
		toggler.setStyle('text-decoration', 'none');
	}
}, $('accordion'));

accordion.togglers.each(function(toggler){
	toggler.addEvent('mouseenter',function(e){

	 var e = new Event(e).stop();
		toggler.removeEvents('click');
	});
	});




	if (Cookie.get('categ') ) {
		opened=0;
		a=0;
		$each(accordion.togglers, function(item){ 
			if (item.id ==  "categ_"+Cookie.get('categ') ) {a = opened; (function(){accordion.display(a);}).delay(100)}
			else { opened++; }
			});
	}

if ($('slideshowContainer')) {

				var obj = {
					wait: 5000, 
					effect: 'fade',
					duration: 1000, 
					loop: true, 
					thumbnails: true,
					backgroundSlider: true
				}
				show = new SlideShow('slideshowContainer','slideshowThumbnail',obj);
				show.play();

}


get_all();

// if (Cookie.get('opened')) accordion.display(Cookie.get('opened'));


if ( $('form') ) {
    if ( $$('select').length > 0 ) {
	    $('form').addEvent('submit', function(e) {
		if ( $$('select').every( function(val) { return val.value; }) ) {
	               ;
		}
		else {
			e = new Event(e).stop();
                        alert("Please select options for this product");
		    }
	});
    }
}

if ( $('gform') ) {
    if ( $$('select').length > 0 ) {
	    $('gform').addEvent('submit', function(e) {
		if ( $$('select').every( function(val) { return val.value; }) ) {
	               ;
		}
		else {
			e = new Event(e).stop();
                        alert("Please select options for this product");
		    }
	});
    }
}


if ($('vat_changer')) {
	$('vat_changer').addEvent('click', function(){
		if (Cookie.get('vat') == "without") {
			Cookie.set('vat','with');
			$('vat_changer').setText('show prices without VAT');
			$('cart_vat').setText('(VAT included)');
			$$('.price_vat').each( function(item) {item.removeClass('hidden_vat')} );
			$$('.price_nonvat').each( function(item) {item.addClass('hidden_vat')} );
			
		}
		else {
			Cookie.set('vat','without');
			$('vat_changer').setText('show prices including VAT');
			$('cart_vat').setText('(without VAT)');
			$$('.price_vat').each( function(item) {item.addClass('hidden_vat')} );
			$$('.price_nonvat').each( function(item) {item.removeClass('hidden_vat')} );
			
		}

	})
}

if ($('currency_changer')) {
	$('currency_changer').addEvent('click', function(){
		$('currency_select').setStyle('display','block');
	})
}



if ( $('del_info')) {
	$('del_info').addEvent('keyup', function() {
		if (this.value.length > 51) {
			this.value = this.value.substr(0,51);
		}
	})
}

// if ($('date_pick')) {
// 	
// make_calendar();	
// 			}


if ( $('more_handler') ) {
	var moreSlider = new Fx.Slide($('description_slide'), {
		onComplete: function() {
			if (this.open) {$('more_handler').setText('More details...').setStyle('background-position','top')}
			else {$('more_handler').setText('Less details...').setStyle('background-position','bottom')}
		}
	}).hide();

	$('more_handler').addEvent('click', function() {
		moreSlider.toggle();
	})

}



});



 // onHideComplete: function() { 
 // 	
 // 	if (  $('date_pick').value.match('Saturday') && $('addresses').value.match('2,') ) { 
 // 	
 // 		$('shipp_taxx').setText("33.99");
 // 		$('shipp_rule').setText($('shipp_rule').getText()+" - Saturday delivery");
 // 		$('big_total').setText(parseFloat(total_cart[currency_id]['vat']+33.99).toFixed(2));
// }
// 	else {
// 		sel_address($('addresses',true))
// 	}
	

function make_calendar(blocked,direction) {
	

	
	$('date_pick').removeClass('dashboard');$$('.dashboard').each(function(itm){itm.remove()});
	
	today = server_time[4]+','+server_time[3]+','+server_time[2]; 
	
	date_pick = new Calendar({ date_pick: 'd/m/Y l' }, { classes: ['dashboard'], direction: direction, blocked:blocked,tweak: {x:-100,y:-40},date:today
						
		
		 });
	
}


function sel_calendar(sel) {
	
	if ( !confirm("Your next step is to pick a delivery date. If you require your goods on a specific day, Please select a date at least one day early to allow us time to sort out any delivery problems.") ) {
		sel.options[0].selected=1;
		return false;
	}
	
	
	
	
	$('date_pick').value="";
	
	if (sel.value=='a') {

		total = parseFloat(total_cart[currency_id]['vat']);

		if ( 0 <= total && total <= 20) {
			ship = 20.95;
		}
		else if ( 20 < total && total <= 90) {
			ship = 23.95;	
		}
		else {
			ship = 16;
		}


		$('shipp_taxx').setText(ship);
	
		shippid_zoneid = $('addresses').value.split(',');
		if (shippid_zoneid == 'add_address')
			shippid_zoneid = $('del_shipp_zone').value.split(',');
	
		shipping.shipping.each( function(item){
			if (item.shipping_id==shippid_zoneid[0] ) {
				if ( total_cart[currency_id]['vat'] < item.max &&  total_cart[currency_id]['vat'] >= item.min ) {
	
						$('shipp_rule').setText(item.name+" - Saturday Express");
						$('big_total').setText(parseFloat(total_cart[currency_id]['vat']+ship).toFixed(2));
					
					}
				}	
			})
		}

			
		else if ( sel.value == 'e' || sel.value == 'pre12' || sel.value == 's') {
			
				var shippid_zoneid=Array();
			
				shippid_zoneid = $('addresses').value.split(',');
			 // alert(shippid_zoneid);
			if (shippid_zoneid == 'add_address')
				shippid_zoneid = $('del_shipp_zone').value.split(',');
				
				
				
				if ( shippid_zoneid[0] == 4 ) shippid_zoneid[0] = 2;
				if ( shippid_zoneid[0] == 5 ) shippid_zoneid[0] = 3; 
				
			
				shipping.shipping.each( function(item){
					if (item.shipping_id==shippid_zoneid[0] ) {
						if ( total_cart[currency_id]['vat'] < item.max &&  total_cart[currency_id]['vat'] >= item.min ) {
							if ( sel.value == 'pre12') {
								$('shipp_taxx').setText(parseFloat(item.amount)+10);	
								$('big_total').setText( (parseFloat(total_cart[currency_id]['vat'])+parseFloat(item.amount)+10).toFixed(2));
								$('shipp_rule').setText("Pre 12.00AM Express");
							}
							else {
								$('shipp_taxx').setText(item.amount);
								$('big_total').setText( (parseFloat(total_cart[currency_id]['vat'])+parseFloat(item.amount)).toFixed(2));
								$('shipp_rule').setText(item.name);

	// console.log(item);

							}

						}
					}	
				})
			
		}
	




// wd_bl -  blocking days
		
		noon = 11;
		wd_bl = '0,6';
		month = server_time[3];
		
		if (sel.value=="s") {
			
				if (server_time[0] == 1 ) {
					if ( server_time[1] >= noon ) {
						direction = 4;
					}
					else {
						direction = 3;
					}
				}	
				
				else if  ( server_time[0] == 2 || server_time[0] == 3 ) {
					if ( server_time[1] >= noon ) {
						direction = 6;
					}
					else {
						direction = 3;
					}
				}
				
				else if  ( server_time[0] ==  3 ||  server_time[0] ==  4 ||  server_time[0] ==  5 ) {
					if ( server_time[1] >= noon ) {
						direction = 6;
					}
					else {
						direction = 5;
					}
				}				
		

		
				else if ( server_time[0] == 6 ) { // good
					direction = 5;
				}
		
				else if (server_time[0]==0 ) {
					direction = 4
				}
			


			
			
					blocked = ['1-24 1 *','0 * * 0,6','23-31 12 *']
					make_calendar(blocked,direction);
			
		}


		else if (sel.value=="a") {
			
			
			if ( ( server_time[1] >= noon &&  server_time[0]>=5 ) || server_time[0]==0 || server_time[0] == 6 ) {
				direction=2;
			}
			else if (server_time[1] < noon && server_time[0] == 5 ) {
				direction=1;
			}
			else if (server_time[0]==0 ) {
				direction=2
			}

			else {
				direction=1;	
			}	

			blocked = ['1-24 1 *','0 * * 0,1,2,3,4,5','23-31 12 *'];
			make_calendar(blocked,direction);
		}
		

		
		
		else if ( sel.value == "e" || sel.value == "pre12") {
			

		// $('date_pick').removeClass('dashboard');$$('.dashboard').each(function(itm){itm.remove()});		
		
		
		
		if (server_time[0] == 5 ) {
			if ( server_time[1] >= noon ) {
				direction = 4;
			}
			else {
				direction = 3;
			}
		}	

		else if ( server_time[0] == 6 ) { // good
			direction = 3;
		}

		else if (server_time[0] == 0 ) {
			direction = 2
		}
		

		
		else if  ( server_time[0] ==  1 || server_time[0] ==  2 ||  server_time[0] ==  3 ||  server_time[0] ==  4 ) {
			if ( server_time[1] >= noon ) {
				direction = 2;
			}
			else {
				direction = 1;
			}
		}				
		
		blocked = ['1-24 1 *','0 * * 0,6','23-31 12 *']
		make_calendar(blocked,direction);
		
		}


}




function sel_address(select,hide) {
	
	
	$('date_pick').value="";
		selected_address = select.value;
	
	if (select.value == 'add_address') {
		$('same_delivery').setStyle('display','block');
		$$('.mnd_tk').each(function(item){ item.addClass('mnd') });
		$('shipp_taxx').setText("--");
		$('big_total').setText(parseFloat(total_cart[currency_id]['vat']).toFixed(2));
		
		$('shipp_rule').setText("Select an address");
		$('del_shipp_zone').selectedIndex = 0;
	} 
	

	 // else if (   $('date_pick').value.match('Saturday') && select.value.match('2,') ) {
	 else if (  select.value.match('2,')  || select.value.match('4,') ) {
	
		$$('.mnd_tk').each(function(item){ item.removeClass('mnd') });
	
	
	
	// <select id="shipp_type" name="shipp_type" onchange="sel_calendar(this)" class="large">
	
		var sel = new Element('select').setProperties({'id':'shipp_type','name':'shipp_type','class':'large mnd'}).addEvent('change', function() {sel_calendar(sel);});
		var o = new Element('option').setText('Select shipping type...').setProperties({'value':''}).injectInside(sel);
		var o = new Element('option').setText('Express').setProperties({'value':'e'}).injectInside(sel);
		var o = new Element('option').setText('Pre 12.00AM Express').setProperties({'value':'pre12'}).injectInside(sel);
		var o = new Element('option').setText('Saturday Express').setProperties({'value':'a'}).injectInside(sel);

		// var o = new Element('option').setText('Standard').setProperties({'value':'s'}).injectInside(sel);
	
		$('shipp_type').replaceWith(sel);
 	
			if ( hide ) $('same_delivery').setStyle('display','none');
		// $('del_shipp_zone').selectedIndex = 0;
	} 
	

	 else if (  select.value.match('3,')  || select.value.match('5,')  ) {
	
		$$('.mnd_tk').each(function(item){ item.removeClass('mnd') });
	
	
	
	// <select id="shipp_type" name="shipp_type" onchange="sel_calendar(this)" class="large">
	
		var sel = new Element('select').setProperties({'id':'shipp_type','name':'shipp_type','class':'large mnd'}).addEvent('change', function() {sel_calendar(sel);});
		var o = new Element('option').setText('Select shipping type...').setProperties({'value':''}).injectInside(sel);
		var o = new Element('option').setText('Highlands/Northern Ireland Express').setProperties({'value':'e'}).injectInside(sel);

		// var o = new Element('option').setText('Standard').setProperties({'value':'s'}).injectInside(sel);
	
		$('shipp_type').replaceWith(sel);
 	
			if ( hide ) $('same_delivery').setStyle('display','none');
		// $('del_shipp_zone').selectedIndex = 0;
	} 
	






	 else if (  select.value.match('8,') ) {
		$$('.mnd_tk').each(function(item){ item.removeClass('mnd') });
		

	var sel = new Element('select').setProperties({'id':'shipp_type','name':'shipp_type','class':'large' }).addEvent('change', function() {sel_calendar(sel);});
	var o = new Element('option').setText('Select shipping type...').setProperties({'value':''}).injectInside(sel);

	var o = new Element('option').setText('Isle of Wight Express').setProperties({'value':'e'}).injectInside(sel);

	$('shipp_type').replaceWith(sel);
		if ( hide ) {
		$$('.mnd_tk').each(function(item){ item.removeClass('mnd') });
			$('same_delivery').setStyle('display','none');
		}
	}
	
	else if (!select.value ) {
		if ( hide ) {
		$$('.mnd_tk').each(function(item){ item.removeClass('mnd') });
			$('same_delivery').setStyle('display','none');
		}
		$('shipp_taxx').setText("--");
		$('shipp_rule').setText("Select an address");
		$('big_total').setText(parseFloat(total_cart[currency_id]['vat']).toFixed(2));
		
	}
	
	else if ( select.value.match('1,') || select.value.match('6,')) {
		alert("Shipping area not available.\nPlease contact Scottish Christmas Trees.")
		$('shipp_taxx').setText("--");
		$('shipp_rule').setText("Select an address");
		$('big_total').setText(parseFloat(total_cart[currency_id]['vat']).toFixed(2));
		
	}
	else {

		$$('.mnd_tk').each(function(item){ item.removeClass('mnd') });

		var sel = new Element('select').setProperties({'id':'shipp_type','name':'shipp_type','class':'large' }).addEvent('change', function() {sel_calendar(sel);});
		var o = new Element('option').setText('Select shipping type...').setProperties({'value':''}).injectInside(sel);
		var o = new Element('option').setText('3-5 day Non Guaranteed').setProperties({'value':'s'}).injectInside(sel);
		
		$('shipp_type').replaceWith(sel);
// 	
	// 
	// 	
	// 	if ( hide ) $('same_delivery').setStyle('display','none');
	// 	var shippid_zoneid=Array();
	// 
	// 	shippid_zoneid = select.value.split(',');
	// 
	// 
	// 
	// 	shipping.shipping.each( function(item){
	// 		if (item.shipping_id==shippid_zoneid[0] ) {
	// 			if ( total_cart[currency_id]['vat'] < item.max &&  total_cart[currency_id]['vat'] > item.min ) {
	// 				$('shipp_taxx').setText(item.amount);
	// 				$('shipp_rule').setText(item.name);
	// 				$('big_total').setText( (parseFloat(total_cart[currency_id]['vat'])+parseFloat(item.amount)).toFixed(2));
	// 				
	// 			}
	// 		}	
	// 	})
	// 
	}
	

}

function validate_newsletter() {

if ( document.getElementById('newsletter_name').value.length < 2 ) {
    alert("Please provide a real name");
    return false;
    }

if (document.getElementById("newsletter_email").value.indexOf('@')==-1  || document.getElementById("newsletter_email").value.indexOf('.')==-1  || document.getElementById("newsletter_email").value.length <= 7 )
    {
    alert("Please provide your email");
    return false;
    }

}

function callmeback() {

if ( $('callback_name').value.length < 3  || $('callback_name').value=='your name') {
    alert("Please provide a real name");
    return false;
    }

if ( $('callback_phone').value.length < 3 || $('callback_phone').value == 'phone number' ) {
    alert("Please provide a phone number");
    return false;
    }

$('callbackform').send( { update:'callbackform_wrapper'} );
return false;




}