//<![CDATA[

////////// FUNCTIONS 


function openWin(path,winW,winH) {
	var iMyWidth;
	var iMyHeight;
    iMyWidth = (window.screen.width/2) - ((winW/2)+ 10); 
	iMyHeight = (window.screen.height/2) - ((winH/2) + 50); 
	var win2 = window.open(path,'',"status,toolbar=0,height="+winH+",width="+winW+",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
    win2.opener=window;
    win2.focus();
    return false;
}


function aMod_externalLink(){    
    var as,i,islink;
    // grab all links, and loop over them
    as=document.getElementsByTagName('a');
    for(i=0;i<as.length;i++){
        // take the link's href
        islink=as[i].href; 
        // and check if it contains the current location 
        var host = new String(window.location.hostname);
        rExp = /www./gi;
        domain = host.replace(rExp, "");

        if(islink.indexOf(domain)==-1 && islink.indexOf('javascript:')==-1){
            if(!as[i].getAttribute('title'))as[i].setAttribute('title',islink);
            as[i].setAttribute("target","_blank"); 
        } 
    }
}


///////////// editable 

function closeIntro(){
	//new Fx.Tween('intro').start('height', '20px');
	
	var top=$('intro');
	top.innerHTML=was;
	top.style.backgroundImage='url(img/top_bg.gif)';
	document.getElement('html').removeClass('active');
}
function openIntro(){
	//new Fx.Tween('intro').start('height', '356px');
	
	var top=$('intro');
	was=top.innerHTML;
	top.style.backgroundImage='none';
	document.getElement('html').addClass('active');
	//
	setTimeout("playIntro('"+fechaTag+"')",800);
}
function toggleIntro(){
	document.getElement('html').toogleClass('active');

}
function playIntro(fechaTag){	
	var intro = new SWFObject("intro.swf", "in", "90%", "90%", "6", "#1a2138");
	intro.write("intro");
	//
	var top=$('intro');
	var a = document.createElement('a');
	a.href='javascript://';
	a.className="close";
	a.onclick=closeIntro;
	//addEvent( a, 'click', 'alert(12)' );
	a.appendChild(document.createTextNode(fechaTag));
	top.appendChild(a);
	return false;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


////////////////// onload 

window.addEvent('domready', function(){
	aMod_externalLink();
	
	var viu=readCookie('viu');
	if(viu!=1){
		openIntro();
		createCookie('viu',1,300);
	}
});




///////////////// SCRIPTS 
 
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}


//]]>

