 /**
 * Created by IntelliJ IDEA.
 * User: Preeta
 * Date: Mar 5, 2008
 * Time: 10:41:19 AM
 */


function add_f_wwres_event_handlers() {
    toggleLinks();
    if (document.getElementById("cccForm") != null && document.getElementById("cccSelect") != null) {
        document.getElementById("cccForm").onsubmit = cccForm_onSubmit;
        document.getElementById("cccSelect").onchange = cccSelect_onChange;
    }
}
var obj=null;

//links View brand | View All starwood  handling logic
function toggleLinks() {
    if (document.location.href.search('brandCode=CORP') > 0)
    {
        obj = document.getElementById('brandShowALL');
        if (obj == null)
            obj = document.getElementById('countryShowALL')
        if (obj != null)
        {
            var href = obj.getAttribute("href");
            var onclick = obj.getAttribute("onclick");

            obj.setAttribute('onclick', "void(0);");

            obj.removeAttribute('href');
            toDefaultLinkColor();
        }
    }
    if (document.location.href.search('brandCode=CORP') < 0)
    {
        obj = document.getElementById('brandShow');
        if (obj == null)
            obj = document.getElementById('countryShow')

        if (obj != null)
        {
            var href = obj.getAttribute("href");
            var onclick = obj.getAttribute("onclick");

            obj.setAttribute('onclick', "void(0);");

            obj.removeAttribute('href');
            toDefaultLinkColor();
        }
    }
    if (document.location.href.search('country=') < 0)
    {
        if (document.getElementById("conName") != null)
            document.getElementById("conName").className = "divHide";
    }
    if (document.location.href.search('country=') > 0) {
        if (document.getElementById("conName") != null)
            document.getElementById('conName').className = "countryName";
    }
}
function noUnderLine(){
    document.getElementById(obj.id).className="noUnderLine";
    }
 
// changes the link to color specific to the brand and also handles the on hover event.
function toDefaultLinkColor() {
   document.getElementById(obj.id).onmouseover=noUnderLine;
    obj.style.fontWeight='normal';
    if (document.location.href.search('westin') > 0) {
        obj.style.color = "#4d4d4d";
    }
    if (document.location.href.search('fourpoints') > 0) {
        obj.style.color = "#000000";
    }
    if (document.location.href.search('sheraton') > 0) {
        obj.style.color = "#653C33";
    }
    if (document.location.href.search('whotels') > 0) {
        obj.style.color = "#1f1f1f";
    }
    if (document.location.href.search('alofthotels') > 0) {
        obj.style.color = "#666666";
    }
    if (document.location.href.search('element') > 0) {
        obj.style.color = "#72756d";
    }
    if (document.location.href.search('lemeridien') > 0) {
        obj.style.color = "#000000";
    }
    if (document.location.href.search('luxury') > 0) {
        obj.style.color = "#4d4d4d";
    }
    if (document.location.href.search('stregis') > 0) {
        obj.style.color = "#777777";
    }
}

function cccForm_onSubmit() {
    if (document.custContactForm.custContactSelect.value.length > 0) {
        document.location = document.custContactForm.custContactSelect.value;
        return false;
    }
}

function cccSelect_onChange() {
    if (document.custContactForm.custContactSelect.value.length > 0) {
        document.location = document.custContactForm.custContactSelect.value;
    }
}

// Safely adds to the document's onLoad event.
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}
addLoadEvent(add_f_wwres_event_handlers);