var w
function openVideoWindow(){
	if (w) w.focus();
	else w = window.open ("/video_window.php","Video","location=0,status=0,scrollbars=0,toolbars=0,width=760,height=480");
	if (w) w.focus();
	else alert("We were not able to display the video in a new window. Please turn off pop-up blocking for this website and try again. Thank you.")
	}

	function share(){
		 location.href="http://stomptheelephant.com/about/video.php";

	}
	
function launchVideo(){
 //   openVideoWindow()
//	return;

// not used...
var video = {
        player:     'iframe',
        content:    '/video_stream.php',
        height:     480,
        width:      720,
        title:      'The Stan Problem'
    };

    Shadowbox.open(video);

};


// javascript document

function download(file){

//	var op = new Fx.Style('content_inner_pane', 'opacity', {duration:500});
//	op.start(100,0);
	var pstring='file='+file;
	var url="/inc/dl.php";
	var pdiv="dl_pane";
	new Ajax(url, {postBody: pstring, update: $(pdiv),
	onComplete: function(){	
		

	}}).request();


}

function submitEmailToAFriend(loc,fromName,fromEmail,toName,toEmail){
	var pstring='location='+loc+"&fromName="+fromName+"&fromEmail="+fromEmail+"&toName="+toName+"&toEmail="+toEmail;
	var url="/inc/emailFriend.php";
	var pdiv="emailFriend_pane";
	new Ajax(url, {postBody: pstring, update: $(pdiv),
	onComplete: function(){	

	}}).request();

}
function writeEmail(tla,dom,nam) {
document.write("<a href='mailto:"+nam+"@"+dom+"."+tla+"'>"+nam+"@"+dom+"."+tla+"</a>");
}

var curSection="pspecs";
function switchp(sect) {
if (curSection) {
	cs=document.getElementById(curSection);
	cn=document.getElementById(curSection+"_nav");
	cs.style.display="none"; 
	cn.className=null;
}
ns=document.getElementById(sect);
nn=document.getElementById(sect+"_nav");
ns.style.display="block";
nn.className="on";
curSection=sect;
}

function switchVal(e,o) {
// e is the element  - o is the orginal value
if (document.getElementById(e.name).value==o) document.getElementById(e.name).value="";
}
function checkVal(e,o) {
// e is the element  - o is the orginal value
if (document.getElementById(e.name).value=="") document.getElementById(e.name).value=o;
}

function writeYear() {
var d=new Date().getFullYear();
document.write (d);
}


String.prototype.toTitleCase = function()
 {
 return this.replace(/\b([a-z])/g,function($0){return $0.toUpperCase()});
 
 }

function checkForm(f){
	var err='';
	if (window.extraValidation) err+=extraValidation(f);
	//alert(".length: "+reqArr);
	for (t=0;t<reqArr.length;t++){
	//alert(reqArr[t]+" - "+f[reqArr[t]]+" - "+f[reqArr[t]].type+" - toString: "+f[reqArr[t]].toString() )
	//if (!f[reqArr[t]]) alert("Not found :" +reqArr[t]);
		if (f[reqArr[t]].type=="text"){
			if (f[reqArr[t]].value=="") err+="\t - "+reqArr[t].replace(/_/g," ")+"\n";
		} else if (f[reqArr[t]].type=="select-one"){
			var selchk=false; 
			for (var o = 0; o < f[reqArr[t]].length; o++) { 
				if (f[reqArr[t]].options[o].value!="" && f[reqArr[t]].options[o].selected) { 
					//alert(f[reqArr[t]].options[o].text);
					selchk=true;
				}
			}
			if (!selchk) err+="\t - "+reqArr[t].replace(/_/g," ")+"\n";
		} 
		
		//else if (f[reqArr[t]].toString().indexOf("NodeList")!=-1){
		// can't check for a radio button type in IE only so we're assuming anything left must be that.... IE blows..
		else{
			var rchk=false; 
			for (var r = 0; r < f[reqArr[t]].length; r++) { 
				if (f[reqArr[t]][r].checked) rchk=true;
			}
			if (!rchk) err+="\t - "+reqArr[t].replace(/_/g," ")+"\n";
		} 
	//	else alert(f[reqArr[t]]+"  - "+t);
	}
	
	//return true;
	if (err!=''){
		alert("All required fields must be completed. You missed:\n"+err.toTitleCase());
		return false;
	} else  return true;
}



// News stuff

var newsString="";
var newsCounter=1;

function News(headline,url){
this.headline=headline;
this.url=url;
newsString+="headline"+newsCounter+"="+this.headline+"&url"+newsCounter+"="+this.url+"&";
newsCounter++;
}

function gatherFlashVars(){
	return "enter_url="+enter_url+"&"+newsString;
}

function newsInit(){

}

function changeClass(me,clas){
alert(me);
}

function showName(market,name){
	//el=document.getElementById(market.toLowerCase());
	//el.style.width="450px";
	//el.style.height="16px";
	//var el=document.getElementById('project_desc_container');
	return("<strong>"+market+"</strong><br/> "+name);
	//el.style.visibility="visible";

}

function hideName(market,w){
	var el=document.getElementById('project_desc_container');
	//el=document.getElementById(market.toLowerCase());
	el.innerHTML="Navigate our projects by mousing over the circles below.";
	//el.style.visibility="hidden";
	//alert(w);
	//w=0;
	//el.style.width=w+"px";
}
var curphoto;

function showProjectImage(file,elem,hreff,orig){
	swapImage(file);
	var  ele=document.getElementById(hreff);
	ele.className='on';
	if (!curphoto) curphoto=document.getElementById(orig);
	curphoto.className='';

	curphoto=ele;
}


var iCnt = 0
var imgArray=null;
function DoLoad() {
if (!imgArray || imgArray.length==0) return;
    
  if (iCnt < imgArray.length) {
    var loadImage = new Image
    iCnt++  
    loadImage.onerror = loadImage.onload = DoLoad
    loadImage.src = imgArray[iCnt-1]
    //alert(loadImage.src+" -- "+imgArray[iCnt-1]);
    
	if (iCnt==1) swapImage(first_image);
    
	
  } else {
  }
}

function writePhotos(){
var xwrite="";
	if (imgArray.length>0) {
	for (r=0;r<imgArray.length;r++){
	xwrite+=('<div class="hiddenphoto" style="background-image:url(/img/projects/large/'+(imgArray[r])+')"></div>');
	
	}}
	document.write(xwrite);
}
var theImage;
window.onload = DoLoad
function sw(sImage){
  var el=document.getElementById("main_photo");
el.style.backgroundImage ="url('"+ theImage+"')";
 el.style.width="350px";
}
function swapImage(sImage) {
 theImage=sImage;
 setTimeout('sw()',100);
 // alert(el.style.width);
}


/* TOOL TIP */

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
**********************************************

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="/img/tt_arrow.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6) var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function tooltip(thetext, thewidth, thecolor){
	if (ns6||ie){
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
		tipobj.innerHTML=thetext
		enabletip=true
		return false
	}
}

function positiontip(e){
	if (enabletip){
		var nondefaultpos=false
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
		var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

		var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
		var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

		var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth){
		//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=curX-tipobj.offsetWidth+"px"
			nondefaultpos=true
		} else if (curX<leftedge) {
			tipobj.style.left="5px"
		} else {
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
			pointerobj.style.left=curX+offsetfromcursorX+"px"
		}	

		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight){
			tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
			nondefaultpos=true
		} else {
			tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
			pointerobj.style.top=curY+offsetfromcursorY+"px"
		}

		tipobj.style.visibility="visible"
		if (!nondefaultpos) pointerobj.style.visibility="visible"
		else pointerobj.style.visibility="hidden"
	}
}

function hidetooltip(){
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		pointerobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}

document.onmousemove=positiontip	
*/