﻿$(document).ready(function(){
    SetBackgroundImages();
    
    /* set focus on first control with tabindex 1 */
      if (typeof($("input:text:first")) == "defined")
      {
        $("input:text:first").focus();
      }
      
})


/* 
 * open the new window according to body heights and widths dimension.
 * TODO: make it work on IE.
 */
function SetWindowDimension(){
    if (document.getElementsByTagName) {
        var bodyElem = document.getElementsByTagName('body')[0];
        if (typeof(window.innerWidth) == 'number') {
            //Non - IE 
            window.innerWidth = bodyElem.clientWidth ;
            window.innerHeight = bodyElem.clientHeight;
        }
        //document.documentElement.clientWidth = bodyElem.clientWidth;
        //window.resizeTo(bodyElem.clientWidth, bodyElem.clientHeight);
    }
    
}

/* clean error messages from */

function cleanErrorMessages(){
    if (document.getElementsByTagName) {
        var ems = document.getElementsByTagName("em");
        for (i = 0; i < ems.length; i++) {
            if (ems[i].style.color == 'red') 
                 ems[i].innerHTML = '&nbsp;'
        }
        
    }
}

/* ----------------------- global form functions -------------------- */

function closeWindow(){
    window.open('', '_parent', '');    
    window.close();         
}


/* ----------------------- forms functions -------------------- */

/*------: nokia/join.aspx :------*/
$(document).ready(function(){
    $('#slsMobileModel').bind("change", function (e) {
    //check if selected item is the last item, meanning other
    alert("test");
        if ($("#ctl00_formBody_slsMobileModel option:selected").text() == $("#ctl00_formBody_slsMobileModel option:last-child").text()) {
            $("#ctl00_txtMobileModelOther:parent").css({ visibility:"visible"})
        }
        
        else {
           $("#ctl00_txtMobileModelOther:parent").css({ visibility:"hidden"})
        }
    });
});



