/*
        Author  :   Anand Kumar Sharma
        Date    :   27-10-2009
*/


jQuery.fn.fadeToggle = function(s, fn)
{
    return (this.is(":visible"))
        ? this.fadeOut(s, fn)
        : this.fadeIn(s, fn);
};

$.style = function (selector, options)
{
     options = $.extend ({type: 'text/css', media: 'all'}, options);
     var sheet = $.style.sheets[options.media];
     if (!sheet)
     {
         var style = $(document.createElement('style')).attr(options).appendTo('head')[0]; 
         if (style.styleSheet)
         {
             // IE
             $.style.sheets[options.media] = sheet = style.styleSheet;
         }else if (style.sheet)
         {
             // Firefox
             $.style.sheets[options.media] = sheet = style.sheet;
             sheet.rules = []; // lets us use the same rules array
         }
     }
     if (sheet.rules [selector]) return $(sheet.rules [selector]);
     if (sheet.cssRules)
     {
         // Firefox
         sheet.insertRule(selector+' {}',sheet.cssRules.length);
         return $(sheet.rules[selector] = sheet.cssRules[sheet.cssRules.length-1]);
     }else
     {
         // IE
         sheet.addRule(selector, null);
         return $(sheet.rules[selector] = sheet.rules[sheet.rules.length-1]);
     }      
};
$.style.sheets = [];




//Add context menu to body. And add click event to anchor tags.===========================
$(document).ready(function() {


        //for msn

        $('a[name=msn]').live('dblclick', function (e) {
            e.preventDefault();
            ShowIM('yes');
        });

        $('a[name=msn]').live('click', function (e) {
            e.preventDefault();
            return false;
        });
		
		$('#btnSignUpNew').live('click', function()
		{
			window.location.href = "http://www.electionmall.com/microsoft/index.aspx";
		});

		//for user profile======================

    $('.userPicFrame').live('click', function () {

        $(this).parent().css("z-index", jqWindowsEngineZIndex++);
        $.ajax(
            {
                type: "POST",
                url: 'MyHandleRequest.aspx',  // Send the login info to this page
                data: { msg: 'up' },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                async: true,    //default is asynchronous request can set to false
                cache: false,
                beforeSend: function () {

                },

                success: function (data) {
                    $('.userProfileWrapper').remove();
                    $('form').append(data);
                    $('.userProfileWrapper').draggable({ containment: 'document', scroll: false }).css("z-index", jqWindowsEngineZIndex++); ;
                    var profileBorder = RUZEE.ShadedBorder.create({ corner: 8, shadow: 16 });
                    profileBorder.render('userProfileWrapper');
                    //profileBorder.render('welcomeUserWrapper');
                }
            }
          );
    });

    $('.userProfileClose').live('click', function () {
        $(this).parent().remove();
    });

    $('.userProfileWrapper').live('click', function () {
        $(this).css("z-index", jqWindowsEngineZIndex++); ;
    });

    $('#btnAlreadyLinked').live('click', function () {
        $(this).parent().parent().remove();
        $('.userProfileList').fadeIn('slow');
    });

    $('a[name=snsprofile]').live('click', function (e) {

        e.preventDefault();
        $toolButton = $('<div class="toolButton">SNS Manager</div>');
        AddToTaskBar($toolButton);
        $toolButton.newWindow(
		                        {
		                            windowTitle: 'SNS Manager',
		                            iframeURL: 'MyHandleRequest.aspx',
		                            width: 800,
		                            height: 740,
		                            isAjax: true,
		                            sendData: 'snsindex.aspx',
		                            isFull: true,
		                            isBrowser: true,
		                            maximizeButton: true,
		                            isResizable: true
		                        });
        $('.userProfileWrapper').remove();
        return false;
    });

    $('#btnProfileImgSave').live('click', function () {
        var ctlImg = '';
        var flagImage = false;
        $('input[name=userProfilePic]').each(function () {
            if (this.checked) {
                flagImage = true;
                ctlImg = this.getAttribute('rel');
            }
        });
        if (flagImage) {

            $.ajax(
            {
                type: "POST",
                url: 'MyHandleRequest.aspx?psave=1',  // Send the login info to this page
                data: { msg: ctlImg },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                async: true,    //default is asynchronous request can set to false
                cache: false,
                beforeSend: function () {
                    $('.userProfileWrapper').showoverlay({ imgPath: 'JSOS/elapsor.gif' });
                },
                success: function (data) {
                    if (data == 'success') {
                        $('.userPicFrame').children('img').attr('src', ctlImg);
                        jAlert('Profile image successfully changed', 'Alert Dialog', function () { $('.userProfileWrapper').remove(); });
                    }
                    else
                        jAlert('There is some problem, please try later!!!', 'Alert Dialog', function () { });

                    $('.userProfileWrapper').hideoverlay();
                   
                }
            }
            );
        }
        else
        { jAlert('Please select a profile image!!!', 'Alert Dialog', function () { }); }

    });

    //======================================
		
        //


        if (readCookie('bgColor')!=null)
	    {
		    ChangeBGColor(readCookie('bgColor'));
	    }
	    if (readCookie('bgImage')!=null)
	    {
		    ChangeBGImage(readCookie('bgImage'));
	    }
	    if (readCookie('themeColor')!=null)
	    {
		    ChangeThemeColor(readCookie('themeColor'));
	    }
	    if (readCookie('themeTextColor')!=null)
	    {
		    ChangeThemeTextColor(readCookie('themeTextColor'));
	    }
	    
	    //============= Payment options =============================

        $('div[name=pOption]').live('mousemove',
            
            function()
            {
                $('.leftColumn').html('').html($(this).attr('rel'));
            }
        );
        
        $('div[name=pOption]').live('mouseout',
            
            function()
            {
                $('.leftColumn').html('').html($('.leftColumn').attr('rel'));
            }
        );
       
            
        
        $('div[name=pOption]').live('click',
            
            function()
            {
                var url = $(this).attr('val');
                var val = $(this).attr('max');
                var isB = false;
                var isF = false;
                var isR = false;
                var isM = false;
                if(val === '1')
                {
                    isB = true;
                    isF = true;
                    isR = true;
                    isM = true;
                }
                
                if(url === 'fax')
                {
                    var murl = $(this).attr('uvr');
                    setTimeout(function(){tryToDownload(murl);},500);
                }
                else if(url === 'phone')
                {
                }
                else
                {
                    $toolButton = $('<div class="toolButton">' + this.title + '</div>');
                                        
                    AddToTaskBar($toolButton);
                    $toolButton.newWindow(
                    {
                        windowTitle: this.title,
                        iframeURL: $(this).attr('val'),
                        width: parseInt(950),
                        height: parseInt(650),
                        isElectionmall:false,
                        isAjax:false,
                        sendData:'A1',
                        isFull:isF,
                        isBrowser:isB,
                        maximizeButton:isM,
                        isResizable:isR,
                        posy:25,
                        isScroll:true
                    });
                }
            }
        );

//===========================================================
        /*$('body').contextMenu('DeskTopMenu', 
        {
		    bindings: 
		    {
			    'ShowDesktop': function(t) {
				    $('.toolButton.active').click();
			    },
			    'Properties': function(t) 
			    {
			        $('body').find('#_color_selector').each(function()
			        {
			            $(this).remove();
			        });
				    $toolButton = $('<div class="toolButton">Properties</div>');
				    AddToTaskBar($toolButton);
				    $toolButton.newWindow({
					    windowTitle:"Properties",
					    domContent: $('#PropertiesContent div'),
					    width:300,
					    height:250
				    });
				    $('div.window-container .bgColorpicker').colorPicker();
				    $('div.window-container .themeColorpicker').colorPicker();
				    $('div.window-container .themeTextColorpicker').colorPicker();
				    $('.bgColorpicker').change(function(){ChangeBGColor($(this).val());});
				    $('.themeColorpicker').change(function(){ChangeThemeColor($(this).val());});
				    $('.themeTextColorpicker').change(function(){ChangeThemeTextColor($(this).val());});
				    $('.bgImagepicker').change(function(){ChangeBGImage($(this).val());});
			    }
		    }
	    });*/
	    
	    $('a[name=modal]').live( "click", function(e)
		    {
		        
	            e.preventDefault();
		        //Get id of div to show.
		        var settings = $(this).attr('rel');
		        var id = $(this).attr('id');
		        var href = $(this).attr('href');
		        var title = $(this).attr('title');
		        var height=0;
		        var width = 0;
		        var setAjax = false;
		        var isSetElectionmall = false;
		        var isFull = false;
		        var isBrowser = false;
		        var isResize = true;
		        var isMaximizeButton=true;
        		if(!validate(title))
                {
                    return;
                }
		        if(settings.search(/iframe|ajax|domcontent|content|execute|redirect/i) != -1)
		        {
		            var params = settings.split('|');
        		    
		            if(params.length > 1)
		            {
		                if(params[1].search(/x/i) != -1)
		                {
		                    var dims = params[1].split('x');
		                    width = dims[0] > 0 ? dims[0] : 780;
		                    height = dims[1] > 0 ? dims[1] : 400;
		                }
		            }
		            else
		            {
		                width = 780;
		                height = 400;
		            }
		            
		            if(settings.search(/browser/i) != -1)
		            {
		                isBrowser = true;
		            }
        		    
		            if(params.length > 2)
		            {
		                if(params[2].search(/ajax/i) != -1)
		                {
		                    setAjax = true;
		                }
		                if(params[2].search(/electionmall/i) != -1)
		                {
		                    isSetElectionmall = true;
		                }
		                if(params[2].search(/full/i) != -1)
		                {
		                    isFull = true;
		                }
		                if(params.length > 3)
		                {
		                    if(params[3].search(/full/i) != -1)
		                    {
		                        isFull = true;
		                    }
		                }
		                
		            }
		            
		            if($(this).attr('max') != null && $(this).attr('max') == "0")
		            {   
		                isResize = false;
		                isMaximizeButton=false;
		            }
		                
		            
        		    
		            switch(params[0])
                    {
                        case 'iframe':
                                    if($(this).attr('val') == 'close')
                                        $(this).parent().parent().parent().remove();
                                    if($(this).attr('val') == 'meclose')
                                        $(this).parent().parent().remove();
                                    $toolButton = $('<div class="toolButton">' + title + '</div>');
                                    
		                            AddToTaskBar($toolButton);
		                            $toolButton.newWindow(
		                            {
			                            windowTitle: title,
			                            iframeURL: href,
			                            width: parseInt(width),
			                            height: parseInt(height),
			                            isElectionmall:isSetElectionmall,
			                            isAjax:setAjax,
			                            sendData:id,
			                            isFull:isFull,
			                            isBrowser:isBrowser,
			                            maximizeButton:isMaximizeButton,
			                            isResizable:isResize
		                            });
		                            
    		                        
                          break;
                        case 'ajax':
                                    $toolButton = $('<div class="toolButton">' + title + '</div>');
		                            AddToTaskBar($toolButton);
		                            $toolButton.newWindow(
		                            {
			                            windowTitle: title,
			                            ajaxURL: href,
			                            width: parseInt(width),
			                            height: parseInt(height),
			                            isAjax:setAjax,
			                            maximizeButton:isMaximizeButton,
			                            isResizable:isResize
		                            });
    		                        
                          break;
                        case 'domcontent':
                                    $toolButton = $('<div class="toolButton">' + title + '</div>');
		                            AddToTaskBar($toolButton);
		                            $toolButton.newWindow(
		                            {
			                            windowTitle: title,
			                            domContent: href,
			                            width: parseInt(width),
			                            height: parseInt(height),
			                            isAjax:setAjax,
			                            sendData:id,
			                            maximizeButton:isMaximizeButton,
			                            isResizable:isResize
		                            });
    		                        
                          break;
                          case 'execute':
									$('#spnErrorLogin').html('');
                                    var objExe = $(this).parent().parent();
                                    var ele = document.getElementsByName(title);
                                    var dtSend = title + '_' + campaign + '#';
                                    for(j=0; j < ele.length; j++)
                                    {
                                        if(ele[j].name == title)
                                        {
                                            if(ele[j].type == 'text' || ele[j].type == 'password' || ele[j].type == 'textarea')
                                            {
                                                dtSend += ele[j].id + '~' + ele[j].value + "#";
                                            }
                                            if(ele[j].type == 'checkbox')
                                            {
                                                if(ele[j].checked)
                                                    dtSend += ele[j].type + '~' + ele[j].value + "#";
                                            }
                                            if(ele[j].type == 'select-one')
                                            {
                                                    dtSend += ele[j].id + '~' + ele[j].options[ele[j].selectedIndex].value + "#";
                                            }
                                            
                                        }
                                    }
                                    $.ajax(
                                    {  
                                        type: "POST",
                                        url: href,  // Send the login info to this page
                                        data: { msg : dtSend },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                                        async: true,    //default is asynchronous request can set to false
                                        cache: false,
                                        beforeSend:function()
                                        {
                                           $('#imgLogin').show();
                                        },
                                        success: function(data)
                                        {  
                                           $('#imgLogin').hide();
                                            if(data != '') // LOGIN OK?
                                            {  
                                                var param = data.split('~');
                                                var login_response='';
                                                if(param[0] == 'Error')
                                                {
                                                    login_response = param[1];
                                                    $('#spnErrorLogin').html(login_response).show(); //blank spnError span
                                                }
                                                else if(param[0] == 'Success')
                                                {
                                                    $('body').append(param[1] + param[2]);
                                                    //Show clock=============================================
                                                   
		                                            $('#dvClockLocal').everyTime(1000, function() 
	                                                {
                                                       $('#dvClockLocal').html(getClockTime());
                                                       $('.clockWrapper').show();
                                                        
                                                    });
                                                    AddEventForClock();
                                                    
                                                    $('#imgBeta').remove();
                                                    $('#Start').oneTime(100, function() 
                                                    {
                                                        //call menu function.
                                                        $("ul#menubar").simplemenu();
                                                        $('.mysticky').stickynote({container:'sticky', assignData:'none', type:'user'});
                                                        $('#eventCalenderMonthly').eventCalendar({type:'month'});
                                                        $('#eventCalenderWeekly').eventCalendar({type:'week'});
                                                        $('#eventCalenderDaily').eventCalendar({type:'daily'});
					                                    $.fn.EasyWidgets({callbacks : {onChangePositions : function(str){SaveWidget(str);}}});
                                                        $('#news').innerfade(
                                                        {
						                                    animationtype: 'slide',
						                                    speed: 1000,
						                                    timeout: 3000,
						                                    type: 'sequence',
						                                    containerheight: '200px'
					                                    });
					                                    $('.box').live("click",
                                                            function()
                                                            {
                                                                 $('.selecbox').slideToggle(500);
                                                            }
                                                        );
                                                        //script for welcome window
                                                        ShowWelComeMsg();
                                                        AddEventForMenu();
                                                        AddEventForWeather(); //Removing weather api
                                                        StartMenuOver();
                                                        StartSlider();
														 $('#welcomeUserWrapper').draggable({ containment: 'document', scroll: false });
                                                        //ShowIM('yes');
   		                                                //====================================================================
                                                        var opts = { align: 'bottom', size: 50, labels: true, source: function(i){ return this.src.replace(/gif$/,'png'); }};
                                                        $('#fishEyeMenu').jqDock(opts);
                                                        
				                                    });

                                                    //=============================================
                                                    //if it is modal window.
                                                    if(objExe.parent('.window-content').length > 0)
                                                    {
                                                        $toolButton = objExe.parent().parent().data("toolButton");
                                                        $toolButton.remove();
                                                        objExe.parent().parent().remove();
                                                    }
                                                    else//if it is from login page.
                                                    {
                                                        $('#loginWrapper').remove();
                                                        $('body').removeClass('bodyLogin');
                                                        $('body').addClass('mainBody');
                                                    }
                                                    
                                                    //show welcome msg==========================
                                                    
                                                    
                                                    //===========================================
                                                    
                                                }
                                                else if(param[0] == 'message')
                                                {
                                                    login_response = param[1];
                                                    //alert(login_response);
                                                    jAlert(login_response, 'Alert Dialog', function(r) {if(r==true){$("#box").fadeOut(300);}});                                                    
                                                    $toolButton = objExe.parent().parent().data("toolButton");
                                                    $toolButton.remove();
                                                    objExe.parent().parent().remove(); //blank spnError span
                                                }
                                                else if(param[0] == 'redirect')
                                                {
                                                    window.location.assign(param[1]);
                                                }
                                            }
                                        }
                                    });  
                          break;
                        case 'redirect':
                        if(id == 'lo')
                        {
                            MyBulletinBoard.logOut();
                        }
                          $.ajax(
                            {  
                                type: "POST",
                                url: href,  // Send the login info to this page
                                data: { msg : id },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                                async: true,    //default is asynchronous request can set to false
                                cache: false,
                                success: function(data)
                                {  
                                    //objExe[0].hideElapsor();
                                    //Get data and set data to iframe src attribute.
                                    //$iframe[0].src = data;
                                    var dataFinal = data.split('~');
                                    if(dataFinal.length > 1)
                                    {
                                        if(dataFinal[0] == 'redirect')
                                        {
                                            window.location.assign(dataFinal[1]);
                                        }
                                    }
                                }
                            });  
                          break;
                        default:
                            $toolButton = $('<div class="toolButton">' + title + '</div>');
		                    AddToTaskBar($toolButton)
		                    $toolButton.newWindow({
			                    windowTitle: title,
			                    content: href,
			                    width: parseInt(width),
			                    height: parseInt(height),
                                maximizeButton:isMaximizeButton,
                                isResizable:isResize
		                    });
                          break;
                    }
		        }
    		
	        });
	        
	         $('#txtPwd').live("keyup",function(e){
		        
                GetKeyCode(e,'btnLogin');
	        });
            
            $('#Start, #StartMenu, .startBtn').live("click",function(){
		        $('#StartMenu').slideToggle();
                
	        });
	        
	        
	        $('.closeWindow').live('click',function()
              {
                    $(this).parent().parent().remove();
              });
	        
	        //Removing weather api
	        $('.showweather').live("mouseout",function(){
		        $('.weathertip').each(function()
	            {
	                $(this).remove();
	            });
		    
	        });
	        
	        
	        //=========== For townhall ================
	        
	        $('a[name=dbTwonhall]').live("dblclick",function(e){
		        e.preventDefault();
		        
		        $.ajax(
                            {  
                                type: "POST",
                                url: "MyHandleRequest.aspx",   // Send the login info to this page
                                data: { msg : 'townhall' },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                                async: true,    //default is asynchronous request can set to false
                                cache: false,
                                beforeSend:function()
                                {
                                    
                                },
                                success: function(data)
                                { 
                                  var strResult = data.split('~');
                                  if(strResult[0] == 'redirect')
                                  {
                                    window.location.assign(strResult[1]);
                                    return false;
                                  }
                                   $("body").append(strResult[1]);
                                }
                            }); 
	        });
	        
	        $('a[name=dbTwonhall]').live("click",function(e){
		       e.preventDefault();
		    
	        });
	        
	        $('#dvCloseBtn').live("click",function(e){
		       e.preventDefault();
		       $(this).parent().remove();
	        });
	        
	         $('#btnTownhall').live("click",function(e){
		       e.preventDefault();
		       $('#dvMessageBinder').html('');
		       var flag = false;
		       $('input[rel=townhall]').each(function()
		       {
		        
		            if(this.value == '')
		            {
		                flag = true;
		                $('#dvMessageBinder').html('<div class=\"errorIcon\"></div><p class=\"redErrorTxt\">' + this.title + ' cannot be empty.</p>');
		                return false;
		            }
		       });
		       if(!flag)
		       {
		            $('#dvMessageBinder').html('<div class=\"errorIcon\"></div><p class=\"redErrorTxt\">Login Failed.</p>');
		       }
	        });
	        
	        //===========================================
	        
	    
	        $('body').live("click",function(){
		        $('#StartMenu').hide();
		        //if($('.startBtn').attr('val') == 'click')
		            //$('.startBtn').attr('val','').css('background','url(images/startIconOver.png)');
    		    
	        });
	        
	        $('a[name=dbmodal]').live( "click", function(e)
		    {
		        e.preventDefault();
		        
		        return false;
		        
		    });
		    

   /************************************** Get Html For a Forgot Password **************************************************/
		    
		    $('a[name=fgtpwd]').live( "click", function(e)
		    {
		      e.preventDefault();//to stop deafault functionality of anchor tag
		       var dtSend='fpwd';
		        $.ajax(
                            {  
                                type: "POST",
                                url: "MyHandleRequest.aspx",   // Send the login info to this page
                                data: { msg : dtSend },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                                async: true,    //default is asynchronous request can set to false
                                cache: false,
                                beforeSend:function()
                                {
                                 
                                },
                                success: function(data)
                                { 
                                  var strResult = data.split('~');
                                  if(strResult[0] == 'redirect')
                                  {
                                    window.location.assign(strResult[1]);
                                    return false;
                                  }
                                   $("body").append(strResult[1]);
                                   ChangeFocusText();
                                }
                            }); 
		        return false;
		        
		    });
		     /******************************************** Till Here ********************************************/
		    
		    /******************************************** Close Forgot Password *********************************/
		    $('a[name=fgtpwdclose]').live( "click", function(e)
		    {
		        e.preventDefault();
		        $('#dvForgotPassword').remove();
		        return false;
		    });
		    
		    /******************************************** Till Here ********************************************/
		    
		    /*********************Function For Reminder Later***************************************************/
		    
		    $('a[name=remindLater]').live( "click", function(e)
		    {
		        e.preventDefault();
		        $(this).parent().parent().remove();
		        return false;
		        
		    });
		    
		    $('a[name=linkEmtProd]').live( "click", function(e)
		    {
		        e.preventDefault();
		        var settings = $(this).attr('rel');
		        var id = $(this).attr('id');
		        var href = $(this).attr('href');
		        var title = $(this).attr('title');
		        var height=0;
		        var width = 0;
		        var setAjax = true;
		        var isResize = false;
		        var isMaximizeButton=false;
	            var params = settings.split('|');
    		    
	            if(params.length > 1)
	            {
	                if(params[1].search(/x/i) != -1)
	                {
	                    var dims = params[1].split('x');
	                    width = dims[0] > 0 ? dims[0] : 780;
	                    height = dims[1] > 0 ? dims[1] : 400;
	                }
	            }
	            else
	            {
	                width = 780;
	                height = 400;
	            }
	            $toolButton = $('<div class="toolButton">' + title + '</div>');
                                    
                AddToTaskBar($toolButton);
                $toolButton.newWindow(
                {
                    windowTitle: title,
                    iframeURL: href,
                    width: parseInt(width),
                    height: parseInt(height),
                    isAjax:setAjax,
                    sendData:id,
                    maximizeButton:isMaximizeButton,
                    isResizable:isResize
                });
		                            
		        $(this).parent().parent().remove();
		        return false;
		        
		    });
		    
		    /************************************************* Till Here *****************************************/
		  
		    /******************************************** Send Functionality  For ForGot Password ****************/
		    $('a[name=fgtcall]').live( "click", function(e)
		    {
		        e.preventDefault();
		        //call forgot password functionality function
		        ForgotPassword($(this).parent().find('#txtuname').val());
		        return false;
		        
		    });
		    
		     /******************************************************** Till Here *************************************************/
		   
		     /*************** Get Html For a Change Password When User Login And He Got Auto Generated Password From Forgot Password Link *****************************************/
		   
		    $('a[name=resetpwd]').live( "click", function(e)
		    {
		      e.preventDefault();//to stop deafault functionality of anchor tag
		       var dtSend='rpwd';
		        $.ajax(
                            {  
                                type: "POST",
                                url: "MyHandleRequest.aspx",   // Send the login info to this page
                                data: { msg : dtSend },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                                async: true,    //default is asynchronous request can set to false
                                cache: false,
                                beforeSend:function()
                                {
                                 
                                },
                                success: function(data)
                                {
                                  var strResult = data.split('~');
                                  if(strResult[0] == 'redirect')
                                  {
                                    window.location.assign(strResult[1]);
                                    return false;
                                  }
                                  // var _div_ForgotPassword = $(document.createElement('div'));
                                  $("body").append(strResult[1]);
                                  $('.changePasswordWrapper').css('top','20%').css('left','20%');
                                  //ChangeFocusText();
                                  $('#welcomeWrapper').remove();//close welcome window when click chnage login button
                                }
                                
                            }); 
		        return false;
		        
		    });
		    
		     /********************************** Till Here *************************************************/
		    
		 
		     /************************* Close Change Password which got by forget password  ****************/
		    $('a[name=closechngpwd]').live( "click", function(e)
		    {
		        e.preventDefault();
		        $('.changePasswordWrapper').remove();
		        return false;
		    });
		    
		     /**************** Change Auto Generated Password Which Got By Forget Password *****************/
		   $('a[name=submitchngpwd]').live( "click", function(e)
		    {
		        e.preventDefault();
		        //call change password functionality function
		        ChangePassword($(this).parent().parent().find('#newPassword').val());
		        return false;
		    });
		    
		    /********************************************** Till Here **********************************************/
		    //Removing weather api
		    $('img[name=weatherSet],a[name=weatherSet]').live( "click", function(e)
		    {
		        e.preventDefault();
		        if($('#hdnAddWeather').val() != '2')
		        {
		            //alert('You do not have permission to update weather');
		            jAlert('You do not have permission to update weather.', 'Alert Dialog',function(r){});
		            return false;
		        }
		        var dtWthSend = '';
		        var wthType = '';
		        var wthUrl = 'MyHandleRequest.aspx';
		        var obj = this;
		        if(this.id == 'weatherSettings')
		        {
		            dtWthSend = 'addWeather';
		            if($('.dvWeatherUpdater').length > 0)
		                return false;
		            wthType = '1';
		        }
		        else
		        {
		            dtWthSend = 'updateWeather';
		            var el = document.getElementsByName(this.name);
		            for(i=0; i<el.length; i++)
		            {
		                if(el[i].type == 'text')
		                {
						if(el[i].value.length > 5 || el[i].value.length < 5 )
						{
								jAlert('Zip/Postal code must be 5 char long.', 'Alert Dialog',function(r){});
								
								return false;
							}
		                    wthUrl += '?wcity=' + (el[i].value == '' ? '20007' : el[i].value);
		                }
		            }
		            
		            wthType = '2';
		        }
		        
		        $.ajax(
                {  
                    type: "POST",
                    url: wthUrl,  // Send the login info to this page
                    data: { msg : dtWthSend },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                    async: true,    //default is asynchronous request can set to false
                    cache: false,
                    beforeSend:function()
                    {
                        $(obj).parent().parent().showoverlay();
                    },
                    success: function(data)
                    {  
                        var strResult = data.split('~');
                          if(strResult[0] == 'redirect')
                          {
                            window.location.assign(strResult[1]);
                            return false;
                          }
                        if(wthType == '1')
                        {
                            $('body').append(strResult[1]);
                            $('.dvWeatherUpdater').css("z-index",jqWindowsEngineZIndex++).draggable({containment:'document',scroll: false});
                       }
                        else
                        {
                            if(wthType == '2')
                                $('.dvWeatherUpdater').remove();
                            $('.dvWeather').remove();
                            $('body').append(strResult[1]);
                            AddEventForWeather();
                        }
                        $(obj).parent().parent().hideoverlay();
                       
                    }
                });  
		        return false;
		        
		    });
		    
		    $('div[name=closebtn]').live('click',function()
		    {
		        $('.' + $(this).attr('rel')).remove();
		    });
		    
	        
	        
	        $('a[name=tsmodal]').live( "click", function(e)
		    {
		        e.preventDefault();
		        var sendData = document.getElementById('search_box').value;
		        if(sendData == '')
		            sendData = 'politics';
		        
                $toolButton = $('<div class="toolButton">' + this.title + '</div>');
                AddToTaskBar($toolButton);
                $toolButton.newWindow(
                {
                    windowTitle: this.title,
                    iframeURL: this.href + '?search=' + sendData,
                    width: 760,
                    height: 400,
                    isAjax:false,
                    sendData:'A1',
                    isFull:true,
                    isBrowser:true
                });
                
                if($(this).attr('val') == 'close')
		        {
                    var $win = $(this).parent().parent().parent().parent().parent().parent().parent();
                    $toolButton = $win.data("toolButton");
                    $toolButton.remove();
                    $win.remove();
                }
		        return false;
		        
		    });
	        
	        $('a[name=dbmodal]').live( "dblclick", function(e)
		    {
		        
	            e.preventDefault();
		        //Get id of div to show.
		        var settings = $(this).attr('rel');
		        var id = $(this).attr('id');
		        var href = $(this).attr('href');
		        var title = $(this).attr('title');
		        var height=0;
		        var width = 0;
		        var setAjax = false;
		        var isSetElectionmall = false;
		        var isFull = false;
		        var isBrowser = false;
		        var isMaximizeButton = false;
			    var isResize = false;
		        if(settings.search(/iframe|ajax|domcontent|content|execute|redirect/i) != -1)
		        {
		            var params = settings.split('|');
        		    
		            if(params.length > 1)
		            {
		                if(params[1].search(/x/i) != -1)
		                {
		                    var dims = params[1].split('x');
		                    width = dims[0] > 0 ? dims[0] : 780;
		                    height = dims[1] > 0 ? dims[1] : 400;
		                }
		            }
		            else
		            {
		                width = 780;
		                height = 400;
		            }
        		    
        		    if(settings.search(/browser/i) != -1)
		            {
		                isBrowser = true;
		            }
        		    
		            if(params.length > 2)
		            {
		                if(params[2].search(/ajax/i) != -1)
		                {
		                    setAjax = true;
		                }
		                if(params[2].search(/electionmall/i) != -1)
		                {
		                    isSetElectionmall = true;
		                }
		                if(params.length > 3)
		                {
		                    if(params[3].search(/full/i) != -1)
		                    {
		                        isFull = true;
		                    }
		                }
		            }
        		    
		            switch(params[0])
                    {
                        case 'iframe':
                                    if($(this).attr('val') == 'close')
                                        $(this).parent().parent().parent().remove();
                                    $toolButton = $('<div class="toolButton">' + title + '</div>');
		                            AddToTaskBar($toolButton);
		                            $toolButton.newWindow(
		                            {
			                            windowTitle: title,
			                            iframeURL: href,
			                            width: parseInt(width),
			                            height: parseInt(height),
			                            isElectionmall:isSetElectionmall,
			                            isAjax:setAjax,
			                            sendData:id,
			                            isFull:isFull,
			                            isBrowser:isBrowser,
			                            maximizeButton:isMaximizeButton,
			                            isResizable:isResize
			                            
		                            });
    		                        
                          break;
                        case 'ajax':
                                    $toolButton = $('<div class="toolButton">' + title + '</div>');
		                            AddToTaskBar($toolButton);
		                            $toolButton.newWindow(
		                            {
			                            windowTitle: title,
			                            ajaxURL: href,
			                            width: parseInt(width),
			                            height: parseInt(height),
			                            isAjax:setAjax
		                            });
    		                        
                          break;
                        case 'domcontent':
                                    $toolButton = $('<div class="toolButton">' + title + '</div>');
		                            AddToTaskBar($toolButton);
		                            $toolButton.newWindow(
		                            {
			                            windowTitle: title,
			                            domContent: href,
			                            width: parseInt(width),
			                            height: parseInt(height),
			                            isAjax:setAjax,
			                            sendData:id
		                            });
    		                        
                          break;
                        default:
                            $toolButton = $('<div class="toolButton">' + title + '</div>');
		                    AddToTaskBar($toolButton);
		                    $toolButton.newWindow({
			                    windowTitle: title,
			                    content: href,
			                    width: parseInt(width),
			                    height: parseInt(height)
		                    });
    		                
                          break;
                    }
		        }
		        return false;
    		
	        });
   
	        
        
});
//=======================================================

function StartSlider()
{
    $('a[name=btnSlide]').live("click",
	function()
	{
		
		var ctrl = '';
		var flag = false;
		
		var setFocus = function($obj)
        {
            $obj.css("z-index",jqWindowsEngineZIndex++);
        }
		
		if($(this).attr('val') == 'click')
		{
		    $('.sliderContentWrapper').animate({ width: "hide" }, "normal");
			$('.sliderButtonWrapper').animate({ right: "0px" }, "fast");
			$('.sliderContentWrapper').attr('rel','');
			$('img[alt=over]').hide();
			$('img[alt=normal]').show();
			$('a[name=btnSlide]').attr('val','');
			$('#btnSliderClose').hide();
		}
		else
		{
		    //pick machine date time
		   

//Comented on 13aug
//		    var now=new Date();
//		    var myString=now.toLocaleTimeString();
//         // var myString="1:2:3AM";
//            var mySplitResult = myString.split(":");
//            var time1=mySplitResult[0];//hh
//            var time2=mySplitResult[1];//min
//            var ampm=mySplitResult[2];//sec with space am pm
//            var time3=ampm.split(" ");
//            var time4=time3[1]; //am 0r pm
//            var varmachinetime=time1+":"+time2+" "+time4;
                        
		  //Comented on 13aug Till Here
		  
		  var mydate = new Date();
          var time1 = mydate.getHours();
          var time2 = mydate.getMinutes();
          //var ss = mydate.getSeconds()
		  var varmachinetime=time1+":"+time2;
		  
		  
		  
		  
		  
		  
		  
		    
		    //till here
		    $('#btnSliderClose').show();
		    $('a[name=btnSlide]').attr('val','');
		    $('.sliderContentWrapper').animate({ width: "show" }, "normal").attr('rel', 'visible');
		    $('.sliderButtonWrapper').animate({ right: "910px" }, "normal");
		    $('div[rel=tabContent]').hide();
		    $('img[alt=over]').hide();
		    $('img[alt=normal]').show();
		    $('#img' + this.id).hide();
		    $('#img' + this.id + 'Over').show();
		    $('#'+$(this).attr('rel')).show();
		    $(this).attr('val','click');
		    ctrl = $('#'+$(this).attr('rel'));
		    setFocus($('.sliderContentWrapper'));
		    var ctrlVal = '';
		    var ctrlFlag = false;
		    if($(ctrl).children().is('iframe'))
		    {
		        ctrlVal = $(ctrl).children().attr('rel');
		        ctrlFlag = true;
		    }
		    else
		    {
		        ctrlVal = $(ctrl).attr('val');
		    }
		    if(ctrlVal == '')
		    {
		       
		        $.ajax(
                {  
                    type: "POST",
                    //commented by satyendra
                    //url: 'MyHandleRequest.aspx',  // Send the login info to this page   
                    url: 'MyHandleRequest.aspx?s='+varmachinetime,
                    data: { msg : $(ctrl).attr('id') },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                    async: true,    //default is asynchronous request can set to false
                    cache: false,
                    beforeSend:function()
                    {
                        $('.sliderContent').showoverlay();
                    },
                    success: function(data)
                    { 
                          
                         
                          var strResult = data.split('~');
                          if(strResult[0] == 'redirect')
                          {
                            window.location.assign(strResult[1]);
                            return false;
                          }
                          else
                          {
                              if(ctrlFlag)
                              {
                                  $(ctrl).children().attr('src',strResult[1]);//$(ctrl) has id of div (dvCalendar) which when we click slider of calender
                                  $(ctrl).children().attr('rel','view');
                              }
                              else
                              {
                                  $(ctrl).html(strResult[1]);//$(ctrl) has id of div (dvCalendar) which when we click slider of calender
                                  $(ctrl).attr('val','view');
                                  $('.dvScrollNews').MyTicker();
                              }
                              $('.sliderContent').hideoverlay();

                          }
                    }
                }); 
                
                $('.sliderContentWrapper').bind('mousedown', function(e)
                {
                    setFocus($(this));
                    setFocus($('#btnSliderClose'));
                    setFocus($('a[name=btnSlide]'));
            	  
                });
                
            }
            
		}
		
	}
	);
	
	$('#btnSliderClose').live('click',function()
    {
        $('.sliderContentWrapper').animate({ width: "hide" }, "normal");
		$('.sliderButtonWrapper').animate({ right: "0px" }, "fast");
		$('.sliderContentWrapper').attr('rel','');
		$('img[alt=over]').hide();
		$('img[alt=normal]').show();
		$('a[name=btnSlide]').attr('val','');
		$(this).hide();
    });
}

//=============== Slider=====================================


//=================Slider end================================

//Function to set theme of desktop.====================================
function ChangeBGColor(hex)
{
	$('body').css('background-color', hex);
	createCookie('bgColor', hex, 60);
	$('#PropertiesContent .bgColorpicker').val(hex);
}
function ChangeBGImage(i)
{
	if (i=="")
	{
		$('#BGImage').hide();
	}
	else
	{
		$('#BGImage').attr('src', 'bg/'+i+'.jpg').show();
	}
	createCookie('bgImage', i, 60);
}
function ChangeThemeColor(hex)
{

	$.style('div.window-back' ).css('background-color', hex);
	$.style('#StartMenu' ).css('background-color', hex);
	$.style('#ToolBarA' ).css('background-color', hex);
	$.style('#ToolBarB' ).css('background-color', hex);
	$.style('#ToolBar .toolButton' ).css('background-color', hex);
	$.style('#ToolBar *' ).css('background-color', hex);
	$.style('#Start' ).css('background-color', hex);
	createCookie('themeColor', hex, 60);
	$('#PropertiesContent .themeColorpicker').val(hex);
}
function ChangeThemeTextColor(hex)
{
	$.style('#ToolBar *, div.window-titleBar, div.window-statusBar').css('color', hex);
	$.style('div.window-titleBar' ).css('color', hex);
	$.style('#StartMenu' ).css('color', hex);
	$.style('#ToolBarA' ).css('color', hex);
	$.style('#ToolBarB' ).css('color', hex);
	$.style('#ToolBar .toolButton' ).css('color', hex);
	$.style('div.window-statusBar' ).css('color', hex);
	$.style('#Start' ).css('color', hex);
	createCookie('themeTextColor', hex, 60);
	$('#PropertiesContent .themeTextColorpicker').val(hex);
}

function createCookie(name,value,days) 
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) 
{
	createCookie(name,"",-1);
}

//=====================================================================

//Get time in format=========================================
function getClockTime()
{
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   var day    =  now.toLocaleDateString();
   var ap = "AM";
   if (hour   > 11) { ap = "PM";             }
   if (hour   > 12) { hour = hour - 12;      }
   if (hour   == 0) { hour = 12;             }
   if (hour   < 10) { hour   =hour;   }
   if (minute < 10) { minute = "0" + minute; }
   if (second < 10) { second = "0" + second; }
   var timeString = ' <div class="timeWrapper"><span class="displayDate">' + day + '</span><br /><span class="displayTime">' + hour + ':' + minute + " " + ap + '</span><br /><span class="displayZone">Local Time</span></div><div  class="addTimeZone" title="Add Time Zone"><img src="images/spacer.gif" width="18" height="18" alt="" /></div>';
   return timeString;
}
//=============================================================
//============================== Add event for mouseover on menu ==========

function AddEventForMenu()
{
    $('div[name=divMenuArrow]').each(function()
    {
        var ctl = this;
        $(this).parent().hover
        (
            function()
            {
                $(ctl).removeClass('menuArrow').addClass('menuArrowOver');
            },
            function()
            {
                $(ctl).removeClass('menuArrowOver').addClass('menuArrow');
            }
        )
    });
}

//============================================================================


//============================== Function for clock mouseover and mouseout =======================

function AddEventForClock()
{
    $('.dvClock').each(function()
    {
        if(this.id == 'dvClockLocal')
        {
            $(this).hover
            (
                function()
                {
                    this.style.backgroundImage='url(images/clockBgOver.png)';
                },
                function()
                {
                    this.style.backgroundImage='url(images/clockBg.png)';
                }
            );
        }
        else
        {
        
            $(this).hover
            (
                function()
                {
                    this.style.backgroundImage='url(images/clockBgOverClose.png)';
                },
                function()
                {
                    this.style.backgroundImage='url(images/clockBg.png)';
                }
            );
        }
    });
   
}
//=================================================================================================


//=============================Function for weather============================================

function AddEventForWeather()
{
    
    
    
        var setFocus = function($obj)
        {
            $obj.css("z-index",jqWindowsEngineZIndex++);
        }
    	
	    
        $('.dvWeather').each(function()
        {
            $(this).hover
            (
                function()
                {
                    $(this).css('background','url(images/weatherBgOver.png) no-repeat left top');
                },
                function()
                {
                    $(this).css('background','url(images/weatherBg.png) no-repeat left top');
                }
            );
           
            $(this).draggable({containment:'document',scroll: false});    
                
            $(this).bind('mousedown', function(e)
	        {
		        $obj11 = $(this);
		        setFocus($obj11);
		        
		        $obj11.css('background','url(images/weatherDragBg.png) no-repeat left top');
		        
		        
    		  
                $(document).bind('mouseup', function(e)
                {
	                $(document).unbind('mousemove');
	                $obj11.css('background','url(images/weatherBgOver.png) no-repeat left top');
                });
        	  
            });    
           
           
           

        });
   
}

//==============================================================================================

//============================== Function for saving widget position===========

function SaveWidget(strMyParameters)
{
    $.ajax(
            {  
                type: "POST",
                url: 'MyHandleRequest.aspx?w=save',  // Send the login info to this page
                data: { msg : strMyParameters },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                async: true,    //default is asynchronous request can set to false
                cache: false,
                success: function(data)
                {  
                }
            });  
}

//=========================================================================

//============================== Function for forgot password ===========

function ForgotPassword(strUsername)
{
   $('#dvPwdMessage').html('');
   var flagPwd = false;
   $('input[name=Fpwdtext]').each(function()
   {
        if(this.value == '')
        {
            $('#dvPwdMessage').html('<div class=\"errorIcon\"></div><p class=\"redErrorTxt\">Please Enter ' + this.title + '</p>');
            flagPwd = true;
            return false;
        }
        else if(!new RegExp($(this).attr('validExpress'), "m").test(this.value))
        {
            $('#dvPwdMessage').html('<div class=\"errorIcon\"></div><p class=\"redErrorTxt\">Please enter a valid email address.</p>');
            flagPwd = true;
            return false;
        }
   });
   
   if(flagPwd)
   {
        return false;
   }
    $.ajax(
            {  
                type: "POST",
                url: 'MyHandleRequest.aspx?w=pwd',  // Send the login info to this page
                data: { msg : strUsername },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                async: true,    //default is asynchronous request can set to false
                cache: false,
                beforeSend:function()
                {
                 $('#dvForgotPassword').showoverlay({imgPath:'JSOS/elapsor.gif'});  
                },
                success: function(data)
                {  
                  
                    var dataStr = data.split('~');
                    if(dataStr.length > 0)
                    {
                        if(dataStr[0] == 'success')
                        {
                            $('#dvForgotPassword').hideoverlay();
                            $('#dvPwdMessage').html(dataStr[1]);
                            closedialogboxAutomatically();
                        }
                        else
                        { 
                             $('#dvForgotPassword').hideoverlay();
                             $('#dvPwdMessage').html(dataStr[1]);
                        }
                    }
                }
            });  
}

 /********************************** Till Here **********************************************************/


//============================== Change autogenerated password which get after forgot password ===========

function ChangePassword(strUsername)
{
   $('#dvPwdMessage').html('');
   var flagPwd = false;
   $('input[name=validatePwd]').each(function()
   {
        if(this.value == '')
        {
            $('#dvPwdMessage').html('<div class=\"errorIcon\"></div><p class=\"redErrorTxt\">Please Enter ' + this.title + '</p>');
            flagPwd = true;
            return false;
        }
        else if(this.value.length <= 6)
        {
            $('#dvPwdMessage').html('<div class=\"errorIcon\"></div><p class=\"redErrorTxt\">Password must be greater than 6 chars.</p>');
            flagPwd = true;
            return false;
        }
        if(this.id == 'confirmPwd')
        {
            if(this.value != $('#newPassword').val())
            {
                $('#dvPwdMessage').html('<div class=\"errorIcon\"></div><p class=\"redErrorTxt\">Password is not confirmed</p>');
                flagPwd = true;
                return false;
            }
            
        }
   });
   
   if(flagPwd)
   {
        return false;
   }
    $.ajax(
            {  
                    type: "POST",
                    url: 'MyHandleRequest.aspx?wa=chngepwd',  // Send the login info to this page
                    data: { msg : strUsername },    //equivalent to url parameter "msg=Hellow%20Nurse!"
                    async: true,    //default is asynchronous request can set to false
                    cache: false,
                    beforeSend:function()
                    {
                     $('.changePasswordWrapper').showoverlay({imgPath:'JSOS/elapsor.gif'}); 
                    },
                    
                    success: function(data)
                    {  
                            var dataStr = data.split('~');
                            if(dataStr.length > 0)
                            {
                                if(dataStr[0] == 'success')
                                {
                                   $('.changePasswordWrapper').hideoverlay();
                                   $('#dvPwdMessage').html(dataStr[1]);
                                   closechangepwddialogboxAutomatically();
                                }
                                else
                                {              
                                     $('#dvPwdMessage').html(dataStr[1]);                     
                                     $('.changePasswordWrapper').hideoverlay();
                                }
                             }
                     }
              }
          );  
}

     /********************************** Till Here ****************************************/
 
    /************Close Automatically ForgotPassword DialogBox After Some Time**************/
   function  closedialogboxAutomatically() 
    { 
        setTimeout 
        ( 
            function() 
            { 
              $('#dvForgotPassword').fadeOut(2000); 
            }, 
            4000 
        ); 
    } 

      /******************************** Till Here  ****************************************/
             
    
    
    /************Close Automatically ChangePassword dialog box after some time*************/
   function  closechangepwddialogboxAutomatically() 
    { 
        setTimeout 
        ( 
            function() 
            { 
              $('.changePasswordWrapper').fadeOut(2000); 
            }, 
            4000 
        ); 
    } 

  /************close automatically ChangePassword dialog box after some time***************/


//=========================================================================

//=========================Method for start menu========================

    function StartMenuOver()
    {
        $('.startBtn').each(function()
        {
            $(this).hover
            (
                function()
                {
                    if($(this).attr('val') == 'click')
                    {
                        return false;
                    }
                    this.style.backgroundImage='url(images/startIconOver.png)';
                },
                function()
                {
                    if($(this).attr('val') == 'click')
                    {
                        return false;
                    }
                    this.style.backgroundImage='url(images/startIconActive.png)';
                }
            );
            
            /*$(this).bind('click',function()
            {
                if($(this).attr('val') == 'click')
                {
                    $(this).attr('val','');
                    this.style.backgroundImage='url(images/startIconOver.png)';
                }
                else if($(this).attr('val') == '')
                {
                    $(this).attr('val','click');
                    this.style.backgroundImage='url(images/startIconClick.png)';
                }
            });*/
        });
    }

//====================================================================

//=============== Get Viewport======================================

function GetViewPort()
{
     var viewportwidth;
     var viewportheight;
     var arr = new Array(2)
     // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
     
     if (typeof window.innerWidth != 'undefined')
     {
          viewportwidth = window.innerWidth,
          viewportheight = window.innerHeight
     }
     
    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

     else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
     {
           viewportwidth = document.documentElement.clientWidth,
           viewportheight = document.documentElement.clientHeight
     }
     
     // older versions of IE
     
     else
     {
           viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
           viewportheight = document.getElementsByTagName('body')[0].clientHeight
     }
     arr[0] = viewportheight;
     arr[1] = viewportwidth;
     
     return arr;
 }

//===================================================================

//====================Show welcome msg=================================
function ShowWelComeMsg()
{
    var cDate = new Date();
    var strTitle = '';
    var strContent = document.getElementById('hdnWelcome').value;
    var strProfile = document.getElementById('hdnprofile').value;
    var cHour = cDate.getHours();
    if(cHour >= 5 && cHour < 12)
    {
        strTitle = 'Good Morning!';
    }
    else if(cHour >= 12 && cHour < 17)
    {
        strTitle = 'Good AfterNoon!';
    }
    else
    {
        strTitle = 'Good Evening!';
    }
    //var strMsg = '<div  style="display:block;z-index:-1;" class="welcomeUserWrapper" id="welcomeUserWrapper"><h1>' + strTitle + '</h1><div class="dvLabel">' + strContent + '</div></div>';
	//for profile image
	var strMsg = '<div  style="display:block;z-index:' + jqWindowsEngineZIndex++ + ';" class="welcomeUserWrapper" id="welcomeUserWrapper"><h1>' + strTitle + '</h1><div class="dvLabel">' + strContent + '</div><div class="userPicFrame" style="top:-20px;"><img src="' + strProfile + '" alt="Change profile image." title="Change profile image." /></div></div>';
    $('body').append(strMsg);
    var myBorder = RUZEE.ShadedBorder.create({ corner:8, shadow:16 });
    myBorder.render('welcomeWrapper');
    myBorder.render('welcomeUserWrapper');
}
//=====================================================================

function GetKeyCode(evt,ctrl)
{
    evt = (evt) ? evt : ((event) ? event : null);
    var evver = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null );
    var keynumber = evt.keyCode;
    if(keynumber == 13)
    {
        //alert(keynumber);
        $('#'+ ctrl).click();

    }
}

//==============================================================================

//================== Show IM ===================================================

    function  ShowIM(type) 
    { 
        
        Microsoft.Live.Core.Loader.onDocumentReady(MyBulletinBoard.onLoad);
        Microsoft.Live.Core.Loader.onReady(MyBulletinBoard.onLoaderReady);
        mylogin(type);
        $('.bottomBarBg').show();
    } 
    
    function mylogin(type)
    {
        if(type == 'yes')
        {
            MyBulletinBoard.onButtonLoginClick();
            
        }
    }
    
    function tryToDownload(url)
    {
 
        oIFrm = document.getElementById('myIFrm');
        oIFrm.src = url;
 
    }   

//==============================================================================


