/* site scripts */
var page = "default";
var hasScroll = false;

// rollover images
var main = new Array('n1_home','n1_locations','n1_activities','n1c_sanfrancisco','n1c_newyork','n1c_losangeles',
										 'n1s_about','n1s_press','n1s_advertise','n1s_license','n1s_videoprod','n1s_filmmakers');

// preload rollovers
function preload(imgArr){
	off = new Array();
	on  = new Array();
	for (i=0;i<imgArr.length;i++){
		off[i] = new Image;
		off[i].src = "/images/" + imgArr[i] + "_off.gif";
		on[i] = new Image;
		on[i].src = "/images/" + imgArr[i] + "_on.gif";
	}
}

// onload functions
function init(){
	// set column heights
	if (page == "home"){
		P7_equalCols2(0,'col-home','DIV','col-right','DIV');
	} else if (page == "full"){
		P7_equalCols2(0,'col-left','DIV','col-full','DIV');
	} else {
		P7_equalCols2(0,'col-left','DIV','col-mid','DIV','col-right','DIV');
	}
	// init scroller
	if (hasScroll == true){
		InitialiseScrollableArea();
	}
	// do rollover preloads
	preload(main);
}
window.onload = init;

// rollovers
function roll(img,state){
	document.images[img].src = state ? "/images/"+img+"_on."+getExt(img) : "/images/"+img+"_off."+getExt(img);
}

// find img extension
function getExt(id){
	arr = (document.images[id].src).split('.');
	len = arr.length;
	return arr[len-1];
}

// function to hilight controller box, links & movie description
// reference dynamic movie id array (mArray) written to page
function hiliteClip(id){
	// check to see if a clip is already playing
	if (clipOn < 1){
		for (i=0; i<mArray.length; i++){
			// iterate through movie controllers and hilight or dim
			control = document.getElementById("control-"+mArray[i]);
			control.className = (mArray[i] != id) ? "control-off" : "control-on";
			// iterate through text descriptions and display or hide
			mArray[i] != id ? setIdProperty("intro-"+mArray[i],"display","none") : setIdProperty("intro-"+mArray[i],"display","block");
		}
	}
}

// function to play selected clip
var clipOn = 0;
function playClip(id, clipName){

	for (var i = 0; i < mArray.length; i++)
	{
		if (mArray[i] != id)
		{
			var hdnImgName = document.getElementById("hdnClipImg_" + mArray[i]);
			var targetClip = document.getElementById("movie-" + mArray[i]);
			targetClip.innerHTML = "<img src='" + hdnImgName.value + "' width='160' height='120' alt='' />";
		}
	}

	var movieDiv = "movie-"+id;
	var movieTag = 
		"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='160' height='120'>" +
		"<param name='movie' value='/vitalstream_160_player.swf?stream=" + clipName + "' />" +
		"<param name='salign' value='lt' />" +
		"<param name='quality' value='high' />" +
		"<param name='scale' value='noscale' />" +
		"<param name='FlashVars' value='&amp;bgColor=0xFFFFFF&amp;configFile=http://flash.vitalstream.com/flashgen.cgi?150," + clipName + "%26aname=turnhere_vitalstream_com/_definst_&amp;autoPlay=true&amp;skinName=http://turnhere.sitestream.com/flash/skins/haloSkin_1&amp;bufferTime=3&amp;autoRewind=true' />" +
		"<embed src='/vitalstream_160_player.swf?stream=" + clipName + "' flashvars='&amp;bgColor=0xFFFFFF&amp;configFile=http://flash.vitalstream.com/flashgen.cgi?sname=" + clipName + ",150," + clipName + "%26aname=turnhere_vitalstream_com/_definst_&amp;autoPlay=true&amp;skinName=http://turnhere.sitestream.com/flash/skins/haloSkin_1&amp;bufferTime=3&amp;autoRewind=true' quality='high' scale='noscale' width='160' height='120' salign='lt' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></embed>" +
		"</object>";
	document.getElementById(movieDiv).innerHTML = movieTag;
	playLink = document.getElementById("pLink-"+id);
	playLink.className = "on";
	clipOn = 1;
	setTimeout('endClip()',10000);
}

// function to simulate movie playing end
function endClip(){
	clipOn = 0;
}

// function to play go to full movie
function playFull(id){
	// stub
	alert('go to full movie...');
}




// function to display selected movie description
/*
function showDesc(id){
	var parentDiv = document.getElementById("intro");
	var childDivs = parentDiv.childNodes;
	for (i=0; i<childDivs.length; i++){
		if (childDivs[i].nodeType == 1 && childDivs[i].nodeName.indexOf("DIV") != -1 && childDivs[i].getAttribute("id").indexOf("intro-") != -1){
			el = childDivs[i].getAttribute("id");
			//alert(el);
			if (el.indexOf("-"+id) != -1){
				setIdProperty(el,"display","block");
			} else {
				setIdProperty(el,"display","none");
			}
		}
	}
}
*/

// utility function to set style properties
function setIdProperty(id, property, value ){
	if (document.all){
		document.all[id].style[property] = value;
   	} else if (document.layers){
        document[id][property] = value;
	} else if (document.getElementById){
        var styleObject = document.getElementById(id);
        if (styleObject != null){
            styleObject = styleObject.style;
            styleObject[property] = value;
		}
	}
}

/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}