
/* tabbed menu @home page from cbc.ca */

var frontline = new Array ("tab-lt","tab-ft","tab-lc","tab-latest","tab-featured","tab-local");

function showTab(tg,at,tc,ln){
    ln.blur();
    $ = function(e){e = document.getElementById(e); return e;};
    for (i in tg) {$(tg[i]).className = $(tg[i]).className.replace(/active/,"taboff");}
    $(at).className = $(at).className.replace(/taboff/,"active");
    $(tc).className = $(tc).className.replace(/taboff/,"active");
}


/* clears form input fields */

function clearInput(fieldId) {
    // Pass this function the ID of a form field to have its contents erased on focus.
    if (!document.getElementById || !document.getElementById(fieldId)) {
        return;
    }
    document.getElementById(fieldId).onfocus = function() {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
    };
    document.getElementById(fieldId).onblur = function() {
        if (this.value == '') {
            this.value = this.defaultValue;
        }
    };
}

function checkFormField(formId,fieldId) {
    if (!document.getElementById || !document.getElementById(formId) || !document.getElementById(fieldId)) {
        return;
    }
    clearInput(fieldId);
    document.getElementById(formId).checkField = fieldId;
    document.getElementById(formId).onsubmit = function() {
        if (document.getElementById(this.checkField).value == document.getElementById(this.checkField).defaultValue) {
            return false;
        }
    };
}

window.onload = function() {
    checkFormField('signup','email')
    checkFormField('signup','zip')
    checkFormField('search','qsearch')
    checkFormField('getonmap', 'yourname')
    checkFormField('getonmap', 'youremail')
    checkFormField('getonmap', 'youraddr')
    checkFormField('getonmap', 'yourcity')
    checkFormField('getonmap', 'yourzip')
    checkFormField('getonmap', 'youtube')
    checkFormField('getonmap', 'yourimg')
    checkFormField('getonmap', 'yourstorytitle')
    checkFormField('getonmap', 'yourstory')
    checkFormField('search-theme-form', 'edit-search-theme-form-keys')  
	//checkFormField('node-form', 'edit-title')
    //checkFormField('node-form', 'edit-field-name-last-0-value')
    //checkFormField('node-form', 'edit-email-0-value')    
    //checkFormField('node-form', 'edit-field-name-last-0-value')
    //checkFormField('node-form', 'edit-locations-0-street')
    //checkFormField('node-form', 'edit-locations-0-additional')    
    //checkFormField('node-form', 'edit-locations-0-city')
    //checkFormField('node-form', 'edit-locations-0-province')
    //checkFormField('node-form', 'edit-locations-0-postal-code')    
    //checkFormField('node-form', 'edit-locations-0-country')
};


/* IE6 background image flicker bug fix */
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
