function addtobasket(me){
		
	var productid = me.productid.value;
	var quantity = me.quantity.value;
	var price = me.price.value;
	
	var ajaxurl =  '/ajrgfx/basket/add.asp'
		ajaxurl += '?productid='+productid
	    ajaxurl += '&quantity='+quantity
	    ajaxurl += '&price='+price

	$.ajax({
	    type: 'GET',
		url: ajaxurl,
		success: function(data) {
		
			alert('Varen blev tilføjet kurven');
			
			$('#shopbasket').load('/ajrgfx/basket/add.asp');
		 
		}
	});

}

function updateitemquantity(index,quantity){

	if( isNaN(quantity) ){

		document.location=document.location;

	} else {
	
		$.ajax({
		    type: 'GET',
			url: '/ajrgfx/basket/update.asp?index='+index+'&quantity='+quantity,
			success: function(data) {
				
				document.location=document.location;
			 
			}
		});	
	
	}

}

function removebasketitem(index){

	$.ajax({
	    type: 'GET',
		url: '/ajrgfx/basket/update.asp?index='+index+'&quantity=0',
		success: function(data) {
			
			$('#basket').load('/ajrgfx/basket/add.asp');
			$('#basketitems').load('/ajrgfx/basket/basket-items.asp');
		 
		}
	});	

}

function setbuymoreurl(){

	$.cookie('vaekstcenteret.buymoreurl', location.href)
}

function getbuymoreurl(){
	
	if($.cookie('vaekstcenteret.buymoreurl')){
		
		return $.cookie('vaekstcenteret.buymoreurl')
		
	} else {
	
		return "/"
		
	}
	
}

function getdeliverycountry(value){
	
	$.ajax({
	
	    type: 'GET',
		url: '/ajrgfx/ajax/getcountryname.asp?documentid='+value,
		success: function(data) {
		
			$('#deliverycountry').val(data);
			
		}
		
	});	
	
}

function toggledeliveryaddress(me){
	
	//getdeliverycountry(me.country.value);

	$('#deliveryaddress').toggle();
	
	var togglestatus = $('#deliveryaddress').is(':visible');
	
	if(togglestatus){
	
		$('#usealtdeliveryaddress').val(1);
		
	} else {
	
		$('#usealtdeliveryaddress').val(0);
		
	}	
	
}

function checkorderform(me){
		
	resetfieldclasses(me);
	
	setformcookie(me);
	
	if (me.firstname.value==''){redalert(me.firstname); return false;}
	if (me.lastname.value==''){redalert(me.lastname); return false;}
	if (me.address.value==''){redalert(me.address1); return false;}
	if (me.postalcode.value==''){redalert(me.zipcode); return false;}
	if (me.city.value==''){redalert(me.city); return false;}
	if (me.countrycode.value==''){redalert(me.countrycode); return false;}
	if (me.phone.value==''){redalert(me.phone); return false;}
	
	if (!emailCheck(me.email.value)){redalert(me.email); return false;}
	
	if(me.usealtdeliveryaddress.value==1){
	
		if (me.deliveryname.value==''){redalert(me.deliveryname); return false;}
		if (me.deliveryaddress.value==''){redalert(me.deliveryaddress1); return false;}
		if (me.deliverypostalcode.value==''){redalert(me.deliveryzipcode); return false;}
		if (me.deliverycity.value==''){redalert(me.deliverycity); return false;}
		if (me.deliverycountrycode.value==''){redalert(me.deliverycity); return false;}
		
	}
	
	me.submit();
	
}

function showothercountry(id,country){

	if(country=='Other'){
		
		$('#'+id).show()
		
	} else {
		
		$('#'+id).hide()
		
	}
	
}
