// Flash Loader for Internet Explorer's security FLAW
// Show/Hide Items
function showItem(nItem,e) {
	// e.blur();
	if(nItem != cItem && document.getElementById(nItem)) {
		pItem = cItem + "";
		cItem = nItem + "";
		
		current = document.getElementById(cItem);
		previous = document.getElementById(pItem);
		
		current.style.overflow = "visible";
		current.style.height = "auto";
		previous.style.overflow = "hidden";
		previous.style.height = "0";
	}
}



// Show/Hide Forms
function showForm(nForm,e) {
	// e.blur();
	if(nForm != cForm && document.getElementById(nForm)) {
		pForm = cForm + "";
		cForm = nForm + "";
		
		document.getElementById(pForm).style.display = "none";
		document.getElementById(cForm).style.display = "block";
	}
}		



// Popup Window
function popUp(URL,wW,wH) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+wW+",height="+wH+"');");
}


// Open links in external window for XHTML 1.0 Strict compliancy
// To make a link open in external window add the "rel" attribute to the <a> tag
// and set its value to "external" example:
//     <a href="http://www.google.com" rel="external">Google</a>
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}



// Image rollover - for use please make sure image names follow the following name scheme:
// Idle Image:  image_i.gif
// Hover Image: image_o.gif
// File extension and anything before the _i. does not matter so long as it is consistent between
// the two states (e.g. "image_i.gif" and "hoverimage_o.gif" does not work)
// Usage:
// <img src="image_i.gif" alt="" onmouseover="rollOver(this)" onmouseout="rollOut(this)" />
var oldImage = "";
function rollOver(oImg) {
	oldImage = oImg.src;
	var newImage = oldImage.replace("_i.","_o.");
	oImg.src = newImage;
}
function rollOut(oImg) {
	oImg.src = oldImage;
}

// Replace input field with default value on blur if nothing was entered
// Usage: <input type="text" value="Default Value" onfocus="clearText(this)" onblur="replaceText(this)" />
function clearText(thefield) {
	if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 
 
function replaceText(thefield) {
	if (thefield.value=="") { thefield.value = thefield.defaultValue }
}



function simplePreload() { 
	var args = simplePreload.arguments;
	document.imageArray = new Array(args.length);
	for(var i=0; i<args.length; i++) {
		document.imageArray[i] = new Image;
		document.imageArray[i].src = args[i];
	}
}



// moo.FX Accordion Configuration
function init(){
	var stretchers = $$('.stretcher'); //div that stretches

    var togglers = $$('h3.display'); //h3s where I click on
	
	//accordion effect
	var myAccordion = new Accordion(
		togglers, stretchers, {opacity: true, duration: 400}
	);
	
	//hash function
	
	function checkHash(){
		var found = false;
		togglers.each(function(h3, i){
			if (window.location.href.indexOf(h3.title) > 0) {
				myAccordion.showThisHideOpen(stretchers[i]);
				found = true;
			}
		});
		return found;
	}
	
	// Open first item (or whichever item in the array - 0 order) on page load
	// if (!checkHash()) myAccordion.showThisHideOpen(stretchers[0]);
	
	// Disable Accordion and create just an individual item expand/collapse usability
	myAccordion.showThisHideOpen = function(toShow){this.clearAndToggle(toShow);};
}


function getFlashMovieObject(movieName)	{
	if (window.document[movieName]) {
	  return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
		if (document.embeds && document.embeds[movieName]) {
			return document.embeds[movieName]; 
		} else {
			return document.getElementById(movieName);
		}
	}
}




function loadVideo(videoID) {
	var flashMovie=getFlashMovieObject("myFlashMovie");
	// flashMovie.setMovie('hhh');
	flashMovie.SetVariable("/:videoToLoad", videoID);
}



function startup() {
	externalLinks();
	simplePreload("images/btn_company_o.gif","images/btn_contact_o.gif","images/btn_faq_o.gif","images/btn_news_o.gif","images/btn_services_o.gif","images/btn_showcase_o.gif","images/btn_technology_.gif");
}





function bgSwap(elem) {
	if(elem.style.backgroundImage != "url(images/arrow_d.gif)") {
		elem.style.backgroundImage = "url(images/arrow_d.gif)";
	} else {
		elem.style.backgroundImage = "url(images/arrow_o.gif)";
	}
}

function clientLogin() {
	var login=document.getElementById("clientSignin");
	
	if(login.style.display == "none"){
		login.style.display = "block";
	} else {
		login.style.display = "none";
	}
}
