var fnt = 'loading';
var pnr = null;
var tpp = null;
var cwpp = null;
var opnd = '';
var a_img = "01";
var b_img = "01";
var newwin = '';


function lnSh() { 
	var hddv = document.getElementById('fltdv').style;
	
	hddv.marginLeft='-5px';
	hddv.paddingLeft='5px';
	hddv.paddingRight='8px';
	hddv.height='48px';
	hddv.backgroundImage='url(fileadmin/img/bgln.gif)';
	
	}
	
	
function lnHd () {

	var hddv = document.getElementById('fltdv').style;
	
	hddv.marginLeft='0px';
	hddv.paddingLeft='0px';
	hddv.paddingRight='0px';
	hddv.height='16px';

	}



function getCookie(c_name) {
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "="); //se c`� restituisce la posizione (>0)
  if (c_start!=-1) { 
  
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    c_end+=38;
    if (c_end<27) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}



function setCookie(c_name,value) { //,expiredays
	/*cvalue=getCookie('username');
	if (cvalue=="radioSeven") {
		return false;
	}
	else {*/
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+1);
		var path="; path=/"
		document.cookie=c_name+ "=" +escape(value)+"; expires="+exdate.toGMTString()+path; 
	
		//document.getElementById('c001').style.backgroundColor='transparent';
		//}
}


function delCookie(c_name, value) {
	document.cookie=c_name+ "=" +escape(value)+";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	pnr = '';
}


function popitup(url) {
	
	var dtt = new Date();
	ytt = dtt.getFullYear();
	
	cvalue=getCookie('username');
	cinx = cvalue.indexOf('1970');
	
	
	if ((cvalue == "") || (cinx != -1)) {
		//alert('test');
		window.blur();
		//return false;
	}
		if (!newwin.closed && newwin.location) {
			//newwin.location.href = url;
			newwin.focus();
		}
		else {
			newwin=window.open(url,'SEVEN_radio','height=333,width=380');
			if (!newwin.opener) newwin.opener = self;
		}
		if (window.focus) {newwin.focus()}
		return false;
}



function openRadio(a, b, c) {
	popitup(a);
}

function checkCookie(a, b, c) {

	/*cvalue=getCookie('username');
	if (cvalue=="radioSeven") {
		return false;
	}
	else {
	
		cvalue="radioSeven";
		setCookie('username',cvalue);
		//alert('setc');
		//if (browserName == "Microsoft Internet Explorer") {
		//	alert('setCookie'+cvalue+', a='+a+', b='+b+', c='+c);
		//	}
		openRadio(a, b, c);
		pnr.blur();
	}*/
}

function loadSoundb (a, b, c) { 

	//window.clearTimeout(tpp);
	
	//popitup(a);
	
	if (fnt == 'start') {
		initFade();
	}
}

function stopSound (a) {
	a.focus();
}





function cnctImg(a) {

var b = document.getElementById('c0').style;
var c = document.getElementById('c1').style;
var d = [];
var e = [];

if (a.indexOf('04.jpg') != -1) {
	a = a.replace('04.jpg','01.jpg');
	c.backgroundImage = 'url('+a+')';

	}
else {
	d = a.split("/");
	var h = d.length -1;
	e = d[h].split(".jpg");
	var f = e[0].charAt(1);
	f++;
	if (f == '10') {
		e[0] = f;
	}
	else {
		e[0] = "0"+f;
	}
	d[h] = e[0]+".jpg";
	var g = d.join("/");
	
	if(f>1)
	{
		g = "images/"+d[h];
	}
	
	//alert(g);
	c.backgroundImage = 'url('+g+')';

	}
}

function setImgBg(a) {

	var c0id = document.getElementById('c0').style;
	
	//alert(c0id);
	
	c0id.backgroundImage = 'url('+a+')';
	c0id.backgroundRepeat = 'no-repeat';
	c0id.backgroundPosition = 'top center';
	
	cnctImg(a);
}

	
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
    var i = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

function thisMovie(a) {
	if (browserName == "Microsoft Internet Explorer") {
		return window[a];
	} else {
		return document[a];
	}
}

function stopflv() { 
	frames[1].thisMovie("player").Stop(); 
}

function shfl() {
	document.getElementById('clrfl').style.visibility='visible';
	document.getElementById('clrfl').style.opacity='0.1';
	opacity('clrfl', 0, 80, 500);
	document.getElementById('flvd1').style.visibility='visible';
	window.frames['flvf'].shfl();
	//document.frames['flvf'].fldv.focus();
}

function clfl() {
	window.frames['flvf'].hdfl();
	document.getElementById('clrfl').style.visibility='hidden';
	document.getElementById('flvd1').style.visibility='hidden';
	stopflv();

}


function fadeImg() { 
	
	var c0im = document.getElementById('c0').style.backgroundImage;
	var c1id = document.getElementById('c1').style;
	var urc1 = c1id.backgroundImage.slice(4,-1);
	var cm1m = document.getElementById('c-1').style.backgroundImage;
	
	
	document.getElementById('c0').style.backgroundImage = c1id.backgroundImage; //scambio layer v
	
	//alert('MESSAGGIO PER IL DEBUG, PER DISINSERIRE TEMPORANEAMENTE CLICCARE LA FLASH GALLERY E RIMANERE LI: '+c1id.backgroundImage); //safari becca solo la 02
    //alert('MESSAGGIO PER IL DEBUG, PER DISINSERIRE TEMPORANEAMENTE GLI ALERT CLICCARE LA FLASH GALLERY E RIMANERE LI: c0im='+c0im+'   c1id='+c1id.backgroundImage+'   urc1='+urc1);
    
	opacity('c1', 100, 0, 700);
	
	window.setTimeout("cnctImg('" +urc1 + "');",700);
	opnd = window.setTimeout("opacity('c1', 0, 100, 500);", 8490);
	
}


function initFade() {

	fnt = window.setInterval("fadeImg();", 9000);
	window.setTimeout("opacity('c1', 0, 100, 500);", 8490);
}

function clrTmro() {
	//alert('test');
	window.clearTimeout(tpp);
	delCookie('username', 'radioSeven');
	/*document.getElementById("c001").style.backgroundColor='#ff0000';
	document.getElementById("c001").innerHTML="...debugging popup, please wait";*/
}

function timerPop () {
	tpp = window.setTimeout("setCookie('username','radioSeven');", 2990);
	//tpp = window.setTimeout("delCookie('username', 'todelete');", 2990);

}

function initColdWarPopup () {
	cwpp = window.setInterval("timerPop ();", 3000);
}
initColdWarPopup();






 

