
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_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// JavaScript Document

var W3CDOM = (document.createElement && document.getElementsByTagName);
var mouseOvers = new Array();
var mouseOuts = new Array();

function init()
{
	if (!W3CDOM) return;
	/*var nav = document.getElementById('container');*/
	var inputImgs = document.getElementsByTagName('input');
	var imageImgs = document.getElementsByTagName('img');
	var imgs = new Array();
	for (var i=0; i<imageImgs.length; i++) {imgs.push(imageImgs[i]);}
	for (var i=0; i<inputImgs.length; i++) {imgs.push(inputImgs[i]);}
	//alert (imgs.length);
	for (var i=0; i<imgs.length; i++)
	{
		if (imgs[i].src.indexOf('.gif') != -1) // On cible seulement les lments input de type image avec une extension de type .gif
		{			
			// Get image name
			//alert ( (imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.')) );
			tmp=(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.'));
			
			if ( tmp.indexOf('_') != -1) /* search all img have "_" */
			{
				if (tmp.substring(tmp.lastIndexOf('_')+1) == "n" )
					{
						//alert ( (imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.')) );
						imgs[i].onmouseover = mouseGoesOver;
						imgs[i].onmouseout = mouseGoesOut;
						mouseOuts[i] = new Image();
						mouseOuts[i].src = imgs[i].src;
						mouseOvers[i] = new Image();	
						
						/*	
						if (imgs[i].src.lastIndexOf('_') != -1) { mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('_')) + "_over" + suffix;}
						else { mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('.')) + "_over" + suffix;}
						*/
						var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
						if (imgs[i].src.lastIndexOf('.') != -1) { mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('_')) + "_o" + suffix;}
						imgs[i].number = i;
					}
			}
		}
	} //end for
} //end init

function initreset()
{
	if (!W3CDOM) return;
	var imgs = document.getElementsByTagName('img');
	for (var i=0; i<imgs.length; i++)
	{
		if (imgs[i].src.indexOf('.gif') != -1) // On cible seulement les lments input de type image avec une extension de type .gif
		{			
			tmp=(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.'));
			
			if ( tmp.indexOf('_') != -1) /* search all img have "_" */
			{
				if (tmp.substring(tmp.lastIndexOf('_')+1) == "o" )
				{
					//alert ( (imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.')) );
					var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
					var tmpimg= new Image();
						tmpimg.src=imgs[i].src.substring(0,imgs[i].src.lastIndexOf('_')) + "_n.gif";
					imgs[i].src=tmpimg.src;
				}
			}
		}
	} //end for
} //end initreset

var fsub=false;
var mobj;
var osrc="";
function mouseGoesOver(fsub, mEvent) {
	if (checkIt("msie") != 0) { // use in IE
		if (fsub==true) {
			mobj.src=osrc;
			fsub=false;
		} else {
			this.src = mouseOvers[this.number].src;
		}
		osrc=event.srcElement.src;
		mobj=event.srcElement;
	}
	else {	// use in firefox
		if (fsub==true) {
			mobj.src=osrc;
			fsub=false;
		} else if (fsub=='')  {
			osrc=mEvent.target.src;
			mobj=mEvent.target;
		} else {
			this.src = mouseOvers[this.number].src;
		}
	}
}

function mouseGoesOut() {this.src = mouseOuts[this.number].src;	}

//-->

<!--
var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring;
var version = 0;

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


//flashObject
var FlashObject = function(swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver;
	this.align = "middle";

	this.params = new Object();
	this.variables = new Object();

	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.bypassTxt = "<p>Already have Macromedia Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
	
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('quality', 'high'); // default to high
	this.doDetect = getQueryParamValue('detectflash');
}

var FOP = FlashObject.prototype;

FOP.addParam = function(name, value) { this.params[name] = value; }

FOP.getParams = function() { return this.params; }

FOP.getParam = function(name) { return this.params[name]; }

FOP.addVariable = function(name, value) { this.variables[name] = value; }

FOP.getVariable = function(name) { return this.variables[name]; }

FOP.getVariables = function() { return this.variables; }

FOP.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    return (paramTags == "") ? false:paramTags;
}

FOP.getHTML = function() {
    var flashHTML = "";
    if (navigator.plugins && navigator.mimeTypes.length) { // netscape plugin architecture
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" wmode="transparent" id="' + this.id + '" align="' + this.align + '"  scale="noborder" ';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs()) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    } else { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
		 flashHTML += '<param name="SCALE" value="noborder" />';
		 flashHTML += '<param name="wmode" value="transparent" />';
        if (this.getParamTags()) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    return flashHTML;	
}

FOP.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) { 
    	variablePairs.push(name + "=" + escape(this.getVariable(name))); 
    }
    return (variablePairs.length > 0) ? variablePairs.join("&"):false;
}

FOP.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else if (this.altTxt) {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}		
}

/* ---- detection functions ---- */
function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.mimeTypes.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			var y = x.description;
   			flashversion = y.charAt(y.indexOf('.')-1);
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}

function detectFlash(ver) {	return (getFlashVersion() >= ver) ? true:false; }

// get value of query string param
function getQueryParamValue(param) {
	var q = document.location.search || document.location.href.split("#")[1];
	if (q) {
		var detectIndex = q.indexOf(param +"=");
		var endIndex = (q.indexOf("&", detectIndex) > -1) ? q.indexOf("&", detectIndex) : q.length;
		if (q.length > 1 && detectIndex > -1) {
			return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
		} else {
			return "";
		}
	}
}
// by khang.phan 17/01/2007
// check contact form
function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}
function isEmail(s){
	if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/) != -1)
		return true ;
	return false ;
}

function isBlank(s) {
	if(trim(s) == "" ) 
		return true ;
	return false ;
}

function trim(s) {
	return s.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function isPhone(s) {
	
	if (isNaN(s))
		return true ;
	return false ;
}

function validate(field) 
{ 
	var valid = "0123456789-() "
	var temp;
	for (var i=0; i<field.value.length; i++) 
		{
			temp = "" + field.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") 
			return false;
		}
return true;
}

function checkContact(frmObj) {
	var fo = frmObj;
//	alert(fo.number.value);
	if (isBlank(fo.fullname.value)) {
		alert("Please enter your name.");
		fo.fullname.focus();
		return false;
	}
	if (isBlank(fo.email.value)) {
		alert("Please enter your email.");
		fo.email.focus();
        return false;
	}	
	if (!isEmail(fo.email.value)) {
		alert("Invalid Email format.");
        fo.email.focus();
		return false;
	}
	if (!isBlank(fo.number.value))
	{
		
		if(!validate(fo.number))
				{
					alert("Phone must be numbers! (123-456-7890)");
					fo.number.focus();
					return false;
				}
			
	
	/*
		if (isPhone(fo.number.value))
		{
			alert("Invalid phone number.");
			fo.number.focus();
			return false;
		} */
	}
	if (fo.message.value=="") {
		alert("Please enter your message.");
        fo.message.focus();
		return false;
	}
	if (fo.txtSecurityCode.value=="") {
		alert("Please enter security code.");
        fo.txtSecurityCode.focus();
		return false;
	}
	return true;
}

function saveContact(frmObj) {
	//use ajax to call updating command to server
	//var url_to = 'http://sm-pre/pek/scroll_giken/blogs/thanks.php';
	var url_to = '../../sendmail.php';
	var str_vars = Form.serialize($("frmContact"));

	var myAjax = new Ajax.Request( url_to, { 
								method: 'get', 
								parameters: str_vars, 
								onComplete: showResponse	
							}
					); 
}

function showResponse(originalRequest) {
	var browser = new Browser();
	if (originalRequest.responseText==1)
	{
		if (browser.isIE){
			window.location ="thanks.php";
		}else{
			window.location ="../../thanks.php";
		}
	}else{
		alert("Invalid security code.");
	}
}

function saveContactJP(frmObj) {
	//use ajax to call updating command to server
	//var url_to = 'http://sm-pre/pek/scroll_giken/blogs/thanks.php';
	var url_to = '../../sendmail.php';
	var str_vars = Form.serialize($("frmContact"));

	var myAjax = new Ajax.Request( url_to, { 
								method: 'get', 
								parameters: str_vars, 
								onComplete: showResponseJP	
							}
					); 
}

function showResponseJP(originalRequest) {
	var browser = new Browser();
	if (originalRequest.responseText==1)
	{
		if (browser.isIE){
			window.location ="thank-you.php";
		}else{
			window.location ="../../thank-you.php";
		}
	}else{
		alert("Invalid security code.");
	}
}
/* add Array.push if needed */
if(Array.prototype.push == null){
	Array.prototype.push = function(item) {this[this.length] = item; return this.length;}
}
