// JavaScript Document
// JavaScript Document
var IMPORTJS = {
	initialize: false,
  path:'',
  param:'',
  init: function() {
	  this.initialize = true;
    var script = document.getElementsByTagName("script");
    for (var i = 0; i<script.length; i++ ){
      var tmp = script[i].src;
      if (tmp.indexOf("/euw.js")!=-1){
        this.path = tmp.replace(/euw\.js(\?.*)?$/,'');
        var includes = tmp.match(/\?.*param=([a-z,]*)/);
        if (includes){
        	this.param = includes[1];
        }        
        break;
      }
    }
  },
  load: function(scriptname){
  	if (!this.initialize){
  		this.init();
  	}
  	var names = scriptname;
  	if (typeof scriptname=='string'){
  		names = [scriptname];
  	}
  	for(var i=0;i<names.length;i++){
  		document.write('<script type="text/javascript" src="' + this.path + names[i] + '"></script>');
  	}
  }
};

IMPORTJS.load(['language.jsp',
'prototype.js',
'browser.js']);

var objImage = null;
var objPrevImage = null;
var objWidth = null;
var objHeight = null;
var imageType = "BIG";
var openerWindow = "";
var iconPath = "";
var audioFiles = "";
var videoFiles = "";
var gSmallImgWidth = 130;
var gSmallImgHeight = 130;
var gDefaultImage = "test.jpg";
var gFilePath = "";
var gGalleryPath = "";
var gUserModePath = "";
var gGalleryWindowWidth = 1;//780;
var gGalleryWindowHeight = 1;//540;
/**
var browser_languages = ",en-us,zh-cn,zh-tw,";
var default_language = "en-us";
var user_language = document.all?navigator.browserLanguage.toLowerCase():navigator.language.toLowerCase();
user_language = (user_language==null?"zh-tw":(user_language=="zh-hk"?"zh-tw":user_language));
var help_language = user_language;
if (browser_languages.indexOf("," + user_language + ",")==-1){
  help_language = default_language;
}*/

function DIY_Browser() {
 d=document;
 this.agent=navigator.userAgent.toLowerCase();
 this.major = parseInt(navigator.appVersion);
 this.dom=(d.getElementById)?1:0; // true for ie6, ns6
 this.ns=(d.layers);
 this.ns4up=(this.ns && this.major >=4);
 this.ns6=(this.dom&&navigator.appName=="Netscape");
 this.op=(this.agent.indexOf('opera')!=-1&&this.major<7);
 this.opera5=(this.agent.indexOf("Opera 5")>-1);
 this.ie=(d.all);
 this.ie4=(d.all&&!this.dom)?1:0;
 this.ie4up=(this.ie && this.major >= 4);
 this.ie5=(d.all&&this.dom);
 this.ie6=(this.agent.indexOf("msie 6")>-1 && this.dom && !this.opera5)?1:0;
 this.ie7=(this.agent.indexOf("msie 7")>-1 && this.dom && !this.opera5)?1:0;
 this.win=((this.agent.indexOf("win")!=-1) || (this.agent.indexOf("16bit")!=-1));
 this.mac=(this.agent.indexOf("mac")!=-1);
}

var oBw = new DIY_Browser();

function getH(o) { var h=0; if (oBw.ns) { h=(o.height)? o.height:o.clip.height; return h; } h=(oBw.op)? o.style.pixelHeight:o.offsetHeight; return h; }
function setH(o,h) { if(oBw.ns) {if(o.clip) o.clip.bottom=h;}else if(oBw.op)o.style.pixelHeight=h;else o.style.height=h; }

function getW(o) { var w=0; if(oBw.ns) { w=(o.width)? o.width:o.clip.width; return w; } w=(oBw.op)? o.style.pixelWidth:o.offsetWidth; return w; }
function setW(o,w) { if(oBw.ns) {if(o.clip) o.clip.right=w;}else if(oBw.op)o.style.pixelWidth=w;else o.style.width=w; }

function getX(o) { var x=(oBw.ns)? o.left:(oBw.op)? o.style.pixelLeft:o.offsetLeft; return x;}
function setX(o,x) { (oBw.ns)? o.left=x:(oBw.op)? o.style.pixelLeft=x:o.style.left=x; }

function getY(o) {  var y=(oBw.ns)? o.top:(oBw.op)? o.style.pixelTop:o.offsetTop; return y;}
function setY(o,y) { (oBw.ie||oBw.dom)? o.style.top=y:(oBw.ns)? o.top=y:o.style.pixelTop=y; }

function getPageX(o) { if(oBw.ns) { var x=(o.pageX)? o.pageX:o.x; return x; } else if (oBw.op) {  var x=0; while(eval(o)) { x+=o.stylo.pixelLeft; e=o.offsetParent; } return x; } else { var x=0; while(eval(o)) { x+=o.offsetLeft; o=o.offsetParent; } return x; } }

function getPageY(o) { if(oBw.ns) { var y=(o.pageY)? o.pageY:o.y; return y; } else if (oBw.op) {  var y=0; while(eval(o)) { y+=o.stylo.pixelTop; o=o.offsetParent; } return y; }  else { var y=0; while(eval(o)) { y+=o.offsetTop; o=o.offsetParent; } return y; } }

function mpageX(element){
  var x = 0;
  do{
    if (element.style.position == 'absolute'){
      return x + element.offsetLeft;
    }else{
      x += element.offsetLeft;
      if (element.offsetParent)
        if (element.offsetParent.tagName == 'TABLE')
          if (parseInt(element.offsetParent.border) > 0){
            x += 1;
          }
    }
  }
  while ((element = element.offsetParent));
  return x;
}

// Calculates the absolute page y coordinate of any element
function mpageY(element){
  var y = 0;
  do{
    if (element.style.position == 'absolute'){
      return y + element.offsetTop;
    }else{
      y += element.offsetTop;
      if (element.offsetParent)
        if (element.offsetParent.tagName == 'TABLE')
          if (parseInt(element.offsetParent.border) > 0){
            y += 1;
          }
    }
  }
  while ((element = element.offsetParent));
  return y;
}

//0-prefix,1-li counter,2--current index
function swapHelp(){
  var args=swapHelp.arguments;
	var prefix = args[0];
	var counter = args[1];
	var index = args[2];

	var objLiMenu = document.getElementById(prefix + "LM" + index);
	var objDiv = document.getElementById(prefix + "DIV" + index);
	objLiMenu.className = "current";
	objDiv.style.display="";
	for (var i=1;i<=counter;i++){
	  if (i!=index){
  	  objLiMenu = document.getElementById(prefix + "LM" + i);
	    objDiv = document.getElementById(prefix + "DIV" + i);
		  objLiMenu.className = "";
		  objDiv.style.display="none";
		}
	}
}

function EuwFindObj(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=EuwFindObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function getRadio(w,h,mw,mh){
	var rw = mw/w;
	var rh = mh/h;
	var r = Math.min(rw,rh);
	if ((mw ==0 && mh == 0) || r>1){
		r = 1;
	}else if (mw == 0){
		r = rh<1?rh:1;
	}else if (mh == 0){
		r = rw<1?rw:1;
	}
	w = w*r;
	h = h*r;
	var result = [w,h];
	result.width = w;
	result.height = h;
	return result;
}
function AutoResizeImage(maxWidth,maxHeight,objImg){
	if (typeof(objImg)=='string'){
		objImg = $(objImg);
	}
	if (objImg.src.indexOf("spacer.gif")!=-1) return;
	var img = new Image();
	img.onload = function(){
		this.onload = function(){}
		var wh = getRadio(img.width,img.height,maxWidth,maxHeight);
		objImg.width = wh[0];
		objImg.height = wh[1];
		AlphaImageLoader(objImg);
	}
	img.src = objImg.src;
}

function AlphaImageLoader(img){
  if (is_ie6down){
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + " ' " : " "
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle  
			
			var strNewHTML = "<img src=\"/showroom/admin/images/spacer.gif\" " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\">" 
			img.outerHTML = strNewHTML
			//Debug(strNewHTML);
		}
	}
}

function EuwResizeRatio(maxWidth,maxHeight,objImgTmp){
	var hRatio;
	var wRatio;
	var Ratio = 1;
	var isKernel = true;
	var objImg = EuwFindObj(objImgTmp);
	if (objImg==null) {isKernel = false};
	if (isKernel && objImg.width==0) {isKernel = false};
	var width = 0;
	var height = 0;
	if (isKernel){
		var imgTmp = new Image();
		imgTmp.src = objImg.src;
		width = imgTmp.width;
		height = imgTmp.height;
		if (width==0){
			var timer=window.setTimeout("EuwResizeRatio(" + maxWidth + "," + maxHeight + ",'" + objImgTmp + "')",500);
		}else{
			wRatio = maxWidth / width;
			hRatio = maxHeight / height;
			//alert(wRatio + "--" + hRatio);
			if (maxWidth==0){//
					if (hRatio<1) Ratio = hRatio;
			}else if (maxHeight==0){
					if (wRatio<1) Ratio = wRatio;
			}else if (wRatio<1 || hRatio<1){
					Ratio = (wRatio<=hRatio?wRatio:hRatio);
			}
			if (Ratio<1){
			 objImg.width = width * Ratio;
			 objImg.height = height * Ratio;
			}else{
			 objImg.width = width;
			 objImg.height = height;
			}
		}
	}else{
		var timer=window.setTimeout("EuwResizeRatio(" + maxWidth + "," + maxHeight + ",'" + objImgTmp + "')",500);
	}
}

/**
* @param objImageTmp -- The object for image name
* @param objPrevImageTmp -- The image preview object
* @param imageTypeTmp -- Return image type ('BIG','SMALL')
* @param url -- The open url
* @param name -- The window name
* @param width -- The window width
* @param height -- The window height
*/
function EuwSelectImgFromGallery(objImageTmp,objPrevImageTmp,imageTypeTmp,url,name,width,height){
	objImage = objImageTmp;
	objPrevImage = objPrevImageTmp;
	imageType = imageTypeTmp;
	EuwOpenWindow(url,name,width,height,"resizable=1");
	//var xx = showModalDialog(url,name,"dialogWidth:" + width +"px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
}

function EuwSelectURL(objURL){
  var url = "../selectURL.jsp";
  var returnURL = window.showModalDialog(url,"","dialogWidth:750px; dialogHeight:550px;help:no;scroll:no;status:no");
	if (returnURL!=null && returnURL!='undefined'){
    objURL.value = returnURL;
	}
}

/**
 * Init image src
 * prevImgId -- The preview image id
 * imgName -- The image name
 */
function EuwSetImage(prevImgId,imgName){
	var temp = "";
	var ext = "";
	var imgSrc = "";
	var showimg = new Image();
	var isAudio = 0;
	var isVideo = 0;
	var objPrevImg = EuwFindObj(prevImgId);
	if (objPrevImg!=null){
		if (imgName==gDefaultImage || imgName==""){//set test image
			imgSrc = gGalleryPath + gDefaultImage;
			objPrevImg.width = gSmallImgWidth;
			objPrevImg.height = gSmallImgHeight;
			objPrevImg.src = imgSrc;
		}else{
			isAudio = EuwCheckExt(imgName,audioFiles);
			isVideo = EuwCheckExt(imgName,videoFiles);
			if (openerWindow == "DIGITAL_MEDIA_FILE" && (isAudio==1 || isVideo==1)){//set Digital Media image
				objPrevImg.width = gSmallImgWidth;
				objPrevImg.height = gSmallImgHeight;
				imgSrc = iconPath + (isAudio==1?"audio":"video") + ".gif";
			}else{
				if (imgName.indexOf("/")==-1){
					temp = imgName.replace("b_","s_");
					imgSrc = gGalleryPath + temp;
				}else{
					imgSrc = gGalleryPath + imgName;
				}
				if (imgName.toLowerCase().indexOf(".gif")!=-1){
					objPrevImg.width = gSmallImgWidth;
					objPrevImg.height = gSmallImgHeight;
					objPrevImg.src = imgSrc;
					EuwResizeRatio(gSmallImgWidth,gSmallImgHeight,prevImgId);
				}else{
					objPrevImg.src = imgSrc;
				}
			}
		}
	}
}

/**
 * Select Image From gallery
 * @ objHidImg -- The hidden input object for store image name
 * @ prevImgId -- The preview image object's id
 * @ returnImgType -- The return image type ,'BIG' is return big image name,'SMALL' is return small image name
 * @ width -- The gallery window's width (for Globals variable -EuwGlobals.GALLERY_WINDOW_WIDTH)
 * @ height -- The gallery window's height (for Globals variable -EuwGlobals.GALLERY_WINDOW_HEIGHT)
 */
function EuwSelectImg(objHidImg,prevImgId,returnImgType){
	var objImg = objHidImg;
	var objPrevImg = null;
	var imageType = (returnImgType==null || returnImgType=="")?"BIG":returnImgType;
	if (imageType=="FILE" || imageType=="FLASH" ||  imageType=="3D"){
		objPrevImg = prevImgId;
	}else{
		objPrevImg = EuwFindObj(prevImgId);
	}
	var url = "../gallery/viewCustomerImage.do?src=Select";
	var width = gGalleryWindowWidth;
	var height = gGalleryWindowHeight;
	if (imageType=="FILE" || imageType=="FLASH" ||  imageType=="3D"){
		url = "../filestore/viewCustomerFilestore.do";
	}
	if (screen.width<1024){
		width = 1;//700;
		height = 1;//500;
	}
	EuwSelectImgFromGallery(objImg,objPrevImg,imageType,url,'EuwCustomerGallery',width,height);
}

/**
 * Reset image for test.jpg
 * @ objHidImg -- The hidden input object for store image name
 * @ prevImgId -- The preview image object's id
 */
function EuwDeleteImg(objHidImg, prevImgId){
	var objImg = objHidImg;
	var objPrevImg = EuwFindObj(prevImgId);
	objPrevImg.src = gGalleryPath + gDefaultImage
	objImg.value = gDefaultImage;
	EuwResizeRatio(gSmallImgWidth,gSmallImgHeight,prevImgId);
}

function EuwDeleteFile(formName,hidFileObjName, prevFileObjName){
	var objFile = eval(formName + "." + hidFileObjName);
	var objPrevFile = eval(formName + "." + prevFileObjName);
	objFile.value = "";
	objPrevFile.value = "";
}

/**
* get upload file name
* @path path -- The file full path(eg.C:\pic\abc.jpg)
* @return file name "abc"
*/
function getFileName(path){
	var tmp = path;
	tmp = tmp.substring(tmp.lastIndexOf("\\")+1);
	tmp = tmp.substring(0,tmp.lastIndexOf("."));
	return tmp;
}

/**
* get file full name
* @path path -- The file full path(eg.C:\pic\abc.jpg)
* @return file name -- "abc.jpg"
*/
function getFileFullName(path){
	var tmp = path;
	tmp = tmp.substring(tmp.lastIndexOf("\\")+1);
	return tmp;
}

/**
* get URL file full name
* @path path -- The file full path(eg.C:\pic\abc.jpg)
* @return file name -- abc.jpg
*/
function getURLFileFullName(path){
	var tmp = path;
	var pos = tmp.lastIndexOf("/");
	if (pos!=-1){
		tmp = tmp.substring(pos+1);
	}else{
		tmp = path;
	}
	return tmp;
}

function getFilePath(fPath){
	var tmp = fPath;
	var pos = tmp.lastIndexOf("/");
	if (pos!=-1){
		tmp = tmp.substring(0,pos+1);
	}else{
		tmp = fPath;
	}
	return tmp;
}
/**
 * Function for submit
 * @param formName -- The form name to submit
 */
function EuwFormSubmit(formName){
  eval("document." + formName + ".submit()");
}

/**
 * Close window
 */
function EuwCloseWindow(){
	opener = null;
	window.close();
}

/**
 * sessions time out and back logon again
 */
function EuwReLogon(url){
	if (opener!=null){
		if (opener.parent!=null){
			//opener.parent.opener = null;
			opener.parent.window.location=url;
		}
		EuwCloseWindow();
	}else{
		if (parent!=null){
			if (parent.selectURL!=null || parent.webEditorSelectImage!=null){
				alert(alert_close_win);
			}else{
			  //parent.opener = null;
			  parent.window.location=url;
			}
		}
	}
}

/**
 * Check file's extends name in extList
 */
function EuwCheckExt(path,extList){
	var ext = getFileExt(path);
	extList = extList.toUpperCase();
	var cExt = extList.indexOf("," + ext + ",");
	if (ext == "") return -1;
	if (cExt==-1){
		return 0;
	}else{
		return 1;
	}
}

/**
 * Get file's extends
 */
function getFileExt(path){
	var tmp = path;
	tmp = tmp.substring(tmp.lastIndexOf(".")+1);
	return tmp.toUpperCase();
}

//Open progress
function EuwProgressWindow(url){
  openwindow(url,"EuwWinUploadProgress",320 ,125,"");
  //window.showModelessDialog(url,null,"dialogWidth=320px; dialogHeight:125px; center:yes");
}

//Open upload
function EuwUploadWindow(url){
  openwindow(url,"EuwWinUpload",320 ,125,"");
}
/**
 * Open customer window function
 * @param url -- The open object
 * @param name -- The window name
 * @param options -- The window options
 */
function EuwOpenWindowCustomer(url,name,options){
	window.open(url, name,options);
}

/**
 * Open a no scroll window function
 * @param url -- The open object
 * @param name -- The window name
 * @param width -- The window width
 * @param height -- The window height
 */
function EuwOpenWinNoScroll(url,name,width,height){
	openwindow(url, name,width ,height,"toolbar=no,menubar=no,location=no,personalbar=no,scrollbars=no,resize=no");
}

/**
 * Open window function
 * @param url -- The open object
 * @param name -- The window name
 * @param width -- The window width
 * @param height -- The window height
 * @param options -- The window options
 */
function EuwOpenWindowReturn(url,name,width,height,options){
  return openwindow(url, name,width ,height,options);
}

/**
 * Open window function
 * @param url -- The open object
 * @param name -- The window name
 * @param width -- The window width
 * @param height -- The window height
 * @param options -- The window options
 */
function EuwOpenWindow(url,name,width,height,options){
  openwindow(url, name,width ,height,options);
}

function EuwOpenWindowPos(url,name,width,height,options){
	//var appVer = parseInt(navigator.appVersion);
	var top = 0;
	var left = 0;
	var srcWidth=screen.width-10;
	var srcHeight=screen.height - 57;
	var other="";
	if (options==1){//Left Top
		other="top=0, left=0, screenX=0, screenY=0,";//Netscape
	}else if (options==2){//Right Top
		other="top=0, left=" + (srcWidth-width) + ", screenX=" + (srcWidth-width) + ", screenY=0,";//Netscape
	}else if (options==0){//Center
		other="";
	}else if (options==3){//Left Buttom
		other="top=" + (srcHeight-height) + ", left=0, screenX=0, screenY=" + (srcHeight-height) + ",";//Netscape
	}else if (options==5){//Right Buttom
		other="top=" + (srcHeight-height) + ", left=" + (srcWidth-width) + ", screenX=" + (srcWidth-width) + ", screenY=" + (srcHeight-height) + ",";//Netscape
	}
	openwindow(url, name,width ,height,other);
}

function openwindow( url, winName,width,height,otherproperty)
{
  //width,height
  //otherproperty
  xposition=0; yposition=0;
  if ((parseInt(navigator.appVersion) >= 4 )){
		if (width==1){
			width=screen.width - 10;xposition = 0;
		}else{
			xposition = (screen.width - width) / 2;
		}
		if (height==1){
			height=screen.height - 57;yposition = 0;
		}else{
			yposition = (screen.height - height) / 2 - 15;
		}
		if (yposition < 0 ) yposition = 0;
	}
	theproperty= "width=" + width + ", " + "height=" + height + ", ";
	if (otherproperty==null) otherproperty = "";
	if (otherproperty.toLowerCase().indexOf("screenx")==-1) theproperty += "screenX=" + xposition + ", "; //Netscape
	if (otherproperty.toLowerCase().indexOf("screenY")==-1) theproperty += "screenY=" + yposition + ", "; //Netscape
	if (otherproperty.toLowerCase().indexOf("left")==-1) theproperty += "left=" + xposition + ", "; //IE
	if (otherproperty.toLowerCase().indexOf("top")==-1) theproperty += "top=" + yposition + ", "; //IE

	if (otherproperty.toLowerCase().indexOf("location")==-1) theproperty += "location=0, ";
	if (otherproperty.toLowerCase().indexOf("menubar")==-1) theproperty += "menubar=0, ";
	if (otherproperty.toLowerCase().indexOf("resizable")==-1) theproperty += "resizable=0, ";
	if (otherproperty.toLowerCase().indexOf("scrollbars")==-1) theproperty += "scrollbars=1, ";
	if (otherproperty.toLowerCase().indexOf("status")==-1) theproperty += "status=0, ";
	if (otherproperty.toLowerCase().indexOf("toolbar")==-1) theproperty += "toolbar=0, ";
	if (otherproperty.toLowerCase().indexOf("hotkeys")==-1) theproperty += "hotkeys=0, ";
	theproperty = theproperty + ', ' + otherproperty;
	return window.open( url,winName,theproperty );
}

/*
function EuwCheckNumOnKeyUp(obj){
	if (event.keyCode!=9){
		obj.value=obj.value.replace(/[^0-9.]/g,'').toUpperCase();
	}
}

function EuwCheckIntOnKeyUp(obj){
	if (event.keyCode!=9){
		obj.value=obj.value.replace(/[^0-9]/g,'').toUpperCase();
	}
}*/

//验证只能录入实数onkeypress
function EuwCheckNumOnKeyUp(obj)
{
	if ((window.event.keyCode<45 || window.event.keyCode>57 || window.event.keyCode==47) && window.event.keyCode!=45 && window.event.keyCode!=9)  window.event.returnValue=false;
	if( window.event.keyCode==46 && obj.value.indexOf(".")>-1) window.event.returnValue=false;
}

//验证只能录入整数onkeypress
function EuwCheckIntOnKeyUp(obj)
{
	if ((window.event.keyCode<48 || window.event.keyCode>57) && window.event.keyCode!=45 && window.event.keyCode!=9) window.event.returnValue=false;
}

//验证只能录入整数onkeypress
function EuwCheckIntABSOnKeyUp(obj)
{
	if ((window.event.keyCode<48 || window.event.keyCode>57) && window.event.keyCode!=9) window.event.returnValue=false;
}

//验证只能录入整数onkeypress
function EuwCheckIntABSOnKeyUpMsg(obj,msg)
{
	if ((window.event.keyCode<48 || window.event.keyCode>57) && window.event.keyCode!=9){
    alert(msg);
    window.event.returnValue=false;
  }
}

function EuwGetKeyCode(e){
	var code;
	if (!e) var e = window.event;
	if (e.keyCode){
    code = e.keyCode;
	}else if (e.which){
    code = e.which;
	}
  return code;
}

function EuwOnfocusSelect(obj){
	if (obj.type=="text"){
		obj.select();
	}
}

function EuwStr2Float(as_str,ai_digit,as_type){
	var fdb_tmp = 0;
	var fi_digit = 0;
	var fs_digit = "1";
	var fs_str = "" + as_str;
	var fs_tmp1 = "";
	var fs_tmp2 = "";
	var fi_pos = 0;
	var fi_len = 0;
	fdb_tmp = parseFloat(isNaN(parseFloat(fs_str))?0:fs_str);

	switch (true){
	case (ai_digit==null)://
	  fdb_tmp = fdb_tmp;
	  break;
	case (ai_digit==0)://
	  fdb_tmp = Math.round(fdb_tmp);
	  break;
	case (ai_digit>0)://
		for (var i=0;i<ai_digit;i++) fs_digit +="0";
		fi_digit = parseInt(fs_digit);
		fdb_tmp = Math.round(fdb_tmp * fi_digit) / fi_digit;
		if (as_type=="str"){
  	  fs_tmp1 = fdb_tmp.toString();
			fs_tmp1 +=((fs_tmp1.indexOf(".")!=-1)?"":".") + fs_digit.substr(1);
			fi_pos = fs_tmp1.indexOf(".") + 1 + ai_digit;
			fdb_tmp = fs_tmp1.substr(0,fi_pos);
		}
	  break;
  }
  return fdb_tmp;
}

function EuwLinkConfirmAlert(msg){
	if (confirm(msg)){
		return true;
	}else{
		return false;
	}
}

function trim(str) {
	regExp1 = /^ */;
	regExp2 = / *$/;
	return str.replace(regExp1,'').replace(regExp2,'');
}

function isEmail(strEmail,errorMsg) {
 if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
  return true;
 else
  alert(errorMsg);
  return false ;
}

function EuwJumpToPage(pageCount,obj){
	//if ((window.event.keyCode<48 || window.event.keyCode>57) && window.event.keyCode!=45 && window.event.keyCode!=13) window.event.returnValue=false;
	EuwCheckIntOnKeyUp(obj);
	var tmp = trim(obj.value);
	if (tmp!=""){
		if (parseInt(tmp) > pageCount){
			tmp = pageCount;
		}
		if (parseInt(tmp) <=0) tmp = 1;
		obj.value = tmp;
		return true ;
	}
	return false ;
}

function EuwClearSelected(obj,index){
  if (obj != null){
    if(obj.length==null){
		  if (index==-1) obj.checked = false;
    }else{
      for (i = 0 ; i< obj.length ; i++){
			  if (index!=-1 && index==i){
				  obj[i].checked = true;
				}else{
          obj[i].checked = false;
				}
      }
    }
  }
}

function EuwCheckIsSelected(obj){
	var ischeck = false;
	if (obj != null){
		if(obj.length==null){
			if (obj.checked == true) ischeck = true;
		}else{
			for (i = 0 ; i< obj.length ; i++){
				if (obj[i].checked == true){ischeck = true;break;}
			}
		}
	}
	return ischeck;
}

function EuwSelect(sel,ddl){
	var selectType = ddl.value;
	var obj=sel;
	ddl.options[0].selected=true;
	if(obj){
		if(obj.length==null){
			if (!obj.disabled){
				switch (selectType){
					case "all":obj.checked=true;break;
					case "invert":obj.checked=!obj.checked;break;
					case "none":obj.checked=false;break;
				}
			}
		}else{
			for (var i = 0 ; i< obj.length ; i++){
				if (!obj[i].disabled){
					switch (selectType){
						case "all":obj[i].checked=true;break;
						case "invert":obj[i].checked=!obj[i].checked;break;
						case "none":obj[i].checked=false;break;
					}
			  }
			}
		}
	}
}

/**
 * Clear the object in the form
 * @param obj -- The object in the form
 */
function EuwClearObject(obj){
	obj.value = "";
}

function createFlashHTML(flashPath,w,h){
  var html = "<embed ";
  if (w==-1) w = "95%";
  if (h==-1) h = "95%";
  html += "src=\"" + flashPath + "\" ";
  html += "width=\"" + w + "\" ";
  html += "height=\"" + h + "\" ";
  html += "quality=\"high\" ";
  html += "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
  html += "type=\"application/x-shockwave-flash\" wmode=\"transparent\">";
  html += "</embed>";
  return html;
}

function EuwDeleteFlash(formName,hidFileObjName, prevFileObj){
  var objFile = eval(formName + "." + hidFileObjName);
  objFile.value = "";
  prevFileObj.innerHTML = "<img src=\"" + gGalleryPath + gDefaultImage + "\">";
}

var CurTag = 0;
//Switch wizard left menu
function EuwSwitchLeftMenu(tag){
	var leftpage = parent.EuwFrameLeft;
	leftpage.wizard[tag-1].className = "Current0" + tag;
	if (CurTag!=0 && CurTag!=tag) leftpage.wizard[CurTag-1].className = "List0" + CurTag;
	CurTag = tag;
}

function displayRedirectLoading(){
	if (parent.EuwFrameCenter.setRedirectDivPos!=null){
	  parent.EuwFrameCenter.setRedirectDivPos();
	}
}
var CurDiv = "";
var CurDl = "";
function EuwSwitchLeftAdvanceIcon(id,dlId){
	var objDiv = EuwFindObj(id);
	var objDl = EuwFindObj(dlId);
	objDiv.className = "Current";
	if (objDl!=null)objDl.className = "Current";
	if (CurDiv != "" && EuwFindObj(CurDiv)!=null && EuwFindObj(CurDiv)!=objDiv) {
		var objPrevDiv = EuwFindObj(CurDiv);
		objPrevDiv.className = "";
	}
	if (CurDl != "" && EuwFindObj(CurDl)!=null && EuwFindObj(CurDl)!=objDl) {
		var objPrevDl = EuwFindObj(CurDl);
		objPrevDl.className = "";
	}
	CurDiv = id;
	CurDl = dlId;
	displayRedirectLoading();
	var p = id;
	if (dlId!="") p = dlId;
	
	if (p=="weblanguage"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/webLanguageList.do";
	}else if (p=="companyname"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewCompanyName.do";
	}else if (p=="termssetting"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewTermsSetting.do";
	}else if (p=="keywords"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewKeywords.do";
	}else if (p=="selectdesign"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewSelectModel.do";
	}else if (p=="bgmusic"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewBgMusic.do";
	}else if (p=="webstyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebStyle.do";
	}else if (p=="generalWebStyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebStyle.do";
	}else if (p=="companyNameStyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebStyle.do?ForwardName=CompanyNameStyle";
	}else if (p=="homePageStyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebStyle.do?ForwardName=HomePageStyle";
	}else if (p=="footerStyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebStyle.do?ForwardName=FooterStyle";
	}else if (p=="categoryProductStyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebStyle.do?ForwardName=CategoryProductStyle";
	}else if (p=="newsStyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebStyle.do?ForwardName=NewsStyle";
	}else if (p=="popWindowsStyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebStyle.do?ForwardName=PopWindowStyle";
	}else if (p=="pageSizeStyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewPageSize.do";
	}else if (p=="menuDisplayStyle"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewMenuDisplaySetting.do";
	}else if (p=="webhomepageSection"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebHomePageSections.do";
	}else if (p=="webhomepageLayout"){
  	parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebHomePageLayout.do";
	}else if (p=="managewebpage"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/customWebPageList.do";
	}else if (p=="enquiryFormFormat"){
		parent.EuwFrameCenter.location = "/showroom/admin/enquiry/editViewEnquiryFormFormat.do";
	}else if (p=="enquiryEmail"){
		parent.EuwFrameCenter.location = "/showroom/admin/enquiry/editViewEnquiryEmail.do";
	}else if (p=="headercontent"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewHeaderContent.do";
	}else if (p=="footer"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewFooter.do";
	}else if (p=="showroomsetting"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/editViewShowroomSetting.do";
	}else if (p=="manageCategoryProduct"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/categoryProductList.do";
	}else if (p=="manageNewProduct"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/productList.do?module=NewProduct";
	}else if (p=="manageHotProduct"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/productList.do?module=HotProduct";
	}else if (p=="manageSpecialProduct"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/productList.do?module=SpecialProduct";
	}else if (p=="manageComingSoonProduct"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/productList.do?module=ComingSoonProduct";
	}else if (p=="productoptions"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/productOptionsList.do";
	}else if (p=="supplier"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/supplierList.do";
	}else if (p=="productDisplayMode"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/editViewProductDisplaySetting.do";
	}else if (p=="productDisplayAttribute"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/editViewProductAttribute.do";
	}else if (p=="stockcheck"){
		parent.EuwFrameCenter.location = "/showroom/admin/categoryproduct/stockCheckingProductList.do";
	}else if (p=="livemember"){
		parent.EuwFrameCenter.location = "/showroom/admin/member/editViewLiveMember.do";
	}else if (p=="member"){
		parent.EuwFrameCenter.location = "/showroom/admin/member/memberList.do";
	}else if (p=="group"){
		parent.EuwFrameCenter.location = "/showroom/admin/group/groupList.do";
	}else if (p=="grade"){
		parent.EuwFrameCenter.location = "/showroom/admin/grade/gradeList.do";
	}else if (p=="price"){
		parent.EuwFrameCenter.location = "/showroom/admin/price/viewPriceHistoryList.do";
	}else if (p=="quotation"){
		parent.EuwFrameCenter.location = "/showroom/admin/quotation/viewQuotationHistoryList.do";
	}else if (p=="agreement"){
		parent.EuwFrameCenter.location = "/showroom/admin/agreement/viewAgreementHistoryList.do";
	}else if (p=="purchase"){
		parent.EuwFrameCenter.location = "/showroom/admin/purchase/viewPurchaseHistoryList.do";
	}else if (p=="local"){
		parent.EuwFrameCenter.location = "/showroom/admin/quotation/editViewQuotationLocal.do";
	}else if (p=="productionSchedule"){
		parent.EuwFrameCenter.location = "/showroom/admin/transportationplan/productionScheduleList.do";
	}else if (p=="sea"){
		parent.EuwFrameCenter.location = "/showroom/admin/transportationplan/allSeaTransportationPlanList.do";
	}else if (p=="land"){
		parent.EuwFrameCenter.location = "/showroom/admin/transportationplan/allLandTransportationPlanList.do";
	}else if (p=="air"){
		parent.EuwFrameCenter.location = "/showroom/admin/transportationplan/allAirTransportationPlanList.do";
	}else if (p=="display"){
		parent.EuwFrameCenter.location = "/showroom/admin/transportationplan/editViewProductionScheduleDisplay.do";
	}else if (p=="public"){
		parent.EuwFrameCenter.location = "/showroom/admin/file/publicFileList.do";
	}else if (p=="customer"){
		parent.EuwFrameCenter.location = "/showroom/admin/directory/customerFileCategoryList.do";
	}else if (p=="private"){
		parent.EuwFrameCenter.location = "/showroom/admin/file/privateFileList.do";
	}else if (p=="upload"){
		parent.EuwFrameCenter.location = "/showroom/admin/file/uploadFileList.do";
	}else if (p=="search"){
		parent.EuwFrameCenter.location = "/showroom/admin/file/searchMemberFileList.do";
	}else if (p=="autoresponder"){
		parent.EuwFrameCenter.location = "/showroom/admin/function/editViewAutoResponder.do";
	}else if (p=="news"){
		parent.EuwFrameCenter.location = "/showroom/admin/function/newsList.do";
	}else if (p=="weblink"){
		parent.EuwFrameCenter.location = "/showroom/admin/function/friendLinksList.do";
	}else if (p=="popmessage"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewPopMessage.do";
	}else if (p=="feedback"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewFeedBack.do";
	}else if (p=="message"){
		parent.EuwFrameCenter.location = "/showroom/admin/function/singleSendLeaveWordList.do";
	}else if (p=="systeminformation"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/viewSystemInformation.do";
	}else if (p=="webprofile"){
		parent.EuwFrameCenter.location = "/showroom/admin/skin/editViewWebProfile.do";
	}else if (p=="storageallocation"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/loading.jsp";
	}else if (p=="webEditor"){
		parent.EuwFrameCenter.location = "/showroom/admin/accountrole/webEditorList.do";
	}else if (p=="webRole"){
		parent.EuwFrameCenter.location = "/showroom/admin/accountrole/webRoleList.do";
	}else if (p=="onlineeditor"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewOnlineEditor.do";
	}else if (p=="emailheader"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewEmailHeader.do";
	}else if (p=="otherFeatures"){
		parent.EuwFrameCenter.location = "/showroom/admin/webinfor/editViewOtherFunction.do";
	}else if (p=="livestore"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/editViewLiveStore.do";
	}else if (p=="discount"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/storeDiscountList.do";
	}else if (p=="discountcoupon"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/storeDiscountCouponList.do";
	}else if (p=="deliverycost"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/storeDeliveryCostList.do";
	}else if (p=="vat"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/storeVATList.do";
	}else if (p=="livesampleorder"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/editViewLiveSampleOrder.do";
	}else if (p=="payment"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/storePaymentList.do";
	}else if (p=="termsagreement"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/editViewTermsAgreement.do";
	}else if (p=="orders"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/storeOrderList.do";
	}else if (p=="updateStock"){
		parent.EuwFrameCenter.location = "/showroom/admin/store/editViewStoreOtherFunction.do";
	}else if (p=="sitereport"){
		parent.EuwFrameCenter.location = "/showroom/admin/report/viewVisitSiteReport.do";
	}else if (p=="productreport"){
		parent.EuwFrameCenter.location = "/showroom/admin/report/viewVisitProductReport.do";
	}
}

function HelpBackToWizard(step,src){
    var url = "../help/" + help_language + "/wizard.htm?step=" + step;
    var objSrcURL = parent.EuwFrameCenter.location.href;
    parent.EuwFrameLeft.EuwSwitchLeftMenu(step);
    if (src=="LEFT"){
        if (objSrcURL.indexOf("help")!=-1) url = "wizard.htm?step=" + step;
        RefreshCenter(url);
    }else{
        window.location = url;
    }
}

//Start Help function CENTER HELP DOC
function HelpDOC(docPath){
    window.location.href = "help/" + help_language + "/" + docPath;
}

function RefreshCenter(url){
  parent.EuwFrameCenter.location=url;
}

function SimpleLink(tag){
  //Language Version
  var path = "../../simple/";
  EuwShowLeftMenu();
  var leftpage = parent.EuwFrameLeft;
	if (tag!="Preview"){
		displayRedirectLoading()
	}
  if (tag=="PublishLanguage"){
    window.location = path + "webLanguageList.do?ACTION_TYPE=Publish";
    leftpage.EuwSwitchLeftMenu(1);
  }else if (tag=="DefaultLanguage"){
    window.location = path + "webLanguageList.do?ACTION_TYPE=Default";
    leftpage.EuwSwitchLeftMenu(1);
  }else if (tag=="SelectDesign"){
    window.location = path + "editViewSelectModel.do";
    leftpage.EuwSwitchLeftMenu(2);
  }else if (tag=="BgMusic"){
    window.location = path + "editViewBgMusic.do";
    leftpage.EuwSwitchLeftMenu(2);
  }else if (tag=="CompanyName"){
    window.location = path + "editViewCompanyName.do";
    leftpage.EuwSwitchLeftMenu(3);
  }else if (tag=="HomePage"){
    window.location = path + "editViewWebHomePageSections.do";
    leftpage.EuwSwitchLeftMenu(4);
  }else if (tag=="Profile"){
    window.location = path + "editViewPageSections.do?single=PROFILE";
    leftpage.EuwSwitchLeftMenu(4);
  }else if (tag=="ContactUs"){
    window.location = path + "editViewPageSections.do?single=CONTACT_US";
    leftpage.EuwSwitchLeftMenu(4);
  }else if (tag=="News"){
    window.location = path + "newsList.do";
    leftpage.EuwSwitchLeftMenu(4);
  }else if (tag=="EnquiryEmail"){
    window.location = path + "editViewEnquiryEmail.do";
    leftpage.EuwSwitchLeftMenu(4);
  }else if (tag=="CustomWebPages"){
    window.location = "../../skin/customWebPageList.do?src=simple";
    leftpage.EuwSwitchLeftMenu(4);
  }else if (tag=="ShowroomSetting"){
    window.location = path + "editViewShowroomSetting.do";
    leftpage.EuwSwitchLeftMenu(5);
  }else if (tag=="AddCategory"){
    window.location = path + "categoryProductList.do";
    leftpage.EuwSwitchLeftMenu(5);
  }else if (tag=="Preview"){
    if (window.previewURL==null){
      previewURL = "../../" + leftpage.previewURL;
    }
    window.open(previewURL);
    leftpage.EuwSwitchLeftMenu(6);
  }
}

var curSubMenu = "";
function SwitchMenu(tag){
	if (curSubMenu!=""){
	  var objSubMenuCur = eval("parent.EuwFrameLeft.div" + curSubMenu);
		objSubMenuCur.style.display = "none";
	}
	if (tag=='simple'){
		parent.EuwFrameLeft.But01[1].style.display = "none";
		parent.EuwFrameLeft.divSimple.style.display = "";
		parent.EuwFrameLeft.divSwitchButSimple.style.display = "none";
		parent.EuwFrameLeft.divSwitchButAdvance.style.display = "";
	}else{
		parent.EuwFrameLeft.divSimple.style.display = "none";
		parent.EuwFrameLeft.But01[1].style.display = "";
		parent.EuwFrameLeft.divSwitchButSimple.style.display = "";
		parent.EuwFrameLeft.divSwitchButAdvance.style.display = "none";
	}
}

function SwitchSubMenu(tag){
	var objSubMenu = eval("parent.EuwFrameLeft.div" + tag);
	if (curSubMenu!=""){
	  var objSubMenuCur = eval("parent.EuwFrameLeft.div" + curSubMenu);
		objSubMenuCur.style.display = "none";
	}
	curSubMenu = tag;
	objSubMenu.style.display = "";
}




//Top Menu
function MainMenu(MenuName){
	EuwShowLeftMenu();
	var width = 1;//780;
	var height = 1;//540;
	if (screen.width<1024){
		width = 1;//700;
		height = 1;//500;
	}
	var url = "";
	url = "help/" + help_language + "/";
	//WebsiteWizard,GeneralSetting,WebDesign,ManagePages,ManageProducts,ManageMembers,ManageQuotation
	//ManageSchedule,Gallery,FileUpload,Extras,SystemSetting,PreviewSite,TrafficReports,ContactUs,UserManual,Exit
	if (",Gallery,PreviewSite,UserManual,Exit,".indexOf("," + MenuName + ",")==-1){
		displayRedirectLoading()
	}
	if (MenuName=="LeftSimple"){
		parent.EuwFrameLeft.SwitchMenu("simple");
		RefreshCenter(url + "wizard.htm?step=1");
		EuwHideLeftMenu();
		EuwSwitchTopFlash('h');
	}else if (MenuName=="LeftAdvanced" || MenuName == "TopAdvance"){
		parent.EuwFrameLeft.SwitchMenu("advance");
		RefreshCenter(url + "main.htm");
		EuwSwitchTopFlash('s');
	}else if (MenuName=="Advanced"){
		parent.EuwFrameLeft.SwitchMenu("advance");
		window.location = "main.htm";
		EuwSwitchTopFlash('s');
	}else if (MenuName=="WebsiteWizard"){
		parent.EuwFrameLeft.SwitchMenu("simple");
		RefreshCenter(url + "wizard.htm?step=1");
		EuwHideLeftMenu();
		EuwSwitchTopFlash('h');
	}else if (MenuName=="GeneralSetting"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "general_setting.htm");
	}else if (MenuName=="WebDesign"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "web_design.htm");
	}else if (MenuName=="ManagePages"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "manage_pages.htm");
	}else if (MenuName=="ManageProducts"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "manage_products.htm");
	}else if (MenuName=="ManageMembers"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "manage_member.htm");
	}else if (MenuName=="ManageQuotation"){
    parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "manage_quotation.htm");
	}else if (MenuName=="ManageSchedule"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "manage_schedule.htm");
	}else if (MenuName=="Gallery"){
		EuwOpenWindow("gallery/viewCustomerImage.do?src=Manage","EuwCustomerGallery",width,height,"resizable=1");
	}else if (MenuName=="FileUpload"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "file_upload.htm");
	}else if (MenuName=="Extras"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "extras.htm");
	}else if (MenuName=="SystemSetting"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "system_setting.htm");
	}else if (MenuName=="Store"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "store.htm");
	}else if (MenuName=="PreviewSite"){
		window.open(previewURL);
	}else if (MenuName=="TrafficReports"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		RefreshCenter(url + "traffic_report.htm");
	}else if (MenuName=="ContactUs"){
		RefreshCenter("webinfor/contactUs.jsp");
	}else if (MenuName=="ReportError"){
		RefreshCenter("webinfor/viewReportError.do");
	}else if (MenuName=="SystemInfor"){
		RefreshCenter("webinfor/viewSystemInformation.do");
	}else if (MenuName=="UserManual"){
		window.open("user manual.pdf");
	}else if (MenuName=="Exit"){
		EuwCloseParentWindow();//function in top.jsp
	}
}

//web2go and smeitrade no diff
function setRedirectDivPos(){
	document.write('<scr')
	document.write('ipt>                                  \r\n');
	document.write('var count = 1;                        \r\n');
	document.write('function LoadingAuto(){               \r\n');
	document.write('	count +=1;                          \r\n');
	document.write('	if (count>6){                       \r\n');
	document.write('  	ll.innerText = "Loading.";        \r\n');
	document.write('	  count =1;                         \r\n');
	document.write('	}else{                              \r\n');
	document.write('		ll.innerText = ll.innerText + ".";\r\n');
	document.write('	}                                   \r\n');
	document.write('}                                     \r\n');
	document.write('</scr');
	document.write('ipt>                                  \r\n');
	document.write('<html><head><title></title>\r\n');
	document.write('<style type="text/css">\r\n');
	document.write('body{\r\n');
	document.write('	scrollbar-3d-light-color:#94E0BB;\r\n');
	document.write('	scrollbar-arrow-color:#94E0BB;\r\n');
	document.write('	scrollbar-base-color:#005033;\r\n');
	document.write('	scrollbar-dark-shadow-color:#C4FFB2;\r\n');
	document.write('	scrollbar-face-color:#005033;\r\n');
	document.write('	scrollbar-highlight-color:#68B392;\r\n');
	document.write('	scrollbar-shadow-color:#56A482;\r\n');
	document.write('}\r\n');
	document.write('body{ width: 100%;}\r\n');
	document.write('body.mainbody {\r\n');
	document.write('	overflow-y:scroll;\r\n');
	document.write('	background-color: #003723;\r\n');
	document.write('	margin: 0px;\r\n');
	document.write('}\r\n');

	document.write('table.mainbodyL {\r\n');
	document.write('	background-color: #94B2A5;\r\n');
	document.write('	background-image: url(/showroom/admin/images/main_body_bg_left01.gif);\r\n');
	document.write('	background-repeat: repeat-y;\r\n');
	document.write('	height: 100%;\r\n');
	document.write('}\r\n');
	document.write('td.mainbodyR {\r\n');
	document.write('	background-image: url(/showroom/admin/images/main_body_bg_right01.gif);\r\n');
	document.write('	background-repeat: repeat-y;\r\n');
	document.write('	background-position: right top;\r\n');
	document.write('}\r\n');
	document.write('td.mainbodyPad {\r\n');
	document.write('	padding-right: 17px;\r\n');
	document.write('	padding-left: 13px;\r\n');
	document.write('}\r\n');
	document.write('table.mainbodybottom {\r\n');
	document.write('	background-color: #006237;\r\n');
	document.write('	background-image: url(/showroom/admin/images/page_bottom_center01.gif);\r\n');
	document.write('	background-repeat: repeat-x;\r\n');
	document.write('	height: 40px;\r\n');
	document.write('}\r\n');
	document.write('table.mainbodybottom td{\r\n');
	document.write('	vertical-align: top;\r\n');
	document.write('}\r\n');
	document.write('</style>\r\n');
	document.write('</head>\r\n');
	document.write('<body class="mainbody">\r\n');
	document.write('<div id="redirectLoading" style="position:absolute;display:;height:50px;font-family:Arial; font-size:10pt;"><img src="/showroom/admin/images/loading_02.gif" align="absmiddle"> &nbsp;<span id="ll">Loading.</span></div>\r\n');
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" class="mainbodyL">\r\n');
	document.write('  <tr>\r\n');
	document.write('    <td valign="top" class="mainbodyR mainbodyPad">&nbsp;</td>\r\n');
	document.write('  </tr>\r\n');
	document.write('	<tr>\r\n');
	document.write('		<td height="40">\r\n');
	document.write('			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="mainbodybottom">\r\n');
	document.write('				<tr>\r\n');
	document.write('				<td width="1"><img src="/showroom/admin/images/page_bottom_left01.gif"></td>\r\n');
	document.write('					<td>&nbsp;</td>\r\n');
	document.write('					<td width="1" align="right"><img src="/showroom/admin/images/page_bottom_right01.gif"></td>\r\n');
	document.write('				</tr>\r\n');
	document.write('			</table>\r\n');
	document.write('		</td>\r\n');
	document.write('	</tr>\r\n');
	document.write('</table>\r\n');
	document.write('</body>                               \r\n');
	document.write('</html>                               \r\n');
	document.write('<scr')
	document.write('ipt>                                  \r\n');
	document.write('var a = setInterval(LoadingAuto,500); \r\n');
	document.write('redirectLoading.style.top = document.body.scrollTop+(document.body.clientHeight-document.getElementById("redirectLoading").offsetHeight)/2-40;');
	document.write('redirectLoading.style.left = document.body.scrollLeft+(document.body.clientWidth-document.getElementById("redirectLoading").offsetWidth)/2;');
	document.write('</scr');
	document.write('ipt>                                  \r\n');
}

//Left, Top, center Help page javascript
//Advance Mode MAIN CENTER REDIRECT
function HelpMainDOC(MenuName){
	EuwShowLeftMenu();
	var width = 1;//780;
	var height = 1;//540;
	if (screen.width<1024){
		width = 1;//700;
		height = 1;//500;
	}
	var url = "../../";
	//WebsiteWizard,GeneralSetting,WebDesign,ManagePages,ManageProducts,ManageMembers,ManageQuotation
	//ManageSchedule,Gallery,FileUpload,Extras,SystemSetting,PreviewSite,TrafficReports,ContactUs,UserManual,Exit
	if (MenuName=="WebsiteWizard"){
		parent.EuwFrameLeft.SwitchMenu("simple");
	}else if (MenuName=="GeneralSetting"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		parent.EuwFrameTop.TopMenuSwap(1,'');
	}else if (MenuName=="WebDesign"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		parent.EuwFrameTop.TopMenuSwap(2,'');
	}else if (MenuName=="ManagePages"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		parent.EuwFrameTop.TopMenuSwap(3,'');
	}else if (MenuName=="ManageProducts"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		parent.EuwFrameTop.TopMenuSwap(4,'');
	}else if (MenuName=="ManageMembers"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		parent.EuwFrameTop.TopMenuSwap(5,'');
	}else if (MenuName=="Gallery"){
		EuwOpenWindow("../../gallery/viewCustomerImage.do?src=Manage","EuwCustomerGallery",width,height,"resizable=1");
		parent.EuwFrameTop.TopMenuSwap(6,'');
	}else if (MenuName=="Extras"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		parent.EuwFrameTop.TopMenuSwap(7,'');
	}else if (MenuName=="SystemSetting"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		parent.EuwFrameTop.TopMenuSwap(8,'');
	}else if (MenuName=="Store"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		parent.EuwFrameTop.TopMenuSwap(9,'');
	}else if (MenuName=="PreviewSite"){
		window.open(previewURL);
		parent.EuwFrameTop.TopMenuSwap(10,'');
	}else if (MenuName=="TrafficReports"){
		parent.EuwFrameLeft.SwitchSubMenu(MenuName);
		parent.EuwFrameTop.TopMenuSwap(11,'');
	}else if (MenuName=="ContactUs"){
		parent.EuwFrameCenter.location=url+"webinfor/contactUs.jsp";
	}else if (MenuName=="UserManual"){
		window.open("../../user manual.pdf");
		parent.EuwFrameTop.TopMenuSwap(12,'');
	}else if (MenuName=="Exit"){
		EuwCloseParentWindow();//function in top.jsp
	}
}

//Simple Mode for back to Website Wizard
function EuwHideLeftMenu(){
	parent.EuwFrameButtom.cols="26,*";
	parent.EuwFrameLeft.LeftMenu.style.display="none";
	parent.EuwFrameLeft.showButton.style.display = "";
	parent.EuwFrameTop.TopLogo.src="images/logo_02.gif";
	parent.EuwFrameTop.TopPic.src="images/top_left_pic02b.gif";
}

function EuwShowLeftMenu(){
	if (parent.EuwFrameLeft.LeftMenu.style.display=="none"){;
		parent.EuwFrameLeft.showButton.style.display = "none";
		parent.EuwFrameLeft.LeftMenu.style.display="";
		parent.EuwFrameButtom.cols="181,*";
	  parent.EuwFrameTop.TopLogo.src="images/logo_01.gif";
	  parent.EuwFrameTop.TopPic.src="images/top_left_pic02.gif";
	}
}

function EuwSwitchTopFlash(flag){
	if (flag=="s"){
		parent.EuwFrameTop.TopLogo.src="images/logo_01.gif";
		parent.EuwFrameTop.TopPic.src="images/top_left_pic02.gif";
		parent.EuwFrameTop.TopBut[0].style.display = "";
		parent.EuwFrameTop.TopBut[1].style.display = "none";
		parent.EuwFrameTop.ResetTopMenu(-1);
	}else{
		parent.EuwFrameTop.TopLogo.src="images/logo_02.gif";
		parent.EuwFrameTop.TopPic.src="images/top_left_pic02b.gif";
		parent.EuwFrameTop.TopBut[0].style.display = "none";
		parent.EuwFrameTop.TopBut[1].style.display = "";
		parent.EuwFrameTop.TopMenuSwap(14,'');
	}
}
//End Help Function

function correctPNG() 
{
	for(var i=0; i<document.images.length; i++)
	{
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	  {
	   var imgID = (img.id) ? "id='" + img.id + "' " : ""
	   var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	   var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	   var imgStyle = "display:inline-block;" + img.style.cssText 
	   if (img.align == "left") imgStyle = "float:left;" + imgStyle
	   if (img.align == "right") imgStyle = "float:right;" + imgStyle
	   if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle  
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
	   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	   + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
	   img.outerHTML = strNewHTML
	   i = i-1
	  }
	}
}
