function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  window.status = document.title;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* Set up boolian variables to record the browser type */
	var isNS4 = 0;
	var isIE = 0;
	var isNewNS = 0;

/* Determines the browser name and browser version */
	var brow = ((navigator.appName) + (parseInt(navigator.appVersion)));

/* reassign variable depending on the browser */
	if ((document.getElementById) && ( (parseInt(navigator.appVersion)) >= 5) ) {isNewNS = 1;}
	if (brow == "Netscape4") {isNS4 = 1;}
	if (document.all) {isIE = 1;}

/*browser detection global variable*/
	var is_ie = ((navigator.appName) == "Microsoft Internet Explorer");
	var is_ns = ((navigator.appName) == "Netscape");	
	var version = parseInt(navigator.appVersion); 
	var agt = navigator.userAgent.toLowerCase();
	var is_mac = ((agt.indexOf("mac")) != -1);
	var is_aol = ((agt.indexOf("aol")) != -1);
	var billwin=( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit") !=-1) );
	
/* Bookmark Add to favorite function*/
var PathnameToBookmark=location.pathname; /* i.e. /home.php */
var pageTitle = document.title;
var locationToBookmark = "http://www.gumma.com.tw"+PathnameToBookmark;
function BookmarkUs()
{ 
  if (window.external && billwin)
	    external.AddFavorite(locationToBookmark, pageTitle)
	  else if (isNewNS && billwin) {				
		B2BCD_MozillaSidebar(locationToBookmark,pageTitle,'');
		}
		 else if (is_ns && billwin) {
	    alert("Please press Ctrl+D to bookmark this page");
		}
		else if (is_mac)  {
		 alert("Please press Command-button+D to bookmark this page");
		 }
		 else {
		  alert("Please add us to your favorites / bookmarks!");
		 }
}


function B2BCD_MozillaSidebar(url, tabName, urlCust)
{ /*v1.01 */
    if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function"))
	{
		if(window.sidebar.addPanel){
									 window.sidebar.addPanel (tabName, url, urlCust);
									 alert("Please press Ctrl+D to bookmark this page");
									}
    }
	
	else{
        window.alert("Please press Ctrl+D to bookmark this page");
    	}
}
/* POP UP WINDOW */

function popup(urlForWindow, nameOfWindow, isLimitedWindow, w, h)	{
	if (name == null) name = '';
	if (w == null) w = 450;
	if (h == null) h = 400;
	
	/*workig with screen position of popup window ?*/
	var leftPos=0;
	var topPos=0;

	var el = "width="+w+",height="+h;
	if (isLimitedWindow)
		el += ",resizable=0,scrollbars=0,toolbar=0,location=0,directories=0,status=1,menubar=0,copyhistory=0";
	else
		el += ",resizable=1,scrollbars=1,toolbar=1,location=1,directories=1,status=1,menubar=1,copyhistory=1";

	var win = window.open(urlForWindow, nameOfWindow, el+",left=0,top=0");
	win.location.href = urlForWindow;
	win.focus();
}


/* PRINTING PAGE */

function doPrint(PrintAction,PageContentID) {

if(PrintAction=="Open") {

//old outcomment var PathnameToPrint = location.pathname; /* i.e. /home.php */

var PathnameToPrint = "printing.php";
if(document.name =="IndexHome"){
PathnameToPrint = "/english/printing.php";
}
if(document.name =="IndexChinese"){
PathnameToPrint = "/chinese/printing.php";
}


//alert(document.name);
var CurrentQuery = location.search; /*current url querystring*/

//setting up what page content the printing page will import to print...
var queryString = '?printpage='+PageContentID;

var URL2Print = PathnameToPrint+queryString;

var printWin = popup(URL2Print,'printPop',false,600,550);

return;
} // end of parameter = Open

if(PrintAction=="Print"){
								if(window.print){
								window.print();
								}
								else{
								alert("Select from 'File' menu and your 'Print' option, please!"); 
								}
			}
}

/* JUMP PAGE */
function MM_jumpMenu(targ,selObj,restore){ /*v3.0*/
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  	if (restore) selObj.selectedIndex=0;
}
/* Status bar */
window.status = document.title;

/*Keeping page out of a frame*/
if (top.location != self.location)	{
top.location = self.location;
}
