//===========================================================
// This function is required for IE only, as it doesn't support
// the :hover pseudo class on elements other then <a>
//============================================================
        function InitializeMenu()
        {
            if (document.all && document.getElementById)
            {
                var navRoot = document.getElementById("Nav");
                for (i=0; i<navRoot.childNodes.length; i++)
                {
                    node = navRoot.childNodes[i];
                    if (node.nodeName == "LI")
                    {
                        node.onmouseover=function()
                        {
                            this.className+=" over";
                        }
                        node.onmouseout=function()
                        {
                            this.className=this.className.replace(" over", "");
                        }
                    }
                }
            }       
          }


//=================================================
// Open an new window for send page to a frind with 
//  customized properties
//=================================================

function sendToFriend(objLink) {
    // get the url of the document being sent
    var strCurrentUrl = escape ( parent.document.URL ) ;
    // get the page <title> of the document being sent
    var strPageTitle = parent.document.title;
    var strURLParams = '?ForceUserDeserialize=-1&pageToSend=' + strCurrentUrl + '&pageTitle=' + strPageTitle + '&mode=submitted';
    var strURL = objLink.href + strURLParams;
    var strWindowProperties = 'width=409,height=460,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';    

    // open the window
    openWindow(strURL ,'send_to_a_friend', strWindowProperties);    
    // prevent any further code from executing
    return false;
}

//=================================================
// Open an new window with customized properties
//=================================================
function openWindow(URL, Name, Args){
    popupWin = window.open(URL, Name, Args);
    popupWin.focus();
}

function printPage(){

if(document.getElementById("popup") == null)
{
if (window.print) window.print();
else alert('Your browser does not support javascript printing.\nTo print this page, select File: Print from your menu.\nThis page is already printer friendly.');
}
else
{
printPopUpPage();


}
}

function printPopUpPage(){
var print_content=document.getElementById("popup").innerHTML;
var print_setting = 'toolbar=yes, location=no,directories=yes,menubar=yes,scrollbars=yes,width=400, height=100,top=10,left=200';
var content = "<html><head><title> Print page</title>";
content =content+"</head><body onLoad='self.print(); self.close();'>";
content = content + print_content;
content = content + "</body></html>";
content = content.replace('DISPLAY: block','display:none');
content = content.replace('display: block','display:none');
content = content.replace(">x<",'');
var doc=window.open('','',print_setting);
doc.document.open();
doc.document.write(content);
doc.document.close();
window.self.close();
}



//=================================================
// Open an new window with for popupimage
//=================================================

function popupwindowscroll(url, intWidth,intHeight,blnScroll){
    if (intWidth == null || intHeight == null) {intWidth=750;intHeight=535;}
    if (blnScroll == null) {blnScroll='no';}
    // this is the common window for popups. it resizes to the size needed
    //NewWindow = window.open(url,"POPUPWINDOWSCROLL","toolbar=no,width="+intWidth+",height="+intHeight+",directories=no,status=no,scrollbars=yes,resizable=no,menubar=no,top=0,left=20");
    window.name ="NewWindow";
    NewWindow = window.open(url,"POPUPWINDOWSCROLL","toolbar=no,width="+intWidth+",height="+intHeight+",directories=no,status=no,scrollbars="+blnScroll+",resizable=no,menubar=no,top=0,left=20");
    NewWindow.resizeTo(intWidth, intHeight);
    NewWindow.focus();
}

//=================================================
// show leaving the site warning
//=================================================

var ExitPopUpsEnabled = true;
var SiteExceptions = new Array ("www.janssen.ca","www.livingwithuc.ca");

  
  
function ReplaceLinks()
{
    var currentdomain = document.domain;
    if (ExitPopUpsEnabled)
    {
        for (l=0; l<document.links.length; l++) 
        {
            current_href = document.links[l].href.toLowerCase();
            if (current_href.indexOf(currentdomain) == -1 && current_href.substring(0,1) != "/" && current_href.indexOf("(") == -1 )
            {
                if (!(SiteExceptions.in_array(document.links[l].hostname)) && (current_href.indexOf("mailto:")== -1))
                { 
                    var link = document.links[l];
                    if (link) AttachEvent(link,"click",ExitPopUp,false)
                }
                    
            } 
        }
    }
 }


function ExitPopUp(e){
    if (!e) var e = window.event;
    if (!confirm("Vous allez quitter le site " + document.domain + ". Le contenu du site que vous allez visiter n’est pas contrôlé par Janssen."))
    {
        if (e.preventDefault) e.preventDefault();
        e.returnValue = false;
     }
    
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
}


function ExitPopUpFlash(url,popuptreatment)
  {
    if (confirm("You are now leaving the PHEC UC Web site. If you DO NOT wish to leave this site, click Cancel, or click OK to leave PHEC UC"))
    {
            window.name ="NewWindow";
            NewWindow = window.open(url,"PopupWindow",popuptreatment);
            NewWindow.focus();              }  
  }

//Use to attach an event to an object
function AttachEvent(obj,evt,fnc,useCapture){
    if (!useCapture) useCapture=false;
    if (obj.addEventListener){
        obj.addEventListener(evt,fnc,useCapture);
        return true;
    } else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
    else{
        MyAttachEvent(obj,evt,fnc);
        obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
    }
} 

//The following are for browsers like NS4 or IE5Mac which dont support either
//attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc){
    if (!obj.myEvents) obj.myEvents={};
    if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
    var evts = obj.myEvents[evt];
    evts[evts.length]=fnc;
}
function MyFireEvent(obj,evt){
    if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
    var evts = obj.myEvents[evt];
    for (var i=0,len=evts.length;i<len;i++) evts[i]();
}


// Add in_array functionality to an array
Array.prototype.in_array = function(search_term) {
    var i = this.length;
    search_term=search_term.toUpperCase();
    do {
    if (i > 0) {
    if (this[i-1].toUpperCase() === search_term)
    return true; }
    } while (--i);
    return false;
}

 function faq(faqno)
 
 {
 
  if(document.getElementById("faqans" + faqno).style.display.match("none"))
 
  {
 
   //alert(test);
 
   document.getElementById("faqans" + faqno).style.display="block";
 
  }
 
  else
 
  {
 
   //alert(test);
 
   document.getElementById("faqans" + faqno).style.display="none";

   }  
 }

 //Cokkie
 // JavaScript Document

function createCookie(name,value,days) 
{
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function doUnload()
{       
    var strBrowser,strWSLeft,strSWidth;        
    strBrowser = navigator.appName; 
    strSWidth=parseInt(screen.width);   

    var cName;
    cName="BridionUKSID" + document.getElementById("sessID").value; 
    
    if (strBrowser=="Microsoft Internet Explorer")
    {       
        strWSLeft=window.screenLeft;
        
        if(strWSLeft>strSWidth)
        {
            createCookie(cName,"No",365);       
        }
    }
    else
    {               
        strWSLeft= window.screenX;
        if(strWSLeft < strSWidth)
        {   
           createCookie(cName,"No",365);        
        }           
    }
}


function getObj(name)
    {
    if (document.getElementById)
        {
        return document.getElementById(name);
        }
    else if (document.all)
        {
        return document.all[name];
        }
    else if (document.layers)
        {
        return document.layers[name]; 
        }
    else return false;
    }
    
function getWindowWidth()
{
    if (window.innerWidth){
            MySize = window.innerWidth;}
    else{
            MySize = document.body.clientWidth;}
    return MySize;  
}


    
function SetToXY(DivId,x,y)
{
    try
        { 
        document.getElementById(DivId).style.left = x +"px";
        document.getElementById(DivId).style.top = y +"px";
        //alert(y);
        
        }
    catch (e)
        {
        setTimeout("SetToXY('"+DivId+"','"+x+"','"+y+"');",1000);       
        } 
}   


StockWidthPopup="0";
function resizeLoader()
    {
    jQuery("#layerfullpage").css({height:Math.max(jQuery(window).height(), jQuery(document.body).height())});
    PositionneLelayPopup();
    }

function PositionneLelayPopup()
    {
    PosLeft=parseInt(getWindowWidth()-StockWidthPopup)/2;
	PosTop=$(window).scrollTop()+100;
    SetToXY('contenerPopupSite',PosLeft,PosTop)
    }
var htmlElement = top.document.getElementsByTagName('html')[0];

function windowproper()
{
var pageHeight;
var pageWidth;
if( window.innerHeight && window.scrollMaxY ) 
{
pageWidth = window.innerWidth + window.scrollMaxX;
pageHeight = window.innerHeight + window.scrollMaxY;
}
else if( document.body.scrollHeight > document.body.offsetHeight ) 
{
pageWidth = document.body.scrollWidth;
pageHeight = document.body.scrollHeight;
}
else 
{ pageWidth = document.body.offsetWidth + document.body.offsetLeft; pageHeight = document.body.offsetHeight + document.body.offsetTop; }
//alert(pageHeight);
return pageHeight;
}
    
function OpenPopup(Url,HeidthPopup,WidthPopup)
    {
	var pageHeight;
	pageHeight = windowproper();	
    htmlElement.style.overflow = 'hidden';
	//alert(pageHeight);
	window.scrollTo(0,pageHeight);	
    StockWidthPopup=WidthPopup;
	PositionneLelayPopup();
    objFramePop=getObj("FramePopSite");
    objFramePop.width=WidthPopup;
    objFramePop.height=HeidthPopup;
    objFramePop.src=Url;
    getObj('contenerPopupSite').style.display='block';	
    getObj('layerfullpage').style.display='block';
	//getObj('layerfullpage').style.height=document.documentElement.scrollTop + 600 + "px"
	getObj('layerfullpage').style.height=pageHeight + "px";
    getObj('layerfullpage').style.filter='alpha(opacity=60)';
	window.scrollTo(0,pageHeight);	
   
    }

function closePopup()
    {
	//location.reload(true);
    top.getObj('contenerPopupSite').style.display='none';
	top.getObj('layerfullpage').style.height="";
    top.getObj('layerfullpage').style.display='none';
    objFramePop=top.getObj("FramePopSite");
    objFramePop.src="";
    htmlElement.style.overflow = 'scroll';
    //document.body.style.marginRight='0px';
    //top.document.getElementById('contenerPopupSite').style.left ="0px";
    //top.document.getElementById('contenerPopupSite').style.top = "0px";
    
    } 

function ResizePopup(PopHeight,PopWidth)
    {
    parent.getObj("FramePopSite").height=PopHeight;
    parent.getObj("FramePopSite").width=PopWidth;
    }
function OpenPopupRel(url, height, width)
{
    if (document.location.href.indexOf("diagnosed_with_as") >= 0 
        || document.location.href.indexOf("living_with_as") >= 0)
        url = "../" + url;
    OpenPopup(url, height, width);
}

function OpenRecords() 
{
    OpenPopupRel('include/records.jsp','241','638');
}

function OpenTracking() 
{
    OpenPopupRel('../includes/symptom/symptom_tracking.asp','403','638')
    //OpenPopupRel('/include/symptomopen.do','398','638')   
}

function OpenLocator() 
{
    OpenPopupRel('/includes/phec_uc/clinicLocator/clinic_locator.asp','450','640')
    //OpenPopupRel('/include/locatoropen.do','398','638')   
}

function OpenLogin() 
{
    OpenPopupRel('include/login.jsp','339','638')
}

