//	common.js
//
////////////////////////////////////////////////////////////////////////
//	If Javascript is enabled, all navigation anchors will be set to
//	use AJAX exclusively, otherwise, normal page navigation used.
function fixAnchors() {
	var menudivs = ['head','c1','c2','c3','tabs','foot'];
	for (var i=0; i < menudivs.length; i++){
		var menuElement = document.getElementById(menudivs[i]);
		if (menuElement != null) {
			var menuElementList = menuElement.getElementsByTagName('a');
			for (var j=0; j < menuElementList.length; j++) {
				var attr = menuElementList[j].getAttribute("href")
				menuElementList[j].setAttribute("href", "#" + attr);
			}
		}
	}
}
//////////////////////////////////////////////////////////////////////// 
//	On load, if the page is accessed from a site using frames, the page
//	will open in its own window.
if (top.location != self.location) {
	top.location = self.location
	}
////////////////////////////////////////////////////////////////////////
//	Fix for events in older browsers
var message="";

function clickIE() {
	if (document.all) {
		(message);
		return false;
		}
	}

function clickNS(e) {
	if ( document.layers ||( document.getElementById && !document.all )) {
		if ( e.which==2 || e.which==3 ) {
			(message);
			return false;
			}
		}
	}

if (document.layers) {
	document.captureEvents( Event.MOUSEDOWN );
	document.onmousedown = clickNS;
	}
else	{
	document.onmouseup = clickNS;
	document.oncontextmenu = clickIE;
	}
////////////////////////////////////////////////////////////////////////
//	Fix for png transparency in IE 6
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}
////////////////////////////////////////////////////////////////////////

function update( req ) {
	var i;
	for (i = 0; i < req.length; i++ ) { new Ajax.Updater( req[i][0], req[i][1]) ; }
}

function updatePage( nav, id)
{	
	var elems, sty;

	sty = $(nav).getStyle('color');
	if ( id == 0 ) {
		
/*		$('col1', 'col2', 'col3' ).invoke('hide'); */
		$('tabs').update("<img src='images/null.gif' />");
		$('col1').update("&nbsp;");
		$('col2').update("&nbsp;");
		$('col3').update("&nbsp;");
		switch (nav) {
			case 'home':
			case 'cont':
			case 'terms':
				elems = $('head').descendants();
				/*elems.each(Element.setStyle({color:sty}));*/
				$(nav).setStyle({color:'black'});
				new Ajax.Updater( 'content', 'photo.php?photo=index.jpg' );
				break;
			case 'proj':
			case 'firm':
				elems = $('foot').descendants();
				alert(sty);
				/*elems.each(Element.setStyle({color:sty}));*/
				$(nav).setStyle({color:'black'});
				new Ajax.Updater( 'col1', 'col1.php?id=' + id );
		}
	}
	else {
		new Ajax.Updater( 'col1', 'col1.php?nav=' + nav + '&id=' + id );
		new Ajax.Updater( 'col2', 'col2.php?nav=' + nav + '&id=' + id );
		new Ajax.Updater( 'col3', 'col3.php?nav=' + nav + '&id=' + id );
		new Ajax.Updater( 'tabs', 'tabs.php?nav=' + nav + '&id=' + id );
		new Ajax.Updater( 'content', 'content.php?nav=' + nav + '&id=' + id );
	}
}

function updateText( url ) {
	new Ajax.Updater( 'content', url);
}	

function allhide () {
	col1.hide;
	col2.hide;
	col3.hide;
	tabs.hide;
}
