//Main<%=JS_CSS_VERSION%>.js file used in most files. Includes
//Java Script functions to show windows and some common functions. 
//Before modify something here see  JS_CSS_VERSION element in HTCOMNET\web.config file!!!
//var themename=new Array(ulcorn width, height, urcorn width, dlcorn height, rectcorn width, height)
var Y2K=new Array(7,26,6,25,12,12)
var XP=new Array(5,25,4,25,20,11)
var X1=new Array(6,22,6,34,10,10)
var X2=new Array(9,24,9,29,10,10)
var X3=new Array(6,23,6,26,10,10)
var X4=new Array(8,27,8,27,10,10)
var NO=new Array(8,27,8,27,10,10)
var ATTR_READ_ONLY=1;
var ie=navigator.userAgent.toLowerCase().indexOf("msie")!=-1?true:false;
var ie50=navigator.userAgent.toLowerCase().indexOf("msie 5.0")!=-1?true:false;
var Opera=navigator.userAgent.toLowerCase().indexOf("opera")!=-1?true:false;
var Koqueror=navigator.userAgent.toLowerCase().indexOf("konqueror")!=-1?true:false;
var Safari=navigator.userAgent.toLowerCase().indexOf("safari")!=-1?true:false;

var Opera8=navigator.userAgent.toLowerCase().indexOf("opera 8")!=-1?true:false;
var Opera7=navigator.userAgent.toLowerCase().indexOf("opera 7")!=-1?true:false;
var Opera6=navigator.userAgent.toLowerCase().indexOf("opera 6")!=-1?true:false;
var Opera5=navigator.userAgent.toLowerCase().indexOf("opear 5")!=-1?true:false;
var Opera4=navigator.userAgent.toLowerCase().indexOf("opera 4")!=-1?true:false
var Netscape4=navigator.userAgent.toLowerCase().indexOf("mozilla/4.79")!=-1?true:false
var Netscape6=navigator.userAgent.toLowerCase().indexOf("netscape6")!=-1?true:false
var Netscape7=navigator.userAgent.toLowerCase().indexOf("netscape/7")!=-1?true:false
var Netscape8=navigator.userAgent.toLowerCase().indexOf("netscape/8")!=-1?true:false
var IE4=navigator.userAgent.toLowerCase().indexOf("msie 4")!=-1?true:false

var eventObj=null;
var lastcolor=''


function CheckBrowser()
{

	if(Opera4 || Opera5) 
	{	
		window.alert('Sorry, file manager don\'t support your browser. Please install Opera 7 or higher.');
	}
	else if(Opera6) 
	{
		window.alert('Opera 6 don\'t supports Drop down menu in program! Please install Opera 7 or higher.');
	}
	else if(Netscape4) 
	{
		window.alert('Sorry, file manager don\'t support your browser. Please install Netscape 7 or higher.');
	}
	else if(Netscape6) 
	{
		window.alert('Netscape 6 don\'t supports Drop down menu in program! Please install Netscape 7 or higher.');
	}
	else if(IE4) 
	{
		window.alert('Sorry, file manager don\'t support your browser. Please install Internet Explorer 5.0 or higher.');
	}

}
	
function ismouseout(ev, item)
{
    var tgt;
    if (ev.relatedTarget)
        tgt = ev.relatedTarget;
    else if (ev.toElement)
        tgt = ev.toElement;
    return  (!tgt || !IsobjContains(item, tgt));
}


function Xoffset(obj, relativobj)
{
    if (typeof(obj) != 'object' || obj == null)
    {
        return 0;
       }
    else
    {
        return obj.offsetLeft + Xoffset(obj.offsetParent, relativobj);
     }
}

function Yoffset(obj)
{
    if (typeof(obj) != 'object' || obj == null)
    {
        return 0;         
      }
    else
    {
        return obj.offsetTop + Yoffset(obj.offsetParent);
      }
}

function SetStyles(el, stylestr)
{
    if (!stylestr)
        return;
    var stylesarr = stylestr.split(';');
    for (var i = 0; i < stylesarr.length; ++i) {
        var style = stylesarr[i].split(':');
        if (style.length == 2) {
            if (style[0] == 'className')
                el.className = style[1];
            else
            {
                el.style[style[0]] = style[1];
			}
        }
    }
}

function RemoveStyles(el, stylestr)
{
    if (!stylestr)
        return;
    var stylesarr = stylestr.split(';');
    for (var i = 0; i < stylesarr.length; ++i) {
        var style = stylesarr[i].split(':');
        if (style.length == 2) {
            if (style[0] == 'className')
                el.className = '';
            else
            {
	           el.style[style[0]] = '';
            }
        }
    }
}

function IsobjContains(obj, SearchEl)
{
    if (!obj)
        return null;
    else if (obj.contains)
        return obj.contains(SearchEl);
    else
    {
        var i;
		if (!obj.childNodes)
			return false;
		for (i = 0; i < obj.childNodes.length; ++i) {
			var child = obj.childNodes[i];
			if (SearchEl == child)
				return true;
			else if (IsobjContains(child, SearchEl))
				return true;
		}
		return false;
    }
}

function getParent(node)
{
   if (node.parentElement)
     return node.parentElement;
   else if (node.parentNode)
     return node.parentNode;
   else 
     return null;

}

function GetEventStr()
{
	if(eventObj==null) 
	{
		return 'event'
	}
	else
		return eventObj;
}


function getAttribute(obj, attr)
{
	if(obj.getAttribute)
	{
		return obj.getAttribute(attr)
	}
	return null
}


function EmptySelection()
{


	if (window.getSelection)
	{
		if(window.getSelection.removeAllRanges)
			window.getSelection.removeAllRanges();
	}
	else if (document.getSelection)
	{
		if(document.getSelection.removeAllRanges)
			document.getSelection.removeAllRanges()
	}
	else if (document.selection)
	{
		if(document.selection.empty)
			document.selection.empty();
	}
}


function hidesel()
{
	setInterval('EmptySelection()', 5)
}

function Innerheight()
{
	if(document.body.clientHeight)
		return document.body.clientHeight
	else if(window.innerHeight)
		return window.innerHeight;
}

function Innerwidth()
{
	if(document.body.clientWidth)
		return document.body.clientWidth
	else if(window.innerWidth)
		return window.innerWidth;
}

function writetoform(framename, filename, field, value)
{
	window.parent[framename].document.postform.action= filename
	window.parent[framename].document.postform[field].value=value
}

function writepostform()
{
	document.write('<form name="postform" method="post" action=""><input type="hidden" name="content">'+
	'<input type="hidden" name="pattern"><input type="hidden" name="newfoldername"><input type="hidden" name="newfilename">'+
	'<input type="hidden" name="zipname"><input type="hidden" name="addnewzip"><input type="hidden" name="targetname">'+
	'<input type="hidden" name="newname"><input type="hidden" name="filename"><input type="hidden" name="to"><input type="hidden" name="fileorfolder">'+
	'<input type="hidden" name="fullpath"><input type="hidden" name="file"><input type="hidden" name="indexes"><input type="hidden" name="task"></form>')
}

function drawupwin(str, width, height, color, vari)
{
	if(window.parent.topFrame)
		var theme=window.parent.topFrame.ActiveTheme
	else if(window.parent.opener.parent.topFrame)
		var theme=window.parent.opener.parent.topFrame.ActiveTheme
	else
		var theme=window.opener.parent.topFrame.ActiveTheme;
	var s;
	s='<table height="' + height + '" width="' + width + '" border="0" cellspacing="0" cellpadding="0"><tr bgcolor="' + color + '">'+
	'<td width="' + eval(theme+'[0]') + '" height="' + eval(theme+'[1]') + '"><img height="' + eval(theme+'[1]') + '" width="' + eval(theme+'[0]') + '" src="images/themes/' + theme + '/ulcorn.gif">' +
	'</td><td height="' + eval(theme+'[1]') + '" background="images/themes/' + theme + '/uc.gif">' 			
	s=s+'<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr valign="absmiddle">'+
	'<td><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">' + 
	'<b>' + str + '</b></font></td>'
	if(vari==1) s=s+'<td width="280" align="right"><a hre' + 'f="htt' + 'p://ww' + 'w.htt' + 'p-co' + 'm.co' + 'm" target="_blank"><Font color="White" style="font-size:12px;">HTT' + 'P Co' + 'mm' + 'ander 3' + '0-d' + 'ay tr' + 'ial</Font></a></td>';
	if(vari==2) s=s+'<td width="280" align="right"><a hre' + 'f="htt' + 'p://ww' + 'w.htt' + 'p-co' + 'm.co' + 'm" target="_blank"><Font color="White" style="font-size:12px;">HTT' + 'P Co' + 'mm' + 'ander. Onl' + 'y 3' + ' act' + 'ive users</Font></a></td>';
	s=s+'</tr></table>'
	s=s+'</td><td height="' + eval(theme+'[1]') + '" width="' + eval(theme+'[2]') + '"><img src="images/themes/' + theme + '/urcorn.gif" width="' + eval(theme+'[2]') + '" height="' + eval(theme+'[1]') + '">' +
	'</td></tr><tr bgcolor=' + color + '><td width="' + eval(theme+'[0]') + '" background="images/themes/' + theme + '/lb.gif">' +
	'&nbsp;</td><td mytype="emptyfield" valign="top" height="' + (height - eval(theme+'[1]') - eval(theme+'[3]')) + '">';
	document.write(s);
}


function drawdownwin(str)
{
	if(window.parent.topFrame)
		var theme=window.parent.topFrame.ActiveTheme
	else if(window.parent.opener.parent.topFrame)
		var theme=window.parent.opener.parent.topFrame.ActiveTheme
	else
		var theme=window.opener.parent.topFrame.ActiveTheme;
	var s;
	s='</td><td width="' + eval(theme+'[2]') + '" background="images/themes/' + theme + '/rb.gif">&nbsp;</td>'+
	'</tr><tr height="' + eval(theme+'[3]') + '"><td height="' + eval(theme+'[3]') + '" ><img src="images/themes/' + theme + '/dlcorn.gif" width="' + eval(theme+'[0]') + '" height="' + eval(theme+'[3]') + '"></td>'+
	'<td height="' + eval(theme+'[4]') + '" background="images/themes/' + theme + '/dc.gif" >'
	s+='<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
	'<tr valign="absmiddle"><td>'+ str +
	'&nbsp;</td>'+
	'<td width="' + eval(theme+'[4]') + '"><img src="images/themes/' + theme + '/rectcorn.gif" width="' + eval(theme+'[4]') + '" height="' + eval(theme+'[5]') + '"></td>'+
	'</tr></table>'
	s+='</td><td width="' + eval(theme+'[2]') + '" height="' + eval(theme+'[3]') + '"><img src="images/themes/' + theme + '/drcorn.gif" width="' + eval(theme+'[2]') + '" height="' + eval(theme+'[3]') + '"></td>'+
	'</tr></table>';
	document.write(s);
}


function replace(str, symbol, symbol2)
{
	var s=str.toUpperCase();
	var i;
	i=s.indexOf(symbol.toUpperCase(), 0);
	while (i>=0)
	{
		s=s.substring(0,i) + symbol2 + s.substring(i+symbol.length, s.length)
		i=s.indexOf(symbol.toUpperCase(), i+ symbol2.length);
	}
	return(s)
}

function BreakToPieces(str, piecelength, delim)
{
	var ret='';
	while(str.length>piecelength)
	{
		ret = ret + str.substring(0,piecelength) + delim
		str = str.substring(piecelength,str.length)
	}
	ret = ret + str
	return ret;
}


function escapeplus(str)
{
	var s=new String(str);
	s=s.replace('+','STUPIDPLUSSTUPID');
	s=escape(s);
	s=s.replace('STUPIDPLUSSTUPID','%2B');
	
	/*var s=new String(str);	
	s=s.replace('%','%25');
	s=s.replace('?','%3F');
	s=s.replace('&','%26');
	s=s.replace(' ','%20');
	s=s.replace('+','%2B');
	s=s.replace('#','%23');*/
	return(s)
}

function Ext(filename)
{
	var s=new String(filename);
	var n=s.lastIndexOf('.')
	if(n!=-1)
		return s.substring(n+1,s.length).toUpperCase()
	else
		return "";
}

function Path(filename)
{
	var s=new String(filename);
	var n=s.lastIndexOf('\\')
	if (n==-1) n=s.lastIndexOf('\/')
	if (n!=-1) return s.substring(0,n+1)
	return ''
}

function FileName(path)
{
	var s=new String(path);
	var n=s.lastIndexOf('\\')
	if (n==-1) n=s.lastIndexOf('\/')
	if (n!=-1) return s.substring(n+1,s.length)
	return path
}

function JavaFormat(str)
{
	var s=new String(str);
	s=replace(s, '\\','\\\\')
	s=replace(s, '\'','\\\'')
	s=replace(s, '\(','\\\(')
	s=replace(s, '\)','\\\)')
	s=replace(s, '\"','\\\"')
	s=replace(s, '\+','\\\+')
	return s
}

function strFormat(mainstr, str1, str2, str3, str4)
{
	var s=new String(mainstr)
	s=s.replace("\{0\}", str1)
	s=s.replace("\{1\}", str2)
	s=s.replace("\{2\}", str3)
	s=s.replace("\{3\}", str4)
	return s
}

function EndsWith(str, end)
{
	var n=str.toUpperCase().lastIndexOf(end.toUpperCase())
	if( n==-1 || n!=(str.length-end.length))
		return false;
	return true	
}

function StartsWith(str, end)
{
	var n=str.toUpperCase().indexOf(end.toUpperCase())
	if(n==0)
		return true;
	return false	
}

function Exist(arr, value)
{
	var i;
	for(i in arr)
	{
		if(arr[i]==value)
			return true;
	}
	return false;
}

function strCompare(str1, str2, ignorecase)
{
	if(ignorecase==false)
	{
		if(str1==str2)
			return 0
		else
			return 1;
	}
	else
	{
		if(str1.toUpperCase()==str2.toUpperCase())
			return 0
		else
			return 1;
	};
	
}

/*
var CountStartTimeArray=new Array(100);
var CountTotalTimeArray=new Array(100);
var CountFuncArray=new Array(100);
var Countlastid=0;

function StartCountTime(funcname)
{
	var now = new Date().getTime();
	var i=0
	var found=-1;
	for(i=0;i<Countlastid;i++)
	{
		if(strCompare(CountFuncArray[i],funcname)==0)
		{
			found=i;
			break;
		}
	}
	if(found!=-1)
	{
		CountStartTimeArray[found]=now;		
	}
	else
	{
		CountFuncArray[Countlastid] = funcname
		CountStartTimeArray[Countlastid] = now
		CountTotalTimeArray[Countlastid] = 0
		Countlastid++;
	}
}

function FinishCountTime(funcname)
{
	var now = new Date().getTime();
	var i=0
	var found=-1;
	for(i=0;i<Countlastid;i++)
	{
		if(strCompare(CountFuncArray[i],funcname)==0)
		{
			found=i;
			break;
		}
	}
	if(found!=-1)
	{
		CountTotalTimeArray[found] = CountTotalTimeArray[found] + now - CountStartTimeArray[found];
	}

}
function ShowTime(funcname)
{
	var i=0
	var found=-1;
	for(i=0;i<Countlastid;i++)
	{
		if(strCompare(CountFuncArray[i],funcname)==0)
		{
			found=i;
			break;
		}
	}
	if(found!=-1)
	{
		window.alert(funcname + ' time: ' + CountTotalTimeArray[found]);
	}
	else
	{
		window.alert('Function ' + funcname + ' not found!');
	}

}*/