/***********************************************************
***Variaveis a alterar consoante o background e o link******
***********************************************************/
var newBodyImg = "http://ad.pt.doubleclick.net/ad/_REC_INTER_/MOLDURA;tile=1;sz=1500x1024;ord=123456789?";
var newBodyUrl = "http://ad.pt.doubleclick.net/jump/_REC_INTER_/MOLDURA;tile=1;sz=1500x1024;ord=123456789?";

var inicio_moldura = new Date(2012,01,11,08,00,00);
inicio_moldura.setFullYear(2012,01,11);
var fim_moldura = new Date(2012,01,11,20,00,00);
fim_moldura.setFullYear(2012,01,11);
/**********************************************************/
function goUrl(){window.open(newBodyUrl);}
function initBody(){
    var current = document.getElementById('dataActual').value;
    var arraySplit = current.split('T');
    var datepSplit = arraySplit[0].split('-');
    var hoursSplit = arraySplit[1].split(':');
    var currentDate = new Date(datepSplit[0],parseInt(datepSplit[1]-1),datepSplit[2],hoursSplit[0],hoursSplit[1],hoursSplit[2]);
    currentDate.setFullYear(datepSplit[0],parseInt(datepSplit[1]-1),datepSplit[2]);
	//verify if is IE6
	var browser = new String(navigator.appName);
	var browserVersion = new String(navigator.appVersion);
	if(browser.indexOf("Internet Explorer") != -1 && browserVersion.indexOf("MSIE 6.0") != -1)
		return;
    
    //window.setTimeout("call();",2000);
    var t = document.location.href;
    if(t.indexOf("moldura=0") == -1)
    {
        if(currentDate >= inicio_moldura && currentDate <= fim_moldura)
        {
            var htmlMoldura = "<A HREF='http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=tf&c=20&mc=click&pli=3905964&PluID=0&ord=%n'><IMG SRC='http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=tf&c=19&mc=imp&pli=3905964&PluID=0&ord=%n&rtu=-1' BORDER=0 WIDTH=1 HEIGHT=1 ALT='Advertisement'></A>";
            //var htmlMoldura = "<A HREF='http://ad-emea.doubleclick.net/jump/N5648.Cofina/B6246621;sz=1x1;ord=[timestamp]?'><IMG SRC='http://ad-emea.doubleclick.net/ad/N5648.Cofina/B6246621;sz=1x1;ord=[timestamp]?' BORDER=0 WIDTH=1 HEIGHT=1 ALT='Advertisement'></A><div style='width: 100%; height: 100%; position: fixed;left:0px;top:0px; background: transparent url(" + newBodyImg + ") no-repeat center top fixed;'>";
            
            
            var htmlMoldura = "<div style='width: 100%; height: 100%; position: fixed;left:0px;top:0px; background: transparent url(" + newBodyImg + ") no-repeat center top fixed;'>";
            
            htmlMoldura += "<a href='" + newBodyUrl + "' target='_blank'>";
            htmlMoldura += "<img src='http://www.record.xl.pt/common/images/blank.gif' border='0' width='100%' height='100%' /></a></div>";
            
            //tag impressoes
            //htmlMoldura += "<IMG SRC='http://ad-emea.doubleclick.net/ad/N6428.279838.RECORD/B6197819;sz=1x1;ord=[timestamp]?' BORDER=0 WIDTH=1 HEIGHT=1 ALT='Advertisement'/>";
            
            //htmlMoldura += "<div style='width: 100%; height: 121px;'>";
            //htmlMoldura += "<a target='_blank' href='" + newBodyUrl + "'><img src='http://www.record.xl.pt/common/images/blank.gif' border='0' width='100%' height='100%'></a></div>";
            //var htmlBody = document.body.innerHTML;
            //document.body.innerHTML = htmlMoldura + htmlBody;
            
            $("#siteMainFormContainer").css("background","none scroll rgb(255, 255, 255)").css("position","relative").css("z-index","1").css("margin","auto").css("top","118px");
            $("#siteMainFormContainer").css("width","978px");
            
            $(htmlMoldura).appendTo($("body"));
        }
        
        call();
    }
}
