// these scripts are to be available to all pages on the site

//place gloabal variables here
var d = document;


// based on script by Paul Bellows; mod. by Avid Technology, Inc.
function evenColumnsxxx() {
	if (d.getElementById) { // determine if browser uses DOM
		var contentHeight = d.getElementById('ContentBody'); //middle column
		var rightHeight = d.getElementById('Rightside'); //right column
		var leftHeight = d.getElementById('Leftside'); //left column
		if ((rightHeight != null)) { //check if right column exists; set heights to largest
			//alert('I detect three columns/nNow, which one is the highest?');
			if ((contentHeight.offsetHeight >= rightHeight.offsetHeight) && (contentHeight.offsetHeight >= leftHeight.offsetHeight)) {
				//alert('content div is the highest');
				leftHeight.style.height = (contentHeight.offsetHeight) + 'px';
				rightHeight.style.height = (contentHeight.offsetHeight) + 'px';
				contentHeight.style.height = (contentHeight.offsetHeight) + 'px';
			} else if ((rightHeight.offsetHeight >= contentHeight.offsetHeight) && (rightHeight.offsetHeight >= leftHeight.offsetHeight)) {
				//content not the hightest; checking others...
				//alert('right div is the highest');
				leftHeight.style.height = (rightHeight.offsetHeight) + 'px';
				rightHeight.style.height = (rightHeight.offsetHeight) + 'px';
				contentHeight.style.height = (rightHeight.offsetHeight) + 'px';
			} else { //ok, only one column left to be the highest (yup, the left one)
				//alert('left div is the highest');
				leftHeight.style.height = (leftHeight.offsetHeight) + 'px';
				rightHeight.style.height = (leftHeight.offsetHeight) + 'px';
				contentHeight.style.height = (leftHeight.offsetHeight) + 'px';
			}
				
		} else { //assume only two columns; set heights to largest
			if ((leftHeight != null) && (contentHeight != null)) { //this line added by MO 03/11/05. was causing probs on new xpress video pages
				if (contentHeight.offsetHeight >= leftHeight.offsetHeight) {
					leftHeight.style.height = (contentHeight.offsetHeight) + 'px';
				}
			}
		}
	}
}
function evenColumns() {
	if (d.getElementById) { // determine if browser uses DOM
		var contentHeight = d.getElementById('ContentBody'); //middle column
		var rightHeight = d.getElementById('Rightside'); //right column
		var leftHeight = d.getElementById('Leftside'); //left column
		if (rightHeight != null) { //check if right column exists; set heights to largest
			//alert('I detect three columns/nNow, which one is the highest?');
			if ((contentHeight.offsetHeight >= rightHeight.offsetHeight) && (contentHeight.offsetHeight >= leftHeight.offsetHeight)) {
				//alert('content div is the highest');
				leftHeight.style.height = (contentHeight.offsetHeight) + 'px';
				rightHeight.style.height = (contentHeight.offsetHeight) + 'px';
				contentHeight.style.height = (contentHeight.offsetHeight) + 'px';
			} else if ((rightHeight.offsetHeight >= contentHeight.offsetHeight) && (rightHeight.offsetHeight >= leftHeight.offsetHeight)) {
				//content not the hightest; checking others...
				//alert('right div is the highest');
				leftHeight.style.height = (rightHeight.offsetHeight) + 'px';
				rightHeight.style.height = (rightHeight.offsetHeight) + 'px';
				contentHeight.style.height = (rightHeight.offsetHeight) + 'px';
			} else { //ok, only one column left to be the highest (yup, the left one)
				//alert('left div is the highest');
				leftHeight.style.height = (leftHeight.offsetHeight) + 'px';
				rightHeight.style.height = (leftHeight.offsetHeight) + 'px';
				contentHeight.style.height = (leftHeight.offsetHeight) + 'px';
			}
				
		} else if (leftHeight !=null) { //assume only two columns; set heights to largest
			if (contentHeight.offsetHeight >= leftHeight.offsetHeight) {
				leftHeight.style.height = (contentHeight.offsetHeight) + 'px';
				contentHeight.style.height = (contentHeight.offsetHeight) + 'px';
			} else { //left nav taller than content (bad design *yeesh*
				contentHeight.style.height = (leftHeight.offsetHeight) + 'px';
				}
		}
	}
}


//event firings
window.onload = function() {
	if ( AllowResize() ) {
		evenColumns();
		fixFlash();
	}
}

/*
window.onresize = function() {
	if ( AllowResize() ) {
		evenColumns();
	}
}
*/

function AllowResize(){
	// created by tf: 20 sep 06
	// purpose: return boolean to indicate if we can dynamically resize columns for this page.
	// some .net pages go into an endless loop when resizing using the evenColumns function in this script file. 
	// So they have a var set in their page which we will look for here to indicate we should not do the resizing.

	// if the 'thisPageId' exists AND it is 'Rohs' then do NOT allow it.
	var doIt = true;
	try{
		if ( thisPageID == 'Rohs' ){
			doIt = false;
		}
	}
	catch (err){
		// the var doesn't even exist: so allow page to be resized.
	}
	return doIt;
}


//share function to open new windws
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// stuff for hosted website survey 2005

function takeSurvey(){
	surveyCookie = getCookieS('siteSurvey2005');
	if(surveyCookie==null){
		// first time thru, set cookie so we don't prompt them again
		expiresDate = new Date();
		expiresDate.setMonth(expiresDate.getMonth()+3);
		setCookieS('siteSurvey2005',true, expiresDate)
		popup_window();
	}	
}

function popup_window() {
            // Create the popup
            var w = window.open('', 'Survey_Invite', 'width=300, height=200, menubar=no, scrollbars=no, toolbar=no, location=no, resizable=no, top=50, left=50');
            var d = w.document;
            
            //d.write('<link href="/stylesheets/Default.css" type="text/css" rel="stylesheet" />');

            // Create the popup's html
            d.write("<head><title>We Invite you to take the 2005 Avid Web Site Visitor survey</title></head>");
            d.write("<body style='background-color:#FFFFFF'>");
            
            // BEGINNING OF POPUP TEXT CONTENT
            d.write("We invite you to take the 2005 Avid Web Site Visitor Survey.<br>");
	    d.write("Please help us to improve your experience with Avid.com.<br>");
            d.write("Take a few minutes and complete this brief survey.  Your opinions are important to us.<br>");
            d.write("Would you like to take the survey now?<br>");
            // END OF POPUP TEXT CONTENT
            
            // Finish creating popup's html
            d.write("<form onSubmit=\"window.open('http://survey.perseus.com/116396be.htm');self.close();\">");
            d.write("<div align='right'>");
            d.write("<input type='submit' value=' Yes '>&nbsp;");
            d.write("<input type='button' value=' No ' onclick='self.close();'>");
            d.write("</div>");
            d.write("</form>");
            d.write("</body>");
}

function setCookieS(name, value, expire) {
	document.cookie = name + "=" + escape(value) + "; path=/" + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

function getCookieS(Name) {
	var search = Name + "=";
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search);
		if (offset != -1) { // if cookie exists
			offset += search.length;
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end))
		}
	}
}

function openVideoWindowIntl(theURL,wH,wW) {
	var vidWin;
	winWidth=wW;
	winHeight=wH;
	vidWin = window.open(theURL,'videoWin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+winWidth+',height='+winHeight+'');
	vidWin.focus();
}
//for opening up FLV window
function openFLVWin(flash,fWidth,fHeight) {
	var flashWin;
	var winWidth;
	var winHeight;
	winWidth = fWidth + 250;
	winHeight = fHeight + 250;
	flashWin = window.open('http://www.avid.com/video/FLVOnlyPlayer.asp?video='+flash+'&width='+fWidth+'&height='+fHeight,'flashWin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+winWidth+',height='+winHeight+'');
	flashWin.focus();
}



//takeSurvey();

// delete cookie, for testing
//setCookieS('siteSurvey2005','',new Date(1999,1,1));


// end of hosted survey stuff

function openBcastAnim(theURL) {
  bcastWidth=1010;
  bcastHeight=740;
  features = 'toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,status=0,width='+bcastWidth+',height='+bcastHeight;
  newWin = window.open(theURL,'BcastAnim',features);
}

function fixFlash(){
    if(checkIsIE(6.0)){
        //alert('fixing')
        var objArray = document.getElementsByTagName('object');
        for(i=0;i<objArray.length;i++){
            obj = objArray[i];
            //if(obj.classid == 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'){
            if(obj.classid == 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'&&obj.movie!='FLVPlayer_Progressive.swf'){
                obj.id = 'mc';
                obj.outerHTML = obj.outerHTML;
                mc.Play();
                //FLVPlayer.Stop();
            	//FLVPlayer.Play();
             }
        }
     }
}

function fixFlashOld(){
    if(checkIsIE(6.0)){
        //alert('fixing')
        var objArray = document.getElementsByTagName('object');
        for(i=0;i<objArray.length;i++){
            obj = objArray[i];
            if(obj.classid == 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'){
                obj.outerHTML = obj.outerHTML;
             }
        }
     }
}

function checkIsIE(IEvers) { //v5.0
  returnVal = false;
  userAgent=navigator.userAgent, version=0;
  if (userAgent.indexOf('MSIE') != -1) {
  	version = parseFloat(userAgent.substring(userAgent.indexOf('MSIE')+4,userAgent.length));
    if (version >= IEvers){
        returnVal = true;
    }
  }
  return returnVal;       
}

// allows for a jumplist dropdown
function jumpFunction(url){
	url = url.value;
	location.href = url;
}




