/******************************************************************************
  Eion Site main Function - JavaScript
  Version Modified By Janara.
  Based upon:  http://www.eion.com.tw
*******************************************************************************/

/* PreLoader JScript. */
PreLoader('ObjectBlank','images/icon_blank.gif');
PreLoader('CEMHomeOn','ButtonLibraries/ButtonHomeOn.gif');
PreLoader('CEMHomeOff','ButtonLibraries/ButtonHomeOff.gif');

PreLoader('CEMCompanyOn','ButtonLibraries/ButtonCompanyOn.gif');
PreLoader('CEMCompanyOff','ButtonLibraries/ButtonCompanyOff.gif');
PreLoader('CEMFutureWaterHeaterOn','ButtonLibraries/ButtonFutureWaterHeaterOn.gif');
PreLoader('CEMFutureWaterHeaterOff','ButtonLibraries/ButtonFutureWaterHeaterOff.gif');
PreLoader('CEMUnderWaterHeaterOn','ButtonLibraries/ButtonUnderWaterHeaterOn.gif');
PreLoader('CEMUnderWaterHeaterOff','ButtonLibraries/ButtonUnderWaterHeaterOff.gif');
PreLoader('CEMQualityWaterHeaterOn','ButtonLibraries/ButtonQualityWaterHeaterOn.gif');
PreLoader('CEMQualityWaterHeaterOff','ButtonLibraries/ButtonQualityWaterHeaterOff.gif');
PreLoader('CEMProductsOn','ButtonLibraries/ButtonProductsOn.gif');
PreLoader('CEMProductsOff','ButtonLibraries/ButtonProductsOff.gif');
PreLoader('CEMForeverServiceOn','ButtonLibraries/ButtonForeverServiceOn.gif');
PreLoader('CEMForeverServiceOff','ButtonLibraries/ButtonForeverServiceOff.gif');
PreLoader('CEMContactUsOn','ButtonLibraries/ButtonContactUsOn.gif');
PreLoader('CEMContactUsOff','ButtonLibraries/ButtonContactUsOff.gif');

function changeButtonImage(element, eName, eButton) {
	var eButtonType;
	if (eButton==1) {
		eButtonType = "On";
	} else {
		eButtonType = "Off";					
	}
	element.src="ButtonLibraries/CHMenu"+eName+ eButtonType + ".gif"
}	

function PreLoader(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

function changeSubButtonImage(element, eName, eButton) {
	var eButtonType;
	if (eButton==1) {
		eButtonType = "On";
	} else {
		eButtonType = "Off";					
	}
	element.src="../ButtonLibraries/CMB"+eName+ eButtonType + ".gif"
}	

//判斷 v 是否是整數 Security code, Ajax Libraries, Frameworks and Toolkits 
function IsInt(v)
{
    var vArr = v.match(/^[0-9]+$/);
    if (vArr == null)
    {
        return false;
    }
    else
    {
        return true;
    }
}

// DO COOKIE TO DOMAIN
function doCookieSetup(name, value) {
      var argv = doCookieSetup.arguments;
      var argc = doCookieSetup.arguments.length;
      var expires = (argc > 2) ? argv[2] : null;
      var path = (argc > 3) ? argv[3] : null;
      var domain = (argc > 4) ? argv[4] : null;
      var secure = (argc > 5) ? argv[5] : null;

      document.cookie = escape(name) + "=" + escape(value) +
      ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
      ((path == null) ? "" : ("; path=" + path)) +
      ((domain == null) ? "" : ("; domain=" + domain)) +
      ((secure == null) ? "" : ("; secure=" + secure));
}


function CalculateLeftOffset(embraceSettings) {
    var offset = 0;
    while(embraceSettings) {
	    offset += embraceSettings["offsetLeft"];
	    embraceSettings = embraceSettings.offsetParent;
    }
    return offset;
}

function CalculateTopOffset(embraceSettings) {
    var offset = 0;
    while(embraceSettings) {
	    offset += embraceSettings["offsetTop"];
	    embraceSettings = embraceSettings.offsetParent;
    }
    return offset;
}


 // Description.. javascript:openWindow('Url.asp',500,300,0,0,0,0);
getNewWindow=null;
function openWindow(ContentUrl,theWidth,theHeight,theScroll,theStatusbar,theMenubar,theResizable) {

        if(getNewWindow==null){
					var CoordX = (screen.width / 2) - (theWidth / 2);
					var CoordY = (screen.height / 2) - (theHeight / 2);
					getNewWindow = window.open(ContentUrl, 'PMD', 'Left='+CoordX+',Top='+CoordY+',Width='+theWidth+',Height='+theHeight+',ScrollBars='+theScroll+',Status='+theStatusbar+',Menubar='+theMenubar+',Resizable='+theResizable+'');
        }else{
                try{
                        getNewWindow.status;
                        alreadyOpenMsg = "_______________________________________________________\t\n";
                        alert(alreadyOpenMsg + "\n This sub- Windows already opened, if rewill open please first closes the sub- Windows !\n Inspects whether hid to behind ! \n" + alreadyOpenMsg + "\n");
                }catch(e){
                        getNewWindow=null;
				   openWindow(ContentUrl,theWidth,theHeight,theScroll,theStatusbar,theMenubar,theResizable);
                }
        }
}


// Description.. javascript:PopupModalDialog('Url.asp',700,520,1);
function PopupModalDialog(ContentUrl,theWidth,theHeight) {
	var showWindow = window.showModalDialog (ContentUrl,'PMD','dialogWidth='+theWidth+'px;dialogHeight='+theHeight+'px;Scrollbars=Yes;Center=1;Status=No;Help=No');
}


is = new BrowserNavigationCheck()
function BrowserNavigationCheck() {
	var bnCheck = navigator.appName
	if (bnCheck=="Netscape") this.bnCheck = "ns"
	else if (bnCheck=="Microsoft Internet Explorer") this.bnCheck = "ie"
	else this.bnCheck = "ie";
}			

var diagnoseNavigation;
var elementPointX;
var elementPointY;
function echoAlert(eInfo,element) {
	returnElementObj=element;
	// FIX TO CLICK ELEMENT OBJECT
	elementPointX=CalculateLeftOffset(returnElementObj);
	elementPointY=CalculateTopOffset(returnElementObj);
	//
	echoAlertHidden();
	diagnoseNavigation.style.visibility="visible"
	diagnoseNavigation.style.top = elementPointY+"px";
	diagnoseNavigation.style.left = elementPointX+"px";
	echoAlertShow();
}

function echoAlertShow(){
	diagnoseNavigation.style.top = elementPointY+"px";
	diagnoseNavigation.style.left = elementPointX+"px";
	diagnoseNavigation.style.top=(document.body.clientWidth /2)-(260);
	diagnoseNavigation.style.left=(document.body.clientHeight /2)-(60);
	diagnoseNavigation.style.width = 320+"px";
	diagnoseNavigation.style.height = 120+"px";
}

function echoAlertHidden(){
	diagnoseNavigation=document.getElementById("extNavigation");
	diagnoseNavigation.style.visibility="hidden"
	diagnoseNavigation.style.width = 10+"px";
	diagnoseNavigation.style.height = 10+"px";
}

function confirmDeleteCommand(ItemNAMEs) {
	return(confirm('\n確認指令 !\n請確定進行資料刪除工作 ?\t\t\n'));
}

function confirmSaveCommand(ItemNAMEs) {
	return(confirm('\n確認指令 !\n請確定進行資料更新工作 ?\t\t\n'));
}

function get_support(strName,strdoname) {
	top.location.href='mailto:' + strName + '@' + strdoname
}

function addWebTofavority(favName,favUrl) {
	var myWebName;
	var myAddress;
	myWebName = favName;
	myAddress = favUrl;

	if (navigator.appName!="Netscape"){
	window.external.AddFavorite(myAddress, myWebName);
	}else{
	window.location = myAddress;
	}
}

function GotoUrl(linkObjValue) {
	top.location.href = linkObjValue;
}

function jumpTo(s) {
	if (s.selectedIndex != 0) top.location.href = s.options[s.selectedIndex].value;return 1;
}

function changeExchangeObjColor(theMmID,theMmColor) {
	document.getElementById(theMmID).style.backgroundColor=theMmColor;
}

function stopDiagnoseForm() {
	alert("\n 請按頁面中的儲存圖示 ! \t")
	// FOR FORM SUBMIT=NOTHING !
	return false;
}