function populateHourList(defaultHour, maxHour) {
	for (var i=0; i<=maxHour; i++) {
		if (i==defaultHour) {
			document.write('<option SELECTED value="' + i + '">' + i + '</option>' + '\n') ;
		}
		else {
			document.write('<option value="' + i + '">' + i + '</option>' + '\n') ;
		}
	}
}

function populateMinuteList(defaultMinute) {
	for (var i=0; i<60; i++) {
		if (i==defaultMinute) {
			document.write('<option SELECTED value="' + i + '">' + i + '</option>' + '\n') ;
		}
		else {
			document.write('<option value="' + i + '">' + i + '</option>' + '\n') ;
		}
	}
}

function populateYearList(stYear, edYear, defaultYear) {
	var todayDate = new Date() ;
	if (defaultYear==null)
		defaultYear = todayDate.getFullYear() ;

	for (var i=stYear; i<=edYear; i++) {
		if (i==defaultYear) {
			document.write('<option SELECTED value="' + i + '">' + i + '</option>' + '\n') ;
		}
		else {
			document.write('<option value="' + i + '">' + i + '</option>' + '\n') ;
		}
	}
}

function populateMonthList(defaultMon) {
	var todayDate = new Date() ;
	if (defaultMon==null)
		defaultMon = todayDate.getMonth()+1 ;

	for (var i=1; i<=12; i++) {
		if (i==defaultMon) {
			document.write('<option SELECTED value="' + i + '">' + i + '</option>' + '\n') ;
		}
		else {
			document.write('<option value="' + i + '">' + i + '</option>' + '\n') ;
		}
	}
}

function selectAll(frm, selectName) {
	for (var i=0; i<frm.elements.length; i++) {
		if (frm.elements[i].name == selectName)
			frm.elements[i].checked = true ;
	}
}

function selectItem(selectName, value) {
	for (var i=0; i<selectName.length; i++) {
		if (selectName.options[i].value == value)
			selectName.options[i].selected = true ;
	}
}

function confirmDelete(frm, selectName, msg, msgNoSelect) {
	var count=0;
	if (frm != null && selectName !=null) {
		for (var i=0; i<frm.elements.length; i++) {
			if (frm.elements[i].name == selectName &&
				frm.elements[i].checked == true)
				++count;
		}

		if (count==0) {
                    if (msgNoSelect==null)
			alert("No item was selected");
                    else
                        alert(msgNoSelect);
			return false ;
		}
	}

	if (msg==null)
		msg = "Are you sure to delete those selected items? ";
	return  confirm(msg) ;
}

function checkSelect(frm, selectName, msg) {
	var count=0;
	if (msg==null)
		msg="No item was selected";

	for (var i=0; i<frm.elements.length; i++) {
		if (frm.elements[i].name == selectName &&
			frm.elements[i].checked == true)
			++count;
	}

	if (count==0) {
		alert(msg);
		return false ;
	}

	return true ;
}

function checkEditStatus(checkBox, checkEdit) {
	if (checkBox.checked) {
		checkEdit.disabled = '' ;
		checkEdit.focus() ;
	}
	else {
		checkEdit.disabled = "disabled" ;
	}
}

var visibleSelects = new Array(512);
var visibleCount=0;
function hidden_select() {
  visibleCount=0;
  for (var i=0; i<document.forms.length; i++) {
      for (j=0; j<document.forms[i].elements.length; j++) {
          if (document.forms[i].elements[j].type.substr(0, 6)=='select' &&
              document.forms[i].elements[j].name.substr(0, 3)!='cbo' &&
              document.forms[i].elements[j].style.visibility!='hidden') {
              visibleSelects[visibleCount] = document.forms[i].elements[j];
              visibleCount++;
              document.forms[i].elements[j].style.visibility='hidden' ;
          }
      }
  }
}

function show_select() {
/*
  for (var i=0; i<document.forms.length; i++) {
      for (j=0; j<document.forms[i].elements.length; j++) {
          if (document.forms[i].elements[j].type.substr(0, 6)=='select')
              document.forms[i].elements[j].style.visibility='visible' ;
      }
  }
*/
  for (var i=0; i<visibleCount; i++) {
      visibleSelects[i].style.visibility='visible' ;
  }
}
function OpenMenu(MenuId){	hidden_select(); MenuId.style.visibility = 'visible'; }
function CloseMenu(MenuId){	show_select(); MenuId.style.visibility = 'hidden';}


function changeDisableStatus(frm, disableStr, startsWith, endsWith, skipName) {
	for (var i=0; i<frm.elements.length; i++) {
		var match=false;
		if (startsWith!=null && endsWith!=null) {
			match = frm.elements[i].name.substr(0, startsWith.length)==startsWith ;
			if (match) {
				var index = frm.elements[i].name.length - endsWith.length;
				match = (index>=0) &&
						frm.elements[i].name.substr(index, endsWith.length)==endsWith ;
			}
		}
		else if (startsWith!=null) {
			match = frm.elements[i].name.substr(0, startsWith.length)==startsWith;
		}
		else if (endsWith!=null) {
			var index = frm.elements[i].name.length - endsWith.length;
			match = (index>=0) &&
					frm.elements[i].name.substr(index, endsWith.length)==endsWith ;
		}

		if (match) {
			if (skipName==null || frm.elements[i].name != skipName) {
				frm.elements[i].disabled = disableStr ;
			}
		}
	}
}

function changeStatus(frm, check, disable, startsWith, endsWith) {
	var disableStr ;
	if (check.checked) {
		if (disable)
			disableStr = 'disabled' ;
		else
			disableStr = '' ;
	}
	else {
		if (disable)
			disableStr = '' ;
		else
			disableStr = 'disabled' ;
	}

	changeDisableStatus(frm, disableStr, startsWith, endsWith, check.name);
}

function gotoUrl(url) {
    window.location.href = url;
}

function domlay(id,trigger,content,lax,lay) {
    /*
     * Cross browser Layer visibility / Placement Routine
     * Done by Chris Heilmann (mail@ichwill.net)
     * Feel free to use with these lines included!
     * Created with help from Scott Andrews.
     * The marked part of the content change routine is taken
     * from a script by Reyn posted in the DHTML
     * Forum at Website Attraction and changed to work with
     * any layername. Cheers to that!
     * Welcome DOM-1, about time you got included... :)
     */
    // Layer visible
    if (trigger=="1"){
        if (document.layers) document.layers[''+id+''].visibility = "show"
        else if (document.all) document.all[''+id+''].style.visibility = "visible"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
        }
    // Layer hidden
    else if (trigger=="0"){
        if (document.layers) document.layers[''+id+''].visibility = "hide"
        else if (document.all) document.all[''+id+''].style.visibility = "hidden"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
        }
    // Set horizontal position
    if (lax){
        if (document.layers){document.layers[''+id+''].left = lax}
        else if (document.all){document.all[''+id+''].style.left=lax}
        else if (document.getElementById){document.getElementById(''+id+'').style.left=lax+"px"}
        }
    // Set vertical position
    if (lay){
        if (document.layers){document.layers[''+id+''].top = lay}
        else if (document.all){document.all[''+id+''].style.top=lay}
        else if (document.getElementById){document.getElementById(''+id+'').style.top=lay+"px"}
        }
    // change content

    if (content){
    if (document.layers){
        sprite=document.layers[''+id+''].document;
        // add father layers if needed! document.layers[''+father+'']...
        sprite.open();
        sprite.write(content);
        sprite.close();
        }
    else if (document.all) document.all[''+id+''].innerHTML = content;
    else if (document.getElementById){
        //Thanx Reyn!
        rng = document.createRange();
        el = document.getElementById(''+id+'');
        rng.setStartBefore(el);
        htmlFrag = rng.createContextualFragment(content)
        while(el.hasChildNodes()) el.removeChild(el.lastChild);
        el.appendChild(htmlFrag);
        // end of Reyn ;)
        }
    }
}

function showLayer(id, trigger) {
    if (trigger=="1"){
        if (document.layers) document.layers[''+id+''].visibility = "show"
        else if (document.all) document.all[''+id+''].style.visibility = "visible"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
    }
    // Layer hidden
    else if (trigger=="0"){
        if (document.layers) document.layers[''+id+''].visibility = "hide"
        else if (document.all) document.all[''+id+''].style.visibility = "hidden"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
    }
}


function prelisten(title,file,contextPath) {
    pop=window.open(contextPath + "/preview.jsp?file="+file+"&title="+title,"WG_Preview_MIDI",'scrollbars=0,status=yes,width=289,height=151,left=300,top=70');
}

function prelistenUTF8(title,file,contextPath) {
   	var aa= encodeURIComponentNew(title);
    pop=window.open(contextPath + "/previewu.jsp?file="+file+"&title="+aa,"WG_Preview_MIDI",'scrollbars=0,status=yes,width=289,height=151,left=300,top=70');
}

function toUtf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

function toHex(n) {
	var hexchars = "0123456789ABCDEF";
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

function prelistenshortcode(scode) {
    pop=window.open("/prelisten.do?shortcode=" + scode ,"WG_Preview_MIDI",'scrollbars=0,status=yes,width=289,height=151,left=300,top=70');
}

function encodeURIComponentNew(s) {
	var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
  var s = toUtf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}




function previewvideo(title,file,contextPath) {
    pop=window.open(contextPath + "/preview.jsp?file="+file+"&title="+title,"WG_Preview_MIDI",'scrollbars=0,status=yes,width=340,height=300,left=300,top=70');
}

/*function prelisten(signer,title,file,contextPath) {
    pop=window.open(contextPath + "/preview.jsp?signer=" + signer + "&file="+file+"&title="+title,"WG_Preview_MIDI",'scrollbars=0,status=yes,width=289,height=151,left=300,top=70');
}*/

function truetoneprelisten(signer,title,file,contextPath) {
    pop=window.open(contextPath + "/truetonepreview.jsp?signer=" + signer + "&file="+file+"&title="+title,"WG_Preview_MIDI",'scrollbars=0,status=yes,width=532,height=350,left=300,top=70');
}

function polyjpopprelisten(signer,title,file,contextPath) {
    pop=window.open(contextPath + "/polyjpoppreview.jsp?signer=" + signer + "&file="+file+"&title="+title,"WG_Preview_MIDI",'scrollbars=0,status=yes,width=532,height=310,left=300,top=70');
}

function prelistenRBT(signer, title,file,contextPath) {
	var pop=window.open(contextPath + "/preview.jsp?signer=" + signer + "&file="+file+"&title="+title,"WG_Preview_MRBT","width=250,height=100,location=0,menubar=0,toolbar=0,personalbar=0,status=0,scrollbars=0,resizable=0,left=0,top=0");
//	pop.document.write("<title>歌曲試聽: " + title + "</title>");
//	pop.document.write("<embed loop=\"true\" autostart=\"true\" hidden=\"false\" src=\""+file+"\"></embed>");
    if(pop) pop.moveTo(0,0);
}


/*   new function by Casper                      */

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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
      document[grpName] = nbArr = new Array();
      for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
        nbArr[nbArr.length] = img;
      }
    }
}

function showhide(what){
	if (what.style.display=='none'){
		what.style.display='';
	} else {
		what.style.display='none'
	}
}


function MM_findObj(n, d) { //v3.0
  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); return x;
}

function MM_showHideLayers() { //v3.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; }
}

function selectGotoURL(select) {
	var i = select.selectedIndex;
	var href = select.options[i].value;
	if (href == null || href.length == 0) {
		return true;
	} else {
		location.href = href;
		return false;
	}
}

// 加入我的最愛
function addFavorite(title, url) {
	if (navigator.appName != "Netscape") {
		window.external.AddFavorite(url, title);
	} else {
		window.location = myfar;
	}
}

// 計算字串 Byte 數，斷行符號不計
function ByteLength(str) {
	var count = 0;
	if (str != null) {
	  for(i=0; i < str.length; i++) {
			if (str.charCodeAt(i) == 10) {
				continue;
			} else if (str.charCodeAt(i) == 13) {
				continue;
	    } else if (str.charCodeAt(i) > 128) {
	      count = count + 2;
	    } else {
	      count = count + 1;
			}
	}
	}
	return count;
}




function MM_findObj(n, d) { //v3.0
  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); return x;
}

function MM_showHideLayers() { //v3.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; }
}
/*
function prelisten(title,file) {
	pop=window.open("","winName",'scrollbars=0,status=yes,width=289,height=151,left=300,top=70');
	pop.document.write("<title>歌曲試聽</title>");
	pop.document.write("<body background='web/images/prelisten.gif'/>");
	pop.document.write("<table width='289'><tr><td height='40' colspan='2'>&nbsp;</td></tr>");
	pop.document.write("<embed loop=\"true\" autostart=\"true\" hidden=\"true\" src=\""+file+"\"></embed>");
	pop.document.write("<bgsound loop=\"infinite\" src=\""+file+"\"></bgsound>");
	pop.document.write("<tr><td width='30'>&nbsp;</td>");
	pop.document.write("<td width='259' height='40' valign='top'><font size='2'color='#ffffff'>"+title+"</font></td></tr>");
	pop.document.write("<tr><td colspan='2'>");
	pop.document.write("<table width='150'><tr><td width='90'>&nbsp;</td>");
	//pop.document.write("<td width='30'><img style='CURSOR: hand' border='0' src='web/images/listenoff.gif' alt='試聽鈕'/></td>");
	pop.document.write("<td width='30'><img style='CURSOR: hand' onclick='self.close()' border='0' src='web/images/stopoff.gif' alt='試聽鈕'/></td></tr></table>");
	pop.document.write("</td></tr></table>");
}
*/
function popWin(theURL,winName,features)
{
 window.open(theURL,winName,features);
}

// add by anderson MOTO GOGO FUN WEB 新增 Script

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_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; }
}

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_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;
}

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];}
}

function showRowLayer(id, trigger) {
    showLayer(id+'1', trigger);
    showLayer(id+'2', trigger);
}

function confirmDownload(shortCode,mediaType,contextPath) {
/*
	pop=window.open("","winName",'scrollbars=0,status=yes,width=289,height=151,left=300,top=70');
	pop.document.write("<title>歌曲試聽</title>");
	pop.document.write("<body background='" + contextPath + "/images/prelisten.gif'/>");
	pop.document.write("<table width='289'><tr><td height='40' colspan='2'>&nbsp;</td></tr>");
//	pop.document.write("<embed loop=\"true\" autostart=\"true\" hidden=\"true\" src=\""+file+"\"></embed>");
	pop.document.write("<bgsound loop=\"infinite\" src=\""+file+"\"></bgsound>");
	pop.document.write("<tr><td width='30'>&nbsp;</td>");
	pop.document.write("<td width='259' height='40' valign='top'><font size='2'color='#ffffff'>"+title+"</font></td></tr>");
	pop.document.write("<tr><td colspan='2'>");
	pop.document.write("<table width='150'><tr><td width='90'>&nbsp;</td>");
	//pop.document.write("<td width='30'><img style='CURSOR: hand' border='0' src='/images/listenoff.gif' alt='試聽鈕'/></td>");
	pop.document.write("<td width='30'><img style='CURSOR: hand' onclick='self.close()' border='0' src='" + contextPath + "/images/stopoff.gif' alt='試聽鈕'/></td></tr></table>");
	pop.document.write("</td></tr></table>");
*/
    pop=window.open(contextPath + "/actions/confirm.do?shortCode="+shortCode+"&mediaType="+mediaType,"WG_Confirm",'scrollbars=0,status=yes,width=520,height=320,left=300,top=70');
    pop.focus();
}

//add by Kyle for payeasy

function confirmFateDownload(shortCode,mediaType,contextPath,productName,mpPoint) {
    pop=window.open(contextPath + "/actions/confirm.do?shortCode="+shortCode+"&mediaType="+mediaType+"&productName="+productName+"&mpPoint="+mpPoint,"WG_Confirm",'scrollbars=0,status=yes,width=520,height=320,left=300,top=70');
    pop.focus();
}



//add by kyle 2006.04.29

function WG_Generateobj(objAttrs, params, embedAttrs)
{
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

//add by kyle 2006.04.29
function WG_RunFL(){
  var ret =
    WG_GetArgs
    (  arguments, "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  WG_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

//add by kyle 2006.04.29
function WG_GetArgs(args, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();

    switch (currArg){
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}




var http_request = null;

function makeRequest(url) {
    http_request = null;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
            }
        }
    }

    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = alertContents;
    http_request.open('GET', url, true);
    http_request.send(null);
    return false;
}

function alertContents() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            alert(http_request.responseText);
        } else {
            alert('There was a problem with the request.');
        }
    }
}

function sendWebWapPush() {
    var msisdn = document.getElementById("webwappushmsisdn");

    if (!validatePhone(msisdn.value)) {
    	return false;
    }

    var eventcode = document.getElementById("webwappusheventcode");
    var d = new Date();
    var geturl = "/wappushevent/sendwappush.do?msisdn=" + msisdn.value + "&eventcode=" + eventcode.value + "&now=" + d.getTime();

    return makeRequest(geturl);
}

function validatePhone(msisdn)
{
	var id = msisdn;
  var idRE = /^09[0-9]{8}/;
	if (!idRE.test(id)) {
	    alert("請重新輸入正確的手機號碼");
	    return false;
	}
	return true;
}