//********** 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 > 590 )
	{
		document.img_width_size.width = 590;
	}
  
  
}



///////////////////////////////////////////////////////////// Tab ////////////////////////////////////////


function showTab(id){
	document.getElementById("tab_1").style.display = "none";
	document.getElementById("tab_2").style.display = "none";
	document.getElementById("tab_" + id).style.display = "block";
}

function changeImg(tab){
	if(tab == "tab_2"){
		document.getElementById("tab_1_active").style.display = "none";
		document.getElementById("tab_2_inactive").style.display = "none";
		document.getElementById("tab_1_inactive").style.display = "block";
		document.getElementById("tab_2_active").style.display = "block";
	}
	else if(tab == "tab_1"){
		document.getElementById("tab_1_active").style.display = "block";
		document.getElementById("tab_2_inactive").style.display = "block";
		document.getElementById("tab_1_inactive").style.display = "none";
		document.getElementById("tab_2_active").style.display = "none";
	}
}



//***********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);



                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      