var isIE = navigator.userAgent.indexOf( 'MSIE' ) != -1 && navigator.userAgent.indexOf('Opera') == -1;
var isOpera = navigator.userAgent.indexOf('Opera') != -1;
if ( isOpera ) {
//credits: hallvors :D
if(window.Document && !window.Document.prototype.load && document.implementation && document.implementation.createLSParser){
    Document.prototype.load=function(uri){
        if(this.documentElement){this.removeChild(this.documentElement);}
        var doc=(document.implementation.createLSParser( this.async ? document.implementation.MODE_ASYNCHRONOUS:document.implementation.MODE_SYNCHRONOUS, null )).parseURI(uri);
        this.appendChild(this.importNode(doc.documentElement, true));
    }
}
}


var home=new Image();
var products=new Image();
var company=new Image();
var customers=new Image();
var partners=new Image();
var contact=new Image();


home.src="images/home-select.jpg";
products.src="images/products-select.jpg";
company.src="images/company-select.jpg";
customers.src="images/customers-select.jpg";
products.src="images/partners.jpg";
contact.src="images/contact.jpg";

function hoverNav( tdToChange ) 
{
tdToChange.style.borderRight= "solid gray 1px";
tdToChange.style.borderLeft= "solid gray 1px";
}


function leaveNav( tdToChange )
{
tdToChange.style.borderRight= "solid white 1px";
tdToChange.style.borderLeft= "solid white 1px";
}

var objDefer, nameDefer;
function deferhide( obj, id )
{
	objDefer = obj;
	nameDefer = id;
}


function show(obj, idToShow )
{
 obj.style.backgroundColor = '#CCF';
 if (objDefer != null ) 
 {
	hide (objDefer, nameDefer);
 }
 var elem = document.getElementById(idToShow);
 if ( elem != null )
 {
	
 	elem.style.display = 'block';
   }
}


function hide( obj, idToShow )
{
var resize = (obj.tagName == "TR")
 obj.style.backgroundColor = '';
 var elem = document.getElementById(idToShow);
 if ( elem != null )
 {
	elem.style.display = 'none';
	
}
}


function hover( img )
{
imagereplace( img, "select" );
}
function unhover( img )
{
imagereplace( img, "hover") ;
}
function imagereplace( img, action )
{
document.images[img].src = "images/"+img+"-" + action + ".jpg";
}


var id=null;
function delayedLoad( idTD ) {
	clearLoad();
 	id = setTimeout('showSection("' + idTD + '")',500);
}

function clearLoad() {
	if (id != null ) 
 		clearTimeout(id); 
}


function resetStart( )
{
	var saUrl = document.URL.split('?');
	if ( saUrl.length > 1 )
   	 delayedLoad( saUrl[1] );
}


function showSection( idToShow )
{
	var obj = document.getElementById( idToShow + "_td" );
	var elem = document.getElementById(idToShow);
	if ( obj != null && elem != null ) {
		// clear siblings
		for ( var curr = elem.parentNode.firstChild; curr != null ; curr = curr.nextSibling ) 
			if ( curr.tagName == 'DIV' )
				curr.style.display = 'none';
	}
	elem.style.display = 'block';
	//reset sibling backgrounds 
	for ( var divs = obj.parentNode.firstChild; divs != null ; divs = divs.nextSibling ) {
	if ( divs.tagName == 'TD' )
		divs.style.backgroundColor = '';
	} 
	obj.style.backgroundColor = '#ededed';
}
