function winnew(URL,w,h,scrollbar)
{
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar+',toolbar=0,location=0,status=0,menubar=0,resizable=0,dependent=0,copyhistory=0' 
	{
		MyPopUp = window.open(URL,"",settings)
	}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function zoomImage(imgName, imgWidth, imgHeight) {
//imgWindow = window.open(imgName, 'ZoomImage', 'top=0, left=0, toolbar=no, location=no, directories=no, scrollbars=yes, status=no, resizable=yes');
var winWidth=(imgWidth>screen.width)?screen.width:imgWidth;
var winHeight=(imgHeight>screen.height)?screen.height:imgHeight;

var windowX = (screen.height-winHeight)/2;
var windowY = (screen.width-winWidth)/2;
var Html=""+
"<html>"+
"<head>"+
"<title>Zoom Image</title>"+
"</head>"+
"<body style=\"margin: 0px 0px 0px 0px; overflow:auto;\">"+
"<img src=\""+imgName+"\" width=\""+imgWidth+"\" height=\""+imgHeight+"\" border=\"0\" alt=\"\">"+
"</body>"+
"</html>"
	//newWindow = window.open(Url, winName, 'top='+wint+', left='+winl+', toolbar=no, location=no, directories=no, scrollbars=yes, status=no, resizable=yes, width='+winWidth+', height='+winHeight+'');
	//newWindow.focus();

	imgWindow = window.open("", 'ZoomImage', 'top='+windowX+', left='+windowY+', toolbar=no, location=no, directories=no, status=no, resizable=no, width='+winWidth+', height='+winHeight+'');
	imgWindow.blur();
	window.focus()
	//imgWindow.resizeTo(winWidth, winHeight);
	//newWindow.moveTo(windowX, windowY);
	imgWindow.document.open();
	imgWindow.document.write(Html);
	imgWindow.document.close();
	imgWindow.focus()

}


/* Function String */
function Trim(str){
	return RTrim(LTrim(str));
}

function LTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1) j++;
		s = s.substring(j, i);
	}
	return s;
}

function RTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1; // Get length of string
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--;
		s = s.substring(0, i+1);
	}
	return s;
}

function StringReplace(string, text, by) {
// Replaces text with by in string
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;

	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))) return string;
	if (i == -1) return string;

	var newstr = string.substring(0,i) + by;

	if (i+txtLength < strLength)
		newstr += StringReplace(string.substring(i+txtLength,strLength),text,by);

	return newstr;
}

// onKeyPress="return KeyDigit(this.value, event);"
function KeyDigit(str, e) {
var keycode;
if (window.event)
	keycode = window.event.keyCode;
else if (e)
	keycode = e.which;
else
	return true;

if (((keycode>47) && (keycode<58) )  || (keycode==8))
	return true;
else
	return false;
}



/* Function Control */
function EmailValidate(Email) {
	var goodEmail = Email.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

	if (goodEmail){
		return true;
	} else {
		return false
	}
}

function ParseQuery(q) {
	if(q.length > 1) 
		this.q = q.substring(1, q.length);
	else 
		this.q = null;

	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}


function SwitchLang(Lang) {
	var page = new parseUrl();
	try {
		var StrQuery = '?Lang='+Lang
		var keyArray = page.getParameters();

		if(keyArray.length > 0) {
			for(i=0; i<keyArray.length; i++) {
				if (keyArray[i] != 'Lang') {
					StrQuery += '&'+keyArray[i]+'='+page.getValue(keyArray[i]);
				}
			}
		}
		window.location = page.Filename+StrQuery;


	} catch (e) {
		//alert(e.message)

		window.location = page.Filename+'?Lang='+Lang;

	}
	void(0);

}

function parseUrl() {
	
	var URL = unescape(location.href);	// get current URL in plain ASCII
	var xstart = URL.lastIndexOf("/") + 1;
	var xend = URL.length;
	var hereName = URL.substring(xstart, xend);
	var herePath = URL.substring(0, xstart);
	
	if (hereName.lastIndexOf("?") != -1) {
		xend = hereName.lastIndexOf("?");
		hereName = hereName.substring(0, xend);
	}


	this.Path = herePath;
	this.Filename = hereName;
	this.QueryString = window.location.search;
	
	if(this.QueryString.length > 1) 
		this.QueryString = this.QueryString.substring(1, this.QueryString.length);
	else 
		this.QueryString = null;

	this.keyValuePairs = new Array();
	if(this.QueryString) {
		for(var i=0; i < this.QueryString.split("&").length; i++) {
			this.keyValuePairs[i] = this.QueryString.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}

