/*  
	CareerCross JavaScript
*/

window.status="CareerCross";

/*  ----- support checking -----  */

// detect browser support for getElementById and createElement
var canGetElem = false;
var canCreateElem = false;
if (document.getElementById) {
    canGetElem = true;
    if (document.createElement) {
        canCreateElem = true;
    }
}
/*  ----- end support checking -----  */


/*  ----- start open window -----  */
function openWindow( url ) {
  window.open( url, "CareerCross", "width=500,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0" );
}
/*  ----- end open window -----  */

/*  ----- global declarations -----  */
// defines the obChg object, used to store info about elemetns that need to be resized in different resolutions
function obChg(obj, act, sml, lrg) {
    this.id = obj;
    this.action = act;
    this.lowValue = sml;
    this.highValue = lrg;
}

var userWidth;
var docLoaded = false;
var criticalRes = 950;
// resolution above which large widths are used

if (canGetElem) {
    arChgs = new Array();
	arSel = new Array();
 	
	arChgs.push(new obChg("top_menu_wrapper", "width", "760px", "930px"));
	arChgs.push(new obChg("body_wrapper", "width", "760px", "930px"));
	arChgs.push(new obChg("footer_wrapper", "width", "760px", "930px"));
	arChgs.push(new obChg("footer", "width", "760px", "930px"));
	arChgs.push(new obChg("family_menu_wrapper", "width", "760px", "930px"));
	
	arChgs.push(new obChg("breadcrumbs", "width", "446px", "618px"));
	
	arChgs.push(new obChg("middle_column", "width", "449px", "620px"));
	arChgs.push(new obChg("article_heading", "width", "448px", "620px"));
	arChgs.push(new obChg("middle_column_full", "width", "588px", "760px"));	
	arChgs.push(new obChg("middle_narrow_column", "width", "380px", "552px"));
	arChgs.push(new obChg("display_content", "width", "577px", "748px"));	
	arChgs.push(new obChg("display_content_inner", "width", "556px", "728px"));	
	arChgs.push(new obChg("display_content_narrow", "width", "437px", "608px"));
	arChgs.push(new obChg("search_bar_logo", "width", "364px", "532px"));
	
	arChgs.push(new obChg("second_container", "width", "154px", "326px"));
	arChgs.push(new obChg("second_container", "height", "229px", "115px"));

	arChgs.push(new obChg("second_container2", "width", "154px", "326px"));

	arChgs.push(new obChg("other_story_container", "width", "446px", "326px"));	
	arChgs.push(new obChg("other_story_container", "height", "80px", "105px"));	
	
	arChgs.push(new obChg("section1", "width", "446px", "303px"));
	arChgs.push(new obChg("section1", "height", "190px", "190px"));
	
	arChgs.push(new obChg("section2", "width", "446px", "303px"));
	arChgs.push(new obChg("section2", "height", "190px", "190px"));
	
	arChgs.push(new obChg("section3", "width", "446px", "303px"));
	arChgs.push(new obChg("section3", "height", "190px", "190px"));
	
	arChgs.push(new obChg("section4", "width", "446px", "303px"));
	arChgs.push(new obChg("section4", "height", "190px", "190px"));
	
	arChgs.push(new obChg("section5", "width", "446px", "303px"));
	arChgs.push(new obChg("section5", "height", "190px", "190px"));
	
	arChgs.push(new obChg("section6", "width", "446px", "303px"));
	arChgs.push(new obChg("section6", "height", "190px", "190px"));
	
	arChgs.push(new obChg("section7", "width", "446px", "303px"));
	arChgs.push(new obChg("section7", "height", "190px", "190px"));
	
	arChgs.push(new obChg("section8", "width", "446px", "303px"));
	arChgs.push(new obChg("section8", "height", "190px", "190px"));
	
	arChgs.push(new obChg("section_links_left", "width", "190px", "260px"));
	arChgs.push(new obChg("section_links_right", "width", "210px", "300px"));
	
}
/*  ----- end global declarations -----  */

/*  ----- event handlers -----  */
function doOnLoad() {
    docLoaded = true;
	doResize();
	dynamic_table();
}

window.onresize = doResize;

function doResize() {
    if (docLoaded) {
        userWidth = document.body.clientWidth;
        // find current width of browser window
        if (canGetElem) {
            updateDivs();
		}
	}
}
/*  ----- end event handlers -----  */

/*	common functions  */

function getElementsByClassName(clss, prnt, tg) {
    var elements = new Array();
    tg = tg || '*';
    prnt = prnt || document;
    var list = prnt.getElementsByTagName(tg);
    for (var i = 0; i < list.length; ++i) {
        if (list[i].className == clss) {
            elements.push(list[i]);
        }
    }
	return elements;
}

/*  div components  */

function updateDivs() {

	// for each entry in the array of resizing changes required
    for (k in arChgs) {
		// check to see if the element exists on page
        if (document.getElementById(arChgs[k].id)) {
            if (userWidth < criticalRes) {
                tmpTargetVal = arChgs[k].lowValue;
            }
            else {
                tmpTargetVal = arChgs[k].highValue;
            }
            // change the required style
			document.getElementById(arChgs[k].id).style[arChgs[k].action] = tmpTargetVal;
        }
        else {
			// if element isn't found, we might as well delete the entry from the array
            delete arChgs[k];
        }
    }
	   
}

/* Function for changing the color on table rows */
var elem = "TR";
var rClick;

function dynamic_table(){
  if(document.getElementsByTagName){
   var el = document.getElementsByTagName(elem);
    for(var i=0; i<el.length; i++){
     if(el[i].parentNode.parentNode.className.indexOf("content_table") != -1 && el[i].childNodes[0].tagName != "TH"){
     if(i%2 == 1){
      el[i].className = "on";
      el[i].oldClassName = "on";
      el[i].onmouseout  = function(){
	     this.className = "on";
      }
    } else {
      el[i].className = "off";
      el[i].oldClassName = "off";
      el[i].onmouseout  = function(){
	     this.className = "off";
      }
    }
      el[i].onmouseover = function(){
	     if(this.className == this.oldClassName)
	       {this.className = "hover";}
      }
      el[i].onclick = function(){
       if(rClick){
        rClick.className=rClick.oldClassName;
        rClick.onmouseout = function(){this.className = this.oldClassName};
       }
        this.className = "click";
        rClick = this;
        this.onmouseout = function(){return true};
       }
    }
  }
 }
}

/* Function resume progress */
function formSubmit ( selectedtype )
{
  document.resume.page.value = selectedtype ;
  document.resume.submit() ;
}

function setApplicationReply( reply_id )
{	
  var reply_hidden = document.getElementById( reply_id );
  var reply = reply_hidden.value;
  document.employer_add_edit_job.custom_reply.value = reply ;
}

function setApplicationResponse( reply_id )
{	
  var reply_hidden = document.getElementById( reply_id );
  var reply = reply_hidden.value;
  document.employer_application_respond.message.value = reply ;
  document.employer_application_respond.template_id.value = reply_id;
}

function setContactReply( reply_id ) {	
  var reply_hidden = document.getElementById( reply_id );
  var reply = reply_hidden.value;
  document.employer_contact_candidate.message.value = reply ;
}

function setCoverLetter( reply_id ) {	
  var reply_hidden = document.getElementById( reply_id );
  var reply = reply_hidden.value;
  document.getElementById('coverletter').value = reply ;
}

function selectAll(obj) 
{ 
	var checkboxes = document.getElementsByTagName('input'); 
	for (i = 0; i < checkboxes.length; i++) {
           if (checkboxes[i].type == 'checkbox') checkboxes[i].checked = obj.checked;
	} 
} 

/*  ----- end document style changes -----  */
