
function updatequantity_plus(row_id, size_id, product_id){
	
	quantity = parseInt(document.getElementById('quantity'+row_id).value);
	
	if (quantity == '') {
		quantity = 0;
	}
	else {
		quantity = quantity+1;
	}
	//alert(quantity);
	window.location = 'order.do.php?do=quantity&quantity=' + quantity + '&row_id=' + row_id + '&size_id='+size_id+'&product_id='+product_id;
	return;
}

function updatequantity_minus(row_id, size_id, product_id){
	
	quantity = parseInt(document.getElementById('quantity'+row_id).value);
	
	if (quantity == '') {
		quantity = 0;
	}
	else {
		quantity = quantity-1;
	}
	//alert(quantity);
	window.location = 'order.do.php?do=quantity&quantity=' + quantity + '&row_id=' + row_id + '&size_id='+size_id+'&product_id='+product_id;
	return;
}

function change_order_image_bg(id){
	
	document.getElementById('order_image_bg').src = "products/"+id+".jpg";
	
}

function writezero(a) {
	
	if (a.value==''){
		a.value='0';
	}
	
}

function news_replacer(id){
	
	new Ajax.Updater('news_replacer', 'index.do.php?do=news_replacer&id='+id, { method: 'get' });
	
}

function mouseOverDiv(XY)
{
	document.getElementById('newsteaser').innerHTML = XY;
}

function mouseOutDiv()
{
	document.getElementById('newsteaser').innerHTML = "";
}

function addToCart(id, form, count){
	
	var currentDate = new Date();
	var day = currentDate.getDate();
	var month = currentDate.getMonth();
  	var year = currentDate.getFullYear();
  			
	var hours = currentDate.getHours();
  	var minutes = currentDate.getMinutes();
	var seconds = currentDate.getSeconds();
			
	time = day+month+year+hours+minutes+seconds;

	document.getElementById('all_info'+count).innerHTML = "";
	
	size = form.size.value;
	
	new Ajax.Updater('basket', 'cart.do.php?do=add&id='+id+'&size='+size, { method: 'get' });
	
	new Ajax.Updater('options_'+count, 'cart.do.php?do=getoptions&id='+id+'&count='+count+'&time='+time, { method: 'get' });

	new Ajax.Request('cart.do.php?do=getoptions&id='+id+'&count='+count+'&time='+time,
	  {
	    method:'get',
	    onSuccess: function(transport){
	      
	    	document.getElementById('all_info'+count).innerHTML = document.getElementById('shop_info_content'+count).innerHTML;
	    	
	    },
	    onFailure: function(){ alert('Noget gik galt...') }
  	});
	
  	Effect.Appear('middle_pulsate', { duration: 0.5, from: 0, to: 1 });
	setTimeout("Effect.Appear('middle_pulsate', { duration: 0.5, from: 1, to: 0 });", 5000);

}

function minmaxOver(){
	
	document.getElementById('minmax').src = "graphics/minimaxi_hover.png";

}

function minmaxOut(){
	
	document.getElementById('minmax').src = "graphics/minimaxi.png";

}

function expcolDiv(counter)
{
	
	$('shop_info_div'+counter).morph('height:0px;');
	
}

function getInfo(id, counter, obj){
	
	document.getElementById('shop_info_content'+counter).innerHTML = "";
	
	document.getElementById('shop_info_content'+counter).innerHTML += document.getElementById('all_info'+counter).innerHTML;
	
	document.getElementById('maximini'+counter).style.display = "block";

	$('shop_info_div'+counter).morph('height: 80px;');
	
}

function getCat(counter, number){
	
	document.getElementById('shop_info_content'+counter).innerHTML = "<div id=\"maximini"+counter+"\" class=\"minimaxi\"><a id=\"linker"+counter+"\" title=\"Skjul produktinformation\" href=\"javascript: expcolDiv('"+counter+"')\" onmouseup=\"blur()\" onmouseover=\"minmaxOver()\" onmouseout=\"minmaxOut()\" ><img id=\"minmax\" src=\"graphics/minimaxi.png\" /></a></div>";
	
	document.getElementById('shop_info_content'+counter).innerHTML += document.getElementById('all_products_hidden').innerHTML;
	newHeight = (Math.ceil((number / 4))*46)+12;
	
	$('shop_info_div'+counter).morph('height:'+newHeight+'px;');

}

function getRel(number, counter){
	
	document.getElementById('shop_info_content'+counter).innerHTML = "<div id=\"maximini"+counter+"\" class=\"minimaxi\"><a id=\"linker"+counter+"\" title=\"Skjul produktinformation\" href=\"javascript: expcolDiv('"+counter+"')\" onmouseup=\"blur()\" onmouseover=\"minmaxOver()\" onmouseout=\"minmaxOut()\" ><img id=\"minmax\" src=\"graphics/minimaxi.png\" /></a></div>";
	
	document.getElementById('shop_info_content'+counter).innerHTML += document.getElementById('all_related'+counter).innerHTML;
	//str1 = document.getElementById('all_related'+counter).innerHTML;
	
	//regexp = /img/g;
	
	//var arr1 = new Array();
	
	//arr1 = str1.match(regexp);
	
	
		
	if(number == 0){
		
		// Hvis der ingen relaterede produkter er 
		$('shop_info_div'+counter).morph('height: 30px;');
	
	}
	else{
		
		newHeight = (Math.ceil((number / 4))*46)+12;
		
		$('shop_info_div'+counter).morph('height: '+newHeight+'px;');

	}
}

function openRelated(counter){
	
	$('related'+counter).morph('width: 55px;');
	
}