﻿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);
}

function clearTextbox(obj,text){
    if (obj.value == text){ 
        obj.value= "";
    }
}

function fillTextbox(obj, text){
    if (obj.value == ''){
        obj.value= text;
    }
}

function AddToFavorites (url,title) { 
    if (window.external) {
        //IE only
        window.external.AddFavorite(url,title); 
    }
}

function MakeHomePage() {
   document.body.style.behavior='url(#default#homepage)';
   document.body.setHomePage(window.location.href);
}

function setContentHeight() {
    var sidebarLeftHeight = $('#sidebarleft').height();
    var sidebarRightHeight = $('#sidebarright').height();
    var contentTopHeight = $('.contenttop').height();
    var contentBottomHeight = $('.contentbottom').height();
    var contentTabsHeight = $('.tabstrip').height();
    var restHeight = contentBottomHeight+contentTopHeight+contentTabsHeight;
    
    var msie      = jQuery.browser.msie; 
    
    if (sidebarLeftHeight >= sidebarRightHeight) {
        if (msie) {
            $('.contentmain').css("height",sidebarLeftHeight-restHeight);
        } else {
            $('.contentmain').css("min-height",sidebarLeftHeight-restHeight);
        }
    } else {
        if (msie) {
            $('.contentmain').css("height",sidebarRightHeight-restHeight);
        } else {
            $('.contentmain').css("min-height",sidebarRightHeight-restHeight);
        }
    }
}

$(document).ready(function(){
            $(document.body).click(function(e)
             {
			     var srcElement = e.srcElement? e.srcElement : e.target;
			     var hide = true;
		         var elements = $(srcElement).parents(); 
		        for( var i=0;i<elements.length;i++)
		        {
		            if(elements[i].className =='Calendar')
		            {
		                hide = false;
		            }
		        }
		        
		        if(hide)
		        {
		            $(".Calendar").hide();
		        }
		    });
         });

