﻿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=pname+",&nbsp;&nbsp;"+cname+",&nbsp;&nbsp;"+coname;
      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 !='')
		{
			//alert(webisodeUrl);
			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';
  var divid='search_secondary_' + elem.value;
  document.getElementById(divid).style.display='inline';
  if (elem.value=='company')
    SetCompanySearch();
  if (elem.value=='career')
    SetCareerSearch();    

}


function SearchPopulate(elem)
{
  var divid = 'search_secondary_' + elem;
  var sOutput = "";

  
  if (elem=='degree')
  {
      sOutput = '<select name="cmbSearchByDegree" size="1" class="selectSml" style="width:210px;">';
      sOutput = sOutput + '<option class="sd" value="1">Associate’s Degree</option>';
      sOutput = sOutput + '<option class="sd" value="2">Bachelor’s Degree</option>';
      sOutput = sOutput + '<option class="sd" value="3">Master’s Degree</option>';
      sOutput = sOutput + '<option class="sd" value="4">Doctoral Degree</option>';
      sOutput = sOutput + '<option class="sd" value="5">Certification</option>';
      sOutput = sOutput + '<option class="sd" value="6">License</option>';
      sOutput = sOutput + '<option class="sd" value="7">Apprenticeship</option>';
      sOutput = sOutput + '<option class="sd" value="8">Hight 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" id="txtSearchCareer" size="30"/>';
      document.getElementById(divid).innerHTML = sOutput;
  }
    
  if (elem=='company')
  {
      sOutput = '<input type="text" name="txtSearchCompany" id="txtSearchCompany" size="30"/>';
      document.getElementById(divid).innerHTML = sOutput;
  }
  
  
  if (elem=='industry')
  {
      sOutput = '<select name="cmbSearchByIndustry" id="cmbSearchByIndustry" size="1" class="selectSml" style="width:210px;">';
      sOutput = sOutput + '<option class="sd" value="1">Accounting</option>';
      sOutput = sOutput + '<option class="sd" value="2">Advertising & PR</option>';
      sOutput = sOutput + '<option class="sd" value="4">Agriculture & Natural Resources</option>';
      sOutput = sOutput + '<option class="sd" value="3">Architecture & Interior Design</option>';
      sOutput = sOutput + '<option class="sd" value="5">Biotech/ Pharmaceutical</option>';
      sOutput = sOutput + '<option class="sd" value="6">Building & Construction</option>';
      sOutput = sOutput + '<option class="sd" value="7">Business/ Entrepreneur</option>';
      sOutput = sOutput + '<option class="sd" value="23">Communications</option>';
      sOutput = sOutput + '<option class="sd" value="8">Education</option>';
      sOutput = sOutput + '<option class="sd" value="9">Engineering</option>';
      sOutput = sOutput + '<option class="sd" value="10">Entertainment</option>';
      sOutput = sOutput + '<option class="sd" value="11">Fashion</option>';
      sOutput = sOutput + '<option class="sd" value="12">Finance</option>';
      sOutput = sOutput + '<option class="sd" value="13">Government</option>';
      sOutput = sOutput + '<option class="sd" value="14">Health Care</option>';
      sOutput = sOutput + '<option class="sd" value="15">Hospitality/ Tourism</option>';
      sOutput = sOutput + '<option class="sd" value="16">Human Services</option>';
      sOutput = sOutput + '<option class="sd" value="17">Investment Banking</option>';
      sOutput = sOutput + '<option class="sd" value="18">Public Safety & Security</option>';
      sOutput = sOutput + '<option class="sd" value="19">Sales & Marketing</option>';
      sOutput = sOutput + '<option class="sd" value="20">Science</option>';
      sOutput = sOutput + '<option class="sd" value="21">Technology</option>';
      sOutput = sOutput + '<option class="sd" 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;
     //} 

 
  }

  //UpdateSearchValue(elem);
}

function UpdateSearchValue(elem)
{
return false;
}

function doSearch(pForm)
{
  pForm.method="post";
  pForm.action="/jobs/default.asp";
  pForm.submit();
}

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,'/''','');

	  document.getElementById("taReplyComments").value = '';

  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,'/''','');

	  document.getElementById("taReplyComments").value = '';

  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) {} 
       } 
   } 
	 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";
}
