// -------------Browser Detection variables------------
var ns6 = (!document.all && document.getElementById && ( (navigator.userAgent.indexOf("Netscape6/6.2") != -1) || (navigator.userAgent.indexOf("Netscape6/6.1") != -1)));
var ns7 = (!document.all && document.getElementById && (navigator.userAgent.indexOf("Netscape/7") != -1));
var mozilla = (!document.all && document.getElementById && !ns6 && !ns7);
var MSIE4 = ((navigator.appName == "Microsoft Internet Explorer") && (navigator.userAgent.indexOf("MSIE 4") != -1));
var MSIE5_5 = (navigator.userAgent.indexOf("MSIE 5.5") != -1);
var MSIE6 = (navigator.userAgent.indexOf("MSIE 6") != -1);
var MSIE7 = (navigator.userAgent.indexOf("MSIE 7") != -1);
var MSIE5PLUS = (MSIE5_5 || MSIE6 || MSIE7);
var MSIE5OR6 = (MSIE5_5 || MSIE6);
var ns4 = (document.layers && true);
var o5 = (navigator.userAgent.indexOf("Opera 5") != -1);
var o6 = (navigator.userAgent.indexOf("Opera 6") != -1);
var win2000 = ( (navigator.userAgent.indexOf("Windows NT 5.0") != -1) || (navigator.userAgent.indexOf("Windows NT 5.01") != -1));
var winXP = (navigator.userAgent.indexOf("Windows NT 5.1") != -1);
var win2003 = (navigator.userAgent.indexOf("Windows NT 5.2") != -1);
var winVista = (navigator.userAgent.indexOf("Windows NT 6.0") != -1);
var isFirefox1 = (navigator.userAgent.indexOf( "Firefox/1.5" ) != -1 );
var isFirefox2 = (navigator.userAgent.indexOf( "Firefox/2." ) != -1 );
var isFirefox3 = (navigator.userAgent.indexOf( "Firefox/3." ) != -1 );
var isNetscape = (navigator.userAgent.indexOf( "Navigator/" ) != -1 );
var isNetscape2 = (navigator.userAgent.indexOf( "Netscape/" ) != -1 );

var newwinopener; // launch function new win.
var newextopener; // launch external player new win.

// -------------------------------------------------------------------------------------

function SetHome(theObject){
    theObject.style.behavior = 'url(#default#homepage)';
    theObject.setHomePage('http://www.aliant.net');
}

function changeSearchFilter(whichItem) {
    //set the hidden field value to the appropriate value
    var strSearchWidget = whichItem.charAt(6);
    var strSearchWidgetFilterType = whichItem.charAt(8);
    var strFormName = "search" + strSearchWidget;
    var strHiddenFieldName = "search" + strSearchWidget + "_type";
    switch(strSearchWidgetFilterType) {
        case "1":
            document.getElementById("search" + strSearchWidget + "_type").value = "productsservices";
            break;
        case "2":
            document.getElementById("search" + strSearchWidget + "_type").value = "aliantkeywords";
            break;
        case "3":
            document.getElementById("search" + strSearchWidget + "_type").value = "internet";
            break;
    }
    for (x=1; x<4; x++) {
        var objLinkParent = document.getElementById(strFormName + "_" + x).parentNode;
        objLinkParent.className -= " on";
    }
    var objLinkParent = document.getElementById(strFormName + "_" + strSearchWidgetFilterType).parentNode;
    objLinkParent.className += " on";
}


function checkIfClear(theField){

 var stringInit = "";

    if (typeof(js_lang) != "undefined") lang = js_lang;

    if (js_lang == "fr"){
		stringInit = "Entrer votre recherche ici";
	}
	else{
		stringInit = "Enter your search here";
	}

	if (trimString(theField.value) == stringInit){


		theField.value="";

	}


}


function processSearch(whichForm) {

    var strSearchType = whichForm.searchFilter.value;
    var strSearchQuery = whichForm.searchtext.value;

	strSearchQuery = trimString(strSearchQuery);

    var lang = "none";
    var stringInit = "";

    if (typeof(js_lang) != "undefined") lang = js_lang;

    if (js_lang == "fr"){
		stringInit = "Entrer votre recherche ici";
	}
	else{
		stringInit = "Enter your search here";
	}


	    if (strSearchQuery == ''){
			whichForm.searchtext.value = stringInit;
		}
		else if (strSearchQuery == stringInit){
			// do zipola
		}
		else{

		switch( strSearchType )
		{
				case "1":
					window.location.href = "/RedirectCustom.jsp?AnetPSSearch1=" + lang + "&AnetPSSearch2=" +strSearchQuery + "&goto=http://productsandservice.aliant.net/PS/index.jsp?location=search&keyword=" + strSearchQuery;
					break;
				case "2":
					window.location.href = "/RedirectCustom.jsp?AnetSMBSearch1=" + lang + "&AnetSMBSearch2=" +strSearchQuery + "&goto=http://productsandservice.aliant.net/BusinessSMB/index.jsp?location=search&keyword="+ strSearchQuery;
					break;
				case "3":
					window.location.href = "/RedirectCustom.jsp?AnetISearch1=" + lang + "&AnetISearch2=" +strSearchQuery + "&goto=/SubSect.jsp?sectname=CSearch&language=" + lang + "&st=w&q=" + strSearchQuery;
					break;

		}
	}
}

// ---------------------------------new stuff below------------------------------------

function SPENABLED()
{
    if (MSIE5PLUS)
    {
        return true;
    }
    else if (isNetscape || isNetscape2)
    {
        return false;
    }

    else if (isFirefox1 || isFirefox2 || isFirefox3)
    {
        return true;
    }
    else
    {
        return false;
    }
}

// -------------popup blocker detection----------------
function showBlockedMessage(){

    var lang = "none";

    if (typeof(js_lang) != "undefined") lang = js_lang;




    var theDiv = document.getElementById("PopupBlockedDiv");
    var msgEN = "The content you selected is designed to appear in a new window. This new window is being blocked by your browser pop-up blocker settings. Please change these settings to allow pop-ups and click again on the selected link.";
    var msgFR = "Le contenu que vous avez choisi doit apparaître dans une nouvelle fenêtre. Cette nouvelle fenêtre est bloquée par les configurations de votre système. Veuillez changer ces configurations pour permettre à la fenêtre de paraître et cliquez de nouveau sur le lien choisi.";
    var msgUnknown = "The content you selected is designed to appear in a new window. This new window is being blocked by your browser pop-up blocker settings. Please change these settings to allow pop-ups and click again on the selected link.<p>Le contenu que vous avez choisi doit apparaître dans une nouvelle fenêtre. Cette nouvelle fenêtre est bloquée par les configurations de votre système. Veuillez changer ces configurations pour permettre à la fenêtre de paraître et cliquez de nouveau sur le lien choisi.</p>";

    var msgClose = "";

    var divHeight = "180px";

    if(theDiv){
        theDiv.style.display = "block";
        if (lang == 'en'){
            theDiv.innerHTML = msgEN;
            msgClose = "close"
        }
        else if (lang == 'fr'){
            theDiv.innerHTML = msgFR;
            msgClose = "fermer"

        }else{
            theDiv.innerHTML = msgUnknown;
            divHeight = "230px";
            msgClose = "close/fermer"

        }
        theDiv.innerHTML = theDiv.innerHTML + "<p style=\"text-align: right;\"><a href=\"javascript: closeBlockedPopupDiv();\"><b>"+msgClose+"</b></a></p>";
        theDiv.style.height = divHeight;
    }
    else{
        var newdiv = document.createElement('div');
        newdiv.setAttribute('id', 'PopupBlockedDiv');

        if(MSIE5PLUS){
            newdiv.style.position="absolute";
        }
        else{
            newdiv.style.position="fixed";
        }
        newdiv.style.display = "block";


        newdiv.style.bottom="0px";
        newdiv.style.right="0px";


        newdiv.style.width = "300px";
        newdiv.style.fontFamily = "Verdana, Arial, Courier New";
        newdiv.style.fontSize = "12px";
        newdiv.style.color = "#000000";
        newdiv.style.padding = "10px";
        newdiv.style.background = "#E2E2E2";
        newdiv.style.border = "1px solid #000";
        newdiv.style.overflow = "auto";

        if (lang == 'en'){
            newdiv.innerHTML = msgEN;
            msgClose = "close"
        }
        else if (lang == 'fr'){
            newdiv.innerHTML = msgFR;
            msgClose = "fermer"
        }else{
            newdiv.innerHTML = msgUnknown;
            divHeight = "230px";
            msgClose = "close/fermer"
        }
        newdiv.innerHTML = newdiv.innerHTML + "<p style=\"text-align: right;\"><a href=\"javascript: closeBlockedPopupDiv();\"><b>"+msgClose+"</b></a></p>";

        newdiv.style.height = divHeight;

        document.body.appendChild(newdiv);
    }

    // in ie7, the div may be off the visibile portion of the screen. jump to it.
    if(MSIE7) document.getElementById("PopupBlockedDiv").focus();

    flickerBlockedMessage();


    if(MSIE7)
    document.getElementById("closepopuplink").focus();


}

function closeBlockedPopupDiv(){
    var theDiv = document.getElementById("PopupBlockedDiv");

    if(theDiv) {
        theDiv.style.display = 'none';
    }
}

function flickerBlockedMessage(){
    var theDiv = document.getElementById("PopupBlockedDiv");
    if(theDiv){
        theDiv.style.background = "#0A246A";
        theDiv.style.color = "#FFFFFF";
        setTimeout('flickerBlockedMessageB()', 500)
    }
}

function flickerBlockedMessageB(){
    var theDiv = document.getElementById("PopupBlockedDiv");
    if(theDiv){
        theDiv.style.background = "#ffffff";
        theDiv.style.color = "#000000";
    }
}

function positionPopupBlockedMsg(){
    var theDiv = document.getElementById("PopupBlockedDiv");
    //alert("event");
    if(theDiv){
        theDiv.style.display = 'none';
        theDiv.style.display = 'block';
    }

}

// -------------launch new window methods----------------

function launch(url){

  var lang = "none";
  if (typeof(js_lang) != "undefined") lang = js_lang;

  if (!newwinopener || newwinopener.closed){
    newwinopener = open(url, "newwinopener", "resizable,menubar,scrollbars,toolbar,location,directories,status,width=700,height=500,left=100,top=100");
  }
  else if(newwinopener){
    newwinopener.location.replace(url);
  }

  if(newwinopener){
    closeBlockedPopupDiv();
    newwinopener.focus();
  }else{
    //blocked popup scenario.
    eventLogger("gEventType=BlockedPopup&gEventData1=Other_Launch_" + lang);
    showBlockedMessage();
  }
}

// -------------event logger methods----------------

function eventLogger()
{

    // this is the default path to the Logger.jsp.
    var loggerdomain = "";

    // if the url_bb variable exists (with a page using BB_javascript)
    // the logging MUST go to the BB logger. (for Section_BB.jsp)
    //if (typeof(url_bb) != "undefined"){
    //  loggerdomain = url_bb;
    //}

    var loggerurl = loggerdomain + "/Logger.jsp?";

    if(document.getElementById("EventsFrame"))
    {
        //record the event.
        var eventLogger = document.getElementById("EventsFrame");
        for (var i=0;i<arguments.length;i++){
            loggerurl = loggerurl + arguments[i];
        }
        //added to webpage event logger to initiate event frame clearing.
        eventLogger.src = loggerurl + "&resestframe=true";
    }else{
        // no event captured - missing event frame.
        //alert("missing event frame.");
    }
}

function setWeather(wcity){

    setCookie("usrWeather", wcity, global_cookieAge, global_cookiePath, global_cookieDomain);
        //validate that the cookie was successfully set
        var cookieSet = validateCookie("usrWeather");

        //set cookie successfully set, show user a message
        if (cookieSet)
        {
            var thankYouMessageEN = "Thank you, your preference has been saved.";
            var thankYouMessageFR = "Merci, votre choix a été sauvegardé.";
            var thankYouMessage = "";

            //determine the current language
            var currentLanguage = "none";
            if (typeof(js_lang) != "undefined")
            {
                currentLanguage = js_lang;
            }

            //determine message to display
            if (currentLanguage == 'en')
            {
                thankYouMessage = thankYouMessageEN;
            }
            else if (currentLanguage == 'fr')
            {
                thankYouMessage = thankYouMessageFR;
            }
            else
            {
                thankYouMessage = thankYouMessageEN + "<p>" + thankYouMessageFR + "</p>";
            }

            //display the thank you message
            showPopupMessage(thankYouMessage, currentLanguage);
        }

    //window.location.href=window.location.href;
}

function setCookieTab(tabName){

    setCookie("learnTab", tabName, global_cookieAge, global_cookiePath, global_cookieDomain);
    //window.location.href=window.location.href;

}

function setCookieCbcProv(prov){
    setCookie("cbcProv", prov, global_cookieAge, global_cookiePath, global_cookieDomain);
        return validateCookie("cbcProv");
}



// -------------opens a new window----------------


function launch640(url) {
            self.name = "opener";
            remote = open(url, "remote", "resizable=1,menubar=0,scrollbars=1,toolbar=0,location=0,status=0,width=750,height=650,left=25,top=10");
}


// ------------- Home Page Tabs / show hide functions ----------------


  /*
    This sets the last viewed tab based on the cookie info
  */
  function setLastViewedTab(){
    var tabName = getCookie('learnTab');
    var tabNum = 1;

    //if cookie is set
    if(tabName != null && tabName != ""){

      for (i=1;i<=ids.length; i++){
    if(tabName == ids[i]){
      tabNum = i+1;
    }
      }

      //switch to the last tab viewed (cookie)
      switchid(tabName,tabNum);

    }// eo tabName null check
  }


  /*
    Will show the div that has the mouse over and hide all others
  */
  function switchid(id,number){

    //set all class name to nothing
    for (i=1;i<=ids.length;i++)
      {
    document.getElementById("subsection"+i).className = '';
      }

    //
    for (var i=0;i<ids.length;i++)
    {
      if (ids[i] == id)
    showdiv(ids[i],number);
       else
    hidediv(ids[i]);
    }

  }


  /*
    Will hide the div tag by setting display to none
  */
  function hidediv(id) {


    //hide an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
		try
		{
			document.getElementById(id).style.display = 'none';
		}
		catch(err){
			// do nothing
		}
    }
    else {
      if (document.layers) { // Netscape 4
    	document.id.display = 'none';
      }
      else { // IE 4
    	document.all.id.style.display = 'none';
      }
    }
  }

  /*
    Will show the div by setting display and changing class name to on
  */
  function showdiv(id, number) {

    //show an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
		try
		{
    	    document.getElementById(id).style.display = '';
	        //set the class name to on
      	    document.getElementById("subsection"+number).className = 'on';
		}
		catch(err){
			// do nothing
		}
    }
    else {
      if (document.layers) { // Netscape 4
	    document.id.display = 'block';
      }
      else { // IE 4
	    document.all.id.style.display = '';
      }
    }
  }



// -------------eo show hide Home Page Tabs----------------

/************************************************************/
/* START - Code to launch the media player from a video     */
/*         link or atlantic radio link                      */
/************************************************************/

var VideoPlayerWindow;
var VideoPlayerWindowTitle = "VideoPlayer";
var VideoPlayerWindowProperties = "height=600,width=729,status=yes,toolbar=no,menubar=no,location=no,left=10,top=10";

if (mozilla){ VideoPlayerWindowProperties = "height=600,width=733,status=yes,toolbar=no,menubar=no,location=no,left=10,top=10"; }



// -------------video player methods----------------

// 1st step when launching theexternal player.
function launchMediaASX(theurl){

    medialaunch(theurl);

    if (navigator.mimeTypes["application/x-ms-wmp"]){
        // they have the plug in, don't close the window.
    }
    else
    {
        //setTimeout("closetheblank();", 9000);
    }
}

// 2nd step when launching theexternal player.
function medialaunch(url){

  var currentLanguage = "none";

  if (typeof(js_lang) != "undefined")
  {
	currentLanguage = js_lang;
  }

  if (!newextopener || newextopener.closed){
    newextopener = open(url, "newextopener", "resizable,menubar,scrollbars,toolbar,location,directories,status,width=700,height=500,left=100,top=100");
  }
  else if(newextopener){
    newextopener.location.replace(url);
  }

  if(newextopener){
    closeBlockedPopupDiv();
    newextopener.focus();
  }else{
    //blocked popup scenario.
    eventLogger("gEventType=BlockedPopup&gEventData1=ExternalPlayer_AssetLaunch_" + currentLanguage);
    showBlockedMessage();
  }
}

function closetheblank(){
    if (newextopener){
        newextopener.close();
    }
}

// launch standalone
function launchMediaPlayerApp(lang , app, isRadio, category)
{

    var APPEvent = "";
    var APPParm = "";

    var errormsgfr = "Désolé, le Vidéo d'Aliant n'est pas compatible avec Microsoft Internet Explorer 5.5 et versions plus avancées.\n Aussi, le Système d'Exploitation MAC n'est pas compatible.";
    var errormsgen = "Sorry, The Aliant video player is only supported by Microsoft Internet Explorer 5.5 and higher.\n The Mac OS is also not supported at this time.";

    if (app == null || app == 'undefined') app = "";

    if (app != ""){
        APPParm="&app=" + app
        APPEvent= "_" + app;

        if (app == 'AR'){
            errormsgfr = "Désolé, \"Aliant Internet Radio\" n'est pas compatible avec Microsoft Internet Explorer 5.5 et versions plus avancées.\n Aussi, le Système d'Exploitation MAC n'est pas compatible.";
            errormsgen = "Sorry, Aliant Internet Radio is only supported by Microsoft Internet Explorer 5.5 and higher.\n The Mac OS is also not supported at this time.";
        }
    }

    if (SPENABLED())
    {
       //var videoPlayerURL = "/VideoPlayer/index.jsp?language=" + lang + "&app=AR";
       var videoPlayerURL = "/VideoPlayer/index.jsp?language=" + lang + "&app=AR&isRadio=" + isRadio + "&parentName=" + category;

       eventLogger("VideoButton=VideoButton" + APPEvent +"_"+lang);
        if (!VideoPlayerWindow || VideoPlayerWindow.closed)
        {
            VideoPlayerWindow = open(videoPlayerURL, VideoPlayerWindowTitle, VideoPlayerWindowProperties);
        }
        else if(VideoPlayerWindow)
        {
            VideoPlayerWindow.location.replace(videoPlayerURL);
        }

        if(VideoPlayerWindow)
        {
            closePopupMessageWindow();
            VideoPlayerWindow.focus();
        }
        else
        {
            //blocked popup scenario.
            eventLogger("gEventType=BlockedPopup&gEventData1=VideoPlayer_" + app + "Launch_" + lang);
            showBlockedMessage();
        }


    }
    else
    {
        if (lang == 'fr')
        {
            alert(errormsgfr);
            eventLogger("VideoButton=VideoButtonDisabled" + APPEvent +"_"+lang);
        }
        else
        {
            alert(errormsgen);
            eventLogger("VideoButton=VideoButtonDisabled" + APPEvent +"_"+lang);
        }
    }
}


//javascript to launch the media player for the selected video
function launchMediaPlayer(url, id, owner, ctype, lang, theparent, autotype, thefile)
{
    var videoPlayerURL = "/VideoPlayer/index.jsp?language=" + lang + "&categoryName=" + owner + "&contentID=" + id + "&contentType=" + ctype + "&parentName=" + theparent + "&autoType=" + autotype + "&fileName=" + thefile;
    var ExternalEventData = "MediaPlayEvent=MP_"+ctype+";MP_AutoEx_"+ctype+"&mpclevel1="+theparent+"_"+lang+"&mpclevel2="+owner+"_"+lang+"&MediaPlayFile="+thefile+"&MediaPlayContentID="+id;

    if (SPENABLED())
    {

        if (!VideoPlayerWindow || VideoPlayerWindow.closed)
        {
            VideoPlayerWindow = open(videoPlayerURL, VideoPlayerWindowTitle, VideoPlayerWindowProperties);
        }
        else if(VideoPlayerWindow)
        {
            VideoPlayerWindow.location.replace(videoPlayerURL);
        }

        if(VideoPlayerWindow)
        {
            closePopupMessageWindow();
            VideoPlayerWindow.focus();
        }
        else
        {
            //blocked popup scenario.
            eventLogger("gEventType=BlockedPopup&gEventData1=VideoPlayer_AssetLaunch_" + lang);
            showBlockedMessage();
        }
    }
    else
    {
       eventLogger(ExternalEventData); // eventURL defined in level2 xsl
       launchMediaASX(url)
    }
}






//launches the media player with the selected radio station
function launchInternetRadio(url, id, owner, ctype, lang, theparent, autotype, thefile)
{
    var videoPlayerURL = "/VideoPlayer/index.jsp?language=" + lang + "&categoryName=" + owner + "&contentID=" + id + "&contentType=" + ctype + "&parentName=" + theparent + "&autoType=" + autotype + "&fileName=" + thefile + "&isRadio=true";

    if (!VideoPlayerWindow || VideoPlayerWindow.closed)
    {
        VideoPlayerWindow = open(videoPlayerURL, VideoPlayerWindowTitle, VideoPlayerWindowProperties);
    }
    else if(VideoPlayerWindow)
    {
        VideoPlayerWindow.location.replace(videoPlayerURL);
    }
}

/************************************************************/
/* END - Code to launch the media player from a video       */
/*       link or atlantic radio link                        */
/************************************************************/


/************************************************************/
/* START - Code to check for cookies                        */
/************************************************************/

    function validateCookie(cookieName)
    {
        var myCookie = getCookie(cookieName) ;

        //display message if the cookie was not found
        if ((myCookie == null) || (myCookie == ""))
        {
            //determine the current language
            var currentLanguage = "none";
            if (typeof(js_lang) != "undefined")
            {
                currentLanguage = js_lang;
            }

            var cookieMessage = getCookieNotEnabledMessage(cookieName, currentLanguage);
            showPopupMessage(cookieMessage, currentLanguage);
            return false;
        }

        return true;
    }


    function getCookieNotEnabledMessage(cookieName, currentLanguage)
    {
        var cookieMessageEN = "";
        var cookieMessageFR = "";

        //determine the message to display
        switch (cookieName)
        {
            case global_cookieNameLanguage:
                cookieMessageEN = "Please enable cookies to save your preference. This will ensure optimal exposure to all features.";
                cookieMessageFR = "Veuillez activer vos fichiers de témoins (cookies) pour sauvegarder votre choix. Ceci vous permettra de profiter de toutes les fonctions.";
                break;
            case "usrWeather":
                cookieMessageEN = "Please enable cookies to save your preference. This will ensure optimal exposure to all features.";
                cookieMessageFR = "Veuillez activer vos fichiers de témoins (cookies) pour sauvegarder votre choix. Ceci vous permettra de profiter de toutes les fonctions.";
                break;
            case "cbcProv":
                cookieMessageEN = "Please enable cookies to save your preference. This will ensure optimal exposure to all features.";
                cookieMessageFR = "Veuillez activer vos fichiers de témoins (cookies) pour sauvegarder votre choix. Ceci vous permettra de profiter de toutes les fonctions.";
                break;
            default:
                cookieMessageEN = "Unable to set unknown cookie (cookie Name = " + cookieName + ") - English";
                cookieMessageFR = "Unable to set unknown cookie (cookie Name = " + cookieName + ") - French";
        }

        if (currentLanguage == 'en')
        {
            return cookieMessageEN;
        }
        else if (currentLanguage == 'fr')
        {
            return cookieMessageFR;
        }
        else
        {
            return cookieMessageEN + "<p>" + cookieMessageFR + "</p>";
        }
    }





function showPopupMessage(cookieMessage, currentLanguage)
{
        //get reference to the div
    var theDiv = document.getElementById("PopupCookiesNotEnabledDiv");

        //define the close message
    var msgClose = "";
        if (currentLanguage == 'en')
        {
            msgClose = "close";
    }
    else if (currentLanguage == 'fr')
        {
            msgClose = "fermer";
    }
        else
        {
            msgClose = "close/fermer";
        }

        //define the height of the div
    var divHeight = "180px";
        if ((currentLanguage != 'en') && (currentLanguage != 'fr'))
        {
            divHeight = "230px";
        }

    if(theDiv)
        {
            theDiv.style.display = "block";
            theDiv.innerHTML = cookieMessage;
            theDiv.innerHTML = theDiv.innerHTML + "<p style=\"text-align: right;\"><a href=\"javascript: closePopupMessageWindow();\"><b>"+msgClose+"</b></a></p>";
            theDiv.style.height = divHeight;
    }
    else
        {
        var newdiv = document.createElement('div');
        newdiv.setAttribute('id', 'PopupCookiesNotEnabledDiv');

        if(MSIE5OR6)
                {
                    newdiv.style.position="absolute";
        }
        else
                {
                    newdiv.style.position="fixed";
        }
        newdiv.style.display = "block";


        newdiv.style.bottom="0px";
        newdiv.style.right="0px";


        newdiv.style.width = "300px";
        newdiv.style.fontFamily = "Verdana, Arial, Courier New";
        newdiv.style.fontSize = "12px";
        newdiv.style.color = "#000000";
        newdiv.style.padding = "10px";
        newdiv.style.background = "#E2E2E2";
        newdiv.style.border = "1px solid #000";
        newdiv.style.overflow = "auto";

                //set the div text
                newdiv.innerHTML = cookieMessage;
        newdiv.innerHTML = newdiv.innerHTML + "<p style=\"text-align: right;\"><a href=\"javascript: closePopupMessageWindow();\"><b>"+msgClose+"</b></a></p>";
        newdiv.style.height = divHeight;
        document.body.appendChild(newdiv);
    }

    // in ie7, the div may be off the visibile portion of the screen. jump to it.
    if(MSIE7) document.getElementById("PopupCookiesNotEnabledDiv").focus();

    flickerPopupMessageWindow();
}



function closePopupMessageWindow()
{
    var theDiv = document.getElementById("PopupCookiesNotEnabledDiv");

    if(theDiv) {
        theDiv.style.display = 'none';
    }
}


function flickerPopupMessageWindow()
{
    var theDiv = document.getElementById("PopupCookiesNotEnabledDiv");
    if(theDiv){
        theDiv.style.background = "#0A246A";
        theDiv.style.color = "#FFFFFF";
        setTimeout('flickerPopupMessageWindowB()', 500)
    }
}

function flickerPopupMessageWindowB()
{
    var theDiv = document.getElementById("PopupCookiesNotEnabledDiv");
    if(theDiv){
        theDiv.style.background = "#ffffff";
        theDiv.style.color = "#000000";
    }
}



/************************************************************/
/* END - Code to check for cookies                          */
/************************************************************/

/************************************************************/
/* Function for Daily Info Search Blocks                    */
/************************************************************/
function searchDailyInfo(url, keyword , lang)
{
    var searchUrl = url + keyword;

    eventLogger("RedirectSection=PartnerLink&RedirectGroup=DailyInfoSearch_" + lang + "&RedirectSubGroup=" + url);

    launch(searchUrl);
}

// used in Photo Postcard
function submitPostcardPreview(cardForm) {

	var pass = 1;
	var lang = "en";

    if (typeof(js_lang) != "undefined") lang = js_lang;

	var errorMsgEmail = "Invalid email address";
	var errorMsgMissing = "This is a required field.";

	if(lang == "fr"){
		errorMsgEmail = "Adresse courriel non valide";
		errorMsgMissing = "Veuillez vous assurer que la section requise est complétée.";
	}

	cardForm.pcfrom.value = trimString(cardForm.pcfrom.value);
	cardForm.pcfrom.value = trimBads(cardForm.pcfrom.value);
	cardForm.pcfromemail.value = trimString(cardForm.pcfromemail.value);
	cardForm.pcto.value = trimString(cardForm.pcto.value);
	cardForm.pcto.value = trimBads(cardForm.pcto.value);
	cardForm.pctoemail.value = trimString(cardForm.pctoemail.value);
	cardForm.pcmessage.value = trimString(cardForm.pcmessage.value) + " ";
	cardForm.pcmessage.value = trimBads(cardForm.pcmessage.value) + " ";



	if (cardForm.pcfrom.value == "" && pass == 1){
		alert(errorMsgMissing);
		cardForm.pcfrom.focus();
		cardForm.pcfrom.select();
		pass = 0;
	}

	if (cardForm.pcfromemail.value == "" && pass == 1){
		alert(errorMsgMissing);
		cardForm.pcfromemail.focus();
		cardForm.pcfromemail.select();
		pass = 0;
	}

	if (!validEmail(cardForm.pcfromemail.value) && pass == 1) {
		alert(errorMsgEmail + " - " + cardForm.pcfromemail.value );
		cardForm.pcfromemail.focus();
		cardForm.pcfromemail.select();
		pass = 0;
	}

	if (cardForm.pcto.value == "" && pass == 1){
		alert(errorMsgMissing);
		cardForm.pcto.focus();
		cardForm.pcto.select();
		pass = 0;
	}

	if (cardForm.pctoemail.value == "" && pass == 1){
		alert(errorMsgMissing);
		cardForm.pctoemail.focus();
		cardForm.pctoemail.select();
		pass = 0;
	}

	if (!validEmail(cardForm.pctoemail.value) && pass == 1) {
		alert(errorMsgEmail + " - " + cardForm.pctoemail.value );
		cardForm.pctoemail.focus();
		cardForm.pctoemail.select();
		pass = 0;
	}

	if (pass){
		cardForm.submit();
	}

}

function validEmail(theaddress)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    return reg.test(theaddress);
}

function trimString(strText)
{
	while (strText.substring(0,1) == ' ' )
	strText = strText.substring(1, strText.length);

	while (strText.substring(strText.length-1,strText.length) == ' ')
	strText = strText.substring(0, strText.length-1);

	return strText;
}

function trimBads(strText)
{

    strText = strText.replace(/</g, "&lt;");
    strText = strText.replace(/>/g, "&gt;");
    strText = strText.replace(/&/g, "&amp;");
    strText = strText.replace(/&amp;amp;/g, "&amp;");
    strText = strText.replace(/&amp;gt;/g, "&gt;");
    strText = strText.replace(/&amp;lt;/g, "&lt;");

	return strText;
}

function swapDivs(divname1, divname2) {
	if (document.getElementById){
		document.getElementById(divname2).style.display = 'none';
		document.getElementById(divname1).style.display = 'block';

	}
}


