﻿function SetSiteParam(name, value)
{
    //get current cookie (if it exists)
    var cookieName = strCookiePrefix+name;
    var cookieID = readCookie(cookieName);
    if(cookieID != null)
    {
        //clean out the current cookie
        eraseCookie(cookieName);
    }       
    createCookie(cookieName,value);  
}

function GetSiteParam(name)
{
    //get current cookie (if it exists)
    var cookieName = strCookiePrefix+name;
    var cookieID = readCookie(cookieName);
    if(cookieID != null)
    {
        return cookieID;
    }       
    
    return "";
}

function SetSiteParameters()
{
    //determine what type of site we are on.
    if(
        location.href.toLowerCase().indexOf("http://mrprotocolsstaging.alphamedicadev.com") != -1 || 
        location.href.toLowerCase().indexOf("http://onlyforpreview.enhancedcme.com") != -1 ||
        location.href.toLowerCase().indexOf("http://staging.enhancedcme.com") != -1 ||
        location.href.toLowerCase().indexOf("http://enhancedcme.numediaprod.com") != -1
    )
    {
        //we are on the staging site.
        SetSiteParam('services_url', 'http://enhancedcme.numediaprod.com/Services');      
        SetSiteParam('site_url', 'http://enhancedcme.numediaprod.com');  
    }else if(location.href.toLowerCase().indexOf("http://localhost") != -1)
    {
        //we are on a dev machine
        SetSiteParam('services_url', 'http://localhost/ALPH_071206_Enterline_Web_Reg/');      
        SetSiteParam('site_url', 'http://localhost/ALPH_071206_Enterline_Web');      
    }else
    {
        //assume we are on the production server
        SetSiteParam('services_url', 'http://www.enhancedcme.com/Services');      
        SetSiteParam('site_url', 'http://www.enhancedcme.com');  
    }
}

var strCookiePrefix = 'ALPH_071206_Enterline_Web_SiteParam_';

