function isDate(dd, mm, yyyy) {
	var Months = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

	if(isLYear(yyyy) == true) Months[1] = 29;
	if(dd > Months[mm - 1]) return false;
	return true;
}

function isLYear(val) {
	if(val.length == 0) return false;

	var yyyy = parseInt(val);
	if((yyyy % 4 == 0 && yyyy % 100 != 0) || (yyyy % 400 == 0)) return true;
	else return false;
}

function isNum(checkStr) {
	var checkOK = "0123456789.";
	apoint = false;
	for (i=0;i<checkStr.length;i++) {
		allValid = false;
		ch=checkStr.charAt(i);
		for(j=0;j<checkOK.length;j++) {
			if(ch==checkOK.charAt(j)) {
				allValid = true;
				break;
			}
		}
		if (ch == ".") {
			if (apoint == false) { apoint = true; }
			else { allValid = false; }	
		}
		if (allValid == false) break;
	}
	return allValid;
}

function isNo(checkStr) {
	var checkOK = "0123456789";
	for (i=0;i<checkStr.length;i++) {
		allValid = false;
		ch=checkStr.charAt(i);
		for(j=0;j<checkOK.length;j++) {
			if(ch==checkOK.charAt(j)) {
				allValid = true;
				break;
			}
		}
		if (allValid == false) break;
	}
	return allValid;
}

function cint(val) {
	var len = val.length;
	var actChr;
	var newVal = "";
	if(val.length == 0) { return ""; }
	else {
		for(var i1 = 0; i1 < len; i1++) {
			actChr = val.charAt(i1);
			switch(actChr) {
				case "0" :
					newVal = newVal + actChr;
					break;
				case "1" :
					newVal = newVal + actChr;
					break;
				case "2" :
					newVal = newVal + actChr;
					break;
				case "3" :
					newVal = newVal + actChr;
					break;
				case "4" :
					newVal = newVal + actChr;
					break;
				case "5" :
					newVal = newVal + actChr;
					break;
				case "6" :
					newVal = newVal + actChr;
					break;
				case "7" :
					newVal = newVal + actChr;
					break;
				case "8" :
					newVal = newVal + actChr;
					break;
				case "9" :
					newVal = newVal + actChr;
					break;
				case "," :
					if(newVal.indexOf(".") == -1) { newVal = newVal + "."; }
					break;
				case "." :
					if(newVal.indexOf(".") == -1) { newVal = newVal + actChr; }
					break;
				default :
					break;
			}
		}
		newVal = newVal * 1;
		return parseInt(newVal);
	}		 
}

function isEmail( email ) {
	invalidChars = " /:,;"
	if (email == "") { return (false); }
	for (i=0; i < invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) != -1) { return (false);	 }
	}
	atPos = email.indexOf("@", 1)
	if (atPos == -1) {return (false);}
	if (email.indexOf("@", atPos + 1) != -1) { return (false); }
	periodPos = email.indexOf(".", atPos)
	if (periodPos == -1) {	return (false);}
	if (periodPos + 3 > email.length) {	return (false);}
	return (true);
}

function ccur(val, decCou) {
	var len = val.length;
	var actChr;
	var newVal = "";
	if(val.length == 0) {
		return "";
	}
	else {
		for(var i1 = 0; i1 < len; i1++) {
			actChr = val.charAt(i1);
			switch(actChr) {
				case "0" :
					newVal = newVal + actChr;
					break;
				case "1" :
					newVal = newVal + actChr;
					break;
				case "2" :
					newVal = newVal + actChr;
					break;
				case "3" :
					newVal = newVal + actChr;
					break;
				case "4" :
					newVal = newVal + actChr;
					break;
				case "5" :
					newVal = newVal + actChr;
					break;
				case "6" :
					newVal = newVal + actChr;
					break;
				case "7" :
					newVal = newVal + actChr;
					break;
				case "8" :
					newVal = newVal + actChr;
					break;
				case "9" :
					newVal = newVal + actChr;
					break;
				case "," :
					if(newVal.indexOf(".") == -1) {
						newVal = newVal + ".";
					}
					break;
				case "." :
					if(newVal.indexOf(".") == -1) {
						newVal = newVal + actChr;
					}
					break;
				default :
					break;
			}
		}
		if(newVal.indexOf(".") == -1) {
			return newVal * 1;
		}
		else {
			if(decCou >= 0) {
				var posDot = newVal.indexOf(".");
				newVal = newVal.substring(0, ((posDot + 1) + decCou));
			}
			else {
				newVal = newVal.substring(0, (len + 1))
			} 
		}
		if(len == newVal.indexOf(".")) {
			newVal = newVal.substring(0, (len + 1));
			return newVal * 1;
		}
		else {
			return newVal * 1;
		}
	} 
}

function right(val, pos) {
	var result = "";
	if(val.length == 0) {
		return "";
	}
	else {
		result = val.substring((val.length - pos), val.length);
		return result;
	}		 
}

function left(val, pos) {
	var result = "";
	if(val.length == 0) {
		return "";
	}
	else {
		result = val.substring(0, pos);
		return result;
	}		 
}

function mid( val , start_pos , len_pos ) {
	var result = "";

	if(val.length == 0) {
		return "";
	}
	else {
		if ( start_pos > val.length) return '';
		if ( len_pos == null || len_pos.length == 0 ) return "";
		result = val.substr( ( start_pos - 1), len_pos );
		return result;
	}
}

function lcase(val) {
	var result = "";
	if (val.length == 0) {
		return "";
	}
	else {
		result = val.toLowerCase();
		return result;
	}
}

function ucase(val) {
	var result = "";
	if (val.length == 0) {
		return "";
	}
	else {
		result = val.toUpperCase();
		return result;
	}
}

function preload() { //v3.0
	var d = document; 
	if (d.images) { 
		if (!d.pic) d.pic = new Array();
		var i, j = d.pic.length, a = preload.arguments;
		for (i=0; i<a.length; i++) if (a[i].indexOf("#")!=0) { d.pic[j]=new Image; d.pic[j++].src=a[i]; }
	}
}

function check(href)
{
	href = href.toLowerCase();
	var slash = href.lastIndexOf("/");
	if (-1 != slash) { href = href.substr(slash + 1); }
	return href;
}

function movecolor(e,s) {
	if (s == 1) e.style.background = "#FFFF99"
	else e.style.background = "#EEF0F7"
}

function NumOnly() {
	if (event.keyCode>='0'.charCodeAt()&&event.keyCode <= '9'.charCodeAt())
		event.returnValue = true;
	else
		event.returnValue = false;
}

function opLink( p , tg, r, t, m, s, w, h ) {
	if ( tg != "" ) {
		var webnew = window.open( p, tg, "resizable="+r+",toolbar="+t+",directories=0,menubar="+m+",scrollbars="+s+",status=1,width=" + w + ",height=" + h );
		webnew.focus();
	}
	else if ( tg == "" ) window.location.href = p;
}

function winpop( url , po , w , h , r , s ) {
	var wnew = window.open( url , po ,"resizable="+r+",location=0,toolbar=0,directories=0,menubar=0,scrollbars="+s+",status=1,width=" + w + ",height=" + h );
}

function openpx( p, wn, w, h, r, s, c, ox ) {
	if ( ox == 1 ) {
		var PX, PY
		if ( PX == null ) PX=Math.ceil( ( window.screen.width-w ) / 2 );
		if ( PY == null ) PY=Math.ceil( ( window.screen.height-h ) / 2 );

		pgHTML = "<head><title>H&auml;fele Home	</title></head>";
		pgHTML += "<body leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\">";
		pgHTML += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align=\"center\">";
		pgHTML += "<tr><td><img src=\"" + p + "\" border=\"0\" galleryimg=\"no\"></td></tr>";
		if ( c == 1 ) {
			h+=44;
			pgHTML += "<tr height=\"10\"><td></td></tr>";
			pgHTML += "<tr height=\"10\"><td align=\"center\"><input type=\"button\" value=\"CLOSE\" onclick=\"window.close()\"></td></tr>";
		}
		pgHTML += "</table>";
		pgHTML += "</body>";
		var wnew=window.open("", wn ,"resizable="+r+",location=0,toolbar=0,directories=0,menubar=0,scrollbars="+s+",status=1,width=" + w + ",height=" + h )
		wnew.document.open()
		wnew.document.write( pgHTML )
		wnew.document.close()
//		wnew.resizeTo(Math.ceil( w ),Math.ceil(H))
//		wnew.moveTo( Math.ceil( PX ), Math.ceil( PY ) )
	} else if ( ox == 2 ) {
		if ( document.all ) {
			w += 20;
			h += 24;
		} else {
			w += 16;
			h += 16;
		}
		var wnew = window.open( p , wn ,"resizable="+r+",location=0,toolbar=0,directories=0,menubar=0,scrollbars="+s+",status=1,width=" + w + ",height=" + h );
	}
//	if ( document.all ) wnew.moveTo( (( screen.width - w ) / 2 ) , (( screen.height - h ) / 2 ) );
//	else wnew.moveTo( (( screen.availWidth - w ) / 2 ) , (( screen.availHeight - h ) / 2 ) );
	if ( ! wnew.opener ) wnew.opener = self;
	wnew.focus();
}

/***********************************************
* Bookmark site script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
***********************************************/
/* Modified to support Opera */
function bookmarksite( title , url ) {
	if ( window.sidebar ) { // firefox
		window.sidebar.addPanel( title , url , "" );
	} else if ( window.opera && window.print ) { // opera
		var elem = document.createElement('a');
		elem.setAttribute( 'href' , url );
		elem.setAttribute( 'title' , title );
		elem.setAttribute( 'rel' , 'sidebar' );
		elem.click();
	} else if ( document.all ) { // ie
		window.external.AddFavorite( url , title );
	}
}

