function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function NewWindow(url, windowName, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
	win = window.open(url, windowName, winprops);
	if (parseInt(navigator.appVersion) >= 4) { 
		win.window.focus(); 
	}
}

/* change lang */
chl = new Array(5);
chl[0]=".php",
chl[1]=".html",
chl[2]=".htm",
chl[3]=".asp",
chl[4]=".do",
chl[5]=".jsp";
chl[6]=".shtml";
function chlangen() {
var url=document.URL;
var define='http://icweb.no-ip.com:81/';
var define2='http://icweb.no-ip.com:81';

	if(url==define || url==define2){
			url=define+'index_en.php';
			window.location=url;
		}else{
				for (i = 0; i <= 5 ; i++) {
					
					(found =(document.URL).replace(chl[i],''))!= false;
						if (found) {
						newurl =(document.URL).replace(chl[i],'_en'+chl[i]);
						window.location=newurl;
						break;
						}
					}
		}
}
function chlangth() {
		var url=document.URL;
			newurl =(document.URL).replace('_en','');
			window.location=newurl;
}

function swaptb(showtb,hidetb) {
	document.getElementById(showtb).style.display = "block" ;
	document.getElementById(hidetb).style.display = "none" ;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function verifySubmit(){
	if(document.search.zoom_query.value == "Type your keyword" || !document.search.zoom_query.value.match(/\S/)){
		alert('Please input your keyword');
		document.search.zoom_query.focus();
		return false;
	}
	return true;
}
function verifyEmail(){
	if(!document.emailFrom.email.value.match(/\S/)){
		alert('Please input e-mail address');
		document.emailFrom.email.focus();
		return false;
	}else{
		if(!isEmail(document.emailFrom.email.value)){
			alert("e-mail not format");
			document.emailFrom.email.focus();
			return false;
			}
	}
	return true;
}
