var blank_page = "about:blank";

function open_window(targetX,name,width,height,posx,posy,windowoptions,init_target) {
	var it, wo, px, py, host,target;
 
	it = targetX;
	wo = "location=no,toolbar=no,status=no,statusbar=no,scrollbars=no,resizable=no,dependent=yes";
	px = py = 0;
	target = targetX;
	
	if(typeof new_window != "undefined") {
		if(new_window.closed != true) {
			new_window.close();
		}
	}

	if (typeof posx != "undefined") px = posx;
	if (typeof posy != "undefined") py = posy;
	if ((typeof windowoptions != "undefined") && (windowoptions != "")) wo = windowoptions;
	
	
	if (typeof init_target != "undefined") {
		it = init_target;
	} else {
		if (targetX.indexOf("http://") != -1) {
			host = "http://" + window.location.hostname;
			if (navigator.appName != "Opera") {
				if (targetX.indexOf(host) == -1) it = blank_page;
			}
		}
	}
	new_window = window.open(it,name,"width=" + width + ",height=" + height + "," + wo);
	new_window.moveTo(px,py);
	new_window.location.replace(targetX);
	new_window.focus();
	return false;
}

function PopUpDiashow(target)
{
	var cb = document.getElementById('diashow_combo') ;
	var target = cb.options[cb.selectedIndex].value;
	return open_window(target,'SERIE',750,690);
}

function activate(poza)
{
	if(poza!=ActiveSubMenu)
	{
		var a = document.getElementById(poza);
		a.style.color = "white";
		var td = document.getElementById(poza + "_td");
		td.style.backgroundColor = "#0066CD"; 
	}	
}
			
function deactivate(poza)
{
	if(poza!=ActiveSubMenu)
	{
		var a = document.getElementById(poza);
		a.style.color = "black";
		var td = document.getElementById(poza + "_td");
		td.style.backgroundColor = "white"; 
	}		
}

function SetSubMenu()
{
	if(ActiveSubMenu!="none")
	{
		var a = document.getElementById(ActiveSubMenu);
		a.style.color = "white";
		var td = document.getElementById(ActiveSubMenu + "_td");
		td.style.backgroundColor = "#0066CD"; 
	}
}

function ChangePic(lname)
{
	if(lname!=ActiveMenu)
	{
		var a = document.getElementById(lname);
		a.style.color="white";
		var td = document.getElementById(lname+"_Left");
		td.style.backgroundImage = 'url(/SysRes/Sites/VOR/Pics/Nav/mainbutton_high_left.gif)';
		td = document.getElementById(lname+"_Middle");
		td.style.backgroundImage = 'url(/SysRes/Sites/VOR/Pics/Nav/mainbutton_high_middle.gif)';
		td = document.getElementById(lname+"_Right");
		td.style.backgroundImage = 'url(/SysRes/Sites/VOR/Pics//Nav/mainbutton_high_right.gif)';
	}
}

function ChangePicBack(lname)
{
	if(lname!=ActiveMenu)
	{
		var a = document.getElementById(lname);
		a.style.color="black";
		var td = document.getElementById(lname+"_Left");
		td.style.backgroundImage = 'url(/SysRes/Sites/VOR/Pics/Nav/mainbutton_left.gif)';
		td = document.getElementById(lname+"_Middle");
		td.style.backgroundImage = 'url(/SysRes/Sites/VOR/Pics/Nav/mainbutton_middle.gif)';
		td = document.getElementById(lname+"_Right");
		td.style.backgroundImage = 'url(/SysRes/Sites/VOR/Pics//Nav/mainbutton_right.gif)';
	}

}

function Clicked()
{
	if(ActiveMenu=="none") return false;
	var lname = event.srcElement.id;
	if(ActiveMenu!=lname)
	{
		var a = document.getElementById(ActiveMenu);
		if(a!=null){
			a.style.color="black";
			var tdold = document.getElementById(ActiveMenu+"_Left");
			tdold.background = "/SysRes/Sites/VOR/Pics/Nav/mainbutton_left.gif";
			tdold = document.getElementById(ActiveMenu+"_Middle");
			tdold.background = "/SysRes/Sites/VOR/Pics/Nav/mainbutton_middle.gif";
			tdold = document.getElementById(ActiveMenu+"_Right");
			tdold.background = "/SysRes/Sites/VOR/Pics/Nav/mainbutton_right.gif";
		}		
	}
	ActiveMenu = lname;
	var td = document.getElementById(lname+"_Left");
	td.background = "/SysRes/Sites/VOR/Pics/Nav/mainbutton_high_left.gif";
	td = document.getElementById(lname+"_Middle");
	td.background = "/SysRes/Sites/VOR/Pics/Nav/mainbutton_high_middle.gif";
	td = document.getElementById(lname+"_Right");
	td.background = "/SysRes/Sites/VOR/Pics/Nav/mainbutton_high_right.gif";
	bChangeBack = false;
}

function SetHomeLink()
{
	if(ActiveMenu=="none") return false;
	var a = document.getElementById(ActiveMenu);
	if(a!=null){
		a.style.color="white";
		var td = document.getElementById(ActiveMenu+"_Left");
		td.style.backgroundImage = 'url(/SysRes/Sites/VOR/Pics/Nav/mainbutton_high_left.gif)';
		td = document.getElementById(ActiveMenu+"_Middle");
		td.style.backgroundImage = 'url(/SysRes/Sites/VOR/Pics/Nav/mainbutton_high_middle.gif)';
		td = document.getElementById(ActiveMenu+"_Right");
		td.style.backgroundImage = 'url(/SysRes/Sites/VOR/Pics//Nav/mainbutton_high_right.gif)';		
	}
	
}

function GoToURL(sid)
{
	var sel = document.getElementById(sid);
	var url = sel.options[sel.selectedIndex].value;
	window.open(url,'newwindow');

}

function DoSearch()
{
	var keyword = document.SearchForm.search.value;
	window.location = "/engine.aspx/page/vor-searchresult-page/contentkeyword/" + keyword
}

function PrepareForPrint()
{			
	var tb_main = document.getElementById("main");
	tb_main.rows[0].style.display = 'none';
	tb_main.rows[1].style.display = 'none';
	var tb_content = document.getElementById("content");
	var content_row = tb_content.rows[0];
	for(i=0;i<content_row.cells.length;i++)
	{
		if(content_row.cells[i].id != "toprint")
			content_row.cells[i].style.display = 'none';
	}
}

function RedoAfterPrint()
{
	var tb_main = document.getElementById("main");
	tb_main.rows[0].style.display = 'inline';
	tb_main.rows[1].style.display = 'inline';
	var tb_content = document.getElementById("content");
	var content_row = tb_content.rows[0];
	for(i=0;i<content_row.cells.length;i++)
	{
		if(content_row.cells[i].id != "toprint")
			content_row.cells[i].style.display = 'inline';
	}
}

function PrepareForPrint2()
{
	PrepareForPrint();
	var tb_sm = document.getElementById("sub_main");
	tb_sm.rows[0].style.display = 'none';
	tb_sm.rows[1].style.display = 'none';
	var tb_rcontent = document.getElementById("realcontent");
	var content_row = tb_rcontent.rows[0];
	for(i=0;i<content_row.cells.length;i++)
	{
		if(content_row.cells[i].id != "toprint_rc")
			content_row.cells[i].style.display = 'none';
	}
}

function RedoAfterPrint2()
{
	var tb_sm = document.getElementById("sub_main");
	tb_sm.rows[0].style.display = 'inline';
	tb_sm.rows[1].style.display = 'inline';
	var tb_rcontent = document.getElementById("realcontent");
	var content_row = tb_rcontent.rows[0];
	for(i=0;i<content_row.cells.length;i++)
	{
		if(content_row.cells[i].id != "toprint_rc")
			content_row.cells[i].style.display = 'inline';
	}
	RedoAfterPrint();
}

function PrintPage()
{
	window.onbeforeprint=PrepareForPrint;
	window.onafterprint=RedoAfterPrint;
	window.print();
}

function PrintPage2()
{
	window.onbeforeprint=PrepareForPrint2;
	window.onafterprint=RedoAfterPrint2;
	window.print();
}

function SetFrameHeight()
{
	var cf= document.getElementById("contentframe");
	var iheight = 646;
	if(document.body.clientHeight==0)
	{
		iheight = document.documentElement.clientHeight - 154;
	}
	else
	{	
		iheight = document.body.clientHeight - 154;
	}
	//cf.height = iheight;
}

function DisplayFrame()
{
	var trcontent = document.getElementById("contentrow");
	var trframe = document.getElementById("framerow");
	var backlink = document.getElementById("backlink");
	trcontent.style.display = 'none';
	trframe.style.display = 'inline';
	backlink.style.display = 'inline';
}

function HideFrame()
{
	var trcontent = document.getElementById("contentrow");
	var trframe = document.getElementById("framerow");
	var backlink = document.getElementById("backlink");
	trcontent.style.display = 'inline';
	trframe.style.display = 'none';
	backlink.style.display = 'none';
	var cf= document.getElementById("contentframe");
	cf.src="";
}	
