function browseIt()
{
	this.ver = navigator.appVersion.toLowerCase();
	this.verNum = parseInt(this.ver);
	this.agent = navigator.userAgent.toLowerCase();
	this.dom = (document.getElementById ? 1 : 0);
	this.opera = (this.agent.indexOf("opera") > -1 && this.dom ? 1 : 0);
	this.opera7 = (this.opera && this.verNum >= 7);
	this.opera9 = (this.opera && this.verNum >= 9);
	this.ie = (this.ver.indexOf("msie") > -1 && this.dom && !this.opera ? 1 : 0);
	this.ieVer = 0;
	if (this.ie) {
		var pos = this.ver.indexOf("msie");
		if (pos != -1)
			this.ieVer = parseFloat(this.ver.substr(pos + 5));
	}
	this.ie6 = (this.ie && (this.ieVer >= 6));
	this.ie6only = (this.ie && (this.ieVer >= 6) && (this.ieVer < 7));
	this.ie7 = (this.ie && (this.ieVer >= 7));
	this.macOS = (this.agent.indexOf("mac") > -1);
	this.mac = (this.macOS && this.verNum >= 7 ? 1 : 0);
	this.moz = (this.agent.indexOf("gecko") > -1);
	this.ns6 = (this.dom && this.agent.indexOf("netscape") > -1 && this.verNum >= 5 ? 1 : 0);
	this.ff = (this.agent.indexOf("firefox") > -1);
	this.b = (this.ie || this.ns6 || this.opera7 || this.mac || this.moz || this.dom);

	return this;
}

//var px = window.opera ? "" : "px";
var b = new browseIt();

function clearValue(obj,toPwd)
{
	if (obj)
	{
		obj.value = "";
		if (toPwd)
		{
			var parent = obj.parentNode;
			var objId = obj.id;
			
			if (parent != null)
			{
				var oldInput = parent.innerHTML;
				
				oldInput = oldInput.replace('type="text"','');
				oldInput = oldInput.replace('onfocus=clearValue(this,1);','onfocus=clearValue(this,0);');
				oldInput = oldInput.replace('onclick=clearValue(this,1);','onclick=clearValue(this,0);');
				oldInput = oldInput.replace('onfocus="clearValue(this,1);"','onfocus="clearValue(this,0);"');
				oldInput = oldInput.replace('onclick="clearValue(this,1);"','onclick="clearValue(this,0);"');

				oldInput = oldInput.replace('>',' type="password">');
				
				if (oldInput.search(/type=password/i) == -1)
				{
					parent.removeChild(obj);
					parent.innerHTML = oldInput;
				
					var newObj = document.getElementById(objId)
					if (newObj)
					{
						newObj.focus();
						newObj.focus();
					}
				}
			}
		}
	}
} 

function checkKey(e,withCtrl,keys,urls)
{
	var code;
	if (!e) var e = window.event;
	
	if (withCtrl == 1)
	{
		if (e.keyCode && e.ctrlKey) code = e.keyCode;
		else if (e.which && e.ctrlKey) code = e.which;	
	}
	else
	{
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;			
	}

	//alert(code);
	if (keys.length>0)
	{
		for (i=0; i < keys.length; i++)
		{
			if (code == keys[i])
			{
				if (urls[i])
				{
					//alert(urls[i]);
					window.location = urls[i];
				}
			}
		}
	}	
}

function checkKey2(e,id)
{
	var code;
	
	if (!e) var e = window.event;
	
	var keyPressObj = (e.srcElement)?e.srcElement:null;
	keyPressObj = (e.target)?e.target:keyPressObj;
	
	if (e.keyCode)
	{
		code = e.keyCode;
	}
	else if (e.which) 
	{
		code = e.which;	
	}
	
	var dontSubmit = 0;
	if (keyPressObj)
		if (keyPressObj.type == "textarea" || keyPressObj.type == "button")
			dontSubmit = 1;
	
	if (code == 13 && !dontSubmit)
	{
		var submitForm = document.getElementById(id);
		if (submitForm)
		{
			submitForm.submit();
		}
	}
	
} 

function add_click (url,target) {
	if (url) {
	//alert("Debug:"+url);
	//alert("Debug:"+target);
	if (target=="_parent") {
	parent.location.href=url;
	}
	if (target=="_blank") {
	window.open(url);
	}
	if (target=="_self") {
	location.href=url;
	}
	if (target=="_top") {
	top.location.href=url;
	}
	}//end if !url
}

function rollOver(id,file)
{
	var thisObj = document.getElementById(id);
	thisObj.src = file;
}

function replaceContent2(id,url)
{	
	//ShowMessage();
	
	//HTML_AJAX.replace(id,url);
	RequestData(url);
	//replaceContent(id,RequestData(url))
}

function getCalendar(id,p,url,globalUrl)
{
	var SendURL = globalUrl+"ajax.php?p="+p+"&"+url;
	//alert(SendURL);
	//window.scrollTo(0,0); 
	StatusMessage();
	
	var loadingM = document.getElementById('loadingSI');
	if (loadingM)
		loadingM.style.display = "block"; 
			
	replaceContent2(id,SendURL);
}  

function getCalendar2(urlHome,id,p,url,loadingSI)
{
	var SendURL = urlHome + "ajax.php?p="+p+"&"+url;
	//alert(SendURL);
	//window.scrollTo(0,0); 
	StatusMessage();
	
	var loadingM = document.getElementById(loadingSI);
	if (loadingM)
		loadingM.style.display = "block"; 
			
	replaceContent2(id,SendURL);
} 

function setupMessage()
{
	var loading = document.getElementById('HTML_AJAX_LOADING');
	if (!loading) 
	{
		loading = document.createElement('div');
		loading.id = 'HTML_AJAX_LOADING';
		loading.innerHTML = '';		
		loading.className = 'HTML_AJAX_Loading';
		loading.count = 0;	

		document.body.insertBefore(loading,document.body.firstChild);
	} 
	
	loading.style.display = "none";
}

function StatusMessage()
{
	setupMessage();
	return;
	
	//var stMessage = document.getElementById('HTML_AJAX_LOADING');
	//if (stMessage == null)
	//{
		//return;
	//}
		
	//var newPlace = document.getElementById(idContent);	
		
	//if (newPlace != null)
	//{
		//var insertInParent = (newPlace.parentNode)?newPlace.parentNode:newPlace.parent;			
		//insertInParent.appendChild(stMessage);		
	//}
	
	//var parentWidth = insertInParent.offsetWidth;
	
	//stMessage.style.left = "auto";
	//stMessage.style.right = 40 +  "px";
	//stMessage.style.width = 100 +  "px";
	//stMessage.style.height = 20 +  "px";
	//stMessage.style.top = "149px";
	//stMessage.style.display = "block";
}

function ShowHide (id)
{
	var obj = document.getElementById(id);
	
	if (obj)
	{		
		switch (obj.style.display)
		{
			case "none":
				obj.style.display = "block";
				break;
				
			case "block":
				obj.style.display = "none";	
				break;
		}
	}
}
