function setActiveStyleSheet(title) {
  
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) {
		  createCookie("style", title, 365);
		   a.disabled = false;
	  }
    }
  }
  
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

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 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;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie!=null&&cookie!='' ? cookie : getPreferredStyleSheet();
  checkiconstyle(title);
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
  checkiconstyle(title);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);



/*script site check property */


function checkiconstyle(synsite){

idicstyle=new Array("dblue","red","yellow","blue");
idvalicstyle=new Array("-141px","-104px","-123px","-159px");
 for(i=0;i<idicstyle.length;i++) {
	idiconst="ic"+idicstyle[i]; 
    if(synsite==idicstyle[i]){valposiocnst=idvalicstyle[i]+" -380px "; document.getElementById(idiconst).style.backgroundPosition=valposiocnst;}
    else{valposiocnst=idvalicstyle[i]+" -365px";document.getElementById(idiconst).style.backgroundPosition=valposiocnst;}
 }	
}





function mainnews(blockmun){
for(i=1;i<=4;i++){document.getElementById("mainnews"+i).style.display="none";document.getElementById("mainnews"+i).style.top="-277px";document.getElementById("ptrmain"+i).className="";}
//$("#mainnews"+blockmun).fadeIn("0");
document.getElementById("mainnews"+blockmun).style.display="block";
$("#mainnews"+blockmun).animate({"top": "-2px"}, 500);
$("#ptrmain"+blockmun).addClass("current");
	
}





var pos;
var bool=1;
function showhidemain(numele){
if(numele=="1"){pos="0";changepoints('1');}
if(numele=="2"){pos="-472px";changepoints('2');}
if(numele=="3"){pos="-944px";changepoints('3');}
	
	$("#slider").animate({"right": pos}, "slow");
}


function changepoints(sel){
	
for(i=1;i<=3;i++){
	$("#ptn"+i).css("background-position","-18px -883px");
	}
	$("#ptn"+sel).css("background-position","-2px -883px");	
}


function nextpermain(par){
if(par==1){
	
	if(bool>=3){bool=1;showhidemain(bool);}
	else if(bool==1){bool=bool+1;showhidemain(bool);}
	else{bool=bool+1;showhidemain(bool);}	
}

else{
	
	if(bool==1){bool=3;showhidemain(bool);}
	else if(bool==3){bool=bool-1;showhidemain(bool);}
	else{bool=bool-1;showhidemain(bool);}	
	}
}






function mainnews2(numele){
	
	for(i=1;i<=4;i++){
	document.getElementById("imges"+i).style.display="none";
	$("#thumb"+i).css("border-color","");
	}
	$("#imges"+numele).css("display","block");
	$("#thumb"+numele).css("border-color","#b50000");
	
}


function mainnews3(numele){
	
	for(i=1;i<=4;i++){
	document.getElementById("imges"+i).style.display="none";
	$("#thumb"+i).css("border-color","");
	}
	$("#imges"+numele).css("display","block");
	$("#thumb"+numele).css("border-color","#b50000");
	
}






var tgs = new Array( 'div','td','tr');
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}



function openprint(linkpage){
var tool
var lefts=(screen.width/2)-400;
var tops=(screen.height/2)-400;
tool="height=800,width=800,left="+lefts+",top="+tops+",toolbar=no,menubar=no,scrollbars=yes"
window.open(linkpage,"mywindow",tool)
}

function opensend(linkpage){
var tool
var lefts=(screen.width/2)-220;
var tops=(screen.height/2)-150;
tool="height=300,width=440,left="+lefts+",top="+tops+",toolbar=no,menubar=no,scrollbars=yes"
window.open(linkpage,"mywindow",tool)
}

