//  Definizione variabili globali onfocus
var box_obj;
var box_height;
var box_top;
var top;

// Definizione variabili globali case history
var alt;
var i;

var art01_obj;
var art01_height;
var top01;

var art02_obj;
var art02_height;

var art03_obj;
var art03_height;

var art04_obj;
var art04_height;

var art05_obj;
var art05_height;

var timer;
var count = 0;
var obj_array = new Array();
var height_array = new Array ();

// Definizione variabili globali articoli altre riviste
var n;

var art_riv01_obj;
var art_riv01_height;
var top01;

var art_riv02_obj;
var art_riv02_height;

var art_riv03_obj;
var art_riv03_height;

var art_riv04_obj;
var art_riv04_height;

var art_riv05_obj;
var art_riv05_height;

var timer2;
var count2 = 0;
var obj_array2 = new Array();
var height_array2 = new Array ();


// Funzioni on focus

function inizializza() {	
	box_obj=document.getElementById("onfocus").style
	box_height=document.getElementById("onfocus").scrollHeight;
	box_obj.top="130px";
	top=parseInt(box_obj.top);
	move_focus_layer();
}

function move_focus_layer() {
	if (top>-box_height) {
		top=top-1;
		box_obj.top=top+"px";
		setTimeout("move_focus_layer()", 75)
	}
	else {inizializza()}
		
}


// Funxzioni case history

function ini_cs() {

	obj_array[0]=document.getElementById("art_casehistory_01").style;
	height_array[0]=document.getElementById("art_casehistory_01").scrollHeight;

	obj_array[1]=document.getElementById("art_casehistory_02").style;
	height_array[1]=document.getElementById("art_casehistory_02").scrollHeight;

	obj_array[2]=document.getElementById("art_casehistory_03").style;
	height_array[2]=document.getElementById("art_casehistory_03").scrollHeight;
	
	obj_array[3]=document.getElementById("art_casehistory_04").style;
	height_array[3]=document.getElementById("art_casehistory_04").scrollHeight;
	
	obj_array[4]=document.getElementById("art_casehistory_05").style;
	height_array[4]=document.getElementById("art_casehistory_05").scrollHeight;
	
	obj_array[0].visibility="visible";
}

function check() {
	clearTimeout(timer);
	obj_array[count].top="0px";
	read_cs();
}

function read_cs(){
	
	neg_height = -(height_array[count]);
	top01=parseInt(obj_array[count].top);
	if (top01 >= neg_height) {
			top01=top01-1;
			obj_array[count].top=top01+"px";
			timer=setTimeout("read_cs()",50);
	}
	else {
		clearTimeout(timer);
		obj_array[count].top="0px";
	}
}

 
function forward_casehistory() {
	i = 0;
	count++;
	if (count==5) {
		count=4;
		return;
	}
	if (count<=4) {
		for (i; i<=4; i++)
			{obj_array[i].visibility = "hidden"};
		obj_array[count].top="0px";
		obj_array[count].visibility = "visible";
	}
	else {
		return;
	}
}

function back_casehistory() {
	i = 0;
	count--;
	if (count<0) {
		count=0;
		obj_array[0].top="0px";
		return;
	}
	if (count>=0) {
		for (i; i<=4; i++)
			{obj_array[i].visibility = "hidden"};
		obj_array[count].top="0px";
		obj_array[count].visibility = "visible";
	}
	else {
		return;
	}
}


// Funxzioni articoli altre riviste

function ini_riv() {

	obj_array2[0]=document.getElementById("art_riv01").style;
	height_array2[0]=document.getElementById("art_riv01").scrollHeight;

	obj_array2[1]=document.getElementById("art_riv02").style;
	height_array2[1]=document.getElementById("art_riv02").scrollHeight;

	obj_array2[2]=document.getElementById("art_riv03").style;
	height_array2[2]=document.getElementById("art_riv03").scrollHeight;
	
	obj_array2[3]=document.getElementById("art_riv04").style;
	height_array2[3]=document.getElementById("art_riv04").scrollHeight;
	
	obj_array2[4]=document.getElementById("art_riv05").style;
	height_array2[4]=document.getElementById("art_riv05").scrollHeight;
	
	obj_array2[0].visibility="visible";
}

function check_riv() {
	clearTimeout(timer2);
	obj_array2[count2].top="0px";
	read_riv();
}

function read_riv(){
	
	neg_height2 = -(height_array2[count2]);
	top02=parseInt(obj_array2[count2].top);
	if (top02 >= neg_height2) {
			top02--;
			obj_array2[count2].top=top02+"px";
			timer2=setTimeout("read_riv()",50);
	}
	else {
		clearTimeout(timer2);
		obj_array2[count2].top="0px";
	}
}

 
function forward_riv() {
	n = 0;
	count2++;
	if (count2==5) {
		count2=4;
		return;
	}
	if (count2<=4) {
		for (n; n<=4; n++)
			{obj_array2[n].visibility = "hidden"};
		obj_array2[count2].top="0px";
		obj_array2[count2].visibility = "visible";
	}
	else {
		return;
	}
}

function back_riv() {
	n = 0;
	count2--;
	if (count2<0) {
		count2=0;
		obj_array2[0].top="0px";
		return;
	}
	if (count2>=0) {
		for (n; n<=4; n++)
			{obj_array2[n].visibility = "hidden"};
		obj_array2[count2].top="0px";
		obj_array2[count2].visibility = "visible";
	}
	else {
		return;
	}
}

function check(){
	if (document.formsearch.keyw_search.value=="") {
		window.alert("Inserire uno pił termini da ricercare negli articoli");
		document.formsearch.keyw_search.focus();
	}
	
	else {
		document.formsearch.action="ris_search.asp";
		document.formsearch.submit();
	}		
}

function check2(){
	if (document.formsearch.keyw_search.value=="") {
		window.alert("Inserire uno pił termini da ricercare negli articoli");
		document.formsearch.keyw_search.focus();
	}
	
	else {
		document.formsearch.action="../ris_search.asp";
		document.formsearch.submit();
	}		
}