// JavaScript Document



function setFontSize(){document.getElementsByTagName('body')[0].style.fontSize=(arguments[0]+'em');}
		
function handleFontSize(_ckName,_val,_overridable){
	var _domain='',_expires=getDate(),_path='/';
	if((readCookie(_ckName)=='')||(_overridable!=true)){
		createCookie(_ckName,_val,_expires,_path);
	}else{
		_val=readCookie(_ckName);
	}
	setFontSize(_val);
}
		
function readCookie(_name){
	_name+="=";
	var _at=document.cookie.split(';');
	for(_i=0;_i<_at.length;_i++){
		var _st=_at[_i];
		while(_st.charAt(0)==' '){
			_st=_st.substring(1,_st.length);
		}
		if(_st.indexOf(_name)==0){
			return _st.substring(_name.length,_st.length);
		}
	}
	return('');
}		

function createCookie(_name,_val,_expires,_path,_domain){
	var _ck=	_name+'='+escape(_val)
			+((_expires)?'; expires='+_expires.toGMTString():'')
			+((_path)?'; path='+_path:'')
			+((_domain)?'; domain='+_domain:'');
	document.cookie=_ck;
}

function checkCookie(sCookieName){return (document.cookie.indexOf(sCookieName)!=-1)?true:false;}

function clearList(){createCookie('FontSize','');}

function getValues(){alert(document.cookie);}

function getDate(){
	var _now=new Date();
	_now.setTime(_now.getTime()+365*24*60*60*1000);
	return(_now);
}


function addEvent( obj,type,fn ){
	if( obj.attachEvent ){
	   	obj['e'+type+fn] = fn;
	   	obj[type+fn] = function(){obj['e'+type+fn](window.event);};
	   	obj.attachEvent('on'+type, obj[type+fn]);
	 }else{
	   	obj.addEventListener(type,fn,false);
	 }
}

function initFontSize(){
	handleFontSize("FontSize",1,true);
}

// fontSize handler
addEvent(window,"load",initFontSize);




//IMAGE PRELOADING
function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



//POPUP FUNCTION
//var newWin = null; 
//function popUp(strURL, strType, strHeight, strWidth) { 
//function popUp(strURL, strType) { 
// if (newWin != null && !newWin.closed) 
//   newWin.close(); 
// var strOptions=""; 
// if (strType=="console") 
//   strOptions="resizable,height="+ 
//     strHeight+",width="+strWidth; 
// if (strType=="scroll") 
//   strOptions="scrollbars,resizable,height="+ 
//     strHeight+",width="+strWidth; 
// if (strType=="fixed") 
//   strOptions="status,height="+ 
//     strHeight+",width="+strWidth; 
// if (strType=="elastic") 
//   strOptions="toolbar,menubar,scrollbars,"+ 
//     "resizable,location,height="+ 
//     strHeight+",width="+strWidth; 
// newWin = window.open(strURL, 'newWin', strOptions); 
// newWin.focus(); 
//}



var newWin = null; 

function loadPhoto(img){
  foto1= new Image();
  foto1.src=(img);
  control(img);
}
function control(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    theFunction="control('"+img+"')";
    interval=setTimeout(theFunction,20);
  }
}
function viewFoto(img){
 if (newWin != null && !newWin.closed) 
   newWin.close(); 
  iwidth=foto1.width+20;
  iheight=foto1.height+20;
  stringa="width="+iwidth+",height="+iheight;
  newWin=window.open(img,"",stringa);
}









