// get cookie
function getCookie(NameOfCookie){
	if (document.cookie.length > 0) { 
		begin = document.cookie.indexOf(NameOfCookie+"="); 
	if (begin != -1){ 
		begin += NameOfCookie.length+1; 
		end = document.cookie.indexOf(";", begin);
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(begin, end)); } 
	}
	return null; 
}

// set cookie
function setCookie(NameOfCookie, value, expirehours){
	var ExpDate = new Date ();
	ExpDate.setTime(ExpDate.getTime() + (expirehours * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + ((expirehours == null) ? ";" : "; expires=" + ExpDate.toGMTString());
}

// print page
function print_page() {
	var html = "<html><head><title>"+document.title+"</title></head>";
	html += "<link rel=\"stylesheet\" href=\"templates/default/style/style.css\" type=\"text/css\">";
	html += "<body bgcolor=\"#FFFFFF\" topmargin=\"0\">";
	html += "<table height=\"100%\" width=\"100%\" border=\"0\"><tr><td height=\"10\">";
	html += "<img src=\"configs/logo/logo2.gif\" vspace=\"5\">";
	html += "</td></tr><tr><td valign=\"top\" style=\"padding-bottom:5px;padding-top:5px;border-top:1px solid #0071B8;border-bottom:1px solid #0071B8;\">";
	html += "<b class=\"text14px\">"+document.getElementById('tit').innerHTML+"</b><br><br>";
	html += "<span class=\"text12px\" style=\"text-align:justify;\">"+(document.getElementById('cont') ? document.getElementById('cont').innerHTML : '')+(document.getElementById('mod') && document.getElementById('cont') ? "<br><br>" : '')+(document.getElementById('mod') ? document.getElementById('mod').innerHTML : '')+"</span>";
	html += "</td></tr><tr><td height=\"10\" align=\"center\" class=\"text10px\" style=\"padding:5px;\">";
	html += "Copyright© 2006 Lega Italiana Fibrosi Cistica<br>ONLUS - Organizzazione Non Lucrativa di Utilita' Sociale<br>info@fibrosicistica.it";
	html += "</td></tr></table>";
	html += "</body></html>";
	var ident_prt = window.open("","print","height=1,width=1,top="+(screen.height)+",left="+(screen.width));
	ident_prt.document.open();
	ident_prt.document.write(html);
	ident_prt.print();
	ident_prt.document.close();
	ident_prt.close(); 
}

// preload images
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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// switch images
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// openWindow('urlPage', 'namePopup', 'width', 'height', 'yes/no', 'yes/no');
function openWindow(mypage,myname,w,h,resizable,scrollbars){ 
	w = (Number(w) + 1);
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0; 
	settings = 'scrollbars='+scrollbars+',resizable='+resizable+',status=no,height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition;
	win = window.open(mypage,myname,settings);
}

// correct date
function areCharsInList(s,list) {
	var i,c;
	for (i=0;i<s.length; i++) {
		c = s.charAt(i);
	if (list.indexOf(c) == -1)
		return false;
	}
return true;
}

function isDate(str){
	if(str.length!=10){
		return false;
	}
	if(str.charAt(2)!='/' || str.charAt(5)!='/'){
		return false;
	}
	if( !areCharsInList(str.substring(0,2)+str.substring(3,5)+str.substring(6,10), '1234567890') ){
		return false;
	}
	if(str.substring(3,5)>12){
		return false;
	}
	if(str.substring(0,2)>31){
		return false;
	}
return true;
}

function returnSelection(radioButton) {
	var selection=null;
	for(var i=0; i<radioButton.length; i++) {
		 if(radioButton[i].checked) {
		   selection=radioButton[i].value;
		   return selection;
		 }
	}
	return selection; 
}
function MM_openBrWindow(theURL,winName,features){
  window.open(theURL,winName,features);
}

function ingrandisci(){
	//~ var obj = document.getElementById('flvmovie');
	//~ alert(obj.style.height);
	//~ if (obj.height=='') obj.style.height='292px';
	//~ alert(obj.style.height);
	new Effect.Scale('flvmovie',171.2,{scaleX:false,   scaleMode: { originalHeight: 170}}); 
}
function riduci(){
	new Effect.Scale('flvmovie',58.22,{scaleX:false});
}
