/* CommonSpot CMS */

if (typeof(Prototype) == "undefined") 
    throw "loginState.js requires Prototype";

/**
 * @author dworaw01
 * version 2.0 by schmem01
 * notes: added multi boxes ability
 */
 
document.observe("dom:loaded", function() {
	boxes = $$('div.boxes');
	
	if(boxes.length > 0) {
		for(i=0;i<boxes.length;i++) {			
			var childs = boxes[i].childElements('div.equalHeight');

			if(childs.length > 0) {
				var maximum = childs.invoke('getHeight').max();
				if (maximum >= 20) {
					childs.invoke('setStyle', {
						height: (maximum - 20) + 'px'
					});
				}
			}
			
		}
	}

}); 

function isCandidateLogged(handler){
    new Ajax.Request(handler, {
        method: 'post',
        onSuccess: function(transport){
            var data = transport.responseText.evalJSON();

            if (data.WELCOME_BOX_STATUS) {
                $("WelcomeBox").update(data.WELCOME_BOX);
                $("MetaNavigation").replace(data.META_NAVOGATION);
            }
        }
    });
}

function isRecruiterLogged(handler){
    new Ajax.Request(handler, {
        method: 'post',
        onSuccess: function(transport){
            var data = transport.responseText.evalJSON();

            if (data.WELCOME_BOX_STATUS) {
                $("WelcomeBox").update(data.WELCOME_BOX);
            	$("MetaNavigation").replace(data.META_NAVOGATION);
            } else {
                $("WelcomeBox").update(data.WELCOME_BOX);
            }
        }        
    });
}

