var prefsLoaded = false;
var defaultFontSize =75;
var currentFontSize = defaultFontSize;

				
function revertStyles(){

	currentFontSize = defaultFontSize;
	changeFontSize(0);

}

function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 10);

	if(currentFontSize > 120){
		currentFontSize = 120;
	}else if(currentFontSize < 70){
		currentFontSize = 70;
	}

	setFontSize(currentFontSize);
	//alert(readCookie("fontSize"));
}

function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('content_area') : document.all('content_area');
	document.body.style.fontSize = fontSize + '%';
	//alert (document.body.style.fontSize);
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    //date.setTime(date.getTime()+(days*24*60*60*1000));
	date.setDate(date.getDate()+days);
	date.setHours(0,0,0,0);
    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 = setUserOptions;


function setUserOptions(){
	
	if(!prefsLoaded){
		cookie = readCookie("fontSize");
		//alert(cookie);
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);
		prefsLoaded = true;
		
	}
	if(document.getElementById("tip1")!=null&&getCookie('subiect')!=null) ascunde_div_tip_client(getCookie('subiect'))

/* pentru afisare banner craciun in panel left */
/*
var container=document.getElementById("panelLeft");
var divFlash=document.createElement("div");

divFlash.id="flash_div";
var firstChild = document.getElementById("panelLeft").firstChild;
document.getElementById("panelLeft").insertBefore(divFlash, firstChild);
var so = new SWFObject('http://www.orange.ro/oferte-speciale/oferta-de-craciun/days/master-leftmenu.swf','jstest','150','140','8');
                  so.addParam('allowscriptaccess','always');
                  so.addParam('wmode','transparent');
                  so.addVariable('javascriptid','jstest');
                  so.addVariable('enablejs','true');
                  so.addVariable('autostart','true');
                  so.write('flash_div');
*/
}

window.onunload = saveSettings;

function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
}



function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.align == "middle") imgStyle = "margin-left:20px;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            //alert(imgStyle);
			img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
window.onload=correctPNG;window.attachEvent("onload", correctPNG);

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}
//addLoadEvent(correctPNG);



