/* ----------------------------------------------------------------------------------------
File Name: General_Functions.js

	This file handles general functions.
 ----------------------------------------------------------------------------------------*/
var _gGroup = 0;
var first_time2 = true;
var last_item	= "";
//var printObj;
function openLink(url)
{
	popUpWin = open(url, 'popUpWin');
	popUpWin.focus();
}
function popUpWindow(URLStr, left, top, width, height)
{
	var popUpWin=0;
	if(popUpWin)
	{
		if(!popUpWin.closed) popUpWin.close();
	}
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	popUpWin.focus();
}

function limit(El)
{
	if(El.value.length >= 40)
		El.value = El.value.substring(0,40);
}

//--------------------------------------------------------------------------------

function GroupIt(El)
{
	if (El.state !== "down")
	{
		if(first_time2)
		{
			last_item = El.id;
			first_time2 = false;
		}
		else
		{
			if(document.getElementById(last_item))
			{
				document.getElementById(last_item).state = "";
				document.getElementById(last_item).style.cursor = "hand";
				document.getElementById(last_item).src =  "images/" + last_item + "_normal.gif";
			}
			last_item = El.id;
		}
				
		El.style.cursor = "normal";
		El.src = "images/" + El.id + "_over" + ".gif";
		El.state = "down";
	}
} 
function OverIt(El)
{
	if (El.state !== "down")
	{
		El.src = "images/" + El.id + "_over" + ".gif";
		El.state = "over";
	}	
}
function OutIt(El)
{
	if (El.state == "over")
	{
		El.state = "";
		El.src = "images/" + El.id + "_normal" + ".gif";
	}	
	else if (El.state !== "over" && El.state !== "down")
			El.src = "images/" + El.id+ "_normal" + ".gif";
}

function PrintData(type)
{
	/*switch(type)
	{
		case 1:
			printObj = document.getElementById("content");
			break;
	}*/
	
	printWin = open("includes/printWin.html", 'printWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=0,height=0,left=2000, top=2000');
}

//------------ CONTACT FUNCS ---------------------------//
function resetForm(frm)//gets frm form object and clears all data in texts areas and inputs
{
	var allFormEl = new Array();
	allFormEl = frm.getElementsByTagName("INPUT");
	//alert(allFormEl.length)
	
	for(var i=0; i<allFormEl.length; i++)
		if(allFormEl[i].type == "text")
			allFormEl[i].value = "";
	
	allFormEl = frm.getElementsByTagName("INPUT");
	//alert(allFormEl.length)
	
	frm.Comments.value = "";
}

// --------- LEFT MENU SELECTED -------------
/*This function compares current url with the a href attribute in each link in the main menu
and heighlights the selected link*/
function selectedMenuItem(module)
{	
	if(module == "home" || module == "contact")
	{
	    var td = document.getElementById("menu_item_" + module);
	    linkName = td.getElementsByTagName("A");
	    td.innerHTML = "<img src='images/menu_element.gif'><span class='sideMenu_selected'>" + linkName[0].innerHTML + "</span>";
	}
	else //dynamic-pages module
	{
	    var tblMainMenu = document.getElementById("tblMainMenu");
	    var aTDs = new Array();
	    aTDs = tblMainMenu.getElementsByTagName("TD");
    	
	    for(var i=0; i<aTDs.length; i++)
	    {        
	        aHrefs = aTDs[i].getElementsByTagName("A");
	        linkName = aHrefs[0].innerHTML;
	        href = aHrefs[0].href;
	        //alert(aHrefs[0])
	        url = window.location;
	        //alert(linkName+"\n"+url)
	        if(href == url)
	        {
	            aTDs[i].innerHTML = "<img src='images/menu_element.gif'><span class='sideMenu_selected'>" + linkName + "</span>";
	        }
	        else
	        {
                //alert(href+"\n"+url)
                bcDiv = document.getElementById("divBreadCrumbs");
                var aBCs = new Array();
                aBCs = bcDiv.getElementsByTagName("A")
                //alert(aBCs[1].href+" "+href);
                if(aBCs.length > 1 && href == aBCs[1].href)
                {
                    aTDs[i].innerHTML = "<img src='images/menu_element.gif'><span class='sideMenu_selected'>" + linkName + "</span>";
                }
            }
	    }
	}
}


