/*//////////////////////////////////////////////////////////////////////////
	
	hasFlash()
	by Mike Davidson
	
	http://www.mikeindustries.com

	DESCRIPTION: Flash detection script for modern browsers.

///////////////////////////////////////////////////////////////////////////*/

var hasFlash = function(){
	var nRequiredVersion = 7;	
	
	if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") > -1){
		document.write('<script language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('hasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & ' + nRequiredVersion + '))) \n');  
		document.write('<'+'/script\> \n');
		/*	If executed, the VBScript above checks for Flash and sets the hasFlash variable. 
			If VBScript is not supported it's value will still be undefined, so we'll run it though another test
			This will make sure even Opera identified as IE will be tested */
		if(window.hasFlash != null){
			return window.hasFlash;
		}
	}
	
	if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
		var flashDescription = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1))
		return flashVersion >= nRequiredVersion;
	}
	
	return false;
}


/*//////////////////////////////////////////////////////////////////////////

	embedFlashMovie()

	DESCRIPTION: Workaround for embedding Flash movie w/ standards validation.

	ARGUMENTS:
	path:	local path to Flash movie
	swf: 	name of Flash movie (do not include '.swf' extension)
	w:      width value
	h       height value
	imgSrc: path to alternate image
	imgW:   width value of image (sets def value to same as 'w' if undefined)
	imgH:   height value of image (sets def value to same as 'h' if undefined)
	imgAlt: alternate message (sets def message for downloading Flash Player if undefined)
	bgclr:  background color (sets def hex value to #FFFFFF if undefined)


///////////////////////////////////////////////////////////////////////////*/


function embedFlashMovie(path, swf, w, h, imgSrc, imgAlt, imgW, imgH, bgclr) {


	if (imgW == null || imgW == "") {
		imgW = w;
	}
	
	if (imgH == null || imgH == "") {
		imgH = h;
	}
	
	if (imgAlt == null || imgAlt == "") {
		imgAlt = "Click to download the latest Flash Player from Macromedia.";
	}
		
	if (bgclr == null || bgclr == "") {
		bgclr = "#FFFFFF";
	}
		
	
	if (window.hasFlash()) {
		document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + w + "\" height=\"" + h + "\" id=\"" + swf + "\" align=\"middle\">");
		document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
		document.write("<param name=\"movie\" value=\"" + path + swf + ".swf\" />");				
		document.write("<param name=\"quality\" value=\"high\" />");				
		document.write("<param name=\"bgcolor\" value=\"" + bgclr + "\" />");	
		document.write("<embed src=\"" + path + swf + ".swf\" quality=\"high\" bgcolor=\"" + bgclr + "\" width=\"" + w + "\" height=\"" + h + "\" name=\"" + swf + "\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />");				
		document.write("</object>");	
	} else {
		document.write("<img src=\"" + imgSrc + "\" alt=\"" + imgAlt + "\" width=\"" + imgW + "\" height=\"" + imgH + "\" />");	
	}
}



/*//////////////////////////////////////////////////////////////////////////
	
	FORM VALIDATION

///////////////////////////////////////////////////////////////////////////*/

/*========================================================================== 

	validateForm()

	DESCRIPTION: Form validation. Currently hard-coded for Search

	ARGUMENTS:
	none

===========================================================================*/

function validateForm() {
	var keywords = document.ProjectSearch.search.value;
	var invalidEntry = (keywords == null || keywords == "" || keywords == "enter keywords"  );
	if (invalidEntry) {
		var warnString = "Please enter valid keywords.\n\nTIP: You can use excerpts from the project title, project description, project type, service type, as well as other key descriptions of the project(s) your looking for.";
		alert(warnString);
								
	} else {//if all required fields are filled out
		document.ProjectSearch.submit();
	}
} 


/*//////////////////////////////////////////////////////////////////////////
	
	STYLESWITCHER
	
	Original Styleswitcher
	by Paul Snowden
	
	http://www.alistapart.com/articles/alternate

///////////////////////////////////////////////////////////////////////////*/

/*========================================================================== 

	setActiveStyleSheet()

	DESCRIPTION: Loads an alternate stylesheet.

	ARGUMENTS:
	title: Title (string value) of alternate stylesheet w/o '.css' extension

===========================================================================*/


function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}



/*//////////////////////////////////////////////////////////////////////////

	SUCKERFISH DHTML
	
	Original Suckerfish Menu
	by Patrick Griffiths and Dan Webb
	
	http://www.htmldog.com/articles/suckerfish/dropdowns/

///////////////////////////////////////////////////////////////////////////*/

/*========================================================================== 

	sfHover()

	DESCRIPTION: Creates Dynamic Hover effect by assigning 'sfhover' class.

	ARGUMENTS:
	ID: This should be set to an ID specific enought to target tag elements.
	Tag: The parent tag of elements to be hidden/revealed.

===========================================================================*/

function sfHover(ID, Tag) {
	var sfEls = document.getElementById(ID).getElementsByTagName(Tag);
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}


/*//////////////////////////////////////////////////////////////////////////

	INTITIALIZE DOCUMENT


///////////////////////////////////////////////////////////////////////////*/

createMenus = function() {
	sfHover("MainNav", "DD");
	if (document.getElementById("ContextMenus")) {	
		sfHover("ContextMenus", "DIV");
	}
	if (document.getElementById("ProjectLinks")) {	
		sfHover("ProjectLinks", "LI");
	}	
}


window.onload = function() {
	//setActiveStyleSheet("sfMenuOn");
	//for IE 5 Mac
	if (document.all&&document.getElementById) createMenus();
	//for IE 5/6 Win
	else if (window.attachEvent) createMenus();
}