function browserCheck() 
{
	var b = navigator.appName;
	if (b == "Netscape") 
		this.b = "ns";
	else if (b == "Microsoft Internet Explorer") 
		this.b = "ie";
	else 
		this.b = b
	this.us = navigator.userAgent;
	
	//Opera check
	
	this.opera = this.us.indexOf("Opera");
	if(this.opera != -1){
		this.opera = true;
		this.b = "";
	}
	else {
		this.opera = false;
	}
	
	//Firefox Check
	
	this.firefox = this.us.indexOf("Firefox");
	if(this.us.indexOf("Firefox")!=-1){
		this.firefox = true;	
	}else{
		this.firefox = false;	
	}
	
	//DOM Check
	
	this.DOM = (document.createElement && document.getElementsByTagName);
	
	this.version = navigator.appVersion;
	if (this.b == 'ie')
	{ 
		var ve = this.version.indexOf("MSIE")
		this.v = parseInt(this.version.substr(ve+4))
	}
	else 
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v<5)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.ie55 = (this.version.indexOf('MSIE 5.5')>0)
	this.ie6 = (this.version.indexOf('MSIE 6')>0) 
	this.min = (this.ns||this.ie)
}//end BrowserCheck() 

is = new browserCheck();

function checkForm(name_form)
{

	var Form = document.getElementsByName(name_form);
	if (Form != null)
	{

		var elements = document.body.getElementsByTagName("select");
		for (var i=0; i<elements.length; i++)
		{
			if (!elements[i].name)
				continue;
			eval("var tt = document.forms." + name_form+ "." + elements[i].name);
			if (tt == null)
				continue;
			if ((elements[i].getAttribute('required') != null) && (elements[i].getAttribute('required') != '') && (elements[i].value == ''))
			{
				alert(elements[i].getAttribute('required'));
				elements[i].focus();
				return false;
			}
		}

		var tElement = document.body.getElementsByTagName("input");

		for (var i=0; i<tElement.length; i++)
		{
			if (!tElement[i].name || tElement[i].name.indexOf('[')>0)
				continue;
			eval("var tt = document.forms." + name_form+ "." + tElement[i].name);
			if (!tt || tt == null)
				continue;

			if ((tElement[i].getAttribute('required') != null) && (tElement[i].getAttribute('required') != '') && (tElement[i].value == ''))
			{
				alert(tElement[i].getAttribute('required'));
				tElement[i].focus();
				return false;
			}
			if ((tElement[i].getAttribute('equal') != null) && (tElement[i].getAttribute('equal') != ''))
			{
				var t = tElement[i].getAttribute('equal');
				eval("var tt = document.forms." + name_form+ "." + t);
				if ((tt != null) && (tt.value != tElement[i].value))
				{
					alert(tElement[i].getAttribute('equaltext'));
					tt.focus();
					return false;
				}
			}
			if ((tElement[i].getAttribute('minlength') != null) && (tElement[i].getAttribute('minlength') != '') && (tElement[i].value.length < tElement[i].getAttribute('minlength')))
			{
				alert(tElement[i].getAttribute('mintext'));
				tElement[i].focus();
				return false;
			}

			if (tElement[i].getAttribute('name') && (tElement[i].getAttribute('name').substring(0,5) == 'email') && (tElement[i].value != ''))
			{
				if (!echeck(tElement[i].value)) {
					tElement[i].focus();
					alert(tElement[i].getAttribute('required'));
					return false;
					}
			}

		}

		return true;
	}
	else
	{
		return fasle;
	}
}

function confirmDelete(question, where)
{
	temp = window.confirm(question);
	if (temp) //delete
	{
		window.location=where;
	}
}

function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true;					
}

function open_window(link,w,h) //opens new window
{
	var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=no,scrollbars=yes";
	wishWin = window.open(link,'wishWin',win);
}

function WindowProperty(){
	if(is.ie){
		this.iH = document.body.clientHeight;
		this.iW = document.body.clientWidth;	
	}else{
		this.iH = window.innerHeight;
		this.iW = window.innerWidth;	
	}
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		preloadFlag = true;
	}
}

function setHeight(n){
	Container = layer("content");
	H = Container.getHeight();
	Obj = document.getElementById("th");
	if(is.ie){
		Obj.style.height = H - n -2 + "px" ;
	}else{
		Obj.style.height = H - n + "px" ;
	}
}

function clock_status()
{
	window.setTimeout("clock_status()",1000);
	today=new Date();
	if (document.getElementById("clock")!=null)
		document.getElementById("clock").innerHTML="Today: "+today.toLocaleString();
} 
