var __UTILCareerSection__ = 1;

/**
 * Return the bolean value for HREF when you don't want to follow the link.
 *
 * @since       RS3.1
 */
function dontFollowLink()
{
    var userAgent = window.navigator.userAgent;
    var appName = window.navigator.appName;
    if ((appName.indexOf("Explorer") >= 0) && (userAgent.indexOf("Mozilla/3") >= 0) && (userAgent.indexOf("Mac") >= 0))
        return (true);
    else
        return (false);
}
/** Hold all child window opened. */
var popupList = new Array();

/**
 * Function to close all child window.
 *
 * @author      Vincent Desjardins
 * @since       RS3.1
 */
function closeChildWindow()
{
    for (var i=0; i < popupList.length; i++)
    {
        if (!popupList[i].closed)
        {
            popupList[i].close();
        }
    }
}

/**
 * Function to open a window.
 *
 * @author      Vincent Desjardins
 * @since       RS3.1
 * @param     url             Url to display (String)
 * @param     target        Window name (String)
 * @param     width         screen width about to be displayed (int)
 * @param     height        screen height about to be displayed (int)
 * @param     scrollbars    display scrollbar in the browse if = yes (yes or no)
 * @param     topPos        y coordinate of the screen about to be displayed
 * @param     leftPos        X coordinate of the screen about to be displayed
 * @param     pFullScreen Display the browser as full screen if = yes (yes or no)
 * @return      the actual opened popup
 * @since       RS4.1
  *
 * Roger St-Amand 11-01-2005
 * adapt that function to be able to show full screen popup window.
*/
function openWindow(url, target, width, height, resizable, scrollbars, topPos, leftPos, pFullScreen)
{
    /* if pFullScreen flag = yes then show the popup window as full screen popup without any toolbar */
    if (pFullScreen != null && pFullScreen=="yes")
    {
        /* Depending of web browser set the correct style to the popup window */
        if (window.navigator.appName.indexOf("Explorer") >= 0)
        {            
            /* for IE use the following line */
            /* TT82148. Removed "fullscreen" since channelmode does the same but leave the titlebar and buttons which is what we want*/
            popup = window.open(url, target,  'autoscroll=yes, scrollbars=yes, top=0, left=0, channelmode=yes,hotKeys=no,resizable=no,directories=no');
        }
        else
        {
            /* for other browser like netscape and mozila */
            popup = window.open(url, target, 'outerWidth=' + screen.availWidth + ',outerHeight=' + screen.availHeight + ',scrollbars=yes,top=0,left=0,alwaysRaised=yes,hotKeys=no,resizable=no,directories=no');
        }
    }
    else
    {
        /* Display browser as usual with spedified parameters */
        if (topPos  == null)
        {
            if (screen.availHeight != null)
            {
                topPos = ( (screen.availHeight-height-15) < 0) ? 15 : (screen.availHeight-height-15)/2
            }
            else
            {
                topPos = 15
            }
        }
        if (leftPos  == null)
        {
            if (screen.availWidth != null)
            {
                leftPos = ( (screen.availWidth-width-15) < 0) ? 0 : (screen.availWidth-width-15)/2
            }
            else
            {
                leftPos = 15
            }
        }
        var style = "";
        if (width != null)
            style += "width=" + width + ",";
        if (height != null)
            style += "height=" + height + ",";
        if (resizable != null)
            style += "resizable=" + resizable + ",";
        if (scrollbars != null)
            style += "scrollbars=" + scrollbars + ",";
        if (topPos != null)
            style += "top=" + topPos + ",";
        if (leftPos != null)
            style += "left=" + leftPos + ",";
        popup = window.open(url, target, style + "menubar=no,toolbar=no,directories=no,location=no,status=no");
    }
//tt-26843-mlegare: verifier si popup existe puis si popup.focus existe aussi
    if (popup && popup.focus)
    {
        popup.focus();
    }
    popupList[popupList.length] = popup;

    return (popup);
}

function stopEvent() 
{
    var userAgent = window.navigator.userAgent;
    var appName = window.navigator.appName;
    if ((appName.indexOf("Explorer") >= 0) && (userAgent.indexOf("Mozilla/3") >= 0) && (userAgent.indexOf("Mac") >= 0)) {
        return (true);
    } else {
        return (false);
    }
}

var popupList = new Array();

function raiseChange( isset )
{
    if ( (document.formCandidateLogin.ArtCSUserLogin_password.value != "") || (isset) )
    {
        document.formCandidateLogin.radioGroup_loginMode[0].checked=false;
        document.formCandidateLogin.radioGroup_loginMode[1].checked=true;
    }
    else
    {
        document.formCandidateLogin.radioGroup_loginMode[0].checked=true;
        document.formCandidateLogin.radioGroup_loginMode[1].checked=false;
    }
}

var registerArray = new Array();
var arrayCptr = 0;

function register(toRegister)
{
	registerArray[arrayCptr]= toRegister;
	arrayCptr++;
	return true;
}

function executeRegister()
{
	var keepGoing = true; 
	for (var i = 0; i <  registerArray.length; i++)
	{
		keepGoing = eval(registerArray[i]);
	}
	return keepGoing;
}

/**
 * Validates if the client browser support cookies. If not, redirect him 
 * to an error page. This finction shoulb used only when the cieSetting
 * CSDisableCookielessSupport is activated.
 *
 * The redirectURL must be constructed using CareerSectionURLBuilder.buildNeedCookiesURL.
 */
function detectCookieSupport(redirectURL)
{
	if (isCookieEnabled() == false)
    {
        self.location.replace(redirectURL);
    }
}
 
function GetCookie(name)
{
    var result = null;
    var myCookie = " " + document.cookie + ";";
    var searchName = " " + name;
    var startOfCookie = myCookie.indexOf(searchName);
    var endOfCookie;
    if (startOfCookie != -1)
    {
        startOfCookie = myCookie.indexOf("=", startOfCookie) + 1;
        endOfCookie = myCookie.indexOf(";", startOfCookie);
        result = unescape(myCookie.substring(startOfCookie, endOfCookie));
    }
    return result;
}

function setCookie(name, value) 
{ // use: setCookie("name", value);
    document.cookie=name + "=" + escape(value);
}        

function isCookieEnabled()
{
    var retValue = false;
    var cookieName = "CookieEnabled";
    var cookieValue= "ToValidate";
    var alteredValue= "Invalid";
    setCookie(cookieName, cookieValue);
    var allCookies = document.cookie;
    if(allCookies.indexOf(cookieName+ "=" + cookieValue) != -1)
    {
        retValue = true;
    }
    else
    {
        retValue = false;
    }
   setCookie(cookieName, alteredValue);
   return(retValue);
}

/**
 * Jean-Marie Nzabonimpa - TimeZone feature
 * Le 18 octobre 2005 
 *
 * M?me si ce code est d?j? dans "util.js", nous pr?f?rons le dupliquer ici dans UtilCareerSection.js, 
 * vu que la Section Carri?re n'utilise pas util.js (et on ne veut pas qu'il l'utilise
 * 
 */
function prepareClientTimeZone()
{
    var now = new Date();
    document.cookie = "ak_tz=" + (now.getTimezoneOffset() * -1) + "; path=/";
}
prepareClientTimeZone();