var HttpPath = '';

function $(id)
{
    var container = document;
    if(arguments.length > 1 && $(arguments[1]) == null)
    {
        return null;
    }
    else
    {
        if(arguments.length > 1)
        {
            container = $(arguments[1]);
        }
    }
    var obj = null;
    try
    {
        obj = container.getElementById(id);
    }
    catch(e)
    {
        obj = null;
    }
    return obj;
}

function getLeftPos(obj){
	var res = 0;
	while (obj){
		res += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return res;
}

function getTopPos(obj){
	var res = 0;
	while (obj){
		res += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return res;
}

function HtmlEncode(str)
{
    str = str_replace('"', '&quote;', str);
    str = str_replace('>', '&gt;', str);
    str = str_replace('<', '&lt;', str);
    str = str_replace('&', '&amp;', str);
    return str;
}


function GridViewCheckCh(chAll, GridId, ChPrefix)
{
    
    var el = $(GridId + '_container').getElementsByTagName('input');
    var i = 0;
    for(i = 0; i < el.length; i++)
    {
        if(el[i].id != undefined && el[i].id != null && el[i].disabled == false && el[i].id != chAll.id && el[i].id.indexOf(ChPrefix) != -1)
            el[i].checked = chAll.checked;
    }
}

function GridViewCheckChAll(ch, chAllId, GridId, ChPrefix)
{
    
    var el = $(GridId).getElementsByTagName('input');
    var i = 0;
    var flag = true;
    for(i = 0; i < el.length; i++)
    {
        if(el[i].id != undefined && el[i].id != null && el[i].disabled == false && el[i].id != $(chAllId).id && el[i].id.indexOf(ChPrefix) != -1)
        {
            if(!el[i].checked)
            {
                flag = false;
                break;
            }
        }
    }
    $(chAllId).checked = flag;
}

var winProperty = null;
function printProperties(obj)
{
    var doc = null;
    try
    {
        doc = winProperty.document;
    }
    catch(e)
    {
        doc = null;
        winProperty = null;
    }
    if(winProperty == null)
    {
        winProperty= window.open('', 'printProperty', '');
        winProperty.document.open('text/html');
        winProperty.document.write('<html><body><div id="content"></div></body></html>');
        winProperty.document.close();
    }
    doc = winProperty.document.getElementById('content');
    for( var item in obj)
    {
        doc.innerHTML += item + ' = ' + obj[item] + '\n<br />\n';
    }
    
    doc.innerHTML += '<br /><br /><br />';
}

//setTimeout('printProperty($("ctl00_LeftMenu_ctl01_1"))', 2000);



////////////////////////////////////////////////////////////////
//////////////     Developers                  /////////////////
////////////////////////////////////////////////////////////////

		
///////////////////////////////////
///////                    ////////
///////      Debug         ////////
///////                    ////////
///////////////////////////////////


var myDebugWindow = null;
var isRuningDebug = false;

function debug(str)
{
	if (!isActiveDebug)
		return false;
	
	if(myDebugWindow == null)
	{
		try
		{
			myDebugWindow = window.open('', ('myDebugWindow'), 'width=800,height=800,toolbar=0,status=1,location=0,menubar=0,scrollbars=1');
		
			var doc = myDebugWindow.document;
			doc.open('text/html');
			doc.write('<html><head><title>Debud</title></head><body style="background-color:#1e4060; padding: 0px; margin: 0px;"><table cellspacing="0" cellpadding="0" border="0" style="width: 100%; height: 100%; background-color:#1e4060;"><tr><td style="height: 10px; background-color:#1e4060;">&nbsp;</td></tr><tr><td id="content" style="color: #082F66; font-size: 10pt; background-color: #BBC5D2; padding-left: 10px; padding-bottom: 20px; font-family: Arial,Verdana,Helvetica; font-weight: bold;" valign="top"></td></tr><tr><td style="height: 10px;">&nbsp;<input type="button" name="stst" id="stst" value="STOP &times;" onclick="opener.debugStartStop()" /> <input type="button" name="cl" id="cl" value="CLEAR" onclick="opener.debugClear()" /></td></tr></table></body></html>');
			doc.close();
			isRuningDebug = true;
		}
		catch(e)
		{
			try
			{
				myDebugWindow.close();
			}
			catch(e)
			{
			}
			myDebugWindow = null;
			isRuningDebug = false;
			return;
		}
	}
		
	try
	{
		if(isRuningDebug)
		{
			//str = str.Replace('<', '&lt;');
			str = str_replace('<', '&lt;', str);
			//str = str.Replace('>', '&rt;');
			str = str_replace('>', '&gt;', str);
			str = str_replace('\n', '\n<br>', str);
			myDebugWindow.document.getElementById('content').innerHTML += '<br><hr><br>'+str;
			myDebugWindow.document.body.scrollTop += 100;
		}
	}
	catch(e)
	{
		myDebugWindow = null;
		isRuningDebug = false;
	}
	
}

function debugStartStop()
{
	if(isRuningDebug)
	{
		isRuningDebug = false;
		myDebugWindow.document.getElementById('stst').value = 'START >>';
	}
	else
	{
		isRuningDebug = true;
		myDebugWindow.document.getElementById('stst').value = 'STOP [x]';
	}
}

function debugClear()
{
	myDebugWindow.document.getElementById('content').innerHTML = '';
}

function str_replace(chto, nachto, gde)
{
	var tmp = gde.split(chto);
	gde = '';
	for(var i = 0; i < tmp.length; i++)
		if(i != (tmp.length-1)) gde += tmp[i] + nachto;
		else gde += tmp[i];
		
	return gde;
}

///////////////////////////////////
///////                    ////////
///////      Debug         ////////
///////                    ////////
///////////////////////////////////

var _ico_closedNode = new Image();
_ico_closedNode.src = "images/main_menu/closed_node.gif";
var _ico_openedNode = new Image();
_ico_openedNode.src = "images/main_menu/opened_node.gif";

function MainMenu_changeNodeState(obj, id)
{
    if($(id) != null)
    {
        if($(id).style.display == "none")
        {
            MainMenu_changeNodeStateSubElements(id, 20, "none", "");
            obj.src = _ico_openedNode.src;
        }
        else
        {
            MainMenu_changeNodeStateSubElements(id, 20, "", "none");
            obj.src = _ico_closedNode.src;
        }
    }
}


////////////////////////////////////////////////////////////////
//////////////        Cookie                   /////////////////
////////////////////////////////////////////////////////////////

function getCookieVal (offset) {
     var endstr = document.cookie.indexOf(";", offset);
     if (endstr == -1) endstr = document.cookie.length;
     return unescape(document.cookie.substring(offset, endstr));
 }

 function FixCookieDate(date) {
     var base = new Date(0);
     var skew = base.getTime();
     if (skew > 0)date.setTime(date.getTime() - skew);
 }
 
 function GetCookie(name) {
     var arg = name + "=";
     var alen = arg.length;
     var clen = document.cookie.length;
     var i = 0;
     while (i < clen) {
         var j = i + alen;
         if (document.cookie.substring( i , j ) == arg && (i == 0 || document.cookie.charAt(i-1) == ' ' || document.cookie.charAt(i-1) == ';')) return getCookieVal(j);
         i = document.cookie.indexOf(" ", i ) + 1;
         if (i==0) break;
     }
     return null;
 }
 
 function SetCookie(name,value,expires,path,domain,secure) {
     document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
 }
 
 function DelCookie(name,path,domain) {
     if(GetCookie(name)) {
         document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "expires=Thu, 01-Jan-70 00:00:01 GMT";
     }
 }

////////////////////////////////////////////////////////////////
//////////////     Main Menu                   /////////////////
////////////////////////////////////////////////////////////////

function MainMenu_changeNodeStateSubElements(id, t, defval, val)
{
    var el = $(id).getElementsByTagName('tr');
    var i = 0;
    for(i = 0; i < el.length; i++)
    {
        el[i].style.display = defval;
    }
    if(val == "") $(id).style.display = val;
    for(i = 0; i < el.length; i++)
    {
        setTimeout('MainMenu_changeNodeStateSubElement("' + id + '", ' + i + ',"' + val + '")', t*(i + 1));
    }
    if(defval == "") setTimeout('$("' + id + '").style.display = "' + val + '";', t*(i + 1));
}

function MainMenu_changeNodeStateSubElement(id, pos, val)
{
    var el = $(id).getElementsByTagName('tr');
    if(el.length > pos) el[pos].style.display = val;
}


function MainMenuGroupClick(obj, container_id)
{
    if($(container_id) == null) return;
    if($(container_id).style.display == "none")
    {
        obj.className = "main_menu_category_opened";
        $(container_id).style.display = "";
    }
    else
    {
        obj.className = "main_menu_category_closed";
        $(container_id).style.display = "none";
    }
}


////////////////////////////////////////////////////////////////
//////////////     Pseudo Modal Pop Up         /////////////////
////////////////////////////////////////////////////////////////


var __pseudoModalPopUpWin = null;
var __pseudoModalPopUpInterval = null;
var __pseudoModalPopUpUid = Math.round(Math.random() * 999999999) + "_" + Math.round(Math.random() * 999999999);

function pseudoModalPopUpOpen(url, width, height)
{
    if(__pseudoModalPopUpWin != null) return;
    
    try
    {
        __pseudoModalPopUpWin = window.open(url, ('__pseudoModalPopUp_' + __pseudoModalPopUpUid), 'width=' + width + ', height=' + height + ', location=0, menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0');
        var t = __pseudoModalPopUpWin.document;
    }
    catch(e)
    {
        __pseudoModalPopUpWin = null;
        alert('Please disable Pop Up blocked system for this site.');
        return;
    }
    window.onfocus = function()
    {
        __pseudoModalPopUpCheck();
        if(__pseudoModalPopUpWin != null)
        {
            try
            {
                self.blur();
                __pseudoModalPopUpWin.focus();
            }
            catch(e){}
        }
    }
    document.onunload = function()
    {
        if(__pseudoModalPopUpWin != null)
        {
            try
            {
                __pseudoModalPopUpWin.close();
            }
            catch(e){}
        }
    }
}

function __pseudoModalPopUpCheck()
{
    if(__pseudoModalPopUpWin == null && __pseudoModalPopUpInterval != null)
    {
        clearInterval(__pseudoModalPopUpInterval);
        __pseudoModalPopUpInterval = null;
        return; 
    }
    
    try
    {
        var t = __pseudoModalPopUpWin.document;
        t = __pseudoModalPopUpWin.document.body;
    }
    catch(e)
    {
        __pseudoModalPopUpWin = null;
        window.onfocus = function(){}
    }
}


////////////////////////////////////////////////////////////////
//////////////     Pseudo Modal In Win         /////////////////
////////////////////////////////////////////////////////////////

function AlDesktop()
{
    window.AlDesktop = this;
    
    this.window_arr = new Array();
    
    
    this.dd = null;
    
}

var AlWindow = function()
    {
        this.id = '_';
        this.left = 0;
        this.top = 0;
        this.height = 200;
        this.width = 400;
        this.url = "_blank";
        this.content = null;
        this.onclose = null;
        this.title = '';
        
        this.set_css_class = function(name)
        {
            if(this.obj != null)
            {
                this.obj.className = name;
            }
        }
        
        this.get_css_class = function()
        {
            if(this.obj != null)
            {
                return this.obj.className;
            }
            return null;
        }
        
        this.is_resizable = true;
        this.is_header_visible = true;
        this.is_scroll_visible = true;
        this.is_status_visible = true;
        this.is_modal = false;
        this.is_safe_mode = true;
        this.is_closed = false;
        this.is_destroy = true;
        this.modal_for = document.documentElement;
		this.body = null;
        
        this.obj = null;
        
        this.create = function()
        {
            this.obj = document.createElement('div');
            document.body.appendChild(this.obj);
            //this.obj.className = 'in_win_red';
            this.obj.style.display = 'none';
            this.obj.style.position = 'absolute';
            if(arguments.length > 0)
            {
                this.obj.id = arguments[0];
            }
            else
            {
                this.obj.id = this.getNewId();
            }
            var zIndex = (this.modal_for.style.zIndex)?this.modal_for.style.zIndex:0;
            var zIndexO = (this.modal_for.offsetParent)?this.modal_for.offsetParent:null;
            while(zIndexO)
            {
                zIndex = (zIndexO.style.zIndex)?zIndexO.style.zIndex:zIndex;
                zIndexO = (zIndexO.offsetParent)?zIndexO.offsetParent:null;
            }
            if(this.is_modal && $(this.obj.id + 'in_win_modal_lock_bg') == null)
            {
                var l = document.createElement('div');
                document.body.appendChild(l);
                l.id = this.obj.id + 'in_win_modal_lock_bg';
                l.style.position = 'absolute';
                l.className = 'in_win_locked_bg';
                l.style.height = document.documentElement.scrollHeight+ 'px';// + this.modal_for.height 
                l.style.zIndex = zIndex + 1;
            }
            if(this.is_modal) $(this.obj.id + 'in_win_modal_lock_bg').style.display = '';
            this.obj.style.left = this.left + 'px';
            this.obj.style.top = this.top + 'px';
            this.obj.style.width = this.width + 'px';
            this.obj.style.height = this.height + 'px';
            this.obj.style.zIndex = zIndex + 2;
			
			var el = document.createElement('table');
			el.id = this.obj.id + '_ct';
			el.cellSpacing = '0px';
			el.cellPadding = '0px';
			el.border = '0px';
			el.className = 'maxw maxh in_win_container';
			this.obj.appendChild(el);
			var tmp = el;
			el = document.createElement('tbody');
			tmp.appendChild(el);
			tmp = el;
			if(this.is_header_visible != false)
			{
				el = document.createElement('tr');
				tmp.appendChild(el);
				var tdh = document.createElement('td');
				tdh.id = this.obj.id + '_header';
				tdh.className = 'in_win_header';
				tdh.style.height = '20px';
				el.appendChild(tdh);
				tdh.innerHTML = '<table border="0" cellpadding="0" cellspacing="0" class="maxw"><tr><td class="in_win_title">' + this.title + '</td><td class="in_win_btn" align="right"><img alt="Close" src="images/t1x1.gif" border="0" width="15" height="15" class="in_win_btn_close cursor" onmouseover="this.className=\'in_win_btn_close_act cursor\';" onmouseout="this.className=\'in_win_btn_close cursor\';" onclick="$(\'' + this.obj.id + '\').AlWindow.close();" /></td></tr></table>';
			}
            
            el = document.createElement('tr');
			tmp.appendChild(el);
			var tdb = document.createElement('td');
			tdb.className = 'in_win_content';
			tdb.style.verticalAlign = 'top';
			tdb.style.height = 'auto';
			el.appendChild(tdb);
            if(this.is_safe_mode)
            {
				var ifr = document.createElement('iframe');
				ifr.id = this.obj.id + '_frame';
				ifr.frameborder = 0;
				ifr.scrolling = (this.is_scroll_visible?'yes':'no')
				ifr.marginheight = '0px';
				ifr.marginwidth = '0px';
				ifr.src = this.url;
				ifr.height = '100%';
				ifr.width = '100%';
				ifr.style.border = '0px solid #ffffff';
				ifr.style.height = '100%';
				ifr.style.width = '100%';
            }
            else
            {
                var ifr = document.createElement('div');
				ifr.id = this.obj.id + '_frame'
				ifr.style.overflow = (this.is_scroll_visible?'scroll':'hidden');
            }
			this.body = ifr;
			tdb.appendChild(ifr);
            
            if(this.is_status_visible != false || this.is_resizable != false)
            {
                el = document.createElement('tr');
				tmp.appendChild(el);
				var tdf = document.createElement('td');
				tdf.id = this.obj.id + '_header';
				tdf.className = 'in_win_bottom';
				tdf.style.height = '20px';
				el.appendChild(tdf);
				tdf.innerHTML = '<table border="0" cellpadding="0" cellspacing="0" class="maxw"><tr><td class="maxw in_win_status" colspan="' + (this.is_resizable != false?'1':'2') + '">&nbsp;</td>' + (this.is_resizable != false?'<td class="" align="right" valign="bottom" id="' + this.obj.id + '_resize' + '"><img alt="Resize" src="images/t1x1.gif" width="15" height="15" class="in_win_resize" style="cursor: se-resize;" border="0" /></td>':'') + '</tr></table>';
            }
            
            if(this.url == null && this.content != null && $(this.obj.id + '_frame') != null)
            {
                $(this.obj.id + '_frame').innerHtml = this.content;
            }
            
            this.resizeTo(this.width, this.height);
            this.obj.style.display = '';
            
            this.obj.AlWindow = this;
            
            //initialize
            if(this.is_modal)
            {
                //document.body.style.overflow = 'hidden';
            }
            this.is_closed = false;
            
            if(this.is_resizable) setTimeout("$('" + this.obj.id + '_resize' + "').onmousedown = _AlWindow.__ResizeStartHandler", 500);
            setTimeout("$('" + this.obj.id + '_header' + "').onmousedown = _AlWindow.__DragStartHandler", 500);
            setTimeout("$('" + this.obj.id + "').AlWindow.resizeTo(" + this.width + "," + this.height + ")", 500);
            if(this.is_safe_mode) setTimeout("$('" + this.obj.id + '_frame' + "').contentWindow._AlWindow = $('" + this.obj.id + "').AlWindow", 1000);
        }
        this.close = function()
        {
            if(this.is_closed == true) return;
            this.is_closed = true;
            this.obj.style.display = 'none';
            if(this.onclose != null) this.onclose();
            if($(this.obj.id + '_frame').contentWindow && $(this.obj.id + '_frame').contentWindow._AlWindow && $(this.obj.id + '_frame').contentWindow._AlWindow.onclose != null)
            {
                $(this.obj.id + '_frame').contentWindow._AlWindow.onclose();
            }
            if(arguments.length > 0 ) this.is_destroy = arguments[0];
			if(this.is_destroy == true) document.body.removeChild(this.obj);
            if(this.is_modal && $(this.obj.id + 'in_win_modal_lock_bg') != null)
            {
                $(this.obj.id + 'in_win_modal_lock_bg').style.display = 'none';
            }
            __SelectFix(0, 0, 0, 0, new Array())
        }
        this.show = function()
        {
            var zIndex = (this.modal_for.style.zIndex)?this.modal_for.style.zIndex:0;
            var zIndexO = (this.modal_for.offsetParent)?this.modal_for.offsetParent:null;
            while(zIndexO)
            {
                zIndex = (zIndexO.style.zIndex)?zIndexO.style.zIndex:zIndex;
            }
            if(this.is_modal)
            {
                var l = $(this.obj.id + 'in_win_modal_lock_bg');
                l.style.height = document.documentElement.scrollHeight + 'px';
                l.style.display = '';
                l.style.zIndex = zIndex + 1;
            }
            //alert(this.width +  ' ' + this.height);
            this.resizeTo(this.width, this.height);
            this.obj.style.display = '';
            this.obj.style.zIndex = zIndex + 2;
            this.is_closed = false;
            __SelectFix(this.obj.style.left.replace('px', '')*1, this.obj.style.top.replace('px', '')*1, this.obj.style.height.replace('px', '')*1, this.obj.style.width.replace('px', '')*1, this.obj.getElementsByTagName('select'));
        }
        this.resizeTo = function(x, y)
        {
            if(x != null) this.obj.style.width = x + 'px';
            if(((this.obj.style.width + '').replace('px', '')*1) < 100) this.obj.style.width = '100px';
            if(y != null) this.obj.style.height = y + 'px';
            if(((this.obj.style.height + '').replace('px', '')*1) < 50) this.obj.style.height = '50px';
            $(this.obj.id + '_ct').style.width = this.obj.style.width;
            $(this.obj.id + '_ct').style.height = this.obj.style.height;
            
            $(this.obj.id + '_frame').style.width = this.obj.style.width.replace('px', '') + 'px';
            $(this.obj.id + '_frame').style.height = (this.obj.style.height.replace('px', '')*1 - 40) + 'px';
        }
        this.resizeBy = function(x, y)
        {
            if(x != null)
            {
                x = (x + '').replace('px', '') * 1;
                this.obj.style.width = (((this.obj.style.width + '').replace('px', '')*1) + x) + 'px';
                if(((this.obj.style.width + '').replace('px', '')*1) < 100) this.obj.style.width = '100px';
            }
            if(y != null)
            {
                y = (y + '').replace('px', '') * 1;
                this.obj.style.height = (((this.obj.style.height + '').replace('px', '')*1) + y) + 'px';
                if(((this.obj.style.height + '').replace('px', '')*1) < 50) this.obj.style.height = '50px';
            }
            $(this.obj.id + '_ct').style.width = this.obj.style.width;
            $(this.obj.id + '_ct').style.height = this.obj.style.height;
            
            $(this.obj.id + '_frame').style.width = this.obj.style.width.replace('px', '') + 'px';
            $(this.obj.id + '_frame').style.height = (this.obj.style.height.replace('px', '')*1 - 40) + 'px';
        }
        this.getNewId = function()
        {
            var i = 0;
            while(true)
            {
                if($(window.AlDesktop.id + '_window_' + i) == null)
                {
                    return window.AlDesktop.id + '_window_' + i;
                }
                i++;
            }
            
        }
        
        this.__ResizeStartHandler = function(e)
        {
            var ie = false;
            if(!e)
            {
	            e = window.event;
	            ie = true;
            }
            window.AlWindowDrag = (e.srcElement) ? e.srcElement : e.target;
            window.AlWindowDrag = _AlWindow.__FindDragObject(window.AlWindowDrag);
            
            if(window.AlWindowDrag == null) return;

            if(!ie)
            {
	            window.document.addEventListener("mousemove", _AlWindow.__ResizeRun, true);
	            window.document.addEventListener("mouseup", _AlWindow.__ResizeRelease, true);
	            window.document.addEventListener("mouseout", _AlWindow.__ResizeRun, true);
            }
            else
            {
	            window.document.onmouseup = _AlWindow.__ResizeRelease;
	            window.document.onmouseout = _AlWindow.__ResizeRun;
	            window.document.onmousemove = _AlWindow.__ResizeRun;
            }
            window.document.onselectstart = function() { return false; }
            window.document.ondragstart = function() { return false; }
            
            window.AlWindowDrag.cursorPosX = document.documentElement.scrollLeft + e.clientX;
            window.AlWindowDrag.cursorPosY = document.documentElement.scrollTop + e.clientY;
            
            return false;
        }
        this.__ResizeRun = function(e)
        {
	        if(window.AlWindowDrag == null) return false;
	        var ie = false;
	        if(!e)
	        {
		        e = window.event;
		        ie = true;
	        }
	        if(e == null) return false;

            var x = (document.documentElement.scrollLeft*1 + e.clientX*1 - window.AlWindowDrag.cursorPosX*1)
            var y = (document.documentElement.scrollTop*1 + e.clientY*1 - window.AlWindowDrag.cursorPosY*1)
            window.AlWindowDrag.AlWindow.resizeBy(x, y);
            
            window.AlWindowDrag.cursorPosX = document.documentElement.scrollLeft + e.clientX;
            window.AlWindowDrag.cursorPosY = document.documentElement.scrollTop + e.clientY;
            __SelectFix(window.AlWindowDrag.style.left.replace('px', '')*1, window.AlWindowDrag.style.top.replace('px', '')*1, x, y, window.AlWindowDrag.getElementsByTagName('select'));
	        return false;
	        
        }
        this.__ResizeRelease = function(e)
        {
	        var ie = false;
	        if(!e)
	        {
		        e = window.event;
		        ie = true;
	        }
        	
	        window.document.onmouseup = null;
	        window.document.onmousemove = null;
	        if(!ie)
	        {
		        window.document.removeEventListener("mousemove", _AlWindow.__ResizeRun, true);
		        window.document.removeEventListener("mouseup", _AlWindow.__ResizeRelease, true);
		        window.document.removeEventListener("mouseout", _AlWindow.__ResizeRun, true);
	        }
            window.document.onselectstart = null
            window.document.ondragstart = null;
	        window.document.onmouseout = null;
	        if(!window.AlWindowDrag) return;
	        
	        window.AlWindowDrag = null;
        }
        this.__DragStartHandler = function(e)
        {

            var ie = false;
            if(!e)
            {
	            e = window.event;
	            ie = true;
            }
            window.AlWindowDrag = (e.srcElement) ? e.srcElement : e.target;
            window.AlWindowDrag = _AlWindow.__FindDragObject(window.AlWindowDrag);
        	
        	
            if(window.AlWindowDrag == null) return;

            if(!ie)
            {
	            window.document.addEventListener("mousemove", _AlWindow.__DragRun, true);
	            window.document.addEventListener("mouseup", _AlWindow.__DragRelease, true);
	            window.document.addEventListener("mouseout", _AlWindow.__DragRun, true);
            }
            else
            {
	            window.document.onmouseup = _AlWindow.__DragRelease;
	            window.document.onmouseout = _AlWindow.__DragRun;
	            window.document.onmousemove = _AlWindow.__DragRun;
            }
            window.document.onselectstart = function() { return false; }
            window.document.ondragstart = function() { return false; }

            var left = getLeftPos(window.AlWindowDrag);
            var top = getTopPos(window.AlWindowDrag);
        				
            window.AlWindowDrag.cursorPosX = (document.documentElement.scrollLeft + e.clientX) - left;
            window.AlWindowDrag.cursorPosY = (document.documentElement.scrollTop + e.clientY) - top;
            window.AlWindowDrag.style.cursor = 'move';
            window.AlWindowDrag.style.left =  (document.documentElement.scrollLeft + e.clientX - window.AlWindowDrag.cursorPosX) + 'px';/*left*/
            window.AlWindowDrag.style.top = (document.documentElement.scrollTop + e.clientY - window.AlWindowDrag.cursorPosY) + 'px';//top
        	
            return false;
        }
        this.__FindDragObject = function(obj)
        {
	        if(!obj) return null;
	        
	        if(obj.style.position == 'absolute')
	        {
		        return obj;
	        }
	        if(obj.offsetParent)
	        {
		        return _AlWindow.__FindDragObject(obj.offsetParent);
	        }
	        else
	        {
		        return null;
	        }
        }
        this.__DragRun = function(e)
        {
	        if(window.AlWindowDrag == null) return;
	        var ie = false;
	        if(!e)
	        {
		        e = window.event;
		        ie = true;
	        }
	        var x = (document.documentElement.scrollLeft + e.clientX - window.AlWindowDrag.cursorPosX);
	        if(x < 2) x = 2;
	        var y = (document.documentElement.scrollTop + e.clientY - window.AlWindowDrag.cursorPosY);
	        if(y < 2) y = 2;
	        window.AlWindowDrag.style.left = x + 'px';//(__DragCloneObj.cursorPosX ? __DragCloneObj.cursorPosX : 5) + 'px';
	        window.AlWindowDrag.style.top = y + 'px';//(__DragCloneObj.cursorPosY ? __DragCloneObj.cursorPosY : 5) + 'px';
	        
	        __SelectFix((document.documentElement.scrollLeft + e.clientX - window.AlWindowDrag.cursorPosX), (document.documentElement.scrollTop + e.clientY - window.AlWindowDrag.cursorPosY), window.AlWindowDrag.style.width.replace('px', '')*1, window.AlWindowDrag.style.height.replace('px', '')*1, window.AlWindowDrag.getElementsByTagName('select'))
        }
        this.__DragRelease = function(e)
        {
	        var ie = false;
	        if(!e)
	        {
		        e = window.event;
		        ie = true;
	        }
        	
	        window.document.onmouseup = null;
	        window.document.onmousemove = null;
	        if(!ie)
	        {
		        window.document.removeEventListener("mousemove", _AlWindow.__DragRun, true);
		        window.document.removeEventListener("mouseup", _AlWindow.__DragRelease, true);
		        window.document.removeEventListener("mouseout", _AlWindow.__DragRun, true);
	        }
            window.document.onselectstart = null
            window.document.ondragstart = null;
	        window.document.onmouseout = null;
	        if(!window.AlWindowDrag) return;
	        
            window.AlWindowDrag.style.cursor = '';
	        window.AlWindowDrag = null;
        }
    }
    try
    {
    if(!document._AlWindow)
    {
        document._AlWindow = new AlWindow();
        //document._AlWindow = document._AlWindow.FindThisWindow();
    }
    if(!window._AlWindow) window._AlWindow = document._AlWindow;
    }
    catch(e)
    {
    
    }


var __pseudoModalInWin = null;

function pseudoModalInWinOpen(url, width, height)
{
    if($('pseudoModalInWinLockBg') == null)
    {
        //var lock_bg =  = createElement('div');
        lock_bg.style.display = 'none';
        lock_bg.id = 'pseudoModalInWinLockBg';
        lock_bg.className = 'in_win_locked_bg';
    }
    if($('pseudoModalInWin') == null)
    {
        __pseudoModalInWin = createElement('div');
        __pseudoModalInWin.id = 'pseudoModalInWin';
    }
    
    if(document.body)
    {
        document.body.style.overflow = 'hidden';
    }
    
    
}

function pseudoModalInWinClose()
{
    if(__pseudoModalInWin == null) return;
    __pseudoModalInWin.style.display = 'none';
    if($('pseudoModalInWinLockBg') != null)
    {
        $('pseudoModalInWinLockBg').style.display = 'none';
    }
    document.body.style.overflow = 'auto';
}

function __SelectFix(x, y, w, h, ex)
{
    if(!document.all || navigator.appVersion.indexOf('6.') == -1) return;
    var el = document.getElementsByTagName('select');
    var el_l = 0;
    var el_t = 0;
    var flag = false;
    var flg = false;
    var _w = 0;
    var _h = 0;
    for(var i = 0; i < el.length; i++)
    {
        if(!el[i].id) continue;
        flg = false;
        for(var j = 0; j < ex.length; j++)
        {
            if(el[i].id == ex[j].id)
            {
                flg = true;
                break;
            }
        }
        if(flg) continue;
        el_l = getLeftPos(el[i]);
        if(el_l==0 && el[i].AlWindowFixL) el_l = el[i].AlWindowFixL;
        el_t = getTopPos(el[i]);
        if(el_t==0 && el[i].AlWindowFixT) el_t = el[i].AlWindowFixT;
        flag = false;
        _w = el[i].offsetWidth;
        if(_w==0 && el[i].AlWindowFixW) _w = el[i].AlWindowFixW;
        _h = el[i].offsetHeight;
        if(_h==0 && el[i].AlWindowFixH) _h = el[i].AlWindowFixH;
        flag = ((el_l > x && el_l < (x + w)) && (el_t > y && el_t < (y + h)));
        flag = ((el_l + _w > x && el_l + _w < (x + w)) && (el_t + _h > y && el_t + _h < (y + h))) || flag
        if(flag && el[i].style.display != 'none')
        {
            el[i].style.display = 'none';
            el[i].AlWindowFix = true;
            el[i].AlWindowFixW = _w;
            el[i].AlWindowFixH = _h;
            el[i].AlWindowFixL = el_l;
            el[i].AlWindowFixT = el_t;
            window.status = el[i].id;
        }
        else
        {
            if(!flag && el[i].AlWindowFix && el[i].style.display == 'none')
            {
                el[i].style.display = '';
            }
        }
    }
}

////////////////////////////////////////////////////////////////
//////////////     RichSelectList Script       /////////////////
////////////////////////////////////////////////////////////////

var __RichSelectList_ReturnId = null;
var __RichSelectList_Spliter = "";
var __RichSelectList_IsMultipleAllowed = null;

function __RichSelectList_Url_Click(_ReturnId, _Url, _Spliter, _width, _height, flg)
{
    __RichSelectList_Spliter = _Spliter;
    if(flg == 1) __RichSelectList_IsMultipleAllowed = true;
    else __RichSelectList_IsMultipleAllowed = false;
    __RichSelectList_ReturnId = _ReturnId;
    pseudoModalPopUpOpen(_Url, _width, _height);
}

function __RichSelectList_Script_Click(_ReturnId, _Script, _Spliter, flg)
{
    __RichSelectList_Spliter = _Spliter;
    if(flg == 1) __RichSelectList_IsMultipleAllowed = true;
    else __RichSelectList_IsMultipleAllowed = false;
    __RichSelectList_ReturnId = _ReturnId;
    eval(_Script);
}

function __RichSelectList_SetValue(val, name, className)
{
    if(__RichSelectList_ReturnId == null)
    {
        return;
    }
    $(__RichSelectList_ReturnId).value = val;
    if($(__RichSelectList_ReturnId + '_text') != null && name != null)
    {
        $(__RichSelectList_ReturnId + '_text').value = name;
        if(className != null) $(__RichSelectList_ReturnId + '_text').className = className;
    }
    if(!__RichSelectList_IsMultipleAllowed)
    {
        if(__pseudoModalPopUpWin != null) __pseudoModalPopUpWin.close();
    }
}

function __ExtraTextBox_SetValue(val, spliter, className)
{
    if(__RichSelectList_ReturnId == null)
    {
        return;
    }
    if(!__RichSelectList_IsMultipleAllowed)
    {
        $(__RichSelectList_ReturnId).value = val;
    }
    else
    {
        if($(__RichSelectList_ReturnId).value.indexOf(";"+val+";") == -1)
        {
            if($(__RichSelectList_ReturnId).value.substr($(__RichSelectList_ReturnId).value.length - 1, 1) != ';' && $(__RichSelectList_ReturnId).value.length > 0) $(__RichSelectList_ReturnId).value += ';';
            $(__RichSelectList_ReturnId).value += val + spliter;
        }
    }
    //$(__RichSelectList_ReturnId + '_text').innerHTML = HtmlEncode(name);
    //if(className != null) $(__RichSelectList_ReturnId + '_text').className = className;
    if(!__RichSelectList_IsMultipleAllowed)
    {
        if(__pseudoModalPopUpWin != null) __pseudoModalPopUpWin.close();
    }
}

function __RichSelectList_Clear()
{
    __RichSelectList_ReturnId = null;
    __RichSelectList_IsMultipleAllowed = null;
    if(__pseudoModalPopUpWin != null)__pseudoModalPopUpWin.close();
}



////////////////////////////////////////////////////////////////
//////////////     Message management Script   /////////////////
////////////////////////////////////////////////////////////////

function __viewMessageflags(id)
{
    if($(id) == null) return;
    if($(id).style.display == "none") $(id).style.display = "block";
    else $(id).style.display = "none";
    if(__RichSelectList_ReturnId != null)
    {
        $(id).style.width = $(__RichSelectList_ReturnId + '_text').clientWidth + "px";
        //printProperty($(__RichSelectList_ReturnId + '_text'));
    }
}

function __add_contact_ToMessageTo(id, val)
{
    if(__RichSelectList_ReturnId == null)
    {
        return;
    }
    if(!__RichSelectList_IsMultipleAllowed)
    {
        $(__RichSelectList_ReturnId).value = val;
    }
    else if($(__RichSelectList_ReturnId).value.indexOf(" " + val) == -1 && $(__RichSelectList_ReturnId).value.indexOf(";" + val) == -1 && $(__RichSelectList_ReturnId).value.substr(0, val.length) != val)
    {
        if(str_replace(" ", "", $(__RichSelectList_ReturnId).value) != "")
        {
            $(__RichSelectList_ReturnId).value += __RichSelectList_Spliter;
        }
        $(__RichSelectList_ReturnId).value += val;
    }
    
    if(!__RichSelectList_IsMultipleAllowed)
    {
        if(__pseudoModalPopUpWin != null) __pseudoModalPopUpWin.close();
    }
}

var __add_field_file_last_id = 0;
function _add_field_file(id, prefix, postfix, img)
{
    if($(id) == null) return;
    
    var iel = new Array();
    if($(id + '0') != null)
    {
        iel = $(id + '0').getElementsByTagName("input");
    }
    var name = id;
    __add_field_file_last_id++;
    name += __add_field_file_last_id;
    var str = "";
    str += prefix;
    str += '<div id="' + name + "_container" + '" class="pd_v_2">';
    str += '<table border="0" cellpadding="0" cellspacing="0"><tr><td>';
    str += '<input type="file" id="' + name + "_file" + '" name="' + name + "_file" + '" />';
    str += '</td><td valign="bottom">';
    str += '&nbsp;<img alt="Delete" src="' + img + '" border="0" onclick="$(\'' + name + "_container" + '\').innerHTML=\'\'; $(\'' + name + "_container" + '\').style.display=\'none\';" class="cursor" />';
    str += '</td></tr></table>';
    str += '</div>';
    str += postfix + "\n\n";
    str += '<div id="' + id + '_new"></div>';
    $(id).innerHTML += str;
    
    //setTimeout("_open_field_file('" + name + "_file" + "', 0)", 500);
    $(id).id = id + __add_field_file_last_id;
    $(id + '_new').id = id;
}
function _open_field_file(id, i)
{
    if($(id) == null)
    {
        if(i < 100)
        {
            setTimeout("_open_field_file('" + id + "', " + (i+1) + ")", 200);
        }
        return;
    }
    $(id).click();
}

////////////////////////////////////////////////////////////////
////////////// Availability management Script  /////////////////
////////////////////////////////////////////////////////////////

function displayOnTime(id, t, effect)
{
    if($(id) == null) return;
    if($(id).style.display == "none")
    {
        $(id).style.display = "block";
        __Alpha(id, 100, 100, null);
        setTimeout("displayOnTime('" + id + "', 0, false)", t);
    }
    else
    {
        if(effect)
        {
            __Alpha(id, -10, 100, '$("' + id + '").style.display == "none";');
        }
        else
        {
            $(id).style.display = "none";
        }
    }
}


	var __availability_week_is_allow_edit = false;
	var __availability_week_mouse_up = function()
	{
		__availability_week_is_allow_edit = false;
		document.body.onmouseup = "";
		document.body.onselectstart = "";
		document.body.onmousemove = "";
	}
	
	var __availability_week_marker = 2;
	var __availability_week_data = new Array();
	
	function availability_week_mouse_down()
	{
		__availability_week_is_allow_edit = true;
		document.body.onmouseup = __availability_week_mouse_up;
		document.body.onselectstart = function() { return false; }
		document.body.onselect = function() { return false; }
		document.body.onmousemove = function(e) {
		    if(window.event) e = window.event;
		    e.cancelBubble = true;
		    var obj = e.srcElement?e.srcElement:e.target;
		    if(obj.id && obj.id.indexOf('avint_') != -1)
		    {
		        availability_week_mouse_move(obj);
		    }
		    return false;
		}
	}
	
	function availability_week_mouse_move(obj)
	{
		if(obj.style.backgroundColor != __availability_week_markers[0] || __availability_week_marker != 4)
		{
		    obj.style.backgroundColor = __availability_week_markers[__availability_week_marker];
		}
		return false;
	}


////////////////////////////////////////////////////////////////
//////////////           Effects Script        /////////////////
////////////////////////////////////////////////////////////////

function __Alpha(id, v, l, callback)
{
    if($(id) == null) return;
    try
    {
        if((l + v) < 0 || (l + v) > 100) return;
        var nl = (l + v);
        nl = nl<0?0:nl;
        nl = nl>100?100:nl;
        if(!$(id).style.opacity && $(id).style.filter && $(id).style.filter != null && $(id).style.filter != undefined)
        {
            $(id).style.filter = "alpha(opacity=" + nl + ")";
        }
        else
        {
            $(id).style.opacity = "." + nl;
        }
        if((nl >= 0 && v > 0) || (nl <= 100 && v < 0))
        {
            setTimeout("__Alpha('" + id + "', '" + v + "', '" + nl + "', '" + callback + "')", 100);
        }
        else if(callback != null)
        {
            eval(callback);
        }
    }
    catch(e){}
}

function ___resize_wysiwyg_to_max_width(id, n)
{
    if($(id) == null && n < 50)
    {
        setTimeout("___resize_wysiwyg_to_max_width('" + id + "', " + (n+1) + ")", 200);
    }
    else if($(id) != null)
    {
        $(id).style.width = "100%";
        $(id).width = "100%";
    }
}



////////////////////////////////////////////////////////////////
//////////////   Calendar description item     /////////////////
////////////////////////////////////////////////////////////////

function AlCalendarItem()
{
    this.StartTime = "";
    this.EndTime = "";
    this.Title = "";
    this.Description = null;
    this.CssClass = "grey";
    this.Patch = "day_description/";
    this.OnClick = null;
    
    this.Render = function()
    {
        var out = "";
        out += '<table border="0" cellpadding="0" cellspacing="0" onmouseover="this.className = this.className.replace(\'_active\',\'\'); this.className += \'_active\';"  onmouseout="this.className = this.className.replace(\'_active\',\'\');" class="cursor ' + this.CssClass + '" ' + (this.OnClick!=null?'onclick="' + this.OnClick + '"':"") + '>';
        out += '<tr onmouseover="__hcl_cl();"><td class="calendar_item_t_l"><img alt="." src="' + this.Patch + 't1x1.gif" width="5" height="5" /></td>';
        out += '<td class="maxw calendar_item_t_c"><img alt="." src="' + this.Patch + 't1x1.gif" width="1" height="5" /></td>';
        out += '<td class="calendar_item_t_r"><img alt="." src="' + this.Patch + 't1x1.gif" width="5" height="5" /></td></tr>';
        out += '<tr class="calendar_item_m"><td class="calendar_item_m_l"><img alt="." src="' + this.Patch + 't1x1.gif" width="1" height="1" /></td>';
        out += '<td>';
        out += '<div class="calendar_item_time">' + (this.Title==""?"Available. &nbsp;":"") + this.TimeFormat(this.StartTime) + ' - ' + this.TimeFormat(this.EndTime + 1) + '</div>';
        out += '<div class="calendar_item_title">' + this.Title + '</div>';
        out += '<div class="calendar_item_description">' + this.Description + '</div>';
        out += '</td>';
        out += '<td class="calendar_item_m_r"><img alt="." src="' + this.Patch + 't1x1.gif" width="1" height="1" /></td></tr>';
        out += '<tr><td class="calendar_item_b_l"><img alt="." src="' + this.Patch + 't1x1.gif" width="5" height="5" /></td>';
        out += '<td class="maxw calendar_item_b_c"><img alt="." src="' + this.Patch + 't1x1.gif" width="1" height="5" /></td>';
        out += '<td class="calendar_item_b_r"><img alt="." src="' + this.Patch + 't1x1.gif" width="5" height="5" /></td></tr><table>';
        return out;
    }
    
    this.TimeFormat = function(t)
    {
        var isPm = false;
        var h = (t - t%60)/60;
        if(h >= 12)
        {
            isPm = true;
        }
        if(h > 12)
        {
            h = h - 12
        }
        if(h == 0) h = 12;
        
        return h + ":" + ((t%60+"").length==1?"0":"") + (t%60) + " " + (isPm?"PM":"AM");
    }
    
    this.Sort = function(arr)
    {
        var na = new Array();
        var t = 0;
        for(var i = 0; i < arr.length; i++)
        {
            for(var j = 0; j < arr.length; j++)
            {
                if(arr[j] != null)
                {
                    t = j;
                }
            }
            for(var j = 0; j < arr.length; j++)
            {
                if(arr[j] != null && arr[j].StartTime < arr[t].StartTime) t = j;
            }
            na[na.length] = arr[t];
            arr[t] = null;
        }
        return na;
    }
}

////////////////////////////////////////////////////////////////
//////////////        RichDateBox Script       /////////////////
////////////////////////////////////////////////////////////////

function ___RichDateBoxSetDate(cal)
{
    
}

function ___RichDateBoxUpdateDate(cal)
{

    var day = $(cal.params.inputField.id + '_Day');
    if(day != null) day.value = cal.date.getDate();
    
    var month = $(cal.params.inputField.id + '_Month');
    if(month != null) month.value = cal.date.getMonth() + 1;
    
    var year = $(cal.params.inputField.id + '_Year');
    if(year != null) year.value = cal.date.getFullYear();
    
}

function ___RichDateTimeBoxUpdateDate(cal)
{

    var day = $(cal.params.inputField.id + '_Day');
    if(day != null) day.value = cal.date.getDate();
    
    var month = $(cal.params.inputField.id + '_Month');
    if(month != null) month.value = cal.date.getMonth() + 1;
    
    var year = $(cal.params.inputField.id + '_Year');
    if(year != null) year.value = cal.date.getFullYear();
    
    var hour = $(cal.params.inputField.id + '_Hour');
    if(hour != null) hour.value = cal.date.getHours();
    
    var minute = $(cal.params.inputField.id + '_Minute');
    if(minute != null) minute.value = cal.date.getMinutes();
    
}



////////////////////////////////////////////////////////////////
//////////////         Ticket Script           /////////////////
////////////////////////////////////////////////////////////////
var ___TicketItemsArr = new Array();

function Ticket()
{
    this.Style = null;
    this.CssClass = null;
    this.el = null;
    this.isFree = true;
    this.id = 0;
    this.Controls = new Array();
    this.Patch = "";
    
    this.Create = function(obj)
    {
        if(obj == undefined || obj == null)
        {
            this.el = document.createElement("div");
            $('_specific_container').appendChild(this.el);
        }
        else
        {
            this.el = obj;
            __hcl_cl();
        }
        this.el.style.position = 'absolute';
        this.el.style.display = 'none';
        if(this.CssClass != null) this.el.className = this.CssClass;
        if(this.Style != null) this.el.style = this.Style;
        if(obj == undefined || obj == null)
        {
            this.id =___TicketItemsArr.length;
            ___TicketItemsArr[this.id] = this;
        }
        this.isFree = false;
        return this;
    }
    
    this.GetFree = function()
    {
        for(var i = 0; i < ___TicketItemsArr.length; i++)
        {
            if(___TicketItemsArr[i].isFree)
            {
                ___TicketItemsArr[i].isFree = false;
                ___TicketItemsArr[i].el.innerHTML = "";
                return ___TicketItemsArr[i];
            }
        }
        return this.Create();
    }
    
    this.GetById = function(id)
    {
        if(___TicketItemsArr.length > id) return ___TicketItemsArr[id];
    }
    
    this.Render = function()
    {
        var tmp = "";
        this.el.innerHTML = '';
        tmp += '<div style="border: 1px solid #dddddd;background:#ffffff;">\n';
        for(var i = 0; i < this.Controls.length; i++)
        {
            tmp += this.Controls[i].Render();
        }
        tmp += '\n</div>\n';
        this.el.innerHTML += tmp;
    }
    
    this.Show = function(x, y)
    {
        this.el.style.top = y;
        this.el.style.left = x;
        this.el.style.display = "block";
    }
    
    this.Hidden = function()
    {
        //this.el.style.display = "none";
        this.el.interval = window.setTimeout('__hcl()', 200);
    }
    
    this.Clear = function()
    {
        this.el.style.display = "none";
        this.el.innerHTML = "";
        this.isFree = true;
    }
}

function __hcl()
{
    $('_specific_container').interval = setTimeout("$('_specific_container').obj.Clear();", 50);
}

function __hcl_cl()
{
    if($('_specific_container').interval)
    {
        try
        {
            window.clearTimeout($('_specific_container').interval);
        }
        catch(e){
        }
    }
}

function ___check_form_modification(obj, message)
{
    var __change = false;
    for(var i in document.forms[0].elements)
    {
        try
        {
            if(document.forms[0].elements[i]._alChange)
            {
                __change = true;
            }
        }
        catch(e)
        {}
    }
    if(__change && message != null)
    {
        if(confirm(message))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    return __change;
}











////////////////////////////////////////////////////////////////
//////////////           Last Script           /////////////////
////////////////////////////////////////////////////////////////

function autoResizePopUp()
{
    if($("___base_container") == null) return;
    //printProperties($("___base_container"));
    var h = $("___base_container").clientHeight;
    h = h + "";
    h = h.replace(" ", "");
    h = h.replace("px", "");
    h = (h*1 + 100);
    if(screen.clientHeight - 20 < h) h = (screen.clientHeight.replace("px", "").replace(" ", "") * 1) - 20;
    if(h < 250) h = 250;
    var w = $("___base_container").clientWidth;
    w = w + "";
    w = w.replace(" ", "");
    w = w.replace("px", "");
    w = (w*1 + (w*1==600?60:0));
    if(screen.clientWidth - 20 < w) w = (screen.clientWidth.replace("px", "").replace(" ", "") * 1) - 20;
    if(w < 300) w = 300;
    try
    {
        if(window._AlWindow && window._AlWindow.obj)
        {
           window._AlWindow.resizeTo((w < 600?600:w), h)
        }
        else
        {
            window.resizeTo((w < 600?600:w), h);
        }
    }
    catch(e)
    {
    
    }
}

setTimeout("autoResizePopUp()", 1000);