function addLoadEvent(func) {   
  var oldonload = window.onload;   
  if (typeof window.onload != 'function') {   
    window.onload = func;   
  } else {   
    window.onload = function() {   
      if (oldonload) {   
        oldonload();   
      }   
       func();   
     }   
   }   
 }   

function updateCSS(){
document.getElementById('screenview').href='../css/print.css';
window.print();
}

function restoreCSS(){
document.getElementById('screenview').href='../css/all.css';
}
// 
//********************************** popup ********************************** //
// 
var flag=1;
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function getBodyScrollTop()
{
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}
function getBodyScrollLeft()
{
	return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}
function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}
function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
function getClientCenterX()
{
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1];
		var wid=document.body.scrollWidth;

	return parseInt(wid/2);
}
function getClientCenterY()
{
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1];
		var wid=document.body.scrollWidth;

	return parseInt(hei/2)+getBodyScrollTop();
}
	function openPopup()
		{
		var width=680;
		var height=520;
		
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1]-4;
		var wid=document.body.scrollWidth;

		var half_width=width/2;
		var half_height=height/2;

		document.getElementById('shaded').style.height=hei+"px";
		document.getElementById('shaded').style.width=wid+"px";

		if((getClientCenterY()-half_height)>0) var tp=170;

		document.getElementById('infoiframe_div').style.top=tp+"px";
		document.getElementById('infoiframe_div').style.left=(getClientCenterX()-half_width)+"px";

		document.getElementById('infoiframe_div').style.width=width+"px";
		document.getElementById('infoiframe_div').style.height="auto";
		document.getElementById('shaded').className="shaded_vis";
		document.getElementById('infoiframe_div').className="infoiframe_visible";
		}
	function closepopup()
		{
			document.getElementById('shaded').className="shaded_hid";
			document.getElementById('infoiframe_div').className="infoiframe_hidden";
		}
//
// ***************************************************** leftbanner *****************************************************//
//
var leftslides=new Array();
var textesA=new Array();

var rightslides=new Array();
var righttextesA=new Array();


var curleftslide=1;
var currightslide=1;

var cook=getCookie('leftslide')+"";
var cookR=getCookie('rightslide')+"";

if(cook=="") var goslide=1; else var goslide=parseInt(cook);
if(cookR=="") var goslideR=1; else var goslideR=parseInt(cookR);


leftslides[1]="banner-home-1.gif";
leftslides[2]="banner-home-2.gif";

textesA[1]='/reviews/';
textesA[2]='/reviews/';




rightslides[1]="banner-right-1.gif";
rightslides[2]="banner-right-2.gif";

righttextesA[1]='/reviews/avinol.html';
righttextesA[2]='/reviews/avinol.html';


function getLeftBanner(){

curleftslide=goslide;
	
var topbanner=document.getElementById('left-banner-1');
topbanner.style.backgroundImage="url(../images/"+leftslides[curleftslide]+")";
document.getElementById('left-banner-link').href=textesA[curleftslide];

			var now = new Date()			
			now.setTime(now.getTime()+ 12*31*24*60*60*1000);
			expires=now;
			if(goslide<leftslides.length-1) var newgoslide=goslide+1; else newgoslide=1;

			setCookie("leftslide",newgoslide,expires,"/");


}


function getRightBanner(){

currightslide=goslideR;
var rightbanner=document.getElementById('right-banner');
rightbanner.style.backgroundImage="url(../images/"+rightslides[currightslide]+")";
document.getElementById('right-banner-link').href=righttextesA[currightslide];

			var now = new Date()			
			now.setTime(now.getTime()+ 12*31*24*60*60*1000);
			expires=now;
			if(goslideR<rightslides.length-1) var newgoslideR=goslideR+1; else newgoslideR=1;

			setCookie("rightslide",newgoslideR,expires,"/");


}


function initAnimations(){
	if(document.getElementById('left-banner-1'))
		getLeftBanner();

	if(document.getElementById('right-banner-1'))
		getRightBanner();

}



var path = "/";
var domain = "";
var expires="18000";
var secure=false;

var caution=false;

function setCookie(name, value, expires, path, domain, secure) {
 var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "")
        if (!caution || (name + "=" + escape(value)).length <= 4000)
  {
  //alert(curCookie);
                document.cookie = curCookie
  }
        else
                        document.cookie = curCookie
}
//********************************** Reding ********************************** //
function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return '';
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

//********************************** Deleting ********************************** //
function deleteCookie(name, path, domain) {
//alert(path);
        if (getCookie(name)) {
                document.cookie = name + "=" + 
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT"
        }
}


//
// ***************************************************** fontsize-controller *****************************************************//
//
var fontsizes=new Array;
var currentSize=3;

fontsizes[1]=9;
fontsizes[2]=11;
fontsizes[3]=13;
fontsizes[4]=15;
fontsizes[5]=17;


addLoadEvent(function() {   

});   


function setSize(num){
var cont=document.getElementById('fontarea');
if(cont && fontsizes[num])
	{
var parags=cont.getElementsByTagName("P");
for(var i=0; i<parags.length; i++) {
		parags[i].style.fontSize=fontsizes[num]+"px";
		//#if(num==4 || num==5)
		parags[i].style.lineHeight=(fontsizes[num]+3)+"px";
	}


var litags=cont.getElementsByTagName("LI");
for(var i=0; i<litags.length; i++) {
		litags[i].style.fontSize=fontsizes[num]+"px";
		//#if(num==4 || num==5)
		litags[i].style.lineHeight=(fontsizes[num]+3)+"px";
	}



var htwo=cont.getElementsByTagName("H2");
for(var i=0; i<htwo.length; i++) {
		htwo[i].style.fontSize=(fontsizes[num]+2)+"px";
	}

	}

			var now = new Date()			
			now.setTime(now.getTime()+ 12*31*24*60*60*1000);
			expires=now;

			setCookie("sleepsize",num,expires,"/");
}


function doNextSize(){
if(currentSize<5) { currentSize=currentSize+1;} else currentSize=5;
setSize(currentSize);
}

function doPrevSize(){
if(currentSize>1) { currentSize=currentSize-1;} else currentSize=1;
setSize(currentSize);
}


var path = "/";
var domain = "";
var expires="18000";
var secure=false;

var caution=false;

function setCookie(name, value, expires, path, domain, secure) {
 var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "")
        if (!caution || (name + "=" + escape(value)).length <= 4000)
  {
  //alert(curCookie);
                document.cookie = curCookie
  }
        else
                        document.cookie = curCookie
}
//********************************** Reding ********************************** //
function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return '';
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

//********************************** Deleting ********************************** //
function deleteCookie(name, path, domain) {
//alert(path);
        if (getCookie(name)) {
                document.cookie = name + "=" + 
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT"
        }
}

