//Util.debug = true;

function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}
function showTerm(term,id,description) {
	var terminLowercase=term.toLowerCase();

	if(glossarypopoverTimer) {
    clearTimeout(glossarypopoverTimer);
   	glossarypopoverTimer = null;
  }
	var lyr = $('termPopover');
 	if( ! lyr) {return; }
	
	var activator = $('activator'+terminLowercase);

	if( ! activator) { return; }
	var lyrNewX = Position.page(activator)[0] + Position.realOffset(activator)[0];
	var lyrNewY = Position.page(activator)[1] + Position.realOffset(activator)[1];
	if( ! popoverLoaded) {
		Element.hide('termPopover');
 		getTermContent(id,term,description);
 		popoverLoaded = true;
 	}
	if(lyrNewX+popoverWidth > getWindowWidth()) {

		lyr.setStyle({left:(lyrNewX-popoverWidth-popoverOffsetX)+'px'});
	} else {
		lyr.setStyle({left:(lyrNewX+popoverOffsetX)+'px'});
	}
	lyr.setStyle({top:(lyrNewY+popoverOffsetY)+'px'});
}

function hideTerm() {
		Element.update('termPopover', '');
  	popoverLoaded = false;
}

function doHideTerm () {
	if(document.layer) { return; }
  	glossarypopoverTimer = setTimeout('hideTerm()', 200);
}
function getTermContent(id,term,description) {
	var content = glossaryHtml(id,term, description);
	var div_with_content = '<div id="glossarypopover" class="glossarypopover" onmouseout="doHideTerm()" onmouseover="showTerm(\''+term+'\', \''+id+'\', \''+description+'\')"  style="position:absolute; top:0; left:0; z-index:1000;">' + content+ '</div>';
	var final_mark_up_glossary = div_with_content + '<iframe id="glossarypopover_iefix" style="display:none; position:absolute; z-index:999; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' + 'src="javascript:;" frameborder="0" scrolling="no"></iframe>';
	Util.log(final_mark_up_glossary);
  Element.update('termPopover',final_mark_up_glossary);
	setTimeout(function() {
		var iefix = $('glossarypopover_iefix');
		var popover = $('glossarypopover');
		Position.clone(popover, iefix);
		iefix.show();
		Effect.Appear('termPopover', {duration:0.5});
	}, 50); 
}
function glossaryHtml(id,term, description) {
	var html = new Array();
	html.push('<div class="glossary-container">');
		html.push('<div class="glossary-definition">');
			html.push('<div class="top"></div>');
			html.push('<div class="middle">');
				html.push('<div class="content">');
					html.push('<div class="term">Glossary term:</div>');
					html.push('<dl><dt>&ldquo;'+term+'&rdquo;</dt><dd>'+description+'</dd></dl>');
					html.push('<div class="more">Click <a href="/products_services/glossary/index.html#"'+id+' title="more information"><img src="/common/images/glossary/glossary-icon.gif" /></a>for more information</div>');
				html.push('</div>');
			html.push('</div>');
			html.push('<div class="bottom"></div>');
		html.push('</div>');
	html.push('</div>');
	Util.log(html.join(''));
	return html.join('');
}
var errMail = 'webmaster.com';
var glossarypopoverTimer = null;
var popoverWidth = 270;
var popoverOffsetX = 13;
var popoverOffsetY = -3;
var popoverLoaded = false;	

function printThis()
	 {
				 var printable = window.print;
				 if(printable){
				 window.print();
	}
}
function makepage(content)
{
  return "<html>\n" +
    "<head>\n" +
    "<title>Temporary Printing Window</title>\n" +
    "<script>\n" +
    "function step1() {\n" +
    "  setTimeout('step2()', 10);\n" +
    "}\n" +
    "function step2() {\n" +
    "  window.print();\n" +
    "  window.close();\n" +
    "}\n" +
    "</scr" + "ipt>\n" +
    "</head>\n" +
    "<body onLoad='step1()'>\n" +
   "<div id='content'>"+content+"</div>"
    "</body>\n" +
    "</html>\n";
}
function printThiss()
{
try{
  content= document.getElementById("content").innerHTML;
  link = "about:blank";
  var pw = window.open(link, "_new");
  pw.document.open();
  pw.document.write(makepage(content));
  pw.document.close();
  } catch(err) {
 
  }
}
function isCareersPrefEmpty(checkSegment){
	var loc = document.forms.proprefs.loc.value;
	var err = "Please make a selection from:";
	var myCollege;
	if(checkSegment != null){
		if(checkSegment == 'newgrad' || checkSegment == 'intern' || checkSegment == 'students'){
			myCollege = document.forms.proprefs.coll.value;
			if(myCollege == 'x' || myCollege == ''){
				err += "\n-->College Dropdown";
				myCollege = "x";
			}
		}
	}
	var myCtgy = document.forms.proprefs.cc.value;
	if(myCtgy == 'x' || myCtgy == ''){
		err += "\n-->Career categories Dropdown";
		myCtgy = "x";
	}
	var myLocation = document.forms.proprefs.loc.value;
	if(myLocation == 'x' || myLocation ==''){
		err += "\n-->Locations Dropdown";
		myLocation = "x";
	}
	if(myCollege == 'x' || myCtgy == 'x' || myLocation == 'x'){
		alert(err);
		return false;
	} else {
		document.forms.proprefs.submit();
	}		

}
function isLeftNavLocationValue(checkSegment){
	var err = "Please make a selection from:";
	var myLocation = document.forms.proprefs.loc.value;
	if(myLocation == 'x' || myLocation ==''){
		err += "\n-->Locations Dropdown";
		myLocation = "x";
	}
	if(myLocation == 'x'){
		alert(err);
		return false;
	} else {
		document.forms.proprefs.submit();
	}		
}
function ul_window(which_window, image_width, image_height) {
  var window_width = image_width + 46;
  var window_height = image_height + 175;
  newwin = window.open(which_window, "ul_window", 
'toolbar=1,location=1,directories=1,scrollbars=1,status=1,menubar=1,resizable=1,width=' + window_width + ',height=' + window_height);
window.self.name = "ul_parent";
} 