﻿var vSetG = false;
var vP;
var vC;
function setcareer2(id, video_name, clogo, pname, cname, coname) {
	cid = id;
	c1 = cname;
	c2 = coname;
	if (video_name != '') {
		SetVideo(video_name);
		//document.images['clogo'].src='/images/careers/'+clogo;
		document.getElementById('cname').innerHTML = "<font class='f3'><b>" + pname + ",&nbsp;&nbsp;" + cname + ",&nbsp;&nbsp;" + coname + "</b></font>";
		document.getElementById("cinfo").style.display = "none";
		load_text(1, 'Career Description');
	}
}

function setWebisode(webisodeID, webisodeDescription, webisodeDate, webisodeName, webisodeUrl) {
	cid = webisodeID;
	c1 = webisodeName;
	c2 = webisodeDate;
	if (webisodeName != '') {
		PlayWebisode(webisodeName, webisodeUrl);
		//document.images['clogo'].src='/images/careers/'+clogo;
		document.getElementById('cname').innerHTML = "<font class='f3'><b>" + webisodeName + ",&nbsp;&nbsp;" + webisodeDate + "</b></font>";
	}
}

function setcareer_faq(video_name, quest) {
	if (video_name != '') {
		SetVideoFaq(video_name);
		//document.images['clogo'].src='/images/careers/'+clogo;
		document.getElementById('cname').innerHTML = "<font class='f2'><b>" + quest + "</b></font>";
		//document.getElementById("cinfo").style.display="none";
	}
}

function load_text(tid, link) {
	if (cid == 136 && tid == 6) //vp of it and ementor: take them to the Ementor Question
		var vLink = 'CareerMentorMe.asp?id=' + cid + '&topic_id=topic' + tid + '&topic_name=' + link;
	else
		var vLink = 'CareerInfo.asp?id=' + cid + '&topic_id=topic' + tid + '&topic_name=' + link;

	if (link == 'FindJob') {
		var vLink = 'GetIndeed.asp?q=' + c1 + '&cmp=' + c2 + '&typ=1' + '&lmt=5';
		//alert(vLink);
	}
	if (link == 'FindInternship') {
		var vLink = 'GetIndeed.asp?q=' + c1 + ' Internship&cmp=' + c2 + '&typ=1' + '&lmt=5';
		//alert(vLink);
	}
	parent.frames['careerinfo'].document.location.href = vLink;
	document.getElementById("cinfo").style.display = "";
}

function load_faq(tid, link) {
	var vLink = 'CareerFaq.asp?id=' + cid;
	parent.frames['careerinfo'].document.location.href = vLink;
	document.getElementById("cinfo").style.display = "";
}

function SetVideo(vName) {
	if (vName == '')
		return;
	document.vjsFlashPlayer.SetVariable("player:jsStop", "");
	document.vjsFlashPlayer.SetVariable("player:jsUrl", "http://carcrnrtv.vo.llnwd.net/o16/flash_video/" + vName + ".flv");
	//document.vjsFlashPlayer.SetVariable("player:jsPlay", "");
}

function PlayWebisode(vName, vUrl) {
	if (vName == '')
		return;
	document.vjsFlashPlayer.SetVariable("player:jsStop", "");
	if (vUrl == '')
		document.vjsFlashPlayer.SetVariable("player:jsUrl", "http://carcrnrtv.vo.llnwd.net/o16/flash_video/architect.flv");
	else {
		document.vjsFlashPlayer.SetVariable("player:jsUrl", vUrl);
	}
	document.vjsFlashPlayer.SetVariable("player:jsPlay", "");
}


function SetVideoFaq(vName) {
	if (vName == '')
		return;

	document.vjsFlashPlayer.SetVariable("player:jsStop", "");
	document.vjsFlashPlayer.SetVariable("player:jsUrl", "http://carcrnrtv.vo.llnwd.net/o16/flash_qa/" + vName);
	document.vjsFlashPlayer.SetVariable("player:jsPlay", "");
}

function EMentorWin() {
	mywin = window.open('/mentordetail.asp', 'memdetail', 'width=700,height=400,scrollbars=yes');
}

function SetTopNav(vElem) {
	//alert(document.getElementById('tn_scoop').id);
	document.getElementById(vElem).style.backgroundImage = "url('/images/topNav/red_gradient_29.jpg')";
}
function ReSetTopNav(vElem, bActive) {
	//alert(document.getElementById('tn_scoop').id);
	if (bActive == 1)
		document.getElementById(vElem).style.backgroundImage = "url('/images/topNav/red_gradient_29.jpg')";
	else
		document.getElementById(vElem).style.backgroundImage = "url('/images/topNav/blue_gradient_29.jpg')";
}

function SetCSButton(vElem) {
	//alert(document.getElementById('tn_scoop').id);
	document.getElementById(vElem).style.backgroundImage = "url('/images/topNav/red_gradient_29.jpg')";
}
function ReSetCSButton(vElem) {
	//alert(document.getElementById('tn_scoop').id);
	document.getElementById(vElem).style.backgroundImage = "url('/images/topNav/blue_gradient_29.jpg')";
}

function SearchSelect(elem) {
	document.getElementById('search_secondary_career').style.display = 'none';
	document.getElementById('search_secondary_company').style.display = 'none';
	document.getElementById('search_secondary_degree').style.display = 'none';
	document.getElementById('search_secondary_industry').style.display = 'none';
	document.getElementById('search_secondary_cluster').style.display = 'none';
	document.getElementById('search_secondary_keyword').style.display = 'none';
	var divid = 'search_secondary_' + elem.value;
	document.getElementById(divid).style.display = 'inline';
	if (elem.value == 'company')
		SetCompanySearch();
	if (elem.value == 'career')
		SetCareerSearch();

}
function checkSearchreturn() {
	if (event.keyCode == 13) {
		event.returnValue = false;
		doSearch2(document.frmSearch);
	}
}


function SearchPopulate(elem) {
	var divid = 'search_secondary_' + elem;
	var sOutput = "";

		
	if (elem == 'degree') {
		sOutput = '<select name="cmbSearchByDegree" size="1" class="selectSml" style="width:265px;">';
		sOutput = sOutput + '<option  value="1">Associate’s Degree</option>';
		sOutput = sOutput + '<option  value="2">Bachelor’s Degree</option>';
		sOutput = sOutput + '<option  value="3">Master’s Degree</option>';
		sOutput = sOutput + '<option  value="4">Doctoral Degree</option>';
		sOutput = sOutput + '<option  value="5">Certification</option>';
		sOutput = sOutput + '<option  value="6">License</option>';
		sOutput = sOutput + '<option  value="7">Apprenticeship</option>';
		sOutput = sOutput + '<option  value="8">High School Diploma</option>';
		sOutput = sOutput + '</select>';
		document.getElementById(divid).innerHTML = sOutput;


		for (var i = 0; i < 8; i++) {
			if (document.frmSearch.cmbSearchByDegree.options[i].value == bDegree)
				document.frmSearch.cmbSearchByDegree.options[i].selected = true;
		}
	}

	if (elem == 'career') {
		sOutput = '<input type="text" name="txtSearchCareer" class="textSml" id="txtSearchCareer" size="38"/>';
		document.getElementById(divid).innerHTML = sOutput;
	}

	if (elem == 'company') {
		sOutput = '<input type="text" name="txtSearchCompany" class="textSml" id="txtSearchCompany" size="38"/>';
		document.getElementById(divid).innerHTML = sOutput;
	}

	if (elem == 'keyword') {
		sOutput = '<input type="text" name="txtSearchKeyword" id="txtSearchKeyword" class="textSml" size="40" onkeydown="JavaScript:checkSearchreturn();"/>';
		document.getElementById(divid).innerHTML = sOutput;
	}

	if (elem == 'industry') {
		sOutput = '<select name="cmbSearchByIndustry" id="cmbSearchByIndustry" size="1" class="selectSml" style="width:265px;">';
		sOutput = sOutput + '<option  value="1">Accounting</option>';
		sOutput = sOutput + '<option  value="2">Advertising & PR</option>';
		sOutput = sOutput + '<option  value="4">Agriculture & Natural Resources</option>';
		sOutput = sOutput + '<option  value="3">Architecture & Interior Design</option>';
		sOutput = sOutput + '<option  value="5">Biotech/ Pharmaceutical</option>';
		sOutput = sOutput + '<option  value="6">Building & Construction</option>';
		sOutput = sOutput + '<option  value="7">Business/ Entrepreneur</option>';
		sOutput = sOutput + '<option  value="23">Communications</option>';
		sOutput = sOutput + '<option  value="8">Education</option>';
		sOutput = sOutput + '<option  value="9">Engineering</option>';
		sOutput = sOutput + '<option  value="10">Entertainment</option>';
		sOutput = sOutput + '<option  value="11">Fashion</option>';
		sOutput = sOutput + '<option  value="12">Finance</option>';
		sOutput = sOutput + '<option  value="13">Government</option>';
		sOutput = sOutput + '<option  value="14">Health Care</option>';
		sOutput = sOutput + '<option  value="15">Hospitality/ Tourism</option>';
		sOutput = sOutput + '<option  value="16">Human Services</option>';
		sOutput = sOutput + '<option  value="17">Investment Banking</option>';
		sOutput = sOutput + '<option  value="18">Public Safety & Security</option>';
		sOutput = sOutput + '<option  value="19">Sales & Marketing</option>';
		sOutput = sOutput + '<option  value="20">Science</option>';
		sOutput = sOutput + '<option  value="21">Technology</option>';
		sOutput = sOutput + '<option  value="22">Transportation and Materials Moving</option>';
		sOutput = sOutput + '</select>';
		document.getElementById(divid).innerHTML = sOutput;

		for (var i = 0; i < 23; i++) {
			if (document.frmSearch.cmbSearchByIndustry.options[i].value == bIndustry)
				document.frmSearch.cmbSearchByIndustry.options[i].selected = true;
		}
	}

	if (elem == 'cluster') {
		sOutput = '<select name="cmbSearchByCluster" size="1" class="selectSml" style="width:265px;">';
		sOutput = sOutput + '<option  value="24">Agriculture, Food and Natural Resources</option>;'
		sOutput = sOutput + '<option  value="25">Architecture and Construction</option>;'
		sOutput = sOutput + '<option  value="26">Arts, A/V Technology and Communications</option>;'
		sOutput = sOutput + '<option  value="27">Business, Management and Administration</option>;'
		sOutput = sOutput + '<option  value="28">Education and Training</option>;'
		sOutput = sOutput + '<option  value="36">Finance</option>;'
		sOutput = sOutput + '<option  value="37">Government and Public Administration</option>;'
		sOutput = sOutput + '<option  value="38">Health Science</option>;'
		sOutput = sOutput + '<option  value="39">Hospitality and Tourism</option>;'
		sOutput = sOutput + '<option  value="29">Human Services</option>;'
		sOutput = sOutput + '<option  value="30">Information Technology</option>;'
		sOutput = sOutput + '<option  value="31">Law, Public Safety and Security</option>;'
		sOutput = sOutput + '<option  value="32">Manufacturing</option>;'
		sOutput = sOutput + '<option  value="33">Marketing, Sales and Service</option>;'
		sOutput = sOutput + '<option  value="34">Science, Technology, Engineering and Mathematics</option>;'
		sOutput = sOutput + '<option  value="35">Transportation, Distribution and Logistics </option>;'
		sOutput = sOutput + '</select>';
		
		document.getElementById(divid).innerHTML = sOutput;


		for (var i = 0; i < 16; i++) {
			if (document.frmSearch.cmbSearchByCluster.options[i].value == bCluster)
				document.frmSearch.cmbSearchByCluster.options[i].selected = true;
		}
	}


	//UpdateSearchValue(elem);
}

function UpdateSearchValue(elem) {
	return false;
}

function doSearch2(pForm) {

	if (CheckCookie())
	{
	
	
		var sType = pForm.elements["cmbSearchType"].value;
		var sValue = '';
		if (sType=='career') {
			sValue = pForm.elements["txtSearchCareer"].value;
		}
		else if (sType=='company') {
			sValue = pForm.elements["txtSearchCompany"].value;
		}
		else if (sType == 'degree') {
			sValue = pForm.elements["cmbSearchByDegree"].value;
		}
		else if (sType == 'industry') {
			sValue = pForm.elements["cmbSearchByIndustry"].value;
		}
		else if (sType == 'cluster') {
		sValue = pForm.elements["cmbSearchByCluster"].value;
		}
		else if (sType == 'keyword') {
			sValue = pForm.elements["txtSearchKeyword"].value;
		}	
		
		sValue = sValue.replace(' ', '~');
		var vPath = "/include/_SearchDo.asp?type=" + sType + "&val=" + sValue;
		//alert(vPath);
		makeHttpRequest(vPath, 'ShowSearchResults');
		
  }
}


function ShowSearchResults(vVal) {
	if (vVal.substring(0, 1) == "~")
		opencareer(vVal.substring(1));
	else {
		//	document.getElementById('divSearchResults').innerHTML = vVal;
		document.getElementById('divSearchResults').innerHTML = vVal;
	}

}

function GlobalSearchSelect(elem) {
	document.getElementById('global_search_career').style.display = 'none';
	document.getElementById('global_search_company').style.display = 'none';
	document.getElementById('global_search_scoop').style.display = 'none';
	var divid = 'global_search_' + elem.value;
	document.getElementById(divid).style.display = 'inline';
	if (elem.value == 'career')
		SetCareerSearch();
}


function doGlobalSearch(pForm) {
	if (pForm.cmbGlobalSearchType.value == 'career')
		pForm.action = "/jobs/default.asp";
	else if (pForm.cmbGlobalSearchType.value == 'company')
		pForm.action = "/companies/default.asp";
	else if (pForm.cmbGlobalSearchType.value == 'scoop')
		pForm.action = "/scoop/default.asp";

	pForm.method = "post";
	pForm.submit();
}

function SetGraphics(iMax) {
	if (vSetG == false) {
		vSetG = true;
		var v = vP;
		var d = vC;
		var v1 = v.split(',');
		var d1 = d.split(',');
		for (i = 6; i <= iMax; i++) {

			document.images('c_head' + i).src = '/images/careers/head_' + v1[i] + '.jpg';
			document.images('c_comp' + i).src = '/images/careers/' + d1[i];
		}
	}
}

function toggleBox2(szDivID, iState) // 1 visible, 0 hidden
{
	if (document.layers)         //NN4+
	{
		document.layers[szDivID].display = iState ? "block" : "none";
	}
	else if (document.getElementById)         //gecko + IE 5+
	{
		var obj = document.getElementById(szDivID);
		obj.style.display = iState ? "block" : "none";
	}
	else if (document.all)    // IE 4
	{
		document.all[szDivID].style.display = iState ? "block" : "none";
	}

}

function smartToggleBox(szDivID) {
	if (document.getElementById)         //gecko + IE 5+
	{
		var obj = document.getElementById(szDivID);
		if (obj.style.display == "block")
			toggleBox(szDivID, 0);
		else
			toggleBox(szDivID, 1);
	}
}


function handlePostLink(link) {

	//toggleBox2('comment_bot',1);
	toggleBox2('post_box', 1);
	return false;
}


function submitComment(cid, uid) {

	var isInError;
	var vPath;

	var comment = document.getElementById("taReplyComments").value;
	if (comment == "" || IsMeaningless(comment)) {
		displayMessage("commentBodyReplyError", "You must specify a comment.");
		isInError = true;
	}


	if (isInError)
		return;
	//c1 = replace(c1,'/''','');

	var vPath = "/comments/insertcomments.asp?vid=" + cid + "&uid=" + uid + "&commt=" + comment;
	//alert(vPath);
	makeHttpRequest(vPath, 'insert_comment');
}

function submitScoopComment(cid, uid) {

	var isInError;
	var vPath;

	var comment = document.getElementById("taReplyComments").value;
	if (comment == "" || IsMeaningless(comment)) {
		displayMessage("commentBodyReplyError", "You must specify a comment.");
		isInError = true;
	}


	if (isInError)
		return;
	//c1 = replace(c1,'/''','');

	var vPath = "/comments/insertcomments.asp?sid=" + cid + "&uid=" + uid + "&commt=" + comment;
	//alert(vPath);
	makeHttpRequest(vPath, 'insert_comment');
}

function insert_comment(vVal) {
	document.getElementById('comment_bot').innerHTML = vVal + document.getElementById('comment_bot').innerHTML;
}

function makeHttpRequest(url, callback_function, return_xml) {
	var http_request = false;
	var bFF = FireFoxDetect();

	if (!bFF) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			try {
				http_request = new XMLHttpRequest();
			} catch (e) { }
			}
		}
	}
	else { // Mozilla, Safari,...
		try {
			http_request = new XMLHttpRequest();
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP"); 
				} catch(e) { }
			}
		}
		
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	}

	if (!http_request) {
		alert('Unfortunatelly you browser doesn\'t support this feature.');
		return false;
	}
	http_request.onreadystatechange = function() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				if (return_xml) {
					eval(callback_function + '(http_request.responseXML)');
				} else {
					eval(callback_function + '(http_request.responseText)');
				}
			} else {
				//alert('There was a problem with the request.(Code: ' + http_request.status + ')'); 
			}
		}
	}
	http_request.open('GET', url, true);
	http_request.send(null);
}


function makeHttpRequest2(url, callback_function, return_xml) 
{ 
   var http_request = false; 
   var bFF = FireFoxDetect();
	 
   if (!bFF) 
   { // IE 
       try { 
	         http_request = new ActiveXObject("Msxml2.XMLHTTP"); 
       } catch (e) { 
           try { 
               http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
           } catch (e) {} 
       } 
   } 
	 else
	 { // Mozilla, Safari,... 
       http_request = new XMLHttpRequest(); 
       //http_request = new ActiveXObject("Msxml2.XMLHTTP"); 
       if (http_request.overrideMimeType) { 
           http_request.overrideMimeType('text/xml'); 
       } 
    }

   if (!http_request) { 
       alert('Unfortunatelly you browser doesn\'t support this feature.'); 
       return false; 
   } 
   http_request.onreadystatechange = function() { 
       if (http_request.readyState == 4) { 
           if (http_request.status == 200) { 
               if (return_xml) { 
                   eval(callback_function + '(http_request.responseXML)'); 
               } else { 
                   eval(callback_function + '(http_request.responseText)'); 
               } 
           } else { 
               //alert('There was a problem with the request.(Code: ' + http_request.status + ')'); 
           } 
       } 
   } 
   http_request.open('GET', url, true); 
   http_request.send(null); 
}



function FireFoxDetect() {

	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion = new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion >= 3)
			return true;
		else if (ffversion >= 2)
			return true;
		else if (ffversion >= 1)
			return true;
	}
	else
		return false;
}

function IsMeaningless(str) {
	var tempStr = str.split(" ");
	for (i = 0; i < tempStr.length; i++) {
		if (tempStr[i] != "") {
			return false;
		}
	}
	return true;
}


function displayMessage(divId, messageText) {
	document.getElementById(divId).innerHTML = messageText;
	document.getElementById(divId).style.display = "block";
}

function onMissingAvatar(img) {
	img.src = "http://media1.break.com/static/live/v1/img/site/avatar_mini.gif";
}


function CheckCookie() {

	return true; //JA does not want the message
	 
	var cookieName = 'testCookie' + (new Date().getTime());
	document.cookie = cookieName + '=cookieValue';
	var cookiesEnabled = document.cookie.indexOf(cookieName) != -1;
	if (cookiesEnabled == "") {
		alert("The Search Job Videos feature requires Cookies to be enabled. \n Please enable your Cookies to use this feature.");
		return false;
	}
	else
		return true;
}