function toggleDisplay(id) {
	
  	if (document.getElementById(id).style.display == 'block') {
		
  		document.getElementById(id).style.display = 'none';
		
  	} else {
  		document.getElementById(id).style.display = 'block';
 	}
	return false;
}

function changeBackgroundPosition(id, position) {		
    //alert(" id = " + id);
	//alert(" position = " + position);
	document.getElementById(id).style.backgroundPosition = position; 
}


function changeDisplayDelay(id, attribute) {	
	window.setTimeout("ChangeDisplay('" + id + "','" + attribute + "')", 500);	
}

var TabPreviousNews    = "1";
function ChangeTabNews(Tab, vertical) {
	
  //alert("Tab = " + Tab); /* test */
  
  document.getElementById("tabs-news-link-" + Tab).style.color = "#333333"; /* grey */
  document.getElementById("tabs-news-link-" + TabPreviousNews).style.color = "#ffffff"; /* light grey */
  document.getElementById("tabs-news").style.backgroundPosition = "0 " + vertical; 
  document.getElementById("news-tab-" + TabPreviousNews).style.display = "none";
  document.getElementById("news-tab-" + Tab            ).style.display = "block";
  TabPreviousNews = Tab;   
}

var TabPreviousRelated = "1";
function changeTabRelated(Tab, vertical) {

  document.getElementById("tabs-related").style.backgroundPosition = "0 " + vertical; 
  document.getElementById("related-tab-" + TabPreviousRelated).style.display = "none";
  document.getElementById("related-tab-" + Tab               ).style.display = "block";
  
  TabPreviousRelated = Tab;   
}

var TabPreviousIndustry = "1";
function ChangeTabIndustry(Tab, vertical) {

  document.getElementById("tabs-industry").style.backgroundPosition = "0 " + vertical; 
  document.getElementById("industry-tab-" + TabPreviousIndustry).style.display = "none";
  document.getElementById("industry-tab-" + Tab               ).style.display = "block";
  
  TabPreviousIndustry = Tab;   
}

function changeTab(tab, tabs, vertical) {
	
  alert("tab = " + tab);
  
  for( var i=0; i < document.getElementById(tabs).getElementsByTagName("a").length; i++ ){ // change all link colors inside given Tab div
      
	  document.getElementById(tabs).getElementsByTagName("a")[i].style.color = "#EBEBEB"; // light grey
	  document.getElementById(tabs + "-content-" + i).getElementsByTagName("div")[i].style.display = "none"; 
  }
   
  document.getElementById(tabs).style.backgroundPosition = "0 " + vertical;   
  document.getElementById(tab).style.color = "#5F6062"; /* dark grey */
  document.getElementById(tab + "-content").style.display = "block";
  
}


function ShowAbuseForm(id) {
	
	document.getElementById("abuse" + id).style.display = "block";
	document.getElementById("abuse" + id).innerHTML = '                                         ' +
	  ' <form id="abuse-form-' + id + '" name="abuse-form-' + id + '">                          ' +
	  '     <input class="text-box" type="text" value="Enter a title here" />                   ' +
	  '     <textarea rows="2">Limit: 500 characters. HTML is prohibited.</textarea>            ' +
	  '     <input name="cancel" type="button" class="button secondary left" value="Cancel"     ' +
	  '      onclick="document.getElementById(\'abuse' + id + '\').style.display = \'none\';    ' +
	  '         document.getElementById(\'abuse' + id + '\').style.background = \'white\';  "/> ' +
	  '     <input name="Submit" type="button" class="button" value="Submit" />                 ' +
	  ' </form>                                                                                 ' +
	  ' <br class="clear" />                                                                    '
}


// === mouse capture ==============================
	dropdown1 = false;
	dropdown2 = false;
	dropdown3 = false;
	dropdown4 = false;
	ie =(document.all)?true:false;
	xyChange = false;
	var MouseX = 0;
	var MouseY = 0;
	var PrimaryNavId = "1";
	ie=(document.all)?true:false;
	
	function setMouseXY(e) {
	   var tempX;
	   var tempY;
	   if (ie) {
		  tempX = window.event.clientX + document.body.scrollLeft;
		  tempY = window.event.clientY + document.body.scrollTop;
	   } else {
		  tempX = e.pageX;
		  tempY = e.pageY;
	   }
	   if (tempY < 0) {tempX = 0;}
	   if (tempY < 0) {tempY = 0;}
	   if (MouseX!=tempX || MouseY!=tempY) {
		  xyChange = true;
	   }
	   MouseX = tempX;
	   MouseY = tempY;
	   //alert("X = " + X  + "  Y = " + Y); // test
	   window.setTimeout("CompareMouseCoordinates('" + MouseX + "','" + MouseY + "')", 300); // miliseconds	
	   return true;
	}
	
	function XYchanged() {
	   var ret = xyChange;
	   xyChange = false;
	   return ret;
	}
	
	function beginXYcapture(id) { 	   
	   if (!ie) {
		  document.captureEvents(Event.MOUSEMOVE);
	   }
	   // only capture mouse coordinates on necessary buttons
	   document.getElementById("category-1").onmousemove = setMouseXY;
	   document.getElementById("category-2").onmousemove = setMouseXY;
	   document.getElementById("category-3").onmousemove = setMouseXY;
	   document.getElementById("category-4").onmousemove = setMouseXY;
	}
	
	function endXYcapture() {
	   document.onmousemove = null;
	}

    function CompareMouseCoordinates(x, y) {
		
		//window.status = "MouseX = " + MouseX  + "  x = " + x; // test
		if (x == MouseX) {
			//alert("X = " + X  + "  x = " + x); // test
			
			ChangeDisplay("dropdown-" + PrimaryNavId, "block"); 
            //ChangeDisplay(  "filler-" + PrimaryNavId, "block"); 
           // document.getElementById("category-" + PrimaryNavId).style.backgroundImage = "url(/com.vault.layout.themes.skins/themes/html/./VaultCommon/images/backgrounds/new_one-pix-dropdown-home.jpg)";
		}
		
	}

// === /mouse capture ==============================



// === search key words ============================

var OptionIndex = -1; 

var term = [];  // initialize array

var OptionsHTML;

var arrayLength;

window.onload = function() { // enables onclick on "searchform" in FireFox

  //  document.forms["searchform"].onkeydown = CheckKey;		
}

function BuildOptions() {	
	
		//term.splice(0,arrayLength);		
	OptionIndex = -1; 

	for ( i = 0; i <= arrayLength; i++) { // change array values 
		
		//alert("term[" + i + "] = " + term[i] );		
		//term.splice(i, 1);
		document.searchform.terms.options[i] = null;
	}
	
	arrayLength = Math.floor(Math.random() * 10) + 1; // between 1 and 10
	
	//alert("arrayLength = " + arrayLength);
	
	for ( i = 0; i <= arrayLength; i++) { // change array values 
		term[i] = Math.floor(Math.random() * 100001);		
	}
	
    for ( i = 0; i <= arrayLength - 1; i++) { // create options		
		document.searchform.terms.options[i] = new Option(term[i], term[i]); // Option(text, value)	
    }
    
    //document.searchform.terms.style.height = "300px"	
	document.searchform.terms.size = arrayLength + 1; //term.length; // see all options at once	    
	//document.searchform.terms.options[0].selected;	
	
	
}

function CheckKey(e) {       

    var KeyCode = (window.event) ? event.keyCode : e.keyCode;
				
    if (KeyCode == 40) { // down arrow key   	
	    
		OptionIndex += 1;
		if ( OptionIndex >= arrayLength) { // reached last option
			OptionIndex = arrayLength -1;
		}
		document.searchform.terms.selectedIndex = OptionIndex; 
		ChangeDisplay("terms","block");
		
		document.getElementById("search-text").value = document.searchform.terms.options[document.searchform.terms.selectedIndex].value; // update text box value
	}

    if (KeyCode == 38) { // up arrow key       
		OptionIndex -= 1;
		
		if (OptionIndex < 0) { // reached first option
			OptionIndex = 0;
		}		
		document.searchform.terms.selectedIndex = OptionIndex;
		ChangeDisplay("terms","block");
	}	
		
    if (KeyCode == 13) { // enter key       		
		UpdateSearchValue();		
	}	
	
	if (KeyCode >= 48 ) { // letters and numbers    		
		BuildOptions();		
	}	
	
	document.getElementById("search-text").value = document.searchform.terms.options[document.searchform.terms.selectedIndex].value; // update text box value
}

function UpdateSearchValue() {	 	
	//alert("xx = " + xx);
	document.getElementById("search-text").value = document.searchform.terms.options[document.searchform.terms.selectedIndex].value;	
	OptionIndex = -1; // reset option index
	ChangeDisplay("terms","none");
	document.getElementById("search-text").focus();	
	//document.search.submit();	
}

function ClearDefaultValue() {
	
	if (document.getElementById("search-text").value == "Enter Keywords") {
		   document.getElementById("search-text").value = "";
		   document.getElementById("terms").style.display = "block";		   
	}
}	



// === /search key words ============================


function CharacterCount(text) {
	
	document.getElementById("character-count").innerHTML = "Character Count: " + text.value.length ;
	//alert("text.value.length = " + text.value.length);
	if (text.value.length >= 5){
		//alert("text.value.length = " + text.value.length);
		document.getElementById("character-count").style.color = "red";
		
	}
}


// === CAREER INSIDER ============================
/*
    var tabLinks = new Array();
	var contentDivs = new Array();	
	$(document).ready(function()
		{ 
			  // Grab the tab links and content divs from the page
			  var tabListItems;
			  if(document.getElementById('tabs') != null) {
		      	      tabListItems = document.getElementById('tabs').childNodes;
			      for ( var i = 0; i < tabListItems.length; i++ ) 
				  {
				if ( tabListItems[i].nodeName == "LI" ) 
					{
				  var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
				  var id = getHash( tabLink.getAttribute('href') );
				  tabLinks[id] = tabLink;
				  contentDivs[id] = document.getElementById( id );
				}
			      }
			      // Assign onclick events to the tab links, and
			      // highlight the first tab
			      var i = 0;
			      for ( var id in tabLinks )
				   {
				tabLinks[id].onclick = showTab;
				tabLinks[id].onfocus = function() { this.blur() };
				if ( i == 0 ) tabLinks[id].className = 'selected';
				i++;
			      }
			      // Hide all content divs except the first
			      var i = 0;
			      for ( var id in contentDivs ) 
					{
					 if ( i != 0 ) contentDivs[id].className = 'tabContent hide';
					 i++;
				}
		     }
	  	});	


	function showTab() 
		{
	      var selectedId = getHash( this.getAttribute('href') );
	
	      // Highlight the selected tab, and dim all others.
	      // Also show the selected content div, and hide all others.
	      for ( var id in contentDivs ) 
		  	{
		        if ( id == selectedId ) {
		          tabLinks[id].className = 'selected';
		          contentDivs[id].className = 'tabContent';
		        } else {
		          tabLinks[id].className = '';
		          contentDivs[id].className = 'tabContent hide';
		        }
	    	}

	      // Stop the browser following the link
	      return false;
    	}

	function getFirstChildWithTagName( element, tagName ) 
		{
	      for ( var i = 0; i < element.childNodes.length; i++ ) {
	        if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
	      }
    	}



	function getHash( url )
	 {
      var hashPos = url.lastIndexOf ( '#' );
      return url.substring( hashPos + 1 );
     }*/    	    	
/**
function ShowAbuseForm(id) {
	
	document.getElementById("abuse" + id).style.display = "block";
	document.getElementById("abuse" + id).innerHTML = '                                         ' +
	  ' <form id="abuse' + id + '" name="abuse' + id + '">                                      ' +
	  '     <input class="text-box" type="text" value="Enter a title here" />                   ' +
	  '     <textarea rows="2">Limit: 500 characters. HTML is prohibited.</textarea>            ' +
	  '     <input name="cancel" type="button" class="button secondary left" value="Cancel"     ' +
	  '      onclick="document.getElementById(\'abuse' + id + '\').style.display = \'none\';"/> ' +
	  '     <input name="Submit" type="button" class="button" value="Submit" />                 ' +
	  ' </form>                                                                                 ' +
	  ' <br class="clear" />                                                                    '
}
*/

function getCookie(document,NameOfCookie) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(NameOfCookie + "=");
		if (c_start != -1) { 
			c_start = c_start + NameOfCookie.length + 1; 
			c_end = document.cookie.indexOf(";",c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end)) ;
		} 
	}
	return "";
}

function setCookie(document,NameOfCookie,value,expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie = NameOfCookie+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/";
}

function checkCookie(document) {
	if(document.mainLoginForm.rememberme.checked == true){
		var fieldValue = document.mainLoginForm.userid.value;
		setCookie(document,'userid',fieldValue,365);
	}
	else {
		del_cookie(document,'userid'); 
	}
}
 
function checkCookieLocal(document) {
	if(document.mainLoginForm.rememberme.checked == true){
		var fieldValue = document.mainLoginForm.userid.value;
		var passwordFieldValue = document.mainLoginForm.password.value;
		setCookie(document,'userid',fieldValue,365);
		doSecure(fieldValue,passwordFieldValue);
	} else if(document.loginForm.rememberme.checked == true){
		var fieldValue1 = document.loginForm.userid.value;
		var passwordFieldValue1 = document.loginForm.password.value;
		setCookie(document,'userid',fieldValue1,365);
		doSecure(fieldValue1,passwordFieldValue1);
	}
	else {
		del_cookie(document,'userid'); 
	}
}
        
function del_cookie(NameOfCookie) {
	//document.cookie = NameOfCookie + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/"; 
	document.cookie = 'userid=; expires=Thu, 01-Jan-70 00:00:01 GMT;path=/';
}

//START - REMEMBER ME - JavaScript-1.2 or above required

function permutationGenerator(nNumElements) {
	this.nNumElements     = nNumElements;
	this.antranspositions = new Array;
	var k = 0;
	for (i = 0; i < nNumElements - 1; i++)
	for (j = i + 1; j < nNumElements; j++)
	this.antranspositions[ k++ ] = ( i << 8 ) | j;
	// keep two positions as lo and hi byte!
	this.nNumtranspositions = k;
	this.fromCycle = permutationGenerator_fromCycle;
}

function permutationGenerator_fromCycle(anCycle) {
	var anpermutation = new Array(this.nNumElements);
	for (var i = 0; i < this.nNumElements; i++) anpermutation[i] = i;
	for (var i = 0; i < anCycle.length; i++) {
		var nT = this.antranspositions[anCycle[i]];
		var n1 = nT & 255;
		var n2 = (nT >> 8) & 255;
		nT = anpermutation[n1];
		anpermutation[n1] = anpermutation[n2];
		anpermutation[n2] = nT;
	}
	return anpermutation;
}

function password(strpasswd) {
	this.strpasswd = strpasswd;
	this.getHashValue   = password_getHashValue;
	this.getpermutation = password_getpermutation;
}

function password_getHashValue() {
	var m = 907633409;
	var a = 65599;
	var h = 0;
	for (var i = 0; i < this.strpasswd.length; i++) 
	h = (h % m) * a + this.strpasswd.charCodeAt(i);
	return h;
}

function password_getpermutation() {
	var nNUMELEMENTS = 13;
	var nCYCLELENGTH = 21;
	pg = new permutationGenerator(nNUMELEMENTS);
	var anCycle = new Array(nCYCLELENGTH);
	var npred   = this.getHashValue();
	for (var i = 0; i < nCYCLELENGTH; i++) {
		npred = 314159269 * npred + 907633409;
		anCycle[i] = npred % pg.nNumtranspositions;
	}
	return pg.fromCycle(anCycle);
}

function SecureContext(strText, strSignature, bEscape) {
	this.strSIGNATURE = strSignature || '';
	this.bESCApE      = bEscape || false;
	this.strText = strText;
	this.escape        = SecureContext_escape;
	this.unescape      = SecureContext_unescape;
	this.transliterate = SecureContext_transliterate;
	this.encypher      = SecureContext_encypher;
	this.decypher      = SecureContext_decypher;
	this.sign          = SecureContext_sign;
	this.unsign        = SecureContext_unsign;
	this.secure   = SecureContext_secure;
	this.unsecure = SecureContext_unsecure;
}

function SecureContext_escape(strToEscape) {
	var strEscaped = '';
	for (var i = 0; i < strToEscape.length; i++) {
		var chT = strToEscape.charAt( i );
		switch(chT) {
			case '\r': strEscaped += '\\r'; break;
			case '\n': strEscaped += '\\n'; break;
			case '\\': strEscaped += '\\\\'; break;
			default: strEscaped += chT;
		}
	}
	return strEscaped;
}

function SecureContext_unescape(strToUnescape) {
	var strUnescaped = '';
	var i = 0;
	while (i < strToUnescape.length) {
		var chT = strToUnescape.charAt(i++);
		if ('\\' == chT) {
			chT = strToUnescape.charAt( i++ );
			switch( chT ) {
				case 'r': strUnescaped += '\r'; break;
				case 'n': strUnescaped += '\n'; break;
				case '\\': strUnescaped += '\\'; break;
				default: // not possible
			}
		}
		else strUnescaped += chT;
	}
	return strUnescaped;
}

function SecureContext_transliterate(btransliterate) {
	var strDest = '';

	var nTextIter  = 0;
	var nTexttrail = 0;

	while (nTextIter < this.strText.length) {
		var strRun = '';
		var cSkipped   = 0;
		while (cSkipped < 7 && nTextIter < this.strText.length) {
			var chT = this.strText.charAt(nTextIter++);
			if (-1 == strRun.indexOf(chT)) {
				strRun += chT;
				cSkipped = 0;
			}
			else cSkipped++;
		}
		while (nTexttrail < nTextIter) {
			var nRunIdx = strRun.indexOf(this.strText.charAt(nTexttrail++));
			if (btransliterate) {
			nRunIdx++
			if (nRunIdx == strRun.length) nRunIdx = 0;
			}
			else {
			nRunIdx--;
			if (nRunIdx == -1) nRunIdx += strRun.length;
			}
			strDest += strRun.charAt(nRunIdx);
		}
	}
	this.strText = strDest;
}

function SecureContext_encypher(anperm) {
	var strEncyph = '';
	var nCols     = anperm.length;
	var nRows     = this.strText.length / nCols;
	for (var i = 0; i < nCols; i++) {
		var k = anperm[ i ];
		for (var j = 0; j < nRows; j++) {
			strEncyph += this.strText.charAt(k);
			k         += nCols;
		}
	}
	this.strText = strEncyph;
}

function SecureContext_decypher(anperm) {
	var nRows    = anperm.length;
	var nCols    = this.strText.length / nRows;
	var anRowOfs = new Array;
	for (var i = 0 ; i < nRows; i++) anRowOfs[ anperm[ i ] ] = i * nCols;
	var strplain = '';
	for (var i = 0; i < nCols; i++) {
		for (var j = 0; j < nRows; j++)
			strplain += this.strText.charAt(anRowOfs[ j ] + i);
	}
	this.strText = strplain;
}

function SecureContext_sign(nCols) {
	if (this.bESCApE) {
		this.strText      = this.escape(this.strText);
		this.strSIGNATURE = this.escape(this.strSIGNATURE);
	}
	var nTextLen     = this.strText.length + this.strSIGNATURE.length;
	var nMissingCols = nCols - (nTextLen % nCols);
	var strpadding   = '';  
	if (nMissingCols < nCols)
	for (var i = 0; i < nMissingCols; i++) strpadding += ' ';
	var x = this.strText.length;
	this.strText +=  strpadding + this.strSIGNATURE;
}

function SecureContext_unsign(nCols) {
	if (this.bESCApE) {
		this.strText      = this.unescape(this.strText);
		this.strSIGNATURE = this.unescape(this.strSIGNATURE);
	}
	if ('' == this.strSIGNATURE) return true;
	var nTextLen = this.strText.lastIndexOf(this.strSIGNATURE);
	if (-1 == nTextLen) return false;
	this.strText = this.strText.substr(0, nTextLen);
	return true;
}

function SecureContext_secure(strpasswd) {
	var passwd = new password(strpasswd);
	var anperm   = passwd.getpermutation()
	this.sign(anperm.length);
	this.transliterate(true);
	this.encypher(anperm);
}

function SecureContext_unsecure(strpasswd) {
	var passwd = new password(strpasswd);
	var anperm = passwd.getpermutation()
	this.decypher(anperm);
	this.transliterate(false);
	return this.unsign(anperm.length);
}

function doSecure(userId, userKey) {
	var sc = new SecureContext(userKey, "", false);
	sc.secure(userId);
	set_cookie ( "userkey", sc.strText, 2100, 01, 15, "/", "", "" );
}

function doUnsecure(userId, userKey) {
	var sc = new SecureContext(userKey, "", false);
	if (!sc.unsecure(userId)) 
	   alert('Invalid password used.');

	return sc.strText;
}

//END - REMEMBER ME

function toggleGuideLines(evt) {
	    evt = (evt) ? evt : event;
	    var target = (evt.target) ? evt.target : evt.srcElement;
	    var block = document.getElementById("tips");
	    if (target.id == "flag2") {
	        block.style.display = "block";
			document.getElementById("tips2").style.display = "none";
	    } else {
	        block.style.display = "none";
	    }
  	}
function toggleContestRules(evt) {
	    evt = (evt) ? evt : event;
	    var target = (evt.target) ? evt.target : evt.srcElement;
	    var block = document.getElementById("tips2");
	    if (target.id == "flag2") {
	        block.style.display = "block";
			document.getElementById("tips").style.display = "none";
	    } else {
	        block.style.display = "none";
	    }
  	}
 

// START - LOGIN COOKIES

function delete_cookie ( name, path, domain, secure )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  
  var cookie_string = name + "=; expires=" + cookie_date.toGMTString();

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  document.cookie = cookie_string;
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{

  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results )
    return ( unescape ( results[1] ) );
  else
    return null;
}

// END - LOGIN COOKIES



// open login in center of page

function showBox() {     
	center('login');     
	document.getElementById('login').className = "forlightbox";
	return false; 
} 




function hideBox(){     
	document.getElementById('login').style.display='none';  
	return false; 
}

function center(element){     
	try{         
		element = document.getElementById(element); 
	}catch(e){         
		return;     
	}     
	
	var my_width = 0;     
	var my_height = 0;     
	
	if ( typeof( window.innerWidth ) == 'number' ){
		my_width = window.innerWidth;         
		my_height = window.innerHeight;     
	}else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ){         
			
			my_width = document.documentElement.clientWidth;         
			my_height = document.documentElement.clientHeight;     
			
	} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ){         
			my_width = document.body.clientWidth;         
			my_height = document.body.clientHeight;     
	}     
	
	   
	
	var scrollY = 0;     
	if ( document.documentElement && document.documentElement.scrollTop ){
		scrollY = document.documentElement.scrollTop;    
	}else if ( document.body && document.body.scrollTop ){
		scrollY = document.body.scrollTop;
	}else if ( window.pageYOffset ){
		scrollY = window.pageYOffset;
	}else if ( window.scrollY ){ 
		scrollY = window.scrollY;     
	}     

	var setX = ( 980 - 190 ) / 2;     
	var setY = scrollY+150;     //( my_height - 215 ) / 2 + 
	setX = ( setX < 0 ) ? 0 : setX;     
	setY = ( setY < 0 ) ? 0 : setY;     
	
	document.getElementById('login').style.position = "absolute";     
	document.getElementById('login').style.zIndex = 10000;  
	document.getElementById('login').style.left = setX + "px";     
	document.getElementById('login').style.top = setY + "px";   
	document.getElementById('login').style.display = 'block'; 
	} 


$(function(){
/**  
 * VAULT js object - vault.com
 *
 * @author Sean Lipkin <slipkin@vault.com>
 *
 */
	VAULT = {
		eventElements : {
			loginForm : {
				loginLinks : $('input.showLoginBox, a.showLoginBox'),
				overlay : $('#loginOverlay'),
				btn_close : $('#loginOverlay div.closeLink')
				},
			blogs : {
				a_showHide : $("a.show-hide-blog")
				},
			textfields : $('input[alt=onfocus clear], textarea[alt=onfocus clear], input.onfocus_clear, textarea.onfocus_clear'),
			myVaultConfigs : {
				configLink : '#configLink',
				container :  '#configureTool',
				arrow : {
					container : '#configure-text',
					classes : {
						collapsed : 'right-arrow',
						expanded : 'down-arrow'
						}
					},
				checkBoxes : $('div#configureTool .my-vault-box input[type=checkbox]'),		
				contentBlocks : {
					'Jobs' : '#jobsContent',
					'Blogs' : '#blogsContent',
					'Video' : '#videoDetails',
					'Reviews' : '#employerReviews, #schoolDetails'
				}
			},
			discussions : {
				threads : {
					btn_showReplies : $('a[id^=ref]'),
					btn_noScreenName : $('a[title=no screenname]'),
					userName : $('a[class^=authorMes]'),
					replyFormLink : $('a[title=screenname]'),
					frm_snReg : $('#screen-name'),
					txt_sn : $('#screeN'),
					btn_snCheck : $('input[value=Check Availability]'),
					btn_snReg : $('input#TestKellyR'),
					abuseLink : $('a[title^=abuseform_]'),
					abuseCloseLink : $('input[alt=close abuseform]'),
					guidelines : $('#guidelines'),
					guidelinesLinks : $('.showGuidelines')
					},
				siderail : {}
				}	
		},
		initFuncs : {
			blogs : function(){
					if(VAULT.eventElements.blogs.a_showHide.length > 0){
						VAULT.eventElements.blogs.a_showHide.click(function(){
							$(this).next('.blog-year-list').toggle();
							var plusMinus = $('.plus-minus', this);
							if (plusMinus.text() === '+') {
								plusMinus.text('-');	
							}
							else {
								plusMinus.text('+');
							}
							return false;
						});
					}
				},
			threads : function(){
					VAULT.eventElements.discussions.threads.btn_showReplies.click(function(){
						if($(this).hasClass('watchedthread') === true){
							VAULT.discussions.threads.showReplies(this.id, true); 
						}	
						else{
							VAULT.discussions.threads.showReplies(this.id); 
						}
						return false;
					});	
					VAULT.eventElements.discussions.threads.btn_noScreenName.click(function(){
						VAULT.eventElements.discussions.threads.frm_snReg
						.show()
						.find('#'+VAULT.eventElements.discussions.threads.txt_sn.attr('id')).focus();
						VAULT.eventElements.discussions.threads.frm_snReg.find('input.close').click(function(){					
							VAULT.eventElements.discussions.threads.frm_snReg.hide();
							return false;
							});
						return false;
					});
					VAULT.eventElements.discussions.threads.userName.click(function(){
						var mesNum = this.className.replace('authorMes','');
						VAULT.discussions.threads.toggleUserInfo(this,mesNum);
						return false;
					});
					VAULT.eventElements.discussions.threads.replyFormLink.click(function(){
						VAULT.discussions.threads.callReply(this);
						return false;
					});	
					VAULT.eventElements.discussions.threads.btn_snCheck.click(function(){
						VAULT.discussions.threads.checkAvail('checkName');
						return false;
					});
					VAULT.eventElements.discussions.threads.btn_snReg.click(function(){						 
						VAULT.discussions.threads.checkAvail('addName');	
						return false;
					});
					VAULT.eventElements.discussions.threads.abuseLink.click(function(){
						var message_id = $(this).attr('title').replace('abuseform_','');
						ShowAbuseForm(message_id);
						return false;
					});
					VAULT.eventElements.discussions.threads.abuseCloseLink.click(function(){
						$('#messageId').hide();
						return false;
					});
					VAULT.eventElements.discussions.threads.guidelinesLinks.click(function(){
						VAULT.eventElements.discussions.threads.guidelines.show();
						return false;
					});

				
				},
			clearTextFields : function(){$(VAULT.eventElements.textfields).one('focus',function(){this.value = '';});},
			myVaultConfigsToggle : function(){
							if(VAULT.eventElements.myVaultConfigs.checkBoxes.length === 0){return;}
							$(VAULT.eventElements.myVaultConfigs.checkBoxes).click(function(event){																
								var isChecked =	Boolean($(this).attr('checked'));
								if(isChecked === true) {
									$(VAULT.eventElements.myVaultConfigs.contentBlocks[$(this).attr('id')]).show();
									return;
									}
								$(VAULT.eventElements.myVaultConfigs.contentBlocks[$(this).attr('id')]).hide();
								return;
								});
							$(VAULT.eventElements.myVaultConfigs.configLink).click(function(event){		
							if($(VAULT.eventElements.myVaultConfigs.arrow.container+'[class*='+VAULT.eventElements.myVaultConfigs.arrow.classes.collapsed+']').length > 0){
							$(VAULT.eventElements.myVaultConfigs.arrow.container+'[class*='+VAULT.eventElements.myVaultConfigs.arrow.classes.collapsed+']')
							.removeClass(VAULT.eventElements.myVaultConfigs.arrow.classes.collapsed)
							.addClass(VAULT.eventElements.myVaultConfigs.arrow.classes.expanded);
							$(VAULT.eventElements.myVaultConfigs.container).show();
							return false;
						   }																
							$(VAULT.eventElements.myVaultConfigs.arrow.container+'[class*='+VAULT.eventElements.myVaultConfigs.arrow.classes.expanded+']')
							.removeClass(VAULT.eventElements.myVaultConfigs.arrow.classes.expanded)
							.addClass(VAULT.eventElements.myVaultConfigs.arrow.classes.collapsed)
							$(VAULT.eventElements.myVaultConfigs.container).hide();
							return false;
							});
							
							},
			nowOnVaultInit : function(){
							VAULT.nowOnVault.init();
							},
			responsibilityDropDown : function(){
							VAULT.topNavDropDown.init('#nav-secondary-6','#responsibility');
							},
			locationsDropDown : function(){
							VAULT.topNavDropDown.init('#location h4','#regions');
							},
	
			smallCarousel : function(){
							if($('div#companiesLandingCarouselContainer div#sponsorsScrollStrip').length > 0){
								return new VAULT.Carousel({
									rightArrow : 'div#companiesLandingCarouselContainer div#sponsorsRightArrow',
									leftArrow : 'div#companiesLandingCarouselContainer div#sponsorsLeftArrow',
									numImages : 4,
									imageWidth : 153,
									links : 'div#companiesLandingCarouselContainer div#sponsorsScrollStrip a',
									imgCont : 'div#companiesLandingCarouselContainer div#sponsorsScrollStrip'					   
								});	
							}
				},
			smallSchoolCarousel : function(){
							if($('div#sponsorsCarouselContainerShort div#sponsorsScrollStrip').length > 0){
								return new VAULT.Carousel({
									rightArrow : 'div#sponsorsCarouselContainerShort div#sponsorsRightArrow',
									leftArrow : 'div#sponsorsCarouselContainerShort div#sponsorsLeftArrow',
									numImages : 4,
									imageWidth : 153,
									links : 'div#sponsorsCarouselContainerShort div#sponsorsScrollStrip a',
									imgCont : 'div#sponsorsCarouselContainerShort div#sponsorsScrollStrip'					   
								});	
							}
				},
			videoCarousel : function(){
							if($('div#videoCarouselContainer div#videoScrollStrip').length > 0){
								return new VAULT.Carousel({
									rightArrow : 'div#videoCarouselContainer div#videoRightArrow',
									leftArrow : 'div#videoCarouselContainer div#videoLeftArrow',
									numImages : 4,
									imageWidth : 60,
									links : 'div#videoCarouselContainer div#videoScrollStrip a',
									imgCont : 'div#videoCarouselContainer div#videoScrollStrip'					   
								});
							}
				},
			loginForm : function(){
						VAULT.eventElements.loginForm.loginLinks.click(function(){
							VAULT.eventElements.loginForm.overlay
							.removeClass('hidden')
							.click(function(event){
								if($(event.target).hasClass('fullscreen-overlay') === true){
									VAULT.eventElements.loginForm.overlay.addClass('hidden');
								}
							});
							VAULT.eventElements.loginForm.btn_close.click(function(){
								VAULT.eventElements.loginForm.overlay.addClass('hidden');													   
							});
						return false;
						});
						
			}
				
		},
	Carousel : function(cfg){
		if(typeof cfg === 'undefined'){
			var cfg = {};
		}
		var that =  this;
		this.leftArrow = $(cfg.leftArrow),
		this.rightArrow = $(cfg.rightArrow),
		this.imgCont = $(cfg.imgCont),
		this.leftval = parseInt(this.imgCont.css('left')) || 0,
		this.links = $(cfg.links);
		this.numImages = cfg.numImages || 6,
		this.imageWidth = cfg.imageWidth || 153,
		this.oneRow = function(){return this.numImages * this.imageWidth;},
		this.maxLeft = 0,
		this.minLeft = function(){return this.maxLeft - (this.links.length * this.imageWidth - this.oneRow())},
		this.noRight = false,
		this.noLeft = true;
		
	that.rightArrow.removeClass('inactive')
			.click(function(event){
						if(that.noRight === true){
							return false;
						}
						else if(that.leftval - that.oneRow() < that.minLeft()){
							that.leftval = that.minLeft();	
						}
						else{that.leftval -= that.oneRow();}
						that.imgCont.animate(
							{'left' : that.leftval}, 1250,'swing',
							function(){
								that.noLeft = false;
								that.leftArrow.removeClass('inactive');
								if(that.leftval === that.minLeft()){
									that.noRight = true;
									that.rightArrow.addClass('inactive');
								}//end if
							}//end function
						);//end container
					}//end function(event)							  
				)//end click
			this.leftArrow.click(
					function(event){
						if(that.noLeft === true){
							return false;
						}
						else if(that.leftval + that.oneRow() > that.maxLeft){
							that.leftval = that.maxLeft;
						}
						else{that.leftval += that.oneRow();}
						that.imgCont.animate(							 
							{'left' : that.leftval}, 1250,'swing',
							function(){
								that.noRight = false;
								that.rightArrow.removeClass('inactive');
								if(that.leftval === that.maxLeft){
									that.noLeft = true;
									that.leftArrow.addClass('inactive');
								}//end if	
							}//end function
						);//end container
					}//end function(event)							  
			);//end click	
		},
		topNavDropDown : {
			init : function(target,dropdown){
				var dropdown = $(dropdown);
				$(target).mouseover(function(event){dropdown.show();})
				.mouseout(function(event){$(dropdown).hide();});
				dropdown.mouseover(function(event){dropdown.show();})
				.mouseout(function(event){dropdown.hide();});
			}
		},
		discussions : {
			threads : {
				 lastOpt : 'checkName',
				 lastVal : '',
				 resp : 0,
				 url_reg : '',
				 url_regReply : '',
				 checkAvail : function(option){
					var par = option;
					VAULT.discussions.threads.lastOpt = par;
					if(VAULT.eventElements.discussions.threads.txt_sn.val() === ''){return false;}
					var parVal = VAULT.eventElements.discussions.threads.txt_sn.val();
					VAULT.discussions.threads.lastVal = parVal;
					VAULT.discussions.threads.ajaxGet(par,parVal);
					$('#screenMess').html('checking for screen name');
				},
				ajaxGet: function(paramName,paramValue){
					VAULT.eventElements.discussions.threads.btn_snCheck.attr('disabled','true').css('opacity',.3);
					VAULT.eventElements.discussions.threads.btn_snReg.attr('disabled','true').css('opacity',.3);
					cnt = cnt +1;
					var url = AJAX_URL + "?" + paramName + "=" + paramValue + "&userId=" + userId;
					$.get(url,function(data){
								VAULT.eventElements.discussions.threads.btn_snCheck.removeAttr('disabled').css('opacity',1);
								VAULT.eventElements.discussions.threads.btn_snReg.removeAttr('disabled').css('opacity',1);
								if(data == 1) {  
								if(VAULT.discussions.threads.lastOpt == "addName") {
									if ( document.getElementById("TestKellyR").style.display =='block') {
									  window.location.href=VAULT.discussions.threads.url_reg + "?postedBy=" + VAULT.discussions.threads.lastVal; 
									  }
									  else { 
										window.location.href=VAULT.discussions.threads.url_regReply+ "?postedBy=" + VAULT.discussions.threads.lastVal;
									  }
									}
									document.getElementById('screenMess').innerHTML = VAULT.discussions.threads.lastVal + " is available " ;
								}
								else{
									document.getElementById('screenMess').innerHTML = VAULT.discussions.threads.lastVal + " is not available, please try again " ;
									
								}	
								   
									   
					});
				},
				toggleUserInfo : function(el,count) {
					 var count = count || 0,
					 userinfo = $(el).parent().parent().find("span.extendUser"+count),
					 mesNum = $(el).parent().parent().find("span.authorMes"+count);
				   if (userinfo.css("display") == "none") {
				      mesNum.css('background','#ececec');
				      userinfo.show();
				   }
				   else {
				       mesNum.css('background','transparent');
				       userinfo.hide();
				   }
				 },
				showReplies : function(id, watchflag) {
					var curId = id.replace('ref',''),
					cont =  $("#" + id).parent().parent(), 
					plusminus = $('#'+id+ ' span').eq(0);
					if(typeof watchflag === 'undefined'){		
						$("#ref" + id).parent().parent().find(".member").css('display','block');
						if($('#' + id + ' span').eq(0).html() === '+') {
						 cont.find(".messageDisplayAll"+curId).show();
						 cont.find(".postShort0"+curId).hide();
						 cont.find(".postFull0"+curId).show();
						 plusminus.html('-').css('class','minus');
						}
						else {  
						  cont.find(".messageDisplayAll"+curId).hide();
						  cont.find(".postFull0"+curId).hide();
						  cont.find(".postShort0"+curId).show();
						  plusminus.html('+').css('class','plus');
						}
					}
					else {
						$("#ref" + id).parent().parent().find(".member").css('display','block');
						if($('#' + id + ' span').eq(0).html() === '+') {
						 cont.find('.expendedBlock').show();
						 plusminus.html('-').css('class','minus');
						}
						else {  
						 cont.find('.expendedBlock').hide();
						  plusminus.html('+').css('class','plus');
						}
					}
					
				},
				callReply : function (btn_reply){
					$(btn_reply).hide();
					var threadid = btn_reply.id.replace('reply','');									
					$('#replyMess' +threadid).val('Enter a question or comment to get your discussion started.');
					$('.post_reply').css('background','transparent');
					$('a[title=screenname]')
						.css('opacity',.2)
						.unbind('click')
						.bind('click',function(){return false;});
							$('#replyForm' + threadid).show();
							$('#replyForm' + threadid+' input[name=preview]').bind('click',function(event){VAULT.discussions.threads.previewError(this,threadid);});
							$('#replyForm' + threadid+' input[name=cancel]').one('click',
										function(event){
										$('#replyForm' + threadid+' input[name=preview]').unbind('click');						
										$('#replyForm' + threadid).hide();
										var cont = $(this).parent().parent();
										  $("#replyMess"+threadid).removeAttr('disabled');
										  cont.find('.add_reply').show();
										  cont.find('.edit_reply').hide();
										  cont.find(".defaultPostTitle").show();
										  cont.find(".previewPost").hide();
										  cont.find(".extraForPreview").hide();
										  cont.find('textarea').css(
												{
												'padding-top': 0,
												'height' : '95px',
												'background':'transparent'
												}); 
										$(btn_reply).show();
										$('a[title=screenname]')
											.unbind('click')
											.css('opacity',1)
											.click(function(){		
												VAULT.discussions.threads.callReply(this);
												return false;
											});
							});
				},
				previewError : function(el,threadId) {
					var replyMess = $('#replyMess' + threadId);
					if(replyMess.val() === '' || replyMess.val() === 'Enter a question or comment to get your discussion started.'){    
					  $('#error'+threadId).html('Please enter comments');	
					}
					else {
							var cont = $(el).parent().parent();
							cont.find(".defaultPostTitle").css('display','none');
							cont.find(".errorPost").html('');
							cont.find(".previewPost").css('display','block');
							cont.find(".extraForPreview").css('display','block');
							cont.find('textarea').css(
												{
												'padding-top': '30px',
												'padding-left': '12px',
												'height': '65px',
												'width': '550px',
												'background': '#daf2fa',
												'border': '#a5a5a5 1px solid'
												}); 
							cont.find('.add_reply').css('display','none');
							cont.find('.edit_reply')
								.css('display','block')
								.click(function(){
							   	  var cont = $(el).parent().parent();
								  $("#replyMess"+threadId).removeAttr('disabled');
								  cont.find('.add_reply').show();
								  cont.find('.edit_reply').hide();
								  cont.find(".defaultPostTitle").show();
								  cont.find(".extraForPreview").hide();
								  cont.find('textarea').css(
														{
														'padding-top': 0,
														'height' : '95px',
														'background':'transparent'
														}); 		
									});
							$("#replyMess"+threadId).attr('disabled','true'); 
					 }
				}
			}
				 			
		},
		nowOnVault : {
			tabContainer : $('#nowOnVault > #nowOnVaultUiContainer > #nowOnVaultUiPageIndicatorContainer'),
			tabs : {},
			contentBoxes : $('#nowOnVault > div.homepageModulePadding > div.nowOnVaultTile'),
			leftArrow : $('#nowOnVaultUiContainer > #nowOnVaultUiLeftArrow'),
			rightArrow : $('#nowOnVaultUiContainer > #nowOnVaultUiRightArrow'),
			current : 0,
			rotateFlag : 0,
			activeClass : 'active',
			moveBack : function(){
					$(VAULT.nowOnVault.tabs).eq(VAULT.nowOnVault.current).toggleClass('active');
					$(VAULT.nowOnVault.contentBoxes).eq(VAULT.nowOnVault.current).toggleClass('active');
					if (VAULT.nowOnVault.current-1 === -1){
						VAULT.nowOnVault.current = VAULT.nowOnVault.tabs.length-1;
					}
					else {VAULT.nowOnVault.current-=1;}
					$(VAULT.nowOnVault.tabs).eq(VAULT.nowOnVault.current).toggleClass('active');
					$(VAULT.nowOnVault.contentBoxes).eq(VAULT.nowOnVault.current).toggleClass('active');
				},
			moveForward : function(){
					$(VAULT.nowOnVault.tabs).eq(VAULT.nowOnVault.current).toggleClass('active');
					$(VAULT.nowOnVault.contentBoxes).eq(VAULT.nowOnVault.current).toggleClass('active');
					if (VAULT.nowOnVault.current+1 === VAULT.nowOnVault.tabs.length){
						VAULT.nowOnVault.current = 0;
					}
					else {VAULT.nowOnVault.current+=1;}
					$(VAULT.nowOnVault.tabs).eq(VAULT.nowOnVault.current).toggleClass('active');
					$(VAULT.nowOnVault.contentBoxes).eq(VAULT.nowOnVault.current).toggleClass('active');
				},
			rotate : function(){
						VAULT.nowOnVault.rotateFlag = setInterval(
							function(){
								$(VAULT.nowOnVault.tabs).eq(VAULT.nowOnVault.current).toggleClass('active');
								$(VAULT.nowOnVault.contentBoxes).eq(VAULT.nowOnVault.current).toggleClass('active');
								if (VAULT.nowOnVault.current+1 === VAULT.nowOnVault.tabs.length){
									VAULT.nowOnVault.current = 0;
								}
								else {VAULT.nowOnVault.current+=1;}
								$(VAULT.nowOnVault.tabs).eq(VAULT.nowOnVault.current).toggleClass('active');
								$(VAULT.nowOnVault.contentBoxes).eq(VAULT.nowOnVault.current).toggleClass('active');
							},				
							5000);
						$(VAULT.nowOnVault.leftArrow).click(function(){
							clearInterval(VAULT.nowOnVault.rotateFlag);
							VAULT.nowOnVault.moveBack();
						});	
						$(VAULT.nowOnVault.rightArrow).click(function(){
							clearInterval(VAULT.nowOnVault.rotateFlag);
							VAULT.nowOnVault.moveForward();
						});	
						
					 },
			init : function (){
						if($('#nowOnVaultUiPageIndicatorContainer').length === 0) return; 
						for(var i = 0; i < VAULT.nowOnVault.contentBoxes.length; i+=1){
							$('<span></span>').appendTo(VAULT.nowOnVault.tabContainer);
						}
						VAULT.nowOnVault.tabs = $('#nowOnVault > #nowOnVaultUiContainer > #nowOnVaultUiPageIndicatorContainer > span');
						$(VAULT.nowOnVault.tabs).eq(0).toggleClass('active');
						$(VAULT.nowOnVault.contentBoxes).eq(0).toggleClass('active');
						VAULT.nowOnVault.rotate();
						$(VAULT.nowOnVault.tabs).click(function(event){
							clearInterval(VAULT.nowOnVault.rotateFlag);	
							if ($(event.target).attr('class').indexOf('active') === -1){
								$(event.target).toggleClass('active');
								VAULT.nowOnVault.tabs.eq(VAULT.nowOnVault.current).removeClass('active');
								$(VAULT.nowOnVault.contentBoxes).eq(VAULT.nowOnVault.current).removeClass('active');
								for(var i = 0; i < VAULT.nowOnVault.tabs.length; i+=1){
									if(VAULT.nowOnVault.tabs[i].className.indexOf('active') !== -1){
										VAULT.nowOnVault.current = i;
										$(VAULT.nowOnVault.contentBoxes).eq(VAULT.nowOnVault.current).toggleClass('active');
										break;
									}
								}
							}
						});
				   }
		},
		init : function(){
			for(var key in VAULT.initFuncs){
				VAULT.initFuncs[key]();
			}
		}	
	};

VAULT.init();

});	
