﻿

var currenthost = window.location.host.toLowerCase();


// inizio personalizzazioni

//if (currenthost == 'stage09.ipsoa.it') ShowHomePopup('SHOPMKTNG1', 'http://www.ipsoa.it/marketing/pop_up/offerta_shopwki_pre_hp/pop_up.htm', 15, 930, 1100, 'non visualizzare più');

//if (currenthost == 'stage09.ipsoa.it' || currenthost == 'stage.artelnet.it'|| currenthost == 'stage.ipsoa.it' || currenthost == 'stage.indicitalia.it' || currenthost == 'stage.osra.it' || currenthost == 'testshop.wki.it') {
//    var myStartDate = new Date();
//    myStartDate.setFullYear(2010, 2, 02);
//    var myEndDate = new Date();
//    myEndDate.setFullYear(2010, 2, 12)
//    var today = new Date();
//    if (today > myStartDate && today < myEndDate) {
//        ShowHomePopup(currenthost + 'MKTNG2', 'http://' + currenthost + '/popup.html', 1500, 400, 250, 'Chiudi');
//    }
//}

if (currenthost == 'www.artelnet.it' || currenthost == 'www.ipsoa.it' || currenthost == 'www.indicitalia.it' || currenthost == 'www.osra.it') {
    var myStartDate = new Date();
    myStartDate.setFullYear(2010, 2, 02);
    var myEndDate = new Date();
    myEndDate.setFullYear(2010, 2, 12)
    var today = new Date();
    if (today > myStartDate && today < myEndDate) {
        ShowHomePopup(currenthost + 'MKTNG2', 'http://' + currenthost + '/popup.html', 1500, 400, 250, 'Chiudi');
    }
}

if (currenthost == 'shop.wki.it') {
    var myStartDate = new Date();
    myStartDate.setFullYear(2010, 2, 02);
    var myEndDate = new Date();
    myEndDate.setFullYear(2010, 2, 12)
    var today = new Date();
    if (today > myStartDate && today < myEndDate) {
        ShowHomePopup(currenthost + 'MKTNG2', 'http://' + currenthost + '/popup.html', 1500, 400, 250, 'Chiudi');
    }
}

if (currenthost == 'stage.cedam.com' ) {
    var myStartDate = new Date();
    myStartDate.setFullYear(2010, 2, 02);
    var myEndDate = new Date();
    myEndDate.setFullYear(2010, 2, 12)
    var today = new Date();
    if (today > myStartDate && today < myEndDate) {
        ShowHomePopup(currenthost + 'MKTNG2', 'http://' + currenthost + '/comuni/popup.html', 1500, 400, 250, 'Chiudi');
    }
}



//if (currenthost == 'shop.wki.it') {
//    var myStartDate = new Date();
//    myStartDate.setFullYear(2009, 11, 26);
//    var myEndDate = new Date();
//    myEndDate.setFullYear(2010, 0, 12);
//    var today = new Date();
//    if (today > myStartDate && today < myEndDate) {
//        ShowHomePopup('SHOPMKTNG2', 'http://shop.wki.it/popup.html', 1500, 300, 150, 'Chiudi');
//    } 
//}

//if (currenthost == 'www.ipsoa.it') ShowHomePopup('SHOPMKTNG1', 'http://www.ipsoa.it/marketing/pop_up.htm', 15, 500, 600);
//if (currenthost == 'www.cedam.com') ShowHomePopup('SHOPMKTNG1', 'http://www.ipsoa.it/marketing/pop_up.htm', 15, 500, 600);
//if (currenthost == 'www.indicitalia.it') ShowHomePopup('SHOPMKTNG1', 'http://www.ipsoa.it/marketing/pop_up.htm', 15, 500, 600);

// fine personalizzazioni

function ShowPreHome(name, url) {
    var myEndDate = new Date();
    myEndDate.setFullYear(2009, 11, 27);
    var today = new Date();
    if (today < myEndDate) {   
    var ind = document.cookie.indexOf(name);
    if (ind != -1) return;
    window.location.href = url;
    }

}

function SetCookieAndReturn(name, expiremin, returnurl, days) {
    var myEndDate = new Date();
    myEndDate.setFullYear(2009, 11, 27);
    var today = new Date();
    if (today < myEndDate) {
        var cookieValue = "1";
        var nDays = days;
        var today = new Date();
        var expire = new Date();
        expire.setTime(today.getTime() + expiremin * 60 * 1000);
        document.cookie = name + "=1;expires=" + expire.toGMTString() + ";path=/";
        window.location.href = returnurl;
    }
}


function ShowHomePopup(name, url, expiremin, w, h, closetext) {
    var ind = document.cookie.indexOf(name);
    if (ind != -1) return;
    var T = 100;
    var L = 100;
    if (screen) { 
      T = (document.documentElement.clientHeight - h) / 2;
      L = (document.documentElement.clientWidth - w) / 2;
    }
    if (!closetext) closetext = "chiudi"
    var text = '<div id="' + name + '" class="popupmessage" style="border: #0275ae 2px solid;position:absolute; top:' + T + 'px; left:' + L + 'px" >' +
      '<IFRAME FRAMEBORDER=0 SCROLLING=NO SRC="' + url + '" width=' + w + ' height=' + h + ' style="background-color:transparent"></IFRAME>' +
      '<div align="center" style="background-color:#ffffff;padding: 7px 7px 7px 7px;"><a href="javascript:SetCookieAndClose(\'' + name + '\', ' + expiremin + ' );">' + '<span style="background-color:#0275ae; color:#ffffff; padding: 3px 7px 3px 7px;"><b>' + closetext + '</b></span>' + '</a></div>' +
      '</div>';
    //alert(text);
    document.write(text);
}

function SetCookieAndClose(name, expiremin) {
	var cookieValue = "1";
	var nDays = 30;
	var today = new Date();
	var expire = new Date();
	expire.setTime(today.getTime() + expiremin * 60 * 1000);
	document.cookie = name + "=1;expires=" + expire.toGMTString();
	var comunicazione = document.getElementById(name);
	comunicazione.style.display = 'none';
}