﻿function toggleMe(a, btn){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block";
    btn.value = "[Torna alle informazioni minime necessarie per un confronto]";
  } else {
    e.style.display="none"
    btn.value = "[Clicca qui per avere una tariffa ancora più precisa]";
  }
  return true;
}

function toggleMeImg(a, btn) {
    var e = document.getElementById(a);
    if (!e) return true;
    if (e.style.display == "none") {
        e.style.display = "block";
        btn.src = "../img/handle.confronto.base.jpg";
    } else {
        e.style.display = "none"
        btn.src = "../img/handle.confronto.completo.jpg";
    }
    return true;
}

function toggleMe2(a, btn){
  var e=document.getElementById(a);
  //alert(e);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block";
    btn.value = "[Torna alle informazioni minime necessarie per un confronto]";
  } else {
    e.style.display="none"
    btn.value = "[Clicca qui per approfondire ulteriori coperture]";
  }
  return true;
}
function toggleMe3(a, btn){
  var e=document.getElementById(a);
  //alert(e);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block"; 
  } else {
    e.style.display="none" 
  }
  return true;
}
function toggleTrans(a, btn)
{
    var e=document.getElementById(a);
    if(!e)return true;
    if(e.style.display=="none")
    {
        document.getElementById("ctl00_ContentPlaceHolder1_selecMethod").value = "newSelect";
        for(i=1;i<=11;i++)
            document.getElementById("ctl00_ContentPlaceHolder1_CheckBox"+i).disabled = true;
    }
    else 
    {
        document.getElementById("ctl00_ContentPlaceHolder1_selecMethod").value = "oldSelect";
        for(i=1;i<=11;i++)
            document.getElementById("ctl00_ContentPlaceHolder1_CheckBox"+i).disabled = false;
    }
              
    toggleMe2(a, btn);
}

function toggleMenu(a){
  collapse("Div1", a);
  collapse("Div2", a);
  collapse("Div3", a);
  collapse("Div4", a);
  collapse("Div5", a);
  collapse("Div6", a);
  collapse("Div7", a);
  collapse("Div8", a);
  collapse("Div9", a);
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block";
  } else {
    e.style.display="none"
  }
  return true;
}

function collapse(tag, current)
{
  if (tag == current)
     return true;
  var e=document.getElementById(tag);
  if(!e)return true;
    e.style.display="none";
}


/*
Update 2009-12-23
Author cai
fix show help postion
*/
var hashHelpArray = new Object();
function show_caption(idName)
{ 
    var bX=getAbsoluteLeft(idName)+getElementWidth(idName);
    var bY=getAbsoluteTop(idName);  
    var array=new Array(2);
    array=hashHelpArray[idName]; 
    var sTable='<table cellspacing="0" cellpadding="0"><tr><td class="helpHead">'+array[0]+'</td></tr><tr><td align="left" class="helpBox">'+array[1]+'</td></tr></table>';
    document.getElementById("helpPopin").innerHTML = sTable;   
    document.getElementById("helpPopin").style.display = "block";
    document.getElementById("helpPopin").style.position = "absolute";
    document.getElementById("helpPopin").style.left= bX+"px";
    document.getElementById("helpPopin").style.top = bY+"px"; 
}

function hidden_caption(idName)
{
    document.getElementById("helpPopin").style.display = "none";
}
function onShow()
{
    if(document.getElementById("helpPopin").style.display=="none")
        document.getElementById("helpPopin").style.display="block";
}
function hidShow()
{
    document.getElementById("helpPopin").style.display="none";
}

/**
Create Date : 2009-8-3
Description : [Casa-sicura-risultati] Open Iframe
Author      : Ricardo.Wang
*/
function ShowMMSite(namelik)
{
    document.getElementById("hidCase").style.display = "block";
    var hostString = location.host;
    if(namelik=="directLK")
        hostString = "http://"+hostString+"/comparazione/assicurazione/Case-sicura-direct.aspx";
    if(namelik=="genialloydLK")
        hostString = "http://"+hostString+"/comparazione/assicurazione/Case-sicura-genialLoyd.aspx";
    //document.all.caseFrame.src=hostString;
    window.top.document.getElementById("caseFrame").src=hostString;
    document.getElementById("caseFrame").style.visibility="visible";
}

function testImage(theImageName,popupID) {

    var x = document.getElementById(theImageName).offsetLeft;
    var y = document.getElementById(theImageName).offsetTop;
    document.getElementById(popupID).style.left = 590 + x - 200 + "px";
    document.getElementById(popupID).style.top = y + "px";
    document.getElementById(popupID).style.visibility = "visible";
}

function show_info(el_id) {
    var link1 = "link1_" + el_id;
    var link2 = "link2_" + el_id;
    
    if (document.getElementById(el_id).style.visibility == "visible") {
        document.getElementById(el_id).style.visibility = "hidden";
        document.getElementById(el_id).style.display = "none";
        document.getElementById(link1).style.visibility == "visible";
//        document.getElementById(link2).style.visibility == "hidden";
        document.getElementById(link1).style.display == "block";
//        document.getElementById(link2).style.visibility == "none";
    }
    else {
        document.getElementById(el_id).style.visibility = "visible";
        document.getElementById(el_id).style.display = "block";
        document.getElementById(link1).style.visibility == "hidden";
//        document.getElementById(link2).style.visibility == "visible";
        document.getElementById(link1).style.display == "none";
//        document.getElementById(link2).style.visibility == "block";
    }
    

}

function show_articolo(el_id) {
    var art_point = el_id;
    if (document.getElementById(art_point).style.visibility == "visible") {
        //alert("1");
        document.getElementById(art_point).style.visibility = "hidden";
        document.getElementById(art_point).style.display = "none";
    }
    else {
        //alert("2");
        document.getElementById(art_point).style.visibility = "visible";
        document.getElementById(art_point).style.display = "block";
    }
}

function show_info2(el_id) {
    var tariffa = "tariffa_"+el_id;
    if (document.getElementById(tariffa).style.visibility == "visible") {
        //alert("1");
        document.getElementById(tariffa).style.visibility = "hidden";
        document.getElementById(tariffa).style.display = "none";
    }
    else {
        //alert("2");
        document.getElementById(tariffa).style.visibility = "visible";
        document.getElementById(tariffa).style.display = "block";
    }
}

function cambiaClasse(id, nuovaClasse) {
    var a = document.getElementById(id);
    if(a!=null)
        a.className = nuovaClasse;
}

function cambiaClasseOut(id, nuovaClasse) {
    var a = document.getElementById(id);
    if (a.className == "profile_active") {
        nuovaClasse = "profile_active";
    }
    a.className = nuovaClasse;
}

function removeClass(id) {
    var a = document.getElementById(id);
        cambiaClasse("profile01", "profile_link");
        cambiaClasse("profile02", "profile_link");
        cambiaClasse("profile03", "profile_link");
        cambiaClasse("profile04", "profile_link");
        cambiaClasse("profile05", "profile_link");
        cambiaClasse("profile06", "profile_link");
        cambiaClasse("profile07", "profile_link");
        cambiaClasse("profile08", "profile_link");
        a.className = "profile_active";
}
function OpenTariffe(page)
{
    if($.trim(page)!="")
    { 
        page = page+".html";
        window.open(getBaseURL()+'comparazione/telefono/tariffe/'+page,'openWindow','height=500,width=990,scrollbars=yes');
    }
    else
    {
        alert("No tariffa!");
    }
}
function getBaseURL() 
{
    var url = location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));

    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);

        return baseLocalUrl + "/";
    }
    else {
        // Root Url for domain name
        return baseURL + "/";
    }
}
/*
Creat Date:2009-12-23
Author:cai
*/
function getElementWidth(objectId) {
	x = document.getElementById(objectId);
	return x.offsetWidth;
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	return oTop
}
