var url = "../inc/cart.inc.php";
function manageCart(action,id, persons, price, page) {	
   	// Updates the 
	new Ajax(url, {
   		method: 'get',
	   	update: $('cartContents'),
	   	data: Object.toQueryString({action:action, id:id, persons:persons, price:price, page:page})
   	}).request();

}

function webform(action){
	var url = "../inc/webform.inc.php";
	// Updates the 
	new Ajax(url, {
   		method: 'get',
	   	update: $('theview'),
	   	data: Object.toQueryString({customertype:action})
   	}).request();
}


function test(){
		new Event(this).stop();
		alert('form submittet');
}

function custType(custtype){
	
	new Ajax(url, {
   		method: 'get',
	   	update: $('theCart'),
	   	data: Object.toQueryString({action:'showContact', custtype:custtype})
   	}).request();

}

function pickup() {

		if ($('delivMode').getValue()=='Pickup') {
			
			$('Pickup').removeClass('hide');
			$('timeofpick').removeClass('hide');
			$('time').removeClass('hide');
			$('timeofdel').addClass('hide');
			$('daterow').removeClass('hide');
			if(null != $('difadrbox')){
				$('difadrbox').addClass('hide');
				$('DelivAdr').addClass('hide');
				DelivAdr.hide();
			}
			if(null != $('difadr')){
				if ($('difadr').getProperty('checked') == true) {
					DelivAdr.slideOut();
				}
				$('difadr').removeProperty('checked');
			}

		}
		else if($('delivMode').getValue()=='Delivery'){
			$('Pickup').addClass('hide');
			$('timeofpick').addClass('hide');
			$('timeofdel').removeClass('hide');
			$('daterow').removeClass('hide');
			$('time').removeClass('hide');
			if(null != $('difadrbox')){
				$('difadrbox').removeClass('hide');
			}			

		}
		else{
			$('Pickup').addClass('hide');
			$('timeofpick').addClass('hide');
			$('timeofdel').addClass('hide');
			$('daterow').addClass('hide');
			$('time').addClass('hide');			
			if(null != $('difadrbox')){
				$('difadrbox').addClass('hide');
			}
		}
}

function checkTime(){
	var today = new Date();
	var h = today.getHours();
	var choosendate = this.getValue().split(":");
	var choosenhour = choosendate[0];

	if (h < choosenhour){

	}
	
}

function getCityName(){
	//$('city').setProperty('value','København');
	var post = $('postalcode').getValue();	
	new Ajax(url, {
   		method: 'get',
	   	update: $('city'),
	   	data: Object.toQueryString({action:'getCity', post:post})
   	}).request();

}

function getDelCityName(){
	//$('city').setProperty('value','København');
	var post = $('del_postalcode').getValue();	
	new Ajax(url, {
   		method: 'get',
	   	update: $('del_city'),
	   	data: Object.toQueryString({action:'getDelCity', post:post})
   	}).request();

}

function getMap(id){
	new Ajax(url, {
   		method: 'get',
	   	update: $('loc'),
	   	data: Object.toQueryString({action:'getMap', mapip:id})
   	}).request();	
}
function showContact(){
	
	new Ajax(url, {
   		method: 'get',
	   	update: $('theCart'),
	   	data: Object.toQueryString({action:'showContact'})
   	}).request();

}
function showConfirm(){
	new Ajax(url, {
   		method: 'get',
	   	update: $('theCart'),
	   	data: Object.toQueryString({action:'showConfirm'})
   	}).request();
}

function showYourOrder(){
	new Ajax(url, {
   		method: 'get',
	   	update: $('theCart'),
	   	data: Object.toQueryString({action:'showYourOrder'})
   	}).request();
}

function showThankYou(){
	new Ajax(url, {
   		method: 'get',
	   	update: $('theCart'),
	   	data: Object.toQueryString({action:'showThankYou'})
   	}).request();
}
