
$(document).ready(function(){

    tuneHeight();
    espanditore();
    gestioneFrecce();
    $(".view-macchine .views-fluid-grid-inline:last").css("background-image", "none");
    //$(".page-miscela-master-club-coffee .pane-node:first").css("background-image", "none");
	
	$(".section-miscela .pane-node h2:last, .section-cialde-capsule-al-bar .pane-node h2:last").css("background-image", "none");
	
});

function gestioneFrecce(){
    /*frecce next*/
    $("#btn-next").hide();
    $("#btn-prev").hide();
    if ($("body").hasClass("page-miscela-coffee-lab") == true) {
        $("#btn-next").show();
        $("#btn-next").attr("href", "master-club-coffee");
        $("#btn-prev").show();
        $("#btn-prev").attr("href", "san-francisco");
    }
    if ($("body").hasClass("page-miscela-master-club-coffee") == true) {
        $("#btn-next").show();
        $("#btn-next").attr("href", "caffe-costadoro");
        $("#btn-prev").show();
        $("#btn-prev").attr("href", "coffee-lab");
    }
    
    if ($("body").hasClass("page-miscela-caffe-costadoro") == true) {
        $("#btn-next").show();
        $("#btn-next").attr("href", "san-francisco");
        $("#btn-prev").show();
        $("#btn-prev").attr("href", "master-club-coffee");
    }
    
    if ($("body").hasClass("page-miscela-san-francisco") == true) {
        $("#btn-next").show();
        $("#btn-next").attr("href", "coffee-lab");
        $("#btn-prev").show();
        $("#btn-prev").attr("href", "caffe-costadoro");
    }
	
	
	if ($("body").hasClass("page-sistema-a-capsule-costadoro-coffee-lab") == true) {
        $("#btn-next").show();
        $("#btn-next").attr("href", "sistema-a-cialde-costadoro-coffee-lab");
        $("#btn-prev").show();
        $("#btn-prev").attr("href", "sistema-a-cialde-costadoro-coffee-lab");
    }
	if ($("body").hasClass("page-sistema-a-cialde-costadoro-coffee-lab") == true) {
        $("#btn-next").show();
        $("#btn-next").attr("href", "sistema-a-capsule-costadoro-coffee-lab");
        $("#btn-prev").show();
        $("#btn-prev").attr("href", "sistema-a-capsule-costadoro-coffee-lab");
    }
	if (($("body").hasClass("page-altri-prodotti") == true)||($("body").hasClass("page-linea-moka-espresso"))) {
        
		avanti=$(".pager-next a").attr("href"); 
		indietro=$(".pager-previous a").attr("href"); 
		
		if(avanti){
		$("#btn-next").show();
        $("#btn-next").attr("href", avanti);
		}
		else{
			if ($("body").hasClass("page-altri-prodotti") == true) {
				$("#btn-next").show();
				$("#btn-next").attr("href", "/altri-prodotti");
			}
			if ($("body").hasClass("page-linea-moka-espresso") == true) {
				$("#btn-next").show();
				$("#btn-next").attr("href", "/linea-moka-espresso");
			}
		}
		
		if(indietro){
        $("#btn-prev").show();
        $("#btn-prev").attr("href", indietro);
		}
		else{
			if ($("body").hasClass("page-altri-prodotti") == true) {
				$("#btn-prev").show();
				$("#btn-prev").attr("href", "/altri-prodotti?page=1");
			}
			if ($("body").hasClass("page-linea-moka-espresso") == true) {
				$("#btn-prev").show();
				$("#btn-prev").attr("href", "/linea-moka-espresso?page=1");
			}
		}
    }
	
	
  /*  if ($("body").hasClass("front") == true) {
        $("#btn-next").show();
        $("#btn-prev").show();
    }
  if ($("body").hasClass("node-id-12") == true ||
    $("body").hasClass("node-id-13") == true ||
	 $("body").hasClass("node-id-86") == true ||
    $("body").hasClass("node-id-14") == true) {
        $("#btn-next").show();
        $("#btn-prev").show();
    }*/
}


function espanditore(){
    //nascondi tutti gli elementi
    $(".expand-body").hide();
    //toggle gli elementi figli
    $(".expand-header").click(function(){
        $(this).next(".expand-body").slideToggle("slow");
        $(this).parent("li").toggleClass("open");
    });
}

function tuneHeight(){
    var hmax = 0;
    $(".view-Prodotti .views-field-body").each(function(){
        if (hmax < $(this).height()) {
            hmax = $(this).height();
        }
    });
    $(".view-Prodotti .views-field-body").height(hmax);
    
    
    hmax = 0;
    $(".view-Prodotti .views-field-title").each(function(){
        if (hmax < $(this).height()) {
            hmax = $(this).height();
        }
    });
    $(".view-Prodotti .views-field-title").height(hmax * .6);
    
    hmax = 0;
    $(".view-macchine .views-field-title").each(function(){
        if (hmax < $(this).height()) {
            hmax = $(this).height();
        }
    });
    $(".view-macchine .views-field-title").height(hmax * .6);
    
    hmax = 0;
    $(".view-miscele .views-field-title").each(function(){
        if (hmax < $(this).height()) {
            hmax = $(this).height();
        }
    });
    $(".view-miscele .views-field-title").height(hmax * .6);
}


function loadCss(filename){
    var fileref = document.getElementById("fontcheck")
    fileref.setAttribute("href", filename)
}
function datiAzienda(){
var orig_div_cont=document.getElementById("content").innerhtml;
var myWin=window.open("","myWin","left=230px,top=80px,height=240px,width=320px");
myWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+
'<html><head><title>COSTADORO</title>'+
'<link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/costadoro/css/default.css?O" />'+
'<link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/costadoro/css/layout.css?O" />'+
'<link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/costadoro/css/style.css?O" />'+
'</head><body><div style="padding:16px"><div id="dest_div">'+
'<b>COSTADORO HUNGARY</b> <br>'+
'<br>'+
'CooperLine STUDIO Kft.<br><br>'+
'H-4400, Nyíregyháza<br>'+
'Jósa András utca 13. <br/>'+
'Tel. +36.42.314504<br />Mob. +36.30.9852007<br />Fax. +36.42.314504<br />E-mail: <a href="mailto:info@costadoro.hu">info@costadoro.hu</a>'+
'</div></div></body></html>');
myWin.document.close();
myWin.document.getElementById("dest_div").innerhtml+=orig_div_cont;
}

