/////////////////////////////////////////////////////////////
// Digidesign Cookie functions
/////////////////////////////////////////////////////////////
function setCookie(label, value) {
	var rand = "" + Math.round(Math.random() * 999998);
	var curcookie = getCookie(label);

	//alert(curcookie);
	
	if(curcookie == rand){
		rand = rand + "1"; //change the random value
	}
	//reset current cookie value if exists to a random value
	document.cookie = label + "=" + escape(rand) + "; path=/; domain=.paloalto.avid.com";

	//alert("debug: " + document.cookie);

	//test if the cookie was set
	if(getCookie(label) != rand) {
		alert("You must enable cookies in order to select a country.");
		return;
	}
	
	//set new cookie value
	var expires = new Date();
	expires.setTime(expires.getTime() + (365 * 24 * 60 * 60 * 1000));
	document.cookie = label + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/; domain=.paloalto.avid.com";
	
	//alert(label + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/; domain=.paloalto.avid.com");
	
	//alert("Setting Cookie: " + label + "=" + value);
	
	//alert("Getting Cookie: " + getCookie(label));
	return;
}


function getCookie(label) {
	var labelLen = label.length;
	var cLen = document.cookie.length;
	var i = 0;
	var cEnd;
	while (i < cLen) {
		var j = i + labelLen;
		if ( document.cookie.substring(i, j) == label) {
			cEnd = document.cookie.indexOf(";", j);
			if (cEnd == -1) {
				cEnd = document.cookie.length;
			}
			return unescape(document.cookie.substring(j + 1, cEnd));
		}
		i++;
	}
	return "";
}

//Selects the item in the specified <select> that corresponds to the value of passed cookie
function setSelector(selector, label){
	for(var i=0; i<selector.length; i++){
		if(selector.options[i].value == getCookie(label)){
			selector.options[i].selected = true;
		}
	}
}

//Jump Menu for Header files - Trey
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//Open New Window  - Trey
function MM_openBrWindow(theURL,winName,features) { //v2.0
  var hdlWin = window.open(theURL,winName,features);
  hdlWin.focus();
}

//Show/Hide Function///////////////////////////////////////////////////////////

function disp_toggle(divId){
	if (document.getElementById(divId).className == "dispoff") {
		document.getElementById(divId).className = "dispon";
	}
	else {
		document.getElementById(divId).className = "dispoff";
	}
}

/* imageviewer functions */
function showImage(imageUrl) {
	var imageWin = window.open("index.cfm?page=imageviewer&noheader=1&imageUrl="+imageUrl,'imageW','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes,copyhistory=no,width=1,height=1,top=10,left=10');
	//imageWin.blur();
	imageWin.focus();
}
/* /imageviewer functions */

function writeFlash(fId,swfLoc,flashVars,width,height) {
	//alert("writing");
	var bgcolor = null;
	document.writeln('<object id="'+fId+'" align="bottom" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'">');
	document.writeln('<param name="allowScriptAccess" value="sameDomain"/>');
	document.writeln('<param name="movie" value="'+swfLoc+'"/>');
	document.writeln('<param name="data" value="'+swfLoc+'"/>');
	document.writeln('<param name="quality" value="high"/>');
	document.writeln('<param name="salign" value="lt" />');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('<param name="bgcolor" value="#3f4447" />');
	document.writeln('<param name="FlashVars" value="'+flashVars+'"/>');
	document.writeln('<embed name="'+fId+'" src="'+swfLoc+'" FlashVars="'+flashVars+'" bgcolor="'+bgcolor+'" align="top" salign="lt" wmode="transparent" allowScriptAccess="sameDomain" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" vspace="0" hspace="0"></embed>');
	document.writeln('</object>');
	//alert("done writing");
}
