﻿function Search(objOrigin)
{
    var lang = getLang();
    if (objOrigin == "SearchPage")
    {
       if (document.getElementById("ctl00_ctl00_MainContent_MainContent_txtSearch")!=undefined)
       var sScope=0;
       if (document.getElementById("ctl00_ctl00_MainContent_MainContent_radHealthcareSolutions").checked == true)
        {sScope=1;}
       if (document.getElementById("ctl00_ctl00_MainContent_MainContent_radHealthcareCommunities").checked == true)
        {sScope=2;}
       if (document.getElementById("ctl00_ctl00_MainContent_MainContent_radBusinessSolutions").checked == true)
        {sScope=3;}
       if (document.getElementById("ctl00_ctl00_MainContent_MainContent_radNewsAndEvents").checked == true)
        {sScope=4;}
       if (document.getElementById("ctl00_ctl00_MainContent_MainContent_radAboutUs").checked == true)
        {sScope=5;}
       if (document.getElementById("ctl00_ctl00_MainContent_MainContent_radCompleteSite").checked == true)
        {sScope=0;}
   
       document.getElementById("SearchScope").value = sScope;
       sSearchStr =  document.getElementById("ctl00_ctl00_MainContent_MainContent_txtSearch").value;
       
    }
    else
    {
        sSearchStr = document.getElementById("txtSearch").value;
        var sURL = "/" + lang + "/Search.aspx";
        if (sSearchStr != '' && sSearchStr.toLowerCase() != 'search' && sSearchStr.toLowerCase() != 'recherche')
        {
            sURL = sURL + "?f=" + sSearchStr;                
        }
        //alert("Before setting the URL");
        window.location.href= sURL;
        //alert("After setting the URL");
        return false; 
    }
    
    document.forms[0].submit();
    return true;
}

function SearchKeyPress(e, objOrigin)
    {
        var keyCode;
        if (window.event)
        {
            keyCode=window.event.keyCode;   //Compatibility for Internet Explorer 
        }else{
            keyCode=e.which;                //Compatibility for most other browsers 
        }
        if (keyCode == '13')
        {
            Search(objOrigin);
            return false; 
        }
        else
        {
            return true;
        }  
    }
     
function ClearSearchBox()
    {
        var sSearchStr = document.getElementById("txtSearch").value;
        if (sSearchStr == "SEARCH" || sSearchStr == "RECHERCHE")
        document.getElementById("txtSearch").value = "";
    }
    
function ResetSearchBox()
    {
        var sSearchStr = document.getElementById("txtSearch").value;
        //alert(sSearchStr);
        if (sSearchStr == "")
        {
            if (getLang() == "fr")
                document.getElementById("txtSearch").value = "RECHERCHE";
            else
                document.getElementById("txtSearch").value = "SEARCH";
        }
    }
function PopulateSearchBox()
    {
        if (getLang() == "fr")
            document.getElementById("txtSearch").value = "RECHERCHE";
        else
            document.getElementById("txtSearch").value = "SEARCH";
    }
    
function ChangeScope(sScope)
    {
        document.getElementById("SearchScope").value=sScope;
    }

function getLang()
    {
//            var url = "" + window.location;
//            var urlparts = url.split('/');
        var lang = getURLPart(3); //urlparts[3];
        return lang;
    }
    
function getURLPart(num)
    {
        var url = "" + window.location;
        var urlparts = url.split('/');
        var part = urlparts[num];
        return part;
    }
    
function removeQueryString(strAddress)
    {
        var addressParts = strAddress.split('?');
        var addressNoQS = addressParts[0];
        return addressNoQS;
    }
    
function isInArray(arr, item)
    {
        var idx;
        var last = arr.length;
        for (var i=0; i < last; i++)
            {
                idx = (item == arr[i])?i:-1;
                if (-1 != idx) break;
            }
        //returns true if it is an array
        if (idx == -1)
            return false;
        else
            return true;
    }



function PerformLoad()
    {
       
    }

function WriteFlash(sFlashFilePath, iWidth, iHeight, sBGColor)
    {
        var MinFlashVersion = "6"; 
	    var so = new SWFObject(sFlashFilePath + "?detectflash=true", "SomeTitle", iWidth, iHeight, MinFlashVersion, sBGColor);
	    var LangSuffix;
	    if ('fr' != 'fr')
	        LangSuffix = 'English';
	    else
	        LangSuffix = 'French';
	    
	    document.write("<div id='flashcontent'>");
	    document.write("<div id='NoFlashContent' style='width:400px;margin-top:30px;margin-bottom:30px; margin-left:200px;border-style:solid;border-width:1px;text-align:center;vertical-align:middle;padding:10px;'>");
		document.write('<font size="3" face="verdana"><b>Flash Player 8.0 is required to view certain elements of this site!</b>');
		document.write('<br /><br /><a href=http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=' + LangSuffix + '><img src="/Images/get_flashplayer.gif" /><br />Click here to download Flash Player</a></font>');
	    document.write("</div>");
	    document.write("</div>");
	    //following line is a fix for Netscape for active scripting.
	    so.addParam('swliveconnect', 'true');
	    so.addParam('wmode', 'transparent');
	    
	    so.write("flashcontent");
	}