var wasShown = false;
var isLoadedEver = false;
var tableName;

function InitializeScript( tableN)
{
 tableName = tableN;
 document.write('<IMG id="monkep" STYLE="visibility: hidden; width: 150px; height: 150px; position:absolute; left: 20px; top: 100px; margin-top: 0px;" src="" border="1"  onLoad="monLoaded();">');
}

function monLoaded()
{
	elem = document.getElementById("monkep");
	if (wasShown)
		elem.style.visibility="visible";
	 isLoadedEver = true;
}

function showMonitor( imageURL, obj)
{
	elem = document.getElementById("monkep");
	elem.style.top=(obj.offsetParent.offsetTop+document.getElementById(tableName).offsetTop)+100;
	wasShown = true;
//	elem.onLoad=monLoaded;
	elem.src='http://www.tftpanel.hu/images/kepek/monitorok/'+imageURL;
	if (!isLoadedEver)
		elem.style.visibility="visible";
}

function hideMonitor()
{
	document.getElementById("monkep").style.visibility="hidden"
}

function showhideHelp()
{
	var infoBlock = document.getElementById("infoText");
	var btn = document.getElementById("helpBtn");
	
	if (btn.value != "Infó")
	{
		btn.value = "Infó"
		infoBlock.style.display = "none";		
	}
	else
	{
		btn.value = "Infó elrejtése"
		infoBlock.style.display = "";		
	}
}

function showhideFilter()
{
	var infoBlock = document.getElementById("filterPart");
	var btn = document.getElementById("filterBtn");
	
	if (btn.value != "Szûrõ")
	{
		btn.value = "Szûrõ"
		infoBlock.style.display = "none";		
	}
	else
	{
		btn.value = "Szûrõ elrejtése"
		infoBlock.style.display = "";		
	}
}

function filterTable(showall)
{
	var showSamsung = false;
	var showEIZO = false;
	var showFSC = false;
	if (!showall)
	{
		var check = document.getElementById("filterSamung");
		if (check.checked)
			showSamsung = true;
		check = document.getElementById("filterEIZO");
		if (check.checked)
			showEIZO = true;
		check = document.getElementById("filterFSC");
		if (check.checked)
			showFSC = true;		
	}
	
	var tableObject = document.getElementById(tableName);
        var rows = tableObject.getElementsByTagName("TR");
	var rowNum = rows.length;
	var i = 0;
	var showSection = false;
	if (showall)
		showSection = true;
	for(i=0; i<rowNum; i++)
	{
	    var cells = rows[i].getElementsByTagName("TD");
	    var j = 0;
	    var cellNum = cells.length;
	    if (cellNum < 2)
	    	continue;
	    	
	    if (cellNum == 2)
	    {
			if (!showall)
			    showSection = false;
		    if ( showSamsung && cells[0].innerHTML.indexOf("SAMSUNG")>0)
		    	showSection = true;
		    if ( showEIZO && cells[0].innerHTML.indexOf("EIZO")>0)
		    	showSection = true;
		    if ( showFSC && cells[0].innerHTML.indexOf("Fujitsu Siemens")>0)
		    	showSection = true;
	    }
	    if (showSection)
	    	rows[i].style.display = "";
	    else
	    	rows[i].style.display = "none";
	    
	}
	
}
