var prices = new Array();

jQuery().ready(function()
{



jQuery('#Aanhef').selectbox();
	
jQuery("td.menu_item").hover(function () {
      jQuery(this).css({'background-color' : '#FFFFFF','height' : '62px','width' : '124px'});
      jQuery(this).find("a").css({'color' : '#00294A'});
      jQuery(this).find("td.menu_item_center").css({'height' : '62px'});
      jQuery(this).find("td.menu_left").css({'height' : '53px'});
      jQuery(this).find("td.menu_left_top").css({'background-image' : 'url("/images/menu_left_2.jpg")'});
      jQuery(this).find("td.menu_right_top").css({'background-image' : 'url("/images/menu_right_2.jpg")'});
    }, function () {
      var cssObj = {
        'background-color' : '#006EB4',
        'height' : '38px',
        'width' : '124px'
      }
      jQuery(this).css(cssObj);
      jQuery(this).find("a").css({'color' : '#FFFFFF'});
      jQuery(this).find("td.menu_left").css({'height' : '29px'});
      jQuery(this).find("td.menu_item_center").css({'height' : '36px'});
      jQuery(this).find("td.menu_left_top").css({'background-image' : 'url("/images/menu_left.jpg")'});
      jQuery(this).find("td.menu_right_top").css({'background-image' : 'url("/images/menu_right.jpg")'});
    });
    
    jQuery("td.menu_item").click(function () { 
    	 a = jQuery(this).find("a").attr("href");
    	 window.location = a;
    });
    
    jQuery("div.top_item_active").click(function () { 
    	elem = jQuery(this).find("div");
		jQuery("div#my_types").find("div").css({'display' : 'none'});
		jQuery("div#my_cart").find("div").css({'display' : 'none'});
		if(elem.attr("style")=='display: block;' || elem.attr("style")=='DISPLAY: block'){
			elem.css({'display' : 'none'});
		}else{
			elem.css({'display' : 'block'});			
		}
		
    });
    jQuery("td.top_sub_nav_item").click(function () { 
    	my_id = (jQuery(this).attr("id")).substr(2);
    	fill_type(my_id);
    });
   
    
    jQuery("div#my_types").click(function () { 
    	if(document.getElementById('my_types').className == 'top_item_active'){
    	jQuery("div#my_man").find("div").css({'display' : 'none'});
    	jQuery("div#my_cart").find("div").css({'display' : 'none'});
    	elem = jQuery(this).find("div");
		
		if(elem.attr("style")=='display: block;' || elem.attr("style")=='DISPLAY: block'){
			elem.css({'display' : 'none'});
		}else{
			elem.css({'display' : 'block'});			
		}
		}
		
    });
    
    jQuery("div#my_cart").click(function () { 
    	if(document.getElementById('my_cart').className == 'top_item_active'){
    	jQuery("div#my_man").find("div").css({'display' : 'none'});
    	jQuery("div#my_types").find("div").css({'display' : 'none'});
    	elem = jQuery(this).find("div");
		
		if(elem.attr("style")=='display: block;' || elem.attr("style")=='DISPLAY: block'){
			elem.css({'display' : 'none'});
		}else{
			elem.css({'display' : 'block'});			
		}
		}
		
    });
	old_val_2 = jQuery("#my_types").find("span").html();
	jQuery('.div_pic_click').css({'z-index' : '100'});
})

jQuery(function() {
		jQuery("#tabs").tabs({ cookie: { expires: 30 }});
});






function fill_type(id){
	new_val_1 = jQuery("#m_"+id).html();
	jQuery("#my_man").find("span").html(new_val_1);
	jQuery("#my_types").find("span").html(old_val_2);
	document.getElementById('my_types').className = 'top_item_active';
	document.getElementById('my_cart').className = 'top_item';
	jQuery.ajax({
		   type: "GET",
		   url: "/fill_type.php",
		   data: 'man_id='+id,					   
		   success: function(msg)
		   {		
			  jQuery("div#my_types").find("div").html(msg);
			  jQuery("td.top_sub_nav_item_2").click(function () { 
    			my_id = (jQuery(this).attr("id")).substr(3);
    	    	fill_cart(my_id);
		       });
		   }
 	});
 	
}

function fill_cart(id){
	new_val_2 = jQuery("#mo_"+id).html();
	jQuery("#my_types").find("span").html(new_val_2);
	document.getElementById('my_cart').className = 'top_item_active';
	jQuery.ajax({
		   type: "GET",
		   url: "/fill_cart.php",
		   data: 'model_id='+id,					   
		   success: function(msg)
		   {		
			  jQuery("div#my_cart").find("div").html(msg);
			  jQuery("td.top_sub_nav_item_3").click(function () { 
    			my_id = (jQuery(this).attr("id")).substr(2);
    	    	window.location = "/redir.php?printer_id="+my_id;
		       });
		   }
 	});
}
function aantal_up(){
	jea = jQuery("#aantal").val();
	if(jea<999)
		jea++;
	jQuery("#aantal").val(jea);
}

function aantal_down(){
	jea = jQuery("#aantal").val();
	if(jea>1)
		jea--;
	jQuery("#aantal").val(jea);
}
function go_back(){

history.go(-1);

}

function put_price(sel,disc){

	

	ind = (sel.options.selectedIndex);

	id = (sel.options[ind].value); 

	sub_total = (document.getElementById('subtotal_price').innerHTML.substr(7));

	sub_total = sub_total.replace(",","");

	sub_total = parseFloat(sub_total).toFixed(2);

	document.getElementById('transport_cost').innerHTML = '&euro;&nbsp;'+prices[id].toFixed(2);

	if(disc==-1){

	total_price1 = (parseFloat(sub_total)*(1.19)+parseFloat(prices[id])*(1.19)).toFixed(2);
	total_tax = ((parseFloat(sub_total)+parseFloat(prices[id]))*0.19).toFixed(2);
	

	}else{

	discount = parseFloat(prices[id])-parseFloat(disc);

	if(discount<0)

		discount=0;

	document.getElementById('transport_discount').innerHTML = '-&nbsp;&euro;&nbsp;'+discount.toFixed(2);

//	total_price1 = (parseFloat(sub_total)*(1.19)+parseFloat(prices[id])).toFixed(2)-parseFloat(discount).toFixed(2);
	total_price1 = (parseFloat(sub_total)+parseFloat(prices[id])).toFixed(2)-parseFloat(discount).toFixed(2);
	total_tax = (total_price1*0.19).toFixed(2);
	total_price1 = (total_price1*1.19).toFixed(2);

	}

	total_price1 = parseFloat(total_price1).toFixed(2);

	document.getElementById('total_price').innerHTML = '&euro;&nbsp;'+total_price1;
	document.getElementById('shop_tax').innerHTML = '&euro;&nbsp;'+total_tax;

	

}
