﻿//Browser object - Start
function emi_Browser()
{
	d=document;
	this.agt=navigator.userAgent.toLowerCase();
	this.major=parseInt(navigator.appVersion);
	this.dom=(d.getElementById);
	this.ns=(d.layers);
	this.ns4up=(this.ns && this.major>=4);
	this.ns6=(this.dom&&navigator.appName=="Netscape");
	this.op=(window.opera);
	if(d.all)this.ie=1;else this.ie=0;
	this.ie4=(d.all&&!this.dom);
	this.ie4up=(this.ie&&this.major>=4);
	this.ie5=(d.all&&this.dom);
	this.ie6=(d.nodeType);
	this.sf=(this.agt.indexOf("safari")!=-1);
	this.win=((this.agt.indexOf("win")!=-1)||(this.agt.indexOf("16bit")!=-1));
	this.winme=(this.agt.indexOf("win 9x 4.90")!=-1);
	this.xpsp2=(this.agt.indexOf("sv1")!=-1);
	this.mac=(this.agt.indexOf("mac")!=-1);
}
var oBw=new emi_Browser();
//Browser object - End

//Floating Help - Start
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
function hidelayer(lay)
{
	if (ie4) {document.all[lay].style.visibility = "hidden";}
	if (ns4) {document.layers[lay].visibility = "hide";}
	if (ns6) {document.getElementById([lay]).style.display = "none";}
}
function showlayer(lay)
{
	if (ie4) {document.all[lay].style.visibility = "visible";}
	if (ns4) {document.layers[lay].visibility = "show";}
	if (ns6) {document.getElementById([lay]).style.display = "block";}
}
//Floating Help - End
function emi_pop(s)
{
	window.open(s,"emi_pop","width=520,height=500,scrollbars=yes,resizable=yes");
}

//Please wait... Start
function hideload() { document.getElementById('loading').style.display = 'none'; }
function showload() { document.getElementById('loading').style.display = 'block'; }
//Please wait... End

var helpPopUp;
var bResize=true;
function CallPaneHelp() 
{
	var sw = screen.width*0.24;
	var sWD="toolbar=0,status=0,menubar=0,resizable=1,left="+(screen.width-sw)+",top=0,width="+(sw-12) + ",height="+(screen.height-30);
	bResize=false;
	top.window.resizeTo(screen.width-sw,screen.height);
	top.window.moveTo(0,0);
	helpPopUp = window.open('/ichat/help/helpframe.aspx?pathname='+document.location.pathname,'ichat_help',sWD);
	helpPopUp.focus();
}
function SetThemeCookie(themeName)
{
    var date = new Date();
    date.setTime(date.getTime() + (365*24*60*60*1000));
    var expires = "; expires=" + date.toGMTString();
    document.cookie = "selected_theme" + "=" + themeName + expires +"; path=/";
}
function Select_DeSelectAll (chkVal, idVal)
{
    var frm = document.forms[0];
	
    //Find CheckAll element
    for (j=0; j<frm.length; j++)
    {
        if (frm.elements[j].name.indexOf('cbxSelectAll')!= -1)
            break;
    }
    
    // Look for our Header Template's Checkbox
    if (idVal.indexOf ('cbxSelectAll') != -1)
    {
        // loop through all elements
        for (i=0; i<frm.length; i++)
        {
            //Skip all other fields
            if (frm.elements[i].id.indexOf('cbxSelectRow') == -1)
                continue;
                
            // Check if main checkbox is checked, then select or deselect datagrid/gridview checkboxes 
            if(chkVal == true)
            {
                frm.elements[i].checked = true;
            }
            else
            {
                frm.elements[i].checked = false;
            }
        } 
    }
    else if (idVal.indexOf('cbxSelectRow') != -1)
    {
        // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
        if(frm.elements[idVal].checked == false)
            frm.elements[j].checked = false; 
    }
}

//Calendar Scripts - START
var calPopUp; 

function OpenCalendar(idname, postBack)
{
	calPopUp = window.open('/ichat/calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=180,height=250,left=200,top=250');
	calPopUp.focus();
}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	calPopUp.close();
	theform.elements[id].value = newDate;
}
//Calendar Scripts - END