var IMG_ROOT= "/images/"

function imageOnOff(obj)
{	
	var resultSet = new Array();
	resultSet = getRenderedImgSrc(obj); //Gets the name of the ICON without the extention	

	// MOUSEOVER ACTION
	if((resultSet['imageState']) != ('on.'+resultSet['imageExtention'])) // Checks whether the button is on the ON state already
	{	
		obj.src=IMG_ROOT+resultSet['imageName']+"_on."+resultSet['imageExtention'];	 
		obj.onmouseout = backToOriginalState;			
	}
	
	function backToOriginalState()
	{
		obj.src=IMG_ROOT+resultSet['imageName']+"."+resultSet['imageExtention'];		
	}	
	
}

function getRenderedImgSrc(imgObj)
{
	imgsrc = imgObj.src;	
	img_root = imgsrc.split("/"); 
	img_name = img_root[img_root.length-1];	
	img_nameSpaces = img_name.split("_");

	img_state = img_nameSpaces[img_nameSpaces.length-1]; /* gets the word after last _ , looking for _on */	
	
	justImageName = img_name.split(".");
	
	var resultSet = new Array();
	resultSet['imageName'] = justImageName[0]; // send the image name only up until the extention 
	resultSet['imageExtention'] = justImageName[1]; // sends the image extention
	resultSet['imageState'] = img_state; //sends the state of an image like on.gif, on.jpg
	
	
	return resultSet; //Returns just the image name without the extention	
}


function addTableDiffTr(tableId,darkBg,lightBg)
{
	var tableObj = document.getElementById(tableId);
	var tBody = tableObj.getElementsByTagName('TBODY');
	if(tBody){
		var rows = tBody[0].getElementsByTagName('TR');
	}else{
		var rows = tableObj.getElementsByTagName('TR');
	}
	for(var no=0;no<rows.length;no++){
		if(no%2 == 0)
			rows[no].className=lightBg;
		else 
			rows[no].className=darkBg;
	}
	
}

function clearField(obj)
{
	obj.value="";	
}

function minHeight() //Checks for the required height of the Middle DIV
{
	var middle = document.getElementById('middle');	
	var middleHeight = Element.getHeight(middle);
	
	if(middleHeight < 500 )
	{
		middle.style.height = '500px';
	}
	
}

function getStyle(el,styleProp)
{
	var x = el;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

function getCSSValue(objName,cssProperty,styleSheet)
{
	returnVal = objName.style[cssProperty];
	
	//alert(returnVal);
	//alert(objName.className+' '+cssProperty);
	//alert("Class Name: "+objName.className+" Property: "+cssProperty+" Getting Prop: "+returnVal);
	
	if(returnVal == ''){
	
		//alert(eval(testObj));
		
		  var cssValue= false;
		
		  var ss = document.styleSheets[0];
		
		//cssRules[0] for mozila, rules for explorer
		
			if (navigator.appName=="Microsoft Internet Explorer")
			{
				
		 		 for(i= 0; i< ss.rules.length; i++)
		  			{
		  			
		   			 if(ss.rules[i].selectorText== ('.'+objName.className))
		    			{
		    				  cssValue= ss.rules[i].style[cssProperty];
							  break;
		   				 }
		
		 			 }
		 	 }//end of the if nav name statement
		 	 else
		 	 {
		 	 	for(i= 0; i< ss.cssRules.length; i++)
		  			{
		
					 if(ss.cssRules[i].selectorText== ('.'+objName.className))
		    			{
		    				  cssValue= ss.cssRules[i].style[cssProperty];
		    				  break;
		   				 }
		
		 			 }
		 	}
		 	 	
		  return(cssValue);
	}
	else
		return returnVal;

}

function openClosePortComp(obj)
{

	if(obj.value == 3)
	{
		if (navigator.appName=="Microsoft Internet Explorer")
			document.getElementById('portCompany_holder').style.display="block";
		else document.getElementById('portCompany_holder').style.display="table-row";
			 
	}
	else 
		document.getElementById('portCompany_holder').style.display="none";
	

}	


function initiateNews()
{	
	displayNews(article[0][0], article[0][1], article[0][2]);
	setTimeout ("nextArticle()", 5000 );	
}

function displayNews(title, abstract, link)
{
	var newsHolder = document.getElementById('news_input');
	newsHolder.innerHTML ="<p>"+
						  "<a href='"+link+"' class='news_articleTitle' target='_blank'>"+title+"</a>"+
						  "<span>"+abstract+"</span>"+
						  "<a href='/news/' class='news_moreBtn'><img src='/images/btn_more.jpg'/></a>"+	
						  "</p>";
						  
}

function nextArticle()
{
	//if current article reached the max amount of articles, sets it back to 0
	if(currentArticle == article.length){currentArticle = 0; }
	
	currentArticle = currentArticle + 1; //adds 1 to the array to go to the next array article
	Effect.Fade('news_input'); // creates the fade away effect
	setTimeout ("showNextArticle("+currentArticle+")", 2000 ); //waits for the fadeaway effect to finnish, then start fade in effect
}

function showNextArticle(currentArticle)
{
	//if current article reached the max amount of articles, sets it back to 0
	if(currentArticle == article.length){currentArticle = 0; }
		
	displayNews(article[currentArticle][0],article[currentArticle][1],article[currentArticle][2]);
		
	Effect.Appear('news_input');//Fade in effect initiated				
	setTimeout ("nextArticle()", 5000 );//calls next article
}