//SWAP IMAGE
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// Metrics hash value - used to obtain metrics from vanity URLs
function VanityMetrics() {
	if ((window.location.hash.substr(0,5)==="#ref_") && (typeof(s) != 'undefined')) {
	thisHash=window.location.hash.substr(5,window.location.hash.length-5);
	s.tl(true,'o','Referrer: ' + thisHash);
	}
}



// --- KEYPRESS VALIDATION
function verifyKey(oElement,oEvent){
	if(oEvent.keyCode==13 && oElement.onclick){
		oEvent();
	}
}


/****** Screen size detect *******/
window.onload = function(){setScreenClass();}; 
window.onresize = setScreenClass;

//  Following transition classes will be declared:
//
//	classname		  screenwidth
//	------------------------------------------
//	screen_low		  < 950px	
//	screen_high		  > 950px	


function setScreenClass(){
	var browsertype="working";
	var browser=navigator.appName;
	var verStr=navigator.appVersion;
	if(browser.indexOf("Microsoft Internet Explorer") >= 0){
	  if(verStr.indexOf("MSIE 4") >= 0 || verStr.indexOf("MSIE 6") >= 0){
	   var browsertype="fullscreenonly";
	  }
	}

	if (browsertype != "fullscreenonly" ) {
		var fmt = document.documentElement.clientWidth;
		var cls = (fmt<=950)?'screen_low':(fmt>950&&fmt<=1280)?'screen_high':'screen_high';
		//document.getElementById('count').innerHTML=fmt+'px -> '+cls;
		document.body.className=cls;
	}
		VanityMetrics();
}

function teamLit(lit) {
	if (lit != "onc") {
		document.getElementById("onc").className="";	
	}
	if (lit != "tech") {
		document.getElementById("tech").className="";	
	}
	if (lit != "brand") {
		document.getElementById("brand").className="";	
	}
	if (lit != "admin") {
		document.getElementById("admin").className="";	
	}
	document.getElementById(lit).className="lit";
}










$(document).ready(function () { //HTML DOM document is ready

	//image rollover
	$("a.roll").live('mouseover focus', function(event) {
		$(this).find('img').attr("src", $(this).find('img').attr("src").split('_f1').join('_f2'))
	}).live('mouseout blur', function(event) {/*mouseout*/
		$(this).find('img').attr("src", $(this).find('img').attr("src").split('_f2').join('_f1'))
	});

	//open links in a new window - rel=external
	$("a[rel*=external]").live("hover focus", function() {
		var openText = "Opens in a new browser window";											  
		if ($(this).data("external") == null) {
			var detectNewWin = $(this).attr("title").toLowerCase().split(openText.toLowerCase()).length;
			$(this)
				.attr("target","_blank")
				.data("external",1)
				.attr("title") !=='' && detectNewWin == 1 ? this.title=$(this).attr("title")+'. '+openText+'.'
					: detectNewWin > 1 ? this.title=$(this).attr("title")
					: this.title=openText+'.';	
		}
	});







	//connect tooltip
	$("a.tooltip").live("mouseover focus", function() {
		var tooltipparent = $(this).parent().parent(),
		    tooltipcontent = $(this).find("span").html(),	
		    tooltipimagewidth = ($(this).find("img").width()/2),
		    tooltipposition = $(this).position().left,
		    tooltipvert = $(this).position().top;

		$("<div class=\"tooltip\"><div class=\"tooltipcontent\">"+tooltipcontent+"</div><img src=\"images/site_objects/tooltiparrow.gif\" alt=\"\" /></div>").appendTo(tooltipparent);

		var width = $("div.tooltip").width(),
		    height = $("div.tooltip").height(),
		    tooltipposition = tooltipposition - (width/2) + tooltipimagewidth;
		$("div.tooltip").css({"left":tooltipposition+"px", "width":width+"px"});
		$("div.tooltip img").css({"margin-left": ((width/2) - 7) +"px"});

		if((tooltipparent.attr("class") == "connect")||(tooltipparent.attr("class") == "share")){
			$("div.tooltip").css({"top": ((tooltipvert - height) - 5) +"px"});
		}

	}).live('mouseout blur', function() {
		$("div.tooltip").remove();
	});





});

