//********** setStyle: disabling all the other stylesheets, but the predffered one ****************************************
function setStyle(style) {
  var i, a;
  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") == style) a.disabled = false;
    }
  }
}

//************getActiveStyleSheet: reads the CurrentActive stylesheet. ****************************************************
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;
}

//********** getDefaultStyleSheet: here u can apply the default styleSheet 4 the web site**********************************
function getDefaultStyleSheet() {
  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;
}

//**************createCookie: saves the current styleSheet in a cookie *****************************************************
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=/";
}

//************readCookie: reads the saved styleSheet in the cookie, *********************************************************
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 event: reading the cookie, applying the saved style***********************************************
window.onload = function(e) {
  var cookie = readCookie("currentStyle");
  var myStyle = cookie ? cookie : getDefaultStyleSheet();
  setStyle(myStyle);
  
  ////////////////////////////////////// size of image //////////////////////////////////////////
  if(document.img_width_size.width > 570 )
	{
		document.img_width_size.width = 570;
	}
  
  
}

//***********onunload: calls the createCookie function to save the current styleSheet****************************************
window.onunload = function(e) {
  var myCurrentStyle = getActiveStyleSheet();
  createCookie("currentStyle", myCurrentStyle, 365);
}

//*********** same code lines in the onload event for multiple browsers ************************************
var cookie = readCookie("currentStyle");
var myStyle = cookie ? cookie : getPreferredStyleSheet();
setStyle(myStyle);
  

///////////////////////////////////// the more news tab ///////////////////////////////////////////////

function change_img()
{
	if(document.getElementById("open_tab_news").style.height == "110px")
	{
		document.getElementById("open_tab_news").style.height = "0px";
		document.img_btn.src = "../Images/design/down.gif";
		
	}
	
	else
	{
		document.getElementById("open_tab_news").style.height = "110px";
		document.img_btn.src = "../Images/design/up.gif";
	}
}
