/* Javascript Document - telvue.com - Global Functions
/*
/* version:   1.0
/* date:      9/17/2008
/* author:    brian.crumley@alliedpixel.com
/* website:   http://www.alliedpixel.com
/*
----------------------------------------------------------*/


/* Correct IE6 background-image Flicker
----------------------------------------------------------*/
try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


/* Search Field Functions
----------------------------------------------------------*/
function searchFocus(field) {
	if (document.getElementById(field).value == 'enter search term(s)') {
		document.getElementById(field).value = '';
	};
	document.getElementById(field).style.color = "#636e72";
};
function searchBlur(field) {
	if (document.getElementById(field).value == '') {
		document.getElementById(field).value = 'enter search term(s)';
		document.getElementById(field).style.color = "#cccccc";
	};
};


/* Apply li:hover State to IE6 for Primary and Utility Nav
----------------------------------------------------------
sfNavHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfNavHover);
*/
sfUtilityHover = function() {
	var sfEls = document.getElementById("utility").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfUtilityHover);



/* Subnav "Coming Soon" Text Swap Function - TEMP PHASE I
----------------------------------------------------------*/
swapContent = function(aID, newContent) {
	if(newContent == "over") {
		document.getElementById(aID).innerHTML = "Coming Soon";
		document.getElementById(aID).style.cursor = "default";
		document.getElementById(aID).style.color = "#999";
	} else {
		document.getElementById(aID).innerHTML = newContent;
		document.getElementById(aID).style.color = "#636e72";
	}
};


/* Image Preload and Rollover Functions
----------------------------------------------------------*/
function newImage(arg) {
	if(document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	};
};

function changeImages() {
	if(document.images && (preloadFlag == true)) {
		for(var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		};
	};
};

var preloadFlag = false;

function imageLoader() {
	if (document.images) {
		pre_nav_bkg_left_ov = newImage('http://www.telvue.com/assets/image/nav_bkg-left-ov.gif');
		pre_nav_bkg_right_ov = newImage('http://www.telvue.com/assets/image/nav_bkg-right-ov.gif');
		pre_subnav_bkg_ie6_ov = newImage('http://www.telvue.com/assets/image/subnav_bkg-ie6-ov.gif');
		
		preloadFlag = true;
	};
};


/* Service Login Jump Functions
----------------------------------------------------------*/
function jumpLink(url) {
	window.location = url;
	document.getElementById('login_form').reset();
};


/* Flash Overlay Functions
----------------------------------------------------------*/
function clearCallout(divID) {
	document.getElementById(divID).innerHTML = "";
	document.getElementById(divID).style.display = "none";
};


function writeOverlay(divID, vidPath, hdAspect) {
	var ni = document.getElementById(divID);
	var newdiv = document.createElement('div');
	var divIdName = 'overlayDiv';
	newdiv.setAttribute('id', divIdName);
	ni.appendChild(newdiv);

	document.getElementById(divID).style.display = "block";

	if (!vidPath) {
		var flashvars = {};
			flashvars.myDiv = divID;
		var params = {};
			params.menu = "false";
			params.quality = "best";
			params.wmode = "transparent";
		var attributes = {};
			attributes.id = "telvue_workflow";
		swfobject.embedSWF("/assets/swf/telvue_workflow.swf", "overlayDiv", "100%", "100%", "9.0.0", "/assets/swf/expressInstall.swf", flashvars, params, attributes);
	} else {
		var flashvars = {};
			flashvars.myDiv = divID;
			flashvars.myVid = vidPath;
		var params = {};
			params.menu = "false";
			params.quality = "best";
			params.wmode = "transparent";
		var attributes = {};
			attributes.id = "telvue_player";
		if (hdAspect) {
			swfobject.embedSWF("/assets/swf/telvue_player_hd.swf", "overlayDiv", "100%", "100%", "9.0.0", "/assets/swf/expressInstall.swf", flashvars, params, attributes);
		} else {
			swfobject.embedSWF("/assets/swf/telvue_player.swf", "overlayDiv", "100%", "100%", "9.0.0", "/assets/swf/expressInstall.swf", flashvars, params, attributes);
		}
	};
};

function writeOverlayJW(divID, vidPath) {
	var ni = document.getElementById(divID);
	var newdiv = document.createElement('div');
	var divIdName = 'overlayDiv';
	newdiv.setAttribute('id', divIdName);
	ni.appendChild(newdiv);
	
	document.getElementById(divID).style.display = "block";

	if (!vidPath) {
		var flashvars = {};
			flashvars.myDiv = divID;
		var params = {};
			params.menu = "false";
			params.quality = "best";
			params.wmode = "transparent";
		
		var attributes = {};
			attributes.id = "telvue_workflow";
		
		swfobject.embedSWF("/assets/swf/telvue_workflow.swf", "overlayDiv", "100%", "100%", "9.0.0", "/assets/swf/expressInstall.swf", flashvars, params, attributes);
	} else {
		var flashvars = {};
			flashvars.myDiv = divID;
			flashvars.myVid = vidPath;
		var params = {};
			params.menu = "false";
			params.quality = "best";
			params.wmode = "transparent";
		
		var attributes = {};
			attributes.id = "telvue_player";
		
		swfobject.embedSWF("http://origin.peg.tv/player.swf", "overlayDiv", "100%", "100%", "9.0.0", "/assets/swf/expressInstall.swf", flashvars, params, attributes);
	};
};


/* Cliet List Functions
----------------------------------------------------------*/
function checkProductService(option) {
	killDivs();
			
	if (option == "princeton") {
		jQuery("li#market_li").slideDown("fast");
	} else if (option == "webus" || option == "peg") {
		jQuery("li#market_li").slideUp("fast");
				
		if (option == "webus") {
			jQuery("#webus").fadeIn("normal");
		} else if (option == "peg") {
			jQuery("#peg").fadeIn("normal");
		};
	} else {
		jQuery("li#market_li").slideUp("fast");
	};
};

var clientDivs = new Array("#princeton_peg","#princeton_mso","#princeton_religious","#princeton_university","#princeton_professional","#princeton_educational","#princeton_federal","#princeton_contract","#webus","#peg");

function checkProductServiceMarket(option) {
	for (i=0; i<clientDivs.length; i++) {
		jQuery(clientDivs[i]).hide();
	};
	if (option == "peg") {
		jQuery("#princeton_peg").fadeIn("normal");
	} else if (option == "mso") {
		jQuery("#princeton_mso").fadeIn("normal");
	} else if (option == "religious") {
		jQuery("#princeton_religious").fadeIn("normal");
	} else if (option == "university") {
		jQuery("#princeton_university").fadeIn("normal");
	} else if (option == "professional") {
		jQuery("#princeton_professional").fadeIn("normal");
	} else if (option == "educational") {
		jQuery("#princeton_educational").fadeIn("normal");
	} else if (option == "federal") {
		jQuery("#princeton_federal").fadeIn("normal");
	} else if (option == "contract") {
		jQuery("#princeton_contract").fadeIn("normal");
	};
};

function killDivs() {
	for (i=0; i<clientDivs.length; i++) {
		jQuery(clientDivs[i]).fadeOut("normal");
	};
};


/* Contact Form Functions
----------------------------------------------------------*/
function checkMarket(option) {
	if (option == "other") {
		jQuery("li#market_li").slideDown("fast");
	} else {
		jQuery("li#market_li").slideUp("fast");
	};
};
function checkHear(option) {
	if (option == "other") {
		jQuery("li#hear_li").slideDown("fast");
	} else {
		jQuery("li#hear_li").slideUp("fast");
	};
};

