var URL;
var myAjax;
var size;
var title;
var jsduration = 1;
var jsfrom = 0;
var jsto = 1;
var viewportwidth;
var viewportheight;
function stripslashes(str) 
{
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}
function connectionAjax(URL,pars,divid)
{
	myAjax = new Ajax.Request(URL,{
       			 	 	 	method:'get',
       			 	 	 	parameters: pars, 
       			 	 	 	onComplete: function(originalRequest){$(divid).innerHTML = originalRequest.responseText;}
       			 	 	 	});		
}
function connectcreate(pars)
{	
	URL="../xml/content.php";	
	connectionAjax(URL,pars,'mainpage');
}
function gettrailer(link,id)
{	
	//URL="../xml/trailer.php";
	//pars="id="+id;	
	//connectionAjax(URL,pars,'trailermedia');
	/*
	var obj  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="320" height="320" id="scrubber" align="middle">';
	    obj += '<param name="allowScriptAccess" value="sameDomain" />';
	    obj += '<param name="allowFullScreen" value="false" />';
	    obj += '<param name="FlashVars" value="videoURL='+ link +'images/trailer/'+ id +'" />';
	    obj += '<param name="movie" value="../scrubber.swf" />';
	    obj += '<param name="quality" value="high" />';
	    obj += '<param name="wmode" value="transparent">';
	    obj += '<embed src="../scrubber.swf" quality="high" WMODE="transparent" width="320" height="320" name="scrubber" align="middle" FlashVars="videoURL='+ link +'images/trailer/'+ id +'" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	    obj += '</object>';

	var obj	 = '<object id="flowplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="240">';
			obj += '<param name="movie" value="../flowplayer-3.1.1.swf" />'
			obj += '<param name="autoRun" value="false" />';
			obj += '<param name="start" value="0" />';
			obj += '<param name="wmode" value="transparent">';
			obj += '<param name="flashvars" value=\'config={"clip":{"autoPlay":false,"url":"'+ link +'images/trailer/'+ id +'"},"plugins":{"controls":{"autoHide":"always"}},"playlist":[{"autoPlay":false,"url":"'+ link +'images/trailer/'+ id +'"}]}\' />';
			obj += '<embed type="application/x-shockwave-flash" wmode="transparent" width="320" height="240" src="../flowplayer-3.1.1.swf" flashvars=\'config={"clip":{"autoPlay":false,"url":"'+ link +'images/trailer/'+ id +'"},"plugins":{"controls":{"autoHide":"always"}},"playlist":[{"autoPlay":false,"url":"'+ link +'images/trailer/'+ id +'"}]}\' />';
			obj += '</object>';
			
	var obj	 = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="320" height="240" id="FLVPlayer">';
			obj += '<param name="movie" value="../FLVPlayer_Progressive.swf" />
			obj += '<param name="salign" value="lt" />
			obj += '<param name="quality" value="high" />
			obj += '<param name="scale" value="noscale" />
			obj += '<param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName='+ link +'images/trailer/'+ id +'&autoPlay=false&autoRewind=false" />
			obj += '<embed src="../FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName='+ link +'images/trailer/'+ id +'&autoPlay=false&autoRewind=false" quality="high" scale="noscale" width="320" height="240" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" />    
			obj += '</object>			
	*/			
	var obj	 = '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="320" height="240" id="FLVPlayer" name="FLVPlayer" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >';
			obj += '<param name="movie" value="FLVPlayer_Progressive.swf" />';
			obj += '<param name="flashvars" value=&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName='+ link +'images/trailer/'+ id +'&autoPlay=false&autoRewind=false" />';
			obj += '<param name="quality" value="hight" />';
			obj += '<param name="scale" value="noscale" />';
			obj += '<param name="salign" value="lt" />';
			obj += '<param name="wmode" value="transparent">';			
			obj += '<embed width="320" height="240" src="FLVPlayer_Progressive.swf"  wmode="transparent" flashvars="&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName='+ link +'images/trailer/'+ id +'&autoPlay=false&autoRewind=false" quality="high" scale="noscale" name="FLVPlayer" salign="lt" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ></embed>';
			obj += '</object>';
	$('trailermedia').innerHTML = obj;
}	
function getnews(pars)
{
	URL="../xml/news.php";	
	connectionAjax(URL,pars,'news');
}	
function gettop(type,item)
{	
	var pars = 'type='+type+'&item='+item;
	gettop10(pars);
	gettop5(pars);
}
function gettop10(pars)
{
	URL="../xml/top10.php";	
	connectionAjax(URL,pars,'top10');
}	
function gettop5(pars)
{
	URL="../xml/top5.php";	
	connectionAjax(URL,pars,'top5');
}
function getbanner(type,page)
{
	URL="../xml/banner.php";	
	pars='type='+type+'&page='+page;	
	connectionAjax(URL,pars,type);
}
function pagelimitload(type,item)
{
	if(item)
	{
		try
		{
			window.clearTimeout(TI);
		}
		catch(e){}
		pars = 'type='+ type +'&item='+item;
		URL = "../"+ $('page_version').innerHTML +"/daylimitproduct.php";
		window.location = URL +'?'+ pars;		
	}	
}
function pageload(type,item)
{
	switch(type)
	{	
		case 'child':
			try
			{
				window.clearTimeout(TI);
			}
			catch(e){}
			URL = "../"+ $('page_version').innerHTML +"/children_item.php";
			window.location = URL;
		break;
		case 'forum':
			try
			{
				window.clearTimeout(TI);
			}
			catch(e){}
			URL = "../"+ $('page_version').innerHTML +"/forum.php";
			window.location = URL;
		break;		
		case 'product':
			if(item)
			{
				try
				{
					window.clearTimeout(TI);
				}
				catch(e){}
				pars = 'type='+ type +'&item='+item;
				URL = "../"+ $('page_version').innerHTML +"/product.php";
				window.location = URL +'?'+ pars;		
			}
		break;
		case 'contact':
			try
			{
				window.clearTimeout(TI);
			}
			catch(e){}
			pars = 'type='+ type +'&item='+item;
			URL = "../"+ $('page_version').innerHTML +"/static.php";
			window.location = URL +'?'+ pars;				
		break;
		case 'showlink':
			try
			{
				window.clearTimeout(TI);
			}
			catch(e){}
			pars = 'type='+ type +'&link='+item;
			URL="../xml/mainpage.php";
			connectionAjax(URL,pars,'mainframe');			
		break;
		case 'search':
			try
			{
				window.clearTimeout(TI);
			}
			catch(e){}
			pars = 'type='+ type +'&searchValue='+item;
			URL = "../"+ $('page_version').innerHTML +"/searchResult.php";
			window.location = URL +'?'+ pars;	
		break;	
		case 'search_t':
			try
			{
				window.clearTimeout(TI);
			}
			catch(e){}
			pars = 'type='+ type +'&searchValue='+item;
			URL = "../"+ $('page_version').innerHTML +"/searchResult_t.php";
			window.location = URL +'?'+ pars;	
		break;				
		case 'newsAll':
			try
			{
				window.clearTimeout(TI);
			}
			catch(e){}
			pars = 'type='+ type;
			URL = "../"+ $('page_version').innerHTML +"/newslist.php";
			window.location = URL +'?'+ pars;	
		break;	
		case 'jetsoAll':
			try
			{
				window.clearTimeout(TI);
			}
			catch(e){}
			pars = 'type='+ type;
			URL = "../"+ $('page_version').innerHTML +"/jetsolist.php";
			window.location = URL +'?'+ pars;	
		break;					
	}			
}
function getcontent(pdt,item)
{
	try{	window.clearTimeout(TI);	}
	catch(e){}		
	pars = 'type=product&pdt='+ pdt +'&item='+item;
	URL = "../"+ $('page_version').innerHTML +"/detail.php";	
	window.location = URL +'?'+ pars;
	/*
	pars = 'type=product&pdt='+ pdt +'&item='+item;
	URL="../xml/content.php";
	connectionAjax(URL,pars,'mainframe');
	$('URLaddress').value = $('defineURL').value+ "?" + pars;
	URL="../xml/rightpage.php";
	connectionAjax(URL,pars,'sideframe');
	gettop('product',item);
	*/
}
function getCharProduct(id)
{
	try{	window.clearTimeout(TI);	}
	catch(e){}		
	pars = 'charID='+id;
	URL = "../"+ $('page_version').innerHTML +"/children_product.php";	
	window.location = URL +'?'+ pars;
	/*
	pars = 'type=product&pdt='+ pdt +'&item='+item;
	URL="../xml/content.php";
	connectionAjax(URL,pars,'mainframe');
	$('URLaddress').value = $('defineURL').value+ "?" + pars;
	URL="../xml/rightpage.php";
	connectionAjax(URL,pars,'sideframe');
	gettop('product',item);
	*/
}
function searchResult()
{
	//Element.hide('ID_ADDR_SEL');
	if($('keyword').value)
	{
		pageload('search',$('keyword').value);
	}
}
function searchResult_t()
{
	//Element.hide('ID_ADDR_SEL');
	if($('keyword').value)
	{
		pageload('search_t',$('keyword').value);
	}
}
function nextpage(type,page)
{
	try{	window.clearTimeout(TI);	}
	catch(e){}
	pars = type+'&page='+page;	
	URL = "../"+ $('page_version').innerHTML +"/product.php";
	window.location = URL +'?'+ pars;	
}
function daylimitnextpage(type,page)
{
	try{	window.clearTimeout(TI);	}
	catch(e){}
	pars = type+'&page='+page;	
	URL = "../"+ $('page_version').innerHTML +"/daylimitproduct.php";
	window.location = URL +'?'+ pars;	
}
function searchNextpage(searchValue,page)
{
	try{	window.clearTimeout(TI);	}
	catch(e){}
	pars = searchValue+'&page='+page;	
	URL = "../"+ $('page_version').innerHTML +"/searchResult.php";
	window.location = URL +'?'+ pars;	
}
function GetResult(type,pdt,item)
{
	if(type=='product')
	{
		getcontent(pdt,item);
	}
}
function handleOnMouseOver(oTr)
{
	document.getElementById(oTr).className = "highlightrow";
}	
function NewsMouseOver(oTr)
{
	
}
function handleOnMouseOut(oTr)
{
	document.getElementById(oTr).className = "";				
}
function divclose(divID)
{
	$(divID).innerHTML = '';
	Element.hide(divID);
}
//
//Email div
//
function sendtoemail()
{
	URL="../xml/email.html";	
	pars='';	
	connectionAjax(URL,pars,'divEmail');
	Effect.show('divEmail');
}

function changeindex(version,type,link)
{
	URL = '../xml/changeversion.php';
	pars = 'version='+version+'&type='+type+'&link='+link;
	var myAjax = new Ajax.Request(URL,{
       			 	 								 	method:'get',
       			 	 	 								parameters: pars, 
       			 	 	 								onComplete: function(originalRequest){window.location=originalRequest.responseText;}
       			 	 	 								});
}

function create_new_window(link,title,param)
{
	window.open(link,'',param);
}

//
//searchbar div
//
function find_search_keyword(value, e )
{
	e=(!e)?window.event : e;
	target = (!e.target) ? e.srcElement : e.target;
	$('keyword').value = string_replace(value);
	if(target.nodeType == 3)
 		target = target.parentNode;
	code = (e.charCode) ? e.charCode :
				 ((e.keyCode) ? e.keyCode :
				 ((e.which) ? e.which :0));
	//$('keyword').value = string_replace(value);
	//alert($('keyword').value);
	if((code < 13 && code != 8) ||
		 (code >= 14 && code < 32) ||
		 (code >= 33 && code <= 47) ||
		 (code >= 112 && code <= 123))
	{}
	else if(code == 13)
	{
		searchResult();
	}
	else
	{
		if(value != '' && value.length > 3)
		{
			var URL = '../xml/searchbar.php';
			var pars = 'keyword=' + encodeURI(value);
			try
			{
				var myAjax = new Ajax.Request(
        	     			 URL,
          	   			 {method: 'get', parameters: pars, onComplete: showKeywordResponse, onFailure: reportError}
            	 			 );
      }
      catch(e)
      {}
		}
		else					
			$('scroll').style.visibility = "hidden";				
	}	
}

function string_replace(value)
{
	
	value = value.replace("%","");
	value = value.replace("\*","");
	//value = value.replace("\'","");
	value = value.replace("\/","");
	value = value.replace("\\","");
	//alert(value);
	return value;
}


function reportError(request)
{
	alert('Sorry. There was an error.');
}
    
function xmlToArray(resultXml)
{
	var resultsArray = new Array();
	for(i=0;i<resultXml.length;i++)
	{
		resultsArray[i]=resultXml.item(i).firstChild.data;
	}
	return resultsArray;
}

function showKeywordResponse(originalRequest)
{
	//put returned XML in the textarea        
	var response = originalRequest.responseXML.documentElement;
	keyword_array= new Array();  			
	//var resultXML = originalRequest.responseXML;
	if(response.childNodes.length)
	{
		keyword_array=xmlToArray(response.getElementsByTagName("keyword"));							
	}		
	var div = '<table>';					
	for(i = 0; i < keyword_array.length ; i++)
	{
		try
		{
			value = (keyword_array[i]).split(' * ');
		}
		catch(e){}
		if(value.length > 1)
		{
			keyword_array[i] = (keyword_array[i]).replace(' * ','<br><span style="color:#ff0000;">');
			div += ' <tr id="tr' + i + '" onmouseover="handleOnMouseOver(this.id);" onmouseout="handleOnMouseOut(this.id);" onclick="addtotextbox(\''+ value[0] +'\');"><td> ' + stripslashes(keyword_array[i]) + '</span></td></tr> ';
		}
		else
		{
			div += ' <tr id="tr' + i + '" onmouseover="handleOnMouseOver(this.id);" onmouseout="handleOnMouseOut(this.id);" onclick="addtotextbox(\''+ keyword_array[i] +'\');"><td> ' + stripslashes(keyword_array[i]) + '</td></tr> ';
		}
	}
	div += '</table>';
	$('suggest').innerHTML = div;	
	this.popup = $('scroll');
	this.toggler = $('keyword');			
	var pos = Element.cumulativeOffset(this.toggler);
	var posTop = pos.top + this.toggler.getHeight() - (Prototype.Browser.IE ? 3 : 1);
	var posBottom = pos.top - this.popup.getHeight();
	var posLeft = pos.left;
	var posRight = pos.right
	Element.setStyle(this.popup, {top: posTop + "px", left: posLeft + "px"});	
	showsearch();	
}

function hidesearch()
{
	hidetimeout = window.setTimeout( function(){$('scroll').style.visibility = 'hidden';} , 5 * 1000);
}
function showsearch()
{
	try
	{	
		window.clearTimeout(hidetimeout);
	}
	catch(e){}
	if($('suggest').innerHTML)
	{
		$('scroll').style.visibility = "visible";	
	}
}
function addtotextbox(value)
{
	$('keyword').value = value;
	try
	{	
		window.clearTimeout(hidetimeout);
	}
	catch(e){}	
	$('scroll').style.visibility = 'hidden';
}

function showPop(id,popupId)
{
	var PopupWidth='300';
	var tid = $(id);
	var Pid = $(popupId);
	if (Pid.getStyle("display") == "none") 
	{
		var pos = Element.cumulativeOffset(tid);
		var posTop = pos.top + tid.getHeight() - (Prototype.Browser.IE ? 3 : 1);
		var posBottom = pos.top - Pid.getHeight();
		var posLeft = pos.left;
		var posRight = posLeft + tid.getWidth() - PopupWidth;				
		Element.setStyle(Pid, {top: posTop + "px", left: posRight + "px"});
		Pid.show();
	}
}
function hidePopup(popupId)
{
	$(popupId).hide();
}
function trailerOpen(id,popupId)
{
	var PopupWidth='360';
	var tid = $(id);
	var Pid = $(popupId);
	if (Pid.getStyle("display") == "none") 
	{
		var pos = Element.cumulativeOffset(tid);
		var posTop = pos.top + tid.getHeight() - (Prototype.Browser.IE ? 3 : 1);
		var posBottom = pos.top - Pid.getHeight();
		var posLeft = pos.left;
		var posRight = posLeft + tid.getWidth() - PopupWidth;				
		//Element.setStyle(Pid, {top: posTop + "px", left: posRight + "px"});
		Element.setStyle(Pid, {top: posTop + "px", left: posLeft + "px"});
		Pid.show();
	}
}
function TableShow(type,version,item)
{
	if(item)
	{
		switch(type)
		{
			case"Img":
				$('displayImgResult').show();
				$('displayTextResult').hide();
				$('imgIco').src="../images/"+version+"_index/onclickimgico2.gif";
				$('txtIco').src="../images/"+version+"_index/textico2.gif";
			break;
			case"Txt":
				$('displayImgResult').hide();
				$('displayTextResult').show();
				$('imgIco').src="../images/"+ version +"_index/imgico2.gif";
				$('txtIco').src="../images/"+ version +"_index/onclicktextico2.gif";
			break;
		}
	}
	else
	{
		switch(type)
		{
			case"Img":
				$('displayImgResult').show();
				$('displayTextResult').hide();
				$('imgIco').src="../images/"+version+"_index/onclickimgico.gif";
				$('txtIco').src="../images/"+version+"_index/textico.gif";
			break;
			case"Txt":
				$('displayImgResult').hide();
				$('displayTextResult').show();
				$('imgIco').src="../images/"+ version +"_index/imgico.gif";
				$('txtIco').src="../images/"+ version +"_index/onclicktextico.gif";
			break;
		}		
	}
}
function ShowBshotImg(divID,path,pic)
{
	$(divID).innerHTML = '<table border="0"><tr><td><img src="'+ path + pic +'" onclick="hideBshotImg(\''+divID+'\');"></td><td valign="top"><img src="../images/false.gif" onclick="hideBshotImg(\''+divID+'\');"></td></tr></table>';			
	Element.setStyle(divID, {top: "10px", left: "400px"});	
	$('lightboxOverlay').show();
	$(divID).show();
}
function hideBshotImg(divID)
{
	$(divID).hide();
	$('lightboxOverlay').hide();	
}
function func_check_code(value)
{
		if(value)
		{
			if((value).length > 4 )
			{	
				URL = '../xml/checkCode.php';
				pars = 'code='+value;
				myAjax = new Ajax.Request(URL,{
    	  	 			 	 	 		method:'get',
      	 				 	 	 		parameters: pars, 
       				 	 	 			onComplete: function(originalRequest)
       			 		 	 									{
       			 	 		 										if(originalRequest.responseText == 'true')
       			 	 	 											{
  																			$('correctImg').src="../images/true.gif";
  																			$('correctValue').value="true";
  																			$('btnPost').disabled = false;
       			 	 	 											}
       			 	 	 											else
	       			 	 	 										{
  																			$('correctImg').src="../images/false.gif";
  																			$('correctValue').value="";       			 	 	 											
  																			$('btnPost').disabled = true;
       				 	 	 										}
       				 	 	 									}
      	 				 	 	 		});		   			 	 	 		
				$('correctImg').show();
  		}
  		else
	  	{
  			$('correctImg').src="../images/false.gif";
  			$('correctValue').value="";
  			$('correctImg').show();
  			$('btnPost').disabled = true;
  		}		
  	}
	  else
  	{
  		$('correctValue').value="";
  		$('correctImg').hide(); 
  		$('btnPost').disabled = true; 	
  	}
}
function ismaxlength(obj)
{
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
		obj.value=obj.value.substring(0,mlength)
}
function login()
{
	URL = '../xml/login.php';
	pars = "login_name="+$('login_name').value+"&login_pwd="+$('login_pwd').value;
	var myAjax = new Ajax.Request(URL,{
       			 	 								 	method:'get',
       			 	 	 								parameters: pars, 
       			 	 	 								onComplete: function(originalRequest)
       			 	 	 														{
       			 	 	 															if(originalRequest.responseText)
       			 	 	 															{
       			 	 	 																alert(originalRequest.responseText);
       			 	 	 															}
       			 	 	 															else
       			 	 	 															{
       			 	 	 																window.location.reload(true);
       			 	 	 															}
       			 	 	 														}
       			 	 	 								});	
}
function logout()
{
	URL = '../xml/logout.php';
	pars = '';
	var myAjax = new Ajax.Request(URL,{
       			 	 								 	method:'get',
       			 	 	 								parameters: pars, 
       			 	 	 								onComplete: function(originalRequest)
       			 	 	 														{
       			 	 	 															window.location.reload(true);
       			 	 	 														}
       			 	 	 								});	
}
function poponload(URL)
{
	popwindow = window.open (URL, "","location=1,status=1,scrollbars=1,width=800,height=600");
	//popwindow.moveTo(0,0);
}
function popupDiv(divID,mainTable)
{ 	
 	/*
 	if(divID == 'divbirthday' || divID == 'divmonthly' || divID == 'divreward' || divID == 'divannual')
 	{
 		window.open('DvBpopup.php?type='+divID);
 	}
 	else
 	{
 	*/
 	viewportwidth = window.innerWidth;
 	viewportheight = window.innerHeight	
 	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight 
 	if (typeof window.innerWidth != 'undefined')
 	{
  	viewportwidth = window.innerWidth;
    viewportheight = window.innerHeight;
 	}
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0)
 	{
		viewportwidth = document.documentElement.clientWidth,
		viewportheight = document.documentElement.clientHeight
	}
 	// older versions of IE
 	else
 	{
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}	
	if(viewportheight > $(mainTable).getAttribute("height"))
	{
		//$(divID).setStyle({Height: viewportheight, width: viewportwidth });
		viewportwidth  = Math.ceil(Math.round(viewportwidth / 2) - Math.round($(mainTable).getAttribute("width") / 2));
		
		if(viewportheight > $(mainTable).getAttribute("height"))
			viewportheight = Math.ceil(Math.round(viewportheight / 2) - Math.round($(mainTable).getAttribute("height") / 2));
		//Math.round(viewportheight / 4);
		this.popup = $(mainTable);	
		$(mainTable).setStyle({top: viewportheight, left: viewportwidth });	
	}
	else
	{
		viewportwidth  = Math.ceil(Math.round(viewportwidth / 2) - Math.round($(mainTable).getAttribute("width") / 2));		
		this.popup = $(mainTable);		
		viewportheight = Math.ceil(Math.round(viewportheight / 2) - Math.round($(mainTable).getAttribute("height") / 2)) + 50;	//added by ryan on 2010-06-15
		$(mainTable).setStyle({top: viewportheight, left: viewportwidth });

	}
	$(divID).setStyle({top: document.body.scrollTop });	
	$(divID).appear({ duration: jsduration, from: jsfrom, to: jsto });
	$(mainTable).setStyle({top: document.body.scrollTop + viewportheight });
	$(mainTable).appear({ duration: jsduration, from: jsfrom, to: jsto });
	//}
}

function closepopupDiv(divID,mainTable)
{
	$(divID).fade({ duration: jsduration, from: jsto, to: jsfrom });
	//$(divID).hide();
	$(mainTable).fade({ duration: jsduration, from: jsto, to: jsfrom });
}
function callDisplay(id)
{
	URL="../xml/children_game.php";	
	pars = "id="+id;
	connectionAjax(URL,pars,'divDisplayPicTable');
	popupDiv('divDisplayPic','divDisplayPicTable');
}
function callDownload(id)
{
	window.open("../xml/children_checkDL.php?type=group&gameID="+id);
}
function changePic(id)
{
	//$('description').innerHTML = $('hdescription'+id).value;
	$('filetitle').innerHTML = $('hfiletitle'+id).value;
	$('lPic').src = $('sPic'+id).src;
}
function getFrom()
{
	/*
	var checklimit = 0;
	for(i=0;i < $("picLimit").value;i++)
  {
		if( $("selPic["+i+"]").checked )
		{
			checklimit++;
		} 
  }
  if(checklimit > 0)
  */
		window.open("../xml/children_checkDL.php?"+Form.serialize('childrenform'));
	/*
	else
		if($('page_version').innerHTML == "chi")
  		alert("請選擇圖片!!");
  	else if($('page_version').innerHTML == "eng")
  		alert("Please select picture.");
  */
}
function children_login()
{
	URL = '../xml/login.php';
	pars = "login_name="+$('login_name').value+"&login_pwd="+$('login_pwd').value;
	var myAjax = new Ajax.Request(URL,{
       			 	 								 	method:'get',
       			 	 	 								parameters: pars, 
       			 	 	 								onComplete: function(originalRequest)
       			 	 	 														{
       			 	 	 															if(originalRequest.responseText)
       			 	 	 															{
       			 	 	 																alert(originalRequest.responseText);
       			 	 	 															}
       			 	 	 															else
       			 	 	 															{
       			 	 	 																opener.location.reload();
       			 	 	 																//window.location.reload(true);
       			 	 	 																window.location.href = "../xml/children_checkDL.php?"+Form.serialize('children_form');
       			 	 	 																//window.open("../xml/children_checkDL.php?"+Form.serialize('children_form'));
       			 	 	 																//window.close();
       			 	 	 															}
       			 	 	 														}
       			 	 	 								});	
}
function checklimit(id)
{
	var checklimit = 0;
	for(i=0;i < $("picLimit").value;i++)
  {
		if( $("selPic["+i+"]").checked )
		{
			checklimit++;
		} 
  }
  if(checklimit > 5)
  {  	
  	$(id).checked = false;
  	if($('page_version').innerHTML == "chi")
  		alert("最多下載5張圖!!");
  	else if($('page_version').innerHTML == "eng")
  		alert("Max download: 5 picture.");
  }
}
function closeRule(id)
{
	$(id+'2').hide();
	$(id+'1').show();	
}
function openRule(id)
{
	$(id+'1').hide();
	$(id+'2').show();
}