var menu = new menu();
menu.build();   

var footer = new footer();
footer.build();


//REMOVES IE BLINKING ON BACKGROUNDS
var nav = window.navigator.userAgent.toString().toLowerCase();
var isMSIE = nav.indexOf("msie") > -1 && nav.indexOf("opera") == -1;
if (isMSIE){
document.execCommand("BackgroundImageCache",false,true);
}

var kill_enter = function() { 
};   

var myListener = new YAHOO.util.KeyListener(document, { keys:13 }, { fn:kill_enter } ); 
myListener.enable();
 

var split_domain = document.domain.split(".");
var cookie_domain = split_domain[0]+"."+split_domain[1]+"."+split_domain[2];

function setCookie(c_name,value,expiredays){
  var exdate=new Date()
  exdate.setDate(exdate.getDate()+expiredays)
  document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+"; path=/; domain="+cookie_domain;
}  
function deleteCookie (c_name) {
  if (getCookie(c_name)) {
     document.cookie=c_name+"=;expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain="+cookie_domain;
  }
}
function getCookie(c_name){
  if (document.cookie.length>0)  {
    c_start=document.cookie.indexOf(c_name + "=")
    if (c_start!=-1)    { 
      c_start=c_start + c_name.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 header_login() {
  if (document.getElementById("head_log")){
    YAHOO.util.Get.script("/login/www/js/login.js", {  
    onSuccess: function() { 
      jobvana_page = new login(); 
      jobvana_page.build();
      jobvana_page.check_form();
    }, 
    scope:this });
  }
}


function disableEnterKey(e) {
 var key;

 if(window.event)
      key = window.event.keyCode;     //IE
 else
      key = e.which;     //firefox

 if(key == 13)
      return false;
 else
      return true;
}


function logo_link(){
  window.location.href = "http://"+document.domain+"/";
}

/*
	Fade in an element.  This will look strange if the opacity for the element is not set to 0 first.
*/
function fade_in( elem, callback ) {

	if ( typeof ( elem ) != "object" ) elem = document.getElementById( elem );

	// set opacity to 0 incase it is not already.
	var opacity = 0.00;
	elem.style.opacity = 0.00;
	elem.style.filter = "alpha(opacity=" + opacity + ")"; 

	elem.style.display = "block";

	// create the animation
	var aniObj = new YAHOO.util.Anim(
		elem,
		{ opacity: {from: 0, to: 1 } },
		0.4,
		YAHOO.util.Easing.easeBoth
	);

	if ( typeof( callback ) != "undefined" ) aniObj.onComplete.subscribe( callback );
	aniObj.animate(); // execute the animation
}

/*
	Fade out an element.
*/
function fade_out( elem, callback  ) {

	if ( typeof( elem ) != "object" ) elem = document.getElementById( elem );
	elem.style.display = "block";

	// create the animation
	var aniObj = new YAHOO.util.Anim(
		elem,
		{ opacity: {from: 1, to: 0 } },
		0.4,
		YAHOO.util.Easing.easeBoth
	)

	if ( typeof( callback ) != "undefined" ) aniObj.onComplete.subscribe( callback );
	aniObj.animate(); // execute the animation
}

function getTime() {
	var now = new Date();
	return now.getTime();
}


function getURLVar(urlVarName) {
  var urlHalves = String(document.location).split('?');
  var urlVarValue = '';
  if(urlHalves[1]){
  var urlVars = urlHalves[1].split('&');
    for(i=0; i<=(urlVars.length); i++){
      if(urlVars[i]){
      var urlVarPair = urlVars[i].split('=');
        if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
        	if ( urlVarPair[1] ) urlVarValue = urlVarPair[1];
			else urlVarValue = true;
        }
      }
    }
  }
  return urlVarValue;   
}


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function urlencode( str ) {
                        
    var histogram = {}, unicodeStr='', hexEscStr='';
    var ret = (str+'').toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram["'"] = '%27'; histogram['('] = '%28'; histogram[')'] = '%29'; histogram['*'] = '%2A'; histogram['~'] = '%7E'; histogram['!'] = '%21'; histogram['%20'] = '+'; histogram['\u00DC'] = '%DC'; histogram['\u00FC'] = '%FC'; histogram['\u00C4'] = '%D4'; histogram['\u00E4'] = '%E4'; histogram['\u00D6'] = '%D6'; histogram['\u00F6'] = '%F6'; histogram['\u00DF'] = '%DF'; histogram['\u20AC'] = '%80'; histogram['\u0081'] = '%81'; histogram['\u201A'] = '%82'; histogram['\u0192'] = '%83'; histogram['\u201E'] = '%84'; histogram['\u2026'] = '%85'; histogram['\u2020'] = '%86'; histogram['\u2021'] = '%87'; histogram['\u02C6'] = '%88'; histogram['\u2030'] = '%89'; histogram['\u0160'] = '%8A'; histogram['\u2039'] = '%8B'; histogram['\u0152'] = '%8C'; histogram['\u008D'] = '%8D'; histogram['\u017D'] = '%8E'; histogram['\u008F'] = '%8F'; histogram['\u0090'] = '%90'; histogram['\u2018'] = '%91'; histogram['\u2019'] = '%92'; histogram['\u201C'] = '%93'; histogram['\u201D'] = '%94'; histogram['\u2022'] = '%95'; histogram['\u2013'] = '%96'; histogram['\u2014'] = '%97'; histogram['\u02DC'] = '%98'; histogram['\u2122'] = '%99'; histogram['\u0161'] = '%9A'; histogram['\u203A'] = '%9B'; histogram['\u0153'] = '%9C'; histogram['\u009D'] = '%9D'; histogram['\u017E'] = '%9E'; histogram['\u0178'] = '%9F';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);

    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr];
        ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
}
		 /*
		 * Our <fb:login-button> specifies this function in its onlogin attribute,
		 * which is triggered after the user authenticates the app in the Connect
		 * dialog and the Facebook session has been set in the cookies.
		 */
		function facebook_onlogin_ready() {
			window.location = "/facebooksignup/";
		}
		
function urldecode( str ) {
    var histogram = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urlencode.
    histogram["'"] = '%27'; histogram['('] = '%28'; histogram[')'] = '%29'; histogram['*'] = '%2A'; histogram['~'] = '%7E'; histogram['!'] = '%21';histogram['%20'] = '+'; histogram['\u00DC'] = '%DC'; histogram['\u00FC'] = '%FC'; histogram['\u00C4'] = '%D4'; histogram['\u00E4'] = '%E4'; histogram['\u00D6'] = '%D6'; histogram['\u00F6'] = '%F6'; histogram['\u00DF'] = '%DF'; histogram['\u20AC'] = '%80'; histogram['\u0081'] = '%81'; histogram['\u201A'] = '%82'; histogram['\u0192'] = '%83'; histogram['\u201E'] = '%84'; histogram['\u2026'] = '%85'; histogram['\u2020'] = '%86'; histogram['\u2021'] = '%87'; histogram['\u02C6'] = '%88'; histogram['\u2030'] = '%89'; histogram['\u0160'] = '%8A'; histogram['\u2039'] = '%8B'; histogram['\u0152'] = '%8C'; histogram['\u008D'] = '%8D'; histogram['\u017D'] = '%8E'; histogram['\u008F'] = '%8F'; histogram['\u0090'] = '%90'; histogram['\u2018'] = '%91'; histogram['\u2019'] = '%92'; histogram['\u201C'] = '%93'; histogram['\u201D'] = '%94'; histogram['\u2022'] = '%95'; histogram['\u2013'] = '%96'; histogram['\u2014'] = '%97'; histogram['\u02DC'] = '%98'; histogram['\u2122'] = '%99'; histogram['\u0161'] = '%9A'; histogram['\u203A'] = '%9B'; histogram['\u0153'] = '%9C'; histogram['\u009D'] = '%9D'; histogram['\u017E'] = '%9E'; histogram['\u0178'] = '%9F';

    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);

    return ret;
}


//if (!Array.prototype.forEach)
//{
//	Array.prototype.forEach = function(fun /*, thisp*/)
//	{
//		var len = this.length >>> 0;
//		if (typeof fun != "function")
//		throw new TypeError();
//
//		var thisp = arguments[1];
//		for (var i = 0; i < len; i++)
//{
//			if (i in this)
//			fun.call(thisp, this[i], i, this);
//		}
//	};
//}

