function Is() {
    agent      = navigator.userAgent.toLowerCase();
    this.mac   = (agent.indexOf("mac")        !=   -1);
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns    = ((agent.indexOf('mozilla')   !=   -1) && ((agent.indexOf('spoofer')   ==   -1) && (agent.indexOf('compatible') ==   -1)));
    this.ns2   = (this.ns && (this.major      ==    3));
    this.ns3   = (this.ns && (this.major      ==    3));
    this.ns4b  = (this.ns && (this.major      ==    4) && (this.minor                  <= 4.03));
    this.ns4   = (this.ns && (this.major      ==    4));
    this.ns6   = (this.ns && (this.major     >=    5));
    this.ie    = (agent.indexOf("msie")       !=   -1);
    this.ie3   = (this.ie && (this.major      < 4));
    this.ie4   = (this.ie && (this.major      ==    4) && (agent.indexOf("msie 5.0")   ==   -1));
    this.ie5   = (this.ie && (this.major      ==    4) && (agent.indexOf("msie 5.0")   !=   -1));
    this.ie55  = (this.ie && (this.major      >=    4) && (agent.indexOf("msie 5.5")   !=   -1));
    this.aol   = (agent.indexOf("aol")        !=   -1);
    this.aol3  = (this.aol && this.ie3);
    this.aol4  = (this.aol && this.ie4);
    this.aol5  = (this.aol && this.ie5);
}

var is = new Is();


//************************************************************************************
// Cross Browser Funcitons ver 3.5 
// Copyright (C) by Audi carousel@taiwan.com
// http://www.carousel.com.tw
// http://www.toocool.com.tw
// http://www.chinasofar.com
// http://www.inkstar.com
// http://www.itposter.com
// http://www.innophoto.com
// http://www.plotterMarket.com
// LastModified:Sep,2001 
// Modified Note: For Netscape 6.X , Mozilla captiable

ns4 	= (document.layers);
ns6 	= ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >=5))
ie4 	= (document.all);
//ie4   	= ((parseInt(navigator.appVersion) == 4) && (navigator.appName.indexOf("msie 5.0") == -1));
ie5   	= ((parseInt(navigator.appVersion) == 4) && (navigator.appName.indexOf("msie 5.0") != -1));
ie55  	= ((parseInt(navigator.appVersion) >= 4) && (navigator.appName.indexOf("msie 5.5") != -1));
ver4 	= (ns4 || ie4);
mac45 	= (navigator.appVersion.indexOf("MSIE 4.5") != -1)
isMac 	= (navigator.appVersion.indexOf("Mac") != -1);

var layerRef="null",layerStyleRef="null",styleSwitch="null",nostyleSwitch="null";
var widthClipSwitch="null";
var heightClipSwitch="null";
var bWidth,bHeight,offsetX,offsetY;
var layerTop,layerLeft;
var pxSwtch;
var leftStopPoint=0;
var currTop=120;
var clipScale=7;
var ns=false,ie=false;
var topStop;
var vSpeed;

function init(){
	
	if (ns4) {
		layerStyleRef="layer.";
		layerRef="document.layers[";
		styleSwitch="]";
		pxSwitch="";
		layerTop=".top";
		layerLeft=".left";
		widthClipSwitch="].clip.right";
		heightClipSwitch="].clip.bottom";
		offsetX= "window.pageXOffset";
		offsetY= "window.pageYOffset";
		bHeight=window.innerHeight;
		bWidth= window.innerWidth;
		topStop=120;
		ns4=true;
		document.onmouseup=hide_All_subMenu;
	}
	if (ie4){ // mean ie4,ie5,ie5.5 or above
		layerStyleRef="layer.style.";
		layerRef="document.all[";
		styleSwitch="].style";
		nostyleSwitch="]";
		pxSwitch='px';
		layerTop=".pixelTop";
		layerLeft=".pixelLeft";
		widthClipSwitch=".clientWidth";
		heightClipSwitch=".clientHeight";
		offsetX= "document.body.scrollLeft";
  		offsetY= "document.body.scrollTop";
  		bHeight=document.body.clientHeight;
  		bWidth= document.body.clientWidth;
  		topStop=120;
  		ie=true;
  		document.onmouseup=hide_All_subMenu;
	}
	
	if (ns6){
		layerStyleRef="layer.style.";
		layerRef="document.getElementById(";
		styleSwitch=").style";
		nostyleSwitch=")";
		pxSwitch='px';
		layerTop=".top";
		layerLeft=".left";
		widthClipSwitch=".offsetWidth";
		heightClipSwitch=".offsetHeight";
		offsetX= "window.pageXOffset";
		offsetY= "window.pageYOffset";
		bHeight=window.innerHeight;
		bWidth= window.innerWidth;
		topStop=120;
  		ns6=true;
  		//document.onmousemove=mouseMove;
		document.onmouseup=hide_All_subMenu;
	}
}

//******************************************************************************
// General functions
// functions: showLayer(), hideLayer(), moveLayerto(), changeLayerContent()

function showLayer(layerName){
	eval(layerRef+'"'+layerName+'"'+styleSwitch+'.visibility="visible"');
}
	
function hideLayer(layerName){
	eval(layerRef+'"'+layerName+'"'+styleSwitch+'.visibility="hidden"');
}

function moveLayerto(layerName,top,left){
	//if (ns6){
	//	eval('document.getElementById("'+layerName+'").style.top=top');
	//	eval('document.getElementById("'+layerName+'").style.left=left');
	//}else{	
		eval(layerRef+'"'+layerName+'"'+styleSwitch+'.top=top');
		eval(layerRef+'"'+layerName+'"'+styleSwitch+'.left=left');
	//}	
	
}

function getLayerHeight(layerName){
	var height;
	
	if (ns4) {
		layerRef="document.layers[";
		styleSwitch="]";
		pxSwitch="";
		layerTop=".top";
		layerLeft=".left";
		widthClipSwitch="].clip.right";
		heightClipSwitch="].clip.bottom";
	}
	if (document.all){ // mean ie4,ie5,ie5.5 or above
		layerRef="document.all[";
		nostyleSwitch="]";
		heightClipSwitch=".clientHeight";
		widthClipSwitch=".clientWidth";
	}
	
	if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >=5)){
		layerRef="document.getElementById(";
		nostyleSwitch=")";
		heightClipSwitch=".offsetHeight";
		widthClipSwith=".offsetWidth";
	}
	
	//這是特例，因為在js還沒載入時就讀取了，所以一些變數都沒有了
	eval('height='+layerRef+'"'+layerName+'"'+nostyleSwitch+heightClipSwitch);
	return height;
}

function getLayerWidth(layerName){
	var width;
	
	if (ns4) {
		layerRef="document.layers[";
		styleSwitch="]";
		pxSwitch="";
		layerTop=".top";
		layerLeft=".left";
		widthClipSwitch="].clip.right";
		heightClipSwitch="].clip.bottom";
	}
	if (document.all){ // mean ie4,ie5,ie5.5 or above
		layerRef="document.all[";
		nostyleSwitch="]";
		heightClipSwitch=".clientHeight";
		widthClipSwitch=".clientWidth";
	}
	
	if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >=5)){
		layerRef="document.getElementById(";
		nostyleSwitch=")";
		heightClipSwitch=".offsetHeight";
		widthClipSwith=".offsetWidth";
	}
	
	//這是特例，因為在js還沒載入時就讀取了，所以一些變數都沒有了
	eval('width='+layerRef+'"'+layerName+'"'+nostyleSwitch+widthClipSwitch);
	//return height;
	//height=eval(layerRef+'"subMenu5"'+nostyleSwitch+heightClipSwitch);
	//this is ok eval('height=document.all["'+layerName+'"].clientHeight');
	//this is ok height=document.all.["subMenu5"].clientHeight;
	//this is ok height=document.getElementById("subMenu5").offsetHeight;
	return width;
}

var currLeft,currTop

function moveLayerLeft(layerName){ 
	if (eval(layerRef+'"'+layerName+'"'+styleSwitch+'.left != leftStopPoint+pxSwitch')){
		currLeft-=2;
		eval(layerRef+'"'+layerName+'"'+styleSwitch+'.left = currLeft');
		setTimeout('moveLayerLeft("'+layerName+'")',10);
	 }
}

function changeLayerContent(layerName,text){
        if (navigator.appName == "Netscape") {
                eval('document.layers["'+layerName+'"].document.write("'+text+'")');
                eval('document.layers["'+layerName+'"].document.close()');
        }else{
                eval('document.all["'+layerName+'"].innerHTML="'+text+'"');
        }
}



//********************************************************************************
// onMouseover scroll bars
// functions: scrollLayerDwon(),scrollLayerUp(), rollDown(), rollUp(); rollStop()

var rollOBJ;

function scrollLayerDown(layerName,vSpeed){ 
	var stoppoint
	
	
	// 傳回 layer 的總高度 *注意* IE 不再加 styleSwitch!!!!
	// NS : document.layers[layerName].clip.bottom 
	// IE : document.all[layerName].clientHeight 
	stoppoint=bHeight -60 - eval(layerRef+'"'+layerName+'"'+heightClipSwitch);
	if (stoppoint < 0){
		if (eval(layerRef+'"'+layerName+'"'+styleSwitch+layerTop+ '> stoppoint')){
			currTop-=vSpeed;
			eval(layerRef+'"'+layerName+'"'+styleSwitch+'.top = currTop');
		}	
	}
}

function scrollLayerUp(layerName,vSpeed){ 
	if (eval(layerRef+'"'+layerName+'"'+styleSwitch+layerTop +'< topStop')){
		currTop+=vSpeed;
		eval(layerRef+'"'+layerName+'"'+styleSwitch+'.top = currTop');
	}	
}

function rollDown(layerName,vSpeed){
	var sstring;
	eval(sstring='"'+layerName+'",'+vSpeed);
	
	scrollLayerUp(layerName,vSpeed);
	eval("rollOBJ=setTimeout('rollDown("+sstring+")',10);");
}

function rollUp(layerName,vSpeed){
	var sstring;
	eval(sstring='"'+layerName+'",'+vSpeed);
	
	scrollLayerDown(layerName,vSpeed);
	eval("rollOBJ=setTimeout('rollUp("+sstring+")',10);");
}

function rollStop(){
	clearTimeout(rollOBJ);
}


//********************************************************************************
// For intraPosterSis usage
//
var totalMenu=5;
var menuTop=25;
var menuOffset=2;
var menuHeight=20;
function showMenu(n){
	var submenuHeight=new Array();
	var currMenuTop=0;
	for (var i=1;i<=totalMenu;i++){
		hideLayer(eval('"subMenu'+i+'"'));
		submenuHeight[i]=eval(layerRef+'"subMenu'+i+'"'+nostyleSwitch+heightClipSwitch);
	}
	showLayer(eval('"subMenu'+n+'"'));
	for (var i=1;i<=totalMenu;i++){
		if (i<=n){
			moveLayerto(eval('"menu'+i+'"'),menuTop+menuHeight*(i-1),menuLeft);
			moveLayerto(eval('"subMenu'+i+'"'),menuTop+menuHeight*n,menuLeft+menuOffset);
		}else{
			moveLayerto(eval('"menu'+i+'"'),menuTop+menuHeight*(i-1)+submenuHeight[n],menuLeft);
		}
	}
}



var menuLeft=10;
var menuWidth=80;
var menuOffset=0;
var onScreen=false;
var mainMenuClick=false;

function menuClick(){
	mainMenuClick=!mainMenuClick;
}

function pullMenu(n){
	var newY;
	if (mainMenuClick){
		var submenuWidth=new Array();
		var currMenuWidth=0;
		for (var i=1;i<=totalMenu;i++){
			hideLayer(eval('"subMenu'+i+'"'));
			submenuWidth[i]=eval(layerRef+'"subMenu'+i+'"'+nostyleSwitch+widthClipSwitch);
		}
		
		if (n!=0){
			showLayer(eval('"subMenu'+n+'"'));
			for (var i=1;i<=totalMenu;i++){
				if (i<=n){
					eval('newY='+offsetY);
					//moveLayerto(eval('"menu'+i+'"'),menuTop,menuLeft+menuWidth*(i-1));
					moveLayerto(eval('"subMenu'+i+'"'),menuTop+newY,menuLeft+menuWidth*(i-1));
				}else{
					eval('newY='+offsetY);
					moveLayerto(eval('"menu'+i+'"'),menuTop+newY,menuLeft+menuWidth*(i-1)+submenuWidth[n]);
				}
			}
			onScreen=true;
		}else{
			onScreen=false;
		}
	}
}

function hide_All_subMenu(e){
	if (onScreen){
		pullMenu(0);
		mainMenuClick=false;
	}
}


var img1,img2,img3,img4,img5,img6,img7,img8,img9,img10;
var img11,img12,img13,img14,img15,img16,img17,img18,img19,img20;
var imgc1,imgc2,imgc3,imgc4,imgc5,imgc6,imgc7,imgc8,imgc9,imgc10;
var imgc11,imgc12,imgc13,imgc14,imgc15,imgc16,imgc17,imgc18,imgc19,imgc20;
var imgh1,imgh2,imgh3,imgh4,imgh5,imgh6,imgh7,imgh8,imgh9,imgh10;
var imgh11,imgh12,imgh13,imgh14,imgh15,imgh16,imgh17,imgh18,imgh19,imgh20;

var nowImg;
var imgIndex=1;

for (var i=1;i<=20;i++){
	eval('img'+i+'=new Image();');
	eval('imgc'+i+'=new Image();');
	eval('imgh'+i+'=new Image();');
	eval('img'+i+'.src="/images/Lauch/icon_'+i+'.gif"');
	eval('imgc'+i+'.src="/images/Lauch/icon_'+i+'_c.gif"');
	eval('imgh'+i+'.src="/images/Lauch/icon_'+i+'_h.gif"');
}

function overImage(n){
	eval('nowImg=document.images["i'+n+'"].src');
	eval('document.images["i'+n+'"].src=imgc'+n+'.src');
}

function outImage(n){
	//eval('document.images["i'+n+'"].src="/images/Lauch/icon_'+n+'.gif"');
	eval('document.images["i'+n+'"].src="'+nowImg+'"');
}

function clickImage(n){
	//for (var i=1;i<=20;i++){
	//	eval('document.images["i'+i+'"].src=img'+i+'.src');
	//}	
	eval('document.images["i'+imgIndex+'"].src=img'+imgIndex+'.src');
	eval('document.images["i'+n+'"].src=imgh'+n+'.src');
	eval('nowImg=document.images["i'+n+'"].src');
	imgIndex=n;
}

function setInfo(){
	
	moveLayerto('info',bHeight-eval(layerRef+'["info"]'+heightClipSwitch)-5,30);
	showLayer('info');
}

function openURL(url){
	if (url!='none'){window.open(url);}
}	

function orderDetail(url){
	var winOBJ;
	if (navigator.appName == "Netscape"){
   		var ScreenHeight=window.screen.availHeight;
    		var ScreenWidth=window.screen.availWidth;
    		winOBJ=window.open(url,"ORDER","scrollbars=1,resizable=1,status=yes,width="+(ScreenWidth-12)+",height="+(ScreenHeight-56)+",top=0,left=0");
    	}else{
    		winOBJ=window.open('','ORDER','scrollbars=1,resizable=1status=yes,top=0, left=0,width='+window.screen.availWidth+',height='+window.screen.availHeight);
   		winOBJ.resizeTo(window.screen.availWidth,window.screen.availHeight);
   		winOBJ.location=url;
    	}	
}

//********************************************************************************
// Form Validation function set
//

function checkString(form){
// field can not contain some characters like '"\/?*

	var temp_input;
	var forbidCharString='#+:\\?;=';
	var forbidChar=new Array();
	
	forbidChar=forbidCharString.split('');
	
	if (form.value.indexOf('"')!=-1){
		alert('欄位請勿包含「"」字元');
		temp_input=form.value;
		form.value='';
	}
	if (form.value.indexOf('\'')!=-1){
		alert('欄位請勿包含「\'」字元');
		temp_input=form.value;
		form.value='';
	}
	
	
	for (var i=0;i<forbidChar.length;i++){
		if (form.value.indexOf(forbidChar[i])!=-1){
			alert('欄位請勿包含「'+forbidChar[i]+'」字元');
			temp_input=form.value;
			form.value='';
		}
	}
	
}

function checkNum(form){
// field must be digital 

	var temp_input,temp_length;
	
	if (isNaN(form.value)){
		alert('請輸入數字!');
		form.value='';
		return false
	}
}

function checkNumM(form){
// field must be digital 

	var temp_input,temp_length;

	if (form.value!='-'){	
		if (isNaN(form.value)){
			alert('請輸入數字!');
			form.value='';
			return false
		}
    }

}

function openWindow(strURL,winName,winWidth,winHeight){
	
	var objWindow,blnlongcall=false;
	var winHeightBrowserShell=0;
	
	//center window
	var screenMarginL=0;
	var screenMarginTop=0;
	if(winWidth>0 && winHeight>0){
		screenMarginL=(screen.width - winWidth)/2;
		screenMarginTop=(screen.height - winHeight - winHeightBrowserShell)/2;
	}

	if(blnlongcall==true){
		window.open(strURL,winName,'width='+winWidth+',height='+winHeight+',left=' + screenMarginL + ',top=' + screenMarginTop + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no');
	}else{
		objWindow=window.open(strURL,winName,'scrollbars,resizable,width='+winWidth+',height='+winHeight+',left=' + screenMarginL + ',top=' + screenMarginTop);
	}	
}

function showStep(layerName,method){
	if (method=='show'){method='inline';}
	if (method=='hide'){method='none';}
	if (method=='auto'){
		var sh;
		eval('sh='+layerRef+'"'+layerName+'"'+styleSwitch+'.display');
		if (sh=='none'){method='inline';}
		if (sh=='inline'){method='none';}
	}	
	eval(layerRef+'"'+layerName+'"'+styleSwitch+'.display="'+method+'"');
}