// <![CDATA[
function display(obj,id1,id2,id3,id4,id5,id6,id7) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
document.getElementById(id4).style.display = 'none';
document.getElementById(id5).style.display = 'none';
document.getElementById(id6).style.display = 'none';
document.getElementById(id7).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
if ( txt.match(id3) ) {
document.getElementById(id3).style.display = 'block';
}
if ( txt.match(id4) ) {
document.getElementById(id4).style.display = 'block';
}
if ( txt.match(id5) ) {
document.getElementById(id5).style.display = 'block';
}
if ( txt.match(id6) ) {
document.getElementById(id6).style.display = 'block';
}
if ( txt.match(id7) ) {
document.getElementById(id7).style.display = 'block';
}
}

function display2(obj,id1,id2,id3,id4,id5,id6,id7, id8, id9, id10, id11) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
document.getElementById(id4).style.display = 'none';
document.getElementById(id5).style.display = 'none';
document.getElementById(id6).style.display = 'none';
document.getElementById(id7).style.display = 'none';
document.getElementById(id8).style.display = 'none';
document.getElementById(id9).style.display = 'none';
document.getElementById(id10).style.display = 'none';
document.getElementById(id11).style.display = 'none';


if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
if ( txt.match(id3) ) {
document.getElementById(id3).style.display = 'block';
}
if ( txt.match(id4) ) {
document.getElementById(id4).style.display = 'block';
}
if ( txt.match(id5) ) {
document.getElementById(id5).style.display = 'block';
}
if ( txt.match(id6) ) {
document.getElementById(id6).style.display = 'block';
}
if ( txt.match(id7) ) {
document.getElementById(id7).style.display = 'block';
}
if ( txt.match(id8) ) {
document.getElementById(id8).style.display = 'block';
}
if ( txt.match(id9) ) {
document.getElementById(id9).style.display = 'block';
}
if ( txt.match(id10) ) {
document.getElementById(id10).style.display = 'block';
}
if ( txt.match(id11) ) {
document.getElementById(id11).style.display = 'block';
}
}


function dropdisplay(obj,id1,id2,id3,id4) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
document.getElementById(id4).style.display = 'none';

if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
if ( txt.match(id3) ) {
document.getElementById(id3).style.display = 'block';
}
if ( txt.match(id4) ) {
document.getElementById(id4).style.display = 'block';
}
}


// ]]>

// tab scripts

//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display (or "" if no corresponding tab content)]:
var initialtab=[1, "sc1"]

//Turn menu into single level image tabs (completely hides 2nd level)?
var turntosingle=0 //0 for no (default), 1 for yes

//Disable hyperlinks in 1st level tab images?
var disabletablinks=0 //0 for no (default), 1 for yes


////////Stop editting////////////////

var previoustab=""

if (turntosingle==1)
document.write('<style type="text/css">\n#tabcontentcontainer{display: none;}\n</style>')

function expandcontent(cid, aobject){
if (disabletablinks==1)
aobject.onclick=new Function("return false")
if (document.getElementById && turntosingle==0){
highlighttab(aobject)
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
if (cid!=""){
document.getElementById(cid).style.display="block"
previoustab=cid
}
}
}

function highlighttab(aobject){
if (typeof tabobjlinks=="undefined")
collectddtabs()
for (i=0; i<tabobjlinks.length; i++)
tabobjlinks[i].className=""
aobject.className="current"
}

function collectddtabs(){
var tabobj=document.getElementById("ddtabs")
tabobjlinks=tabobj.getElementsByTagName("A")
}

function do_onload(){
collectddtabs()
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}

/*
if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload
*/

//--------------------------------------------->


var enabletabpersistence=0 //enable tab persistence via session only cookies, so selected tab is remembered?

////NO NEED TO EDIT BELOW////////////////////////
var tabcontentIDs=new Object()

function expandcontent(linkobj){
var ulid=linkobj.parentNode.parentNode.id //id of UL element
var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
for (var i=0; i<ullist.length; i++){
ullist[i].className=""  //deselect all tabs
if (typeof tabcontentIDs[ulid][i]!="undefined") //if tab content within this array index exists (exception: More tabs than there are tab contents)
document.getElementById(tabcontentIDs[ulid][i]).style.display="none" //hide all tab contents
}
linkobj.parentNode.className="selected"  //highlight currently clicked on tab
document.getElementById(linkobj.getAttribute("rel")).style.display="block" //expand corresponding tab content
saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"))
}

function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
if (thetab.getAttribute("rel"))
expandcontent(thetab)
}

function savetabcontentids(ulid, relattribute){// save ids of tab content divs
if (typeof tabcontentIDs[ulid]=="undefined") //if this array doesn't exist yet
tabcontentIDs[ulid]=new Array()
tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute
}

function saveselectedtabcontentid(ulid, selectedtabid){ //set id of clicked on tab as selected tab id & enter into cookie
if (enabletabpersistence==1) //if persistence feature turned on
setCookie(ulid, selectedtabid)
}

function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
var ullist=document.getElementById(ulid).getElementsByTagName("li")
for (var i=0; i<ullist.length; i++){
if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
return ullist[i].getElementsByTagName("a")[0]
break
}
}
}

function initializetabcontent(){
for (var i=0; i<arguments.length; i++){ //loop through passed UL ids
if (enabletabpersistence==0 && getCookie(arguments[i])!="") //clean up cookie if persist=off
setCookie(arguments[i], "")
var clickedontab=getCookie(arguments[i]) //retrieve ID of last clicked on tab from cookie, if any
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
savetabcontentids(arguments[i], ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
ulistlink.onclick=function(){
expandcontent(this)
return false
}
if (ulist[x].className=="selected" && clickedontab=="") //if a tab is set to be selected by default
expandcontent(ulistlink) //auto load currenly selected tab content
}
} //end inner for loop
if (clickedontab!=""){ //if a tab has been previously clicked on per the cookie value
var culistlink=getullistlinkbyId(arguments[i], clickedontab)
if (typeof culistlink!="undefined") //if match found between tabcontent id and rel attribute value
expandcontent(culistlink) //auto load currenly selected tab content
else //else if no match found between tabcontent id and rel attribute value (cookie mis-association)
expandcontent(ulist[0].getElementsByTagName("a")[0]) //just auto load first tab instead
}
} //end outer for loop
}


function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

function setCookie(name, value){
document.cookie = name+"="+value //cookie value is domain wide (path=/)
}



/***********************************
						VIDEO PLAYER 
 ***********************************/
 
var isNav4, isIE4, isNav6 = false; var range = ""; var styleObj = "";
if (navigator.appVersion.charAt(0) >= 4) {
	if (navigator.appName == "Netscape") { if (navigator.appVersion.charAt(0) >= 5) {isNav6 = true;} else {isNav4 = true;}}
	else {isIE4 = true; range = "all."; styleObj = ".style";}
}
function getObject(obj) {var theObj;
	if (typeof obj == "string") {
		if (isNav6) {theObj = document.getElementById(obj); if (theObj != null) theObj = theObj.style;}
		else {theObj = eval("document." + range + obj); if (theObj != null) theObj = eval("theObj" + styleObj);}}
	else {theObj = obj;} return theObj;
}
function show () {var theObj;
	for (var i = 0; i < show.arguments.length; i++) { theObj = getObject(show.arguments[i]);
		if (theObj != null) { theObj.display = "block"; theObj.visibility = "visible";}}
}
function hide () {var theObj;
	for (var i = 0; i < hide.arguments.length; i++) { theObj = getObject(hide.arguments[i]);
		if (theObj != null) { theObj.display = "none"; theObj.visibility = "hidden";}}
}

//Get Position of an Element
var yPos;
var xPos;

function mavGetObjectPosition(objID)
{
    var obj= document.getElementById(objID);
    yPos = obj.offsetTop;
    xPos = obj.offsetLeft;
    
    var tempObj = obj.offsetParent;
    while (tempObj != null)
    {
        yPos += tempObj.offsetTop;
        xPos += tempObj.offsetLeft;
        tempObj = tempObj.offsetParent;
    }
}

/*
function play(target, movid, vars){
	document.getElementById(''+target+'').innerHTML= '<embed src="http://soapbox.msn.com/flash/soapbox1_1.swf" quality="high" width="432" height="364" wmode="transparent" id="'+movid+'" name="'+movid+'" type="application/x-shockwave-flash" pluginspage="http://macromedia.com/go/getflashplayer" flashvars="'+vars+'"><\/embed>'
}
*/

function play(target, movid){
document.getElementById(target).innerHTML=
'<OBJECT ID="WMPlay" width="440" height="362" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"'
+'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,70" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
+'<PARAM name="URL" Value="'+movid+'">'
+'<PARAM name="DisplaySize" Value="0">'
+'<PARAM name="AllowChangeDisplaySize" value="True">'
+'<PARAM NAME="ShowControls" Value="1">'
+'<PARAM NAME="WindowlessVideo" Value="0">'
+'<PARAM NAME="ShowDisplay" Value="1">'
+'<PARAM NAME="ShowStatusBar" Value="1">'
+'<PARAM NAME="AutoStart" Value="TRUE">'
+'<PARAM NAME="InvokeURLS" Value="False">'
+'<PARAM NAME="stretchToFit" Value="True">'
+'<embed name="WMplay" width="440" height="362" type="application/x-mplayer2"'
+'pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"'
+'src="'+movid+'" Name="WMPlay" stretchToFit="True" AllowChangeDisplaySize="True" ShowControls="1" AutoStart="True" ShowDisplay="0" ShowStatusBar="1"><\/embed><\/object>'
}


function positionVid(linkID, vidBox){
		mavGetObjectPosition(linkID);
		document.getElementById(''+vidBox+'').style.top = eval(yPos-200)+"px";				 
}

function clearVids(vidTarget){
	document.getElementById(''+vidTarget+'').innerHTML= '0'
}

function setSize(){
	vidDivHeight = document.getElementById('main').scrollHeight;
	
	if (window.innerWidth) {
		vidDivWidth = window.innerWidth;
	}
	else {
		vidDivWidth = document.body.clientWidth;
	}
	theTop = document.body.scrollTop
	
	document.getElementById('vidBox01').style.height = eval(vidDivHeight+400)+"px";
	document.getElementById('vidBox01').style.width = vidDivWidth+"px";		
	document.getElementById('videoContainer01').style.top = eval(theTop+300)+"px";
	
}

function checkFirstThenSize(){
	if (document.getElementById('vidBox01')) {
		setSize();		
	}
}

function setPositionDiv()
{
	if (window.innerWidth) {
		vidDivWidth = window.innerWidth;
	}
	else {
		vidDivWidth = document.body.clientWidth;
	}

    document.getElementById('vidBox01').style.width = vidDivWidth + 'px';              
	}


/***********************************
						CASE STUDIES
 ***********************************/
 
 function tabActive() {
	var theObj;
	for (var i = 0; i < tabActive.arguments.length; i++) {
		theObj = getObject(tabActive.arguments[i]);
		if (theObj != null) {
			theObj.backgroundColor = "#E2E9EE";
		}
	}
}

function tabInActive() {
	var theObj;
	for (var i = 0; i < tabInActive.arguments.length; i++) {
		theObj = getObject(tabInActive.arguments[i]);
		if (theObj != null) {
			theObj.backgroundColor = "#FFFFFF";
		}
	}
}
