function BrowserInfo() {
	var agent = window.navigator.userAgent;
	if (agent.indexOf("MSIE") != -1) {
			var start = agent.indexOf("MSIE");
			this.name = "MSIE";
			this.version = parseFloat(agent.substring(start + 5, agent.indexOf(";", start)));
	} else if (agent.indexOf("Firefox") != -1) {
			var start = agent.indexOf("Firefox");
			this.name = "Firefox";
			this.version = agent.substring(start + 8, agent.length);
			var firstDec = this.version.indexOf(".") + 1;
			while (this.version.indexOf(".", firstDec) != -1)
				this.version = this.version.substring(0, firstDec) + this.version.substring(firstDec).replace(".", "");
			this.version = parseFloat(this.version);
	} else {
			this.name = "Unknown";
			this.version = 0;
	}
}

var info = new BrowserInfo();
var userAgent = window.navigator.userAgent
var isIE = (window.navigator.userAgent.indexOf("MSIE") != -1);
var isIE6 = (info.name == "MSIE" && info.version < 7);
var isFireFox = (window.navigator.userAgent.indexOf("Firefox") != -1);

if (info.name == "MSIE" && info.version < 7)
	document.writeln('<link href="stylesIE6.css" rel="stylesheet" type="text/css" />');
else
	document.writeln('<link href="stylesDynamic.css" rel="stylesheet" type="text/css" />');

function writePngImage(url, width, height, alt) {
	if (!isIE6)
		document.write("<img alt=\"" + alt + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

function writePngClass(url, width, height, alt, className) {
	if (!isIE6)
		document.write("<img alt=\"" + alt + "\" class=\"" + className + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img alt=\"" + alt + "\" class=\"" + className + "\"  src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

function writePngImageMap(url, width, height, alt, map) {
	if (!isIE6)
		document.write("<img usemap=\"" + map + "\" alt=\"" + alt + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img usemap=\"" + map + "\" src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

function renderFlash(src, width, height, features) {
	document.writeln('<embed src="' + src + '" quality="high" bgcolor="#ffffff" width="' + width + 
					 '" height="' + height + '" align="middle" allowscriptaccess="sameDomain" ' +
					 'type="application/x-shockwave-flash" ' + features + 
					 'pluginspage="http://www.macromedia.com/go/getflashplayer" />');
}

function submitForm(id) 
{
	document.getElementById(id).submit();
	return false;
}

String.prototype.trim = function () {
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

reset_form_value = function(str1, str2, val) {
	if(str1 == val.value.trim())
		val.value = str2;
}







function showMenus() {
	toggleElement('sitemap', 3);
	showMoreMenu(true);
}

function toggleElement(id, steps) {
	var html = document.getElementById(id);
	if (html.style.display != "none") {
		html.style.height = html.offsetHeight + "px";
		html.style.overflow = "hidden";
		animStep(id, false, html.offsetHeight, steps);
	} else {
		html.style.display = "";
		html.style.overflow = "";
		html.style.height = "";
		var h = html.offsetHeight;
		html.style.overflow = "hidden";
		html.style.height = "0px";
		animStep(id, true, h, steps);
	}
	
	return false;
}

function animStep(id, expanding, height, steps) {
	var html = document.getElementById(id);
	var newHeight = parseInt(html.style.height);
	speed = height / steps;
	if (expanding) {
		newHeight += speed;
		
		if (newHeight >= height) {
			html.style.height = height + "px";
			html.style.overflow = "";
			return;
		}
		fadeOne();
	} else {
		newHeight -= speed;
		if (newHeight <= 0) {
			html.style.height = "0px";
			html.style.display = "none";
			return;
		}
	}
	
	html.style.height = newHeight + "px";
	setTimeout("animStep('" + id + "', " + expanding + ", " + height + "," + steps + ");", 10);
}

var delay = 30;
var increment = 5;

function fadeOne() {
	var fade1 = document.getElementById("fade1");

	var fadeTxt = document.getElementById("fadeTxt1"); // has to be here for IE
	fadeTxt.style.width = '100%'; // has to be here for IE

	fade1.style.display = '';

	setOpacity("fadeTxt1", 0);
	fadeDiv("fade1", 0);
	return false;
}

function fadeDiv(div,opacity) {
	if (opacity < 100) {
		opacity += increment;
		switch (div) {
			case "fade1":
				setOpacity("fadeTxt1", opacity);
				setTimeout("fadeDiv('fade1'," + opacity + ");", delay);
				break;
			default:	
				setOpacity(div, opacity);
				setTimeout("fadeDiv('" + div + "'," + opacity + ");", delay);
				break;
		}
	}
}

function setOpacity(div_name, opacity) {
	var div = document.getElementById(div_name);
	div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity + ")";
	div.style.MozOpacity = opacity/100;
	div.style.opacity = opacity/100;
}

var hide;
var show;
var Showing = 0;
var menuVisible = false;

function showMoreMenu(force,obj,position) {

	var divID = document.getElementById(obj);
	divID.style.display = "block";
    divID.style.margin = position;//"-17px 0 0 74px";

	if (menuVisible == true || force == true) {
		if (Showing==1 && !force) { window.status = new Date().getMilliseconds().toString(); return; }

		Showing = 1;

		clearTimeout(show);

		menuVisible = true;
		show = setTimeout("menuFadeIn('" + obj + "');", 250);
	}
}

function hideMoreMenu(obj) {
	var divID = document.getElementById(obj);
	clearTimeout(hide);
	hide = setTimeout("start_hideMoreMenu('" + obj + "');", 500);
}


function cancelHide() {
	Showing = 1;
	clearTimeout(hide);
}

function start_hideMoreMenu(divID) {
	Showing = 0;

	menuFadeOut(divID);
}

function menuFadeIn(id) {
	menuFadeInStep(id, 0);
}

function menuFadeInStep(id,val) {
	var more = document.getElementById(id);

	more.style.display = 'block';

	if (val < 100) {
		val = val + 25;
		setOpacity(id, val);
	}	
	if (val != 100) {
		var hdl = setTimeout("menuFadeInStep('" + id + "'," + val + ");",25);
		id = hdl;
	}
	else {
		if (id=="menu_more_dropdown") {
			moreVisible = true;
			more.style.filter = "";
		}
	}
}

function menuFadeOut(id) {
	var element = document.getElementById("id");
	menuFadeOutStep(id, 100);
}

function menuFadeOutStep(id,val) {
	var more = document.getElementById(id);

	if (val > 0) {
		val = val - 10;
		setOpacity(id, val);
	}
	if (val != 0) {
		var hdl = setTimeout("menuFadeOutStep('" + id + "'," + val + ");",25);
		id = hdl;
	}
	else {	
		if (id=="menu_more_dropdown") {
			menuVisible = false;
			more.style.display = 'none';
		}
	}
}

function loadImage(img) {
	if (document.images) {
	  pic1= new Image(100,25); 
	  pic1.src=img; 
	}
}

function preloadImages() {
	loadImage('images/nav_home.png');
	loadImage('images/nav_home_mo.png')
	loadImage('images/nav_home2.png');
	loadImage('images/nav_home2_mo.png');
	loadImage('images/nav_about.png');
	loadImage('images/nav_about_mo.png');
	loadImage('images/nav_about2.png');
	loadImage('images/nav_about2_mo.png');
	loadImage('images/nav_services.png');
	loadImage('images/nav_services_mo.png');
	loadImage('images/nav_portfolio.png');
	loadImage('images/nav_portfolio_mo.png');
	loadImage('images/nav_contact.png');
	loadImage('images/nav_contact_mo.png');


}
