<!-- html comment, stops browsers not supporting javascript not to print out code.
function cacheExternalDataFile(fileUrl, gEngineID, health, activeGashaponID)//is called from within flash
{
	//inform php gEngine instance of new active gashapon
	xmlHttpNotify = getAjaxObjectXML();
	if(xmlHttpNotify != null){
		xmlHttpNotify.open("GET","../assets/functions/gEngineCommunicate.php?method=setActiveGashapon&gashaponID="+activeGashaponID+"",true);
		xmlHttpNotify.send(null);
	}
	//load external swf
	var dragGashapon = document.getElementById("externalGashapon");	
	dragGashapon.style.visibility = "visible";
	dragGashapon.style.zIndex = 100;
	//remove old
	var gashaEmbed = document.getElementById("dragGashaponSwf");
	if(gashaEmbed != undefined){
		dragGashapon.removeChild(gashaEmbed);
	}
	
	//place loaded clip into a non-behaviour static mode
	var str ="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='<?php echo $protocal ?>://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='220'";
	str +="	height='220' id='dragGashaponSwf' align='middle'>	<param name='allowScriptAccess' value='sameDomain' />";
	str +="	<param name='allowFullScreen' value='false' />";
	str +="	<param name='wmode' value='transparent' />";
	str +=" <param name='menu' value='false' />";
	str +="	<param name='movie' value='"+fileUrl+"?behaviour=externalSetUp' />";
	str +="	<param name='quality' value='high' /><param name='bgcolor' value='#000000' />";		
	str +="	<embed src='"+fileUrl+"?behaviour=externalSetUp'"; 
	str +="	quality='high' ";
	str +="	bgcolor='#000000'"; 
	str +="	width='220' ";
	str +="	height='220' name='dragGashaponSwf' align='middle' allowScriptAccess='sameDomain' ";
	str +="	allowFullScreen='false' type='application/x-shockwave-flash' ";
	str +="	pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='transparent'/>";
	str +="</object>";	
	dragGashapon.style.position = "absolute";		
	dragGashapon.innerHTML = str;	
}
var xmlHttpZodiac;
var zodiacTimeoutID = null;
function getAjaxObjectXML()
{
	
	var objXMLHttp;
	try{  // Firefox, Opera 8.0+, Safari 1.2, mozilla 1.0, Netscape 7  
		objXMLHttp=new XMLHttpRequest(); 
	}
	catch (e){  // Internet Explorer 
		try	{   
			objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP");   
		}
		catch (e){   
			try	{     
				objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");  
			}
			catch (e){      
				alert("Your browser does not support AJAX!");//store items via cookies ?
				return null;    
			}   
		}  
	}
	return objXMLHttp;
}
function disableAllSelectTags(visible)
{
	//in IE, select input tags have an infinitly high z-index, so are above all
	var selectTags = document.getElementsByTagName("select");
	for(var i = 0; i < selectTags.length;i++)
	{
		selectTags[i].style.visibility = visible;
	}
}
function setGashaInfoText(id,textVal, set)
{
	if(set == 'true'){
		document.getElementById("gashaInfo").style.textAlign = 'justify';
	}else{
		document.getElementById("gashaInfo").style.textAlign = 'center';
	}
	document.getElementById("gashaInfo").removeChild(document.getElementById("gashaponInfo"));
	var txt = document.createTextNode(textVal);
	document.getElementById("gashaInfo").appendChild(txt);		
	document.getElementById("gashaInfo").style.color = "#FFFFFF";
}
function collectDisplayGashaponName(id,gashaponName, gashaponMessage)
{
	//when flash load, call php to get name, but if php fail, uses gashaponName, gashaponMessage as backup
	xmlHttpStats = getAjaxObjectXML();			
	if(xmlHttpStats != null){				
		xmlHttpStats.open("GET","../assets/functions/gEngineCommunicate.php?method=getGashaponCustomName&gashaponID="+id+"",true);
		xmlHttpStats.send(null);
		xmlHttpStats.onreadystatechange = xmlHttpResponseDisplayCustomName;
	}
}
function xmlHttpResponseDisplayCustomName()
{
	if (xmlHttpStats.readyState==4)	{
		var xmlDoc = xmlHttpStats.responseXML;		
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var success = xmlNodes[0].childNodes[0].nodeValue;
		var customName = xmlNodes[1].childNodes[0].nodeValue;
		var gashaponName = xmlNodes[2].childNodes[0].nodeValue;
		var gashaponMessage = xmlNodes[3].childNodes[0].nodeValue;	
		var gashaponID = xmlNodes[4].childNodes[0].nodeValue;	
		customName = customName.replace("\'","");
		if(success == "true"){
			displayGashaponName(gashaponName, gashaponMessage, customName,gashaponID);
		}
	}
}
var xmlHttpStats;
function showGashaponStats()
{
	xmlHttpStats = getAjaxObjectXML();			
	if(xmlHttpStats != null){				
		xmlHttpStats.open("GET","../assets/functions/gEngineCommunicate.php?method=getGashaponStats",true);
		xmlHttpStats.send(null);
		xmlHttpStats.onreadystatechange = xmlHttpResponseDisplayStats;
	}
}		
function collectGashaponStats(activeGashaponID)
{
	//called by flash which passes a active gashapon ID 
	xmlHttpStats = getAjaxObjectXML();			
	if(xmlHttpStats != null){
		if(activeGashaponID != undefined){
			xmlHttpStats.open("GET","../assets/functions/gEngineCommunicate.php?method=getGashaponStats&gashaponID="+activeGashaponID+"",true);
		}else{
			xmlHttpStats.open("GET","../assets/functions/gEngineCommunicate.php?method=getGashaponStats",true);
		}
		xmlHttpStats.send(null);
		xmlHttpStats.onreadystatechange = xmlHttpResponseDisplayStats;
	}
}
function xmlHttpResponseDisplayStats()
{
	if (xmlHttpStats.readyState==4)	{
		var xmlDoc = xmlHttpStats.responseXML;		
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var success = xmlNodes[0].childNodes[0].nodeValue;		
		if(success == "true"){
			var health = xmlNodes[1].childNodes[0].nodeValue;
			var totalHealth = xmlNodes[2].childNodes[0].nodeValue;
			var level = xmlNodes[3].childNodes[0].nodeValue;
			var experience = xmlNodes[4].childNodes[0].nodeValue;
			var nextLevelUp = xmlNodes[5].childNodes[0].nodeValue;
			var powerRecharge = xmlNodes[6].childNodes[0].nodeValue;
			var specialRecharge = xmlNodes[7].childNodes[0].nodeValue;
			var condition = xmlNodes[8].childNodes[0].nodeValue;
			var powerName = xmlNodes[9].childNodes[0].nodeValue;
			var specialPowerName = xmlNodes[10].childNodes[0].nodeValue;
			var attack = xmlNodes[11].childNodes[0].nodeValue;
			var defence = xmlNodes[12].childNodes[0].nodeValue;
			var customName = xmlNodes[13].childNodes[0].nodeValue;		
			var activeGashaponID = xmlNodes[14].childNodes[0].nodeValue;					
			var gashaponItemList = xmlNodes[15].childNodes[0].nodeValue;
			var attackSkill = xmlNodes[16].childNodes[0].nodeValue;					
			var defenceSkill = xmlNodes[17].childNodes[0].nodeValue;
			displayGashaponStats(health,totalHealth,level,experience,nextLevelUp,powerRecharge,specialRecharge,condition,powerName,specialPowerName,attack,defence,customName,activeGashaponID,gashaponItemList,attackSkill,defenceSkill);
		}
	}
}
function displayGashaponStats(health,totalHealth,level,experiance,nextLevelUp,powerRecharge,specialRecharge,condition,powerName,specialPowerName,attack,defence,customName,gashaponID,itemList,attackSkill,defenceSkill)
{
	var gashaponCont = document.getElementById("gEngineHolder");
	var titleDiv = document.getElementById("gashaponTitle");
	var titleContentDiv = document.getElementById("titleContentDiv");
	var statsDiv = document.getElementById("gashaponStats");
	if(statsDiv != undefined){				
		titleContentDiv.removeChild(statsDiv);
	}
	statsDiv = document.createElement("div");
	statsDiv.setAttribute("id","gashaponStats");
	//var statsTitle =  document.createElement("h3");
	//statsTitle.setAttribute("id","gashaponStatsTitle");
	//var tempText = document.createTextNode("GASHAPON STATS");			
	//statsTitle.appendChild(tempText);
	//statsDiv.appendChild(statsTitle);
	var infoDataDiv = document.createElement("div");
	infoDataDiv.setAttribute("id","statsContentDiv");
	var customNameHolder = document.createElement("div");
	var customNameTxtGrey = document.createElement("h4"); 
	var customNameTxt = document.createTextNode("Change Name: ");
	customNameTxtGrey.appendChild(customNameTxt);
	customNameHolder.appendChild(customNameTxtGrey);
	var customNameField = document.createElement("span");
	customNameHolder.appendChild(customNameField);
	var nameValue = (customName != "none") ? customName : "Enter name";
	var hovOver = "\'button_CustomName button_CustomName_Hover\'";
	var hovOut = "\'button_CustomName\'";
	var activeGashaponID = "\'"+gashaponID+"\'";
	nameValue = nameValue.replace("\'","");
	customName = customName.replace("\'","");
	var oldName = "\'"+customName+"\'";
	var html = '<input maxlength="18" type="text" onkeypress="enterGashaponUserName(this,event,'+activeGashaponID+','+oldName+')" class="text" id="gashaponCustomName" value="'+nameValue+'">';
	html += '<input type="button" style="margin:2px" name="attackNinja" id="attackNinjaBtn" onclick="buttonGashaponUserName('+activeGashaponID+', '+oldName+');" class="button_CustomName" value="" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
	html += '</form>';
	html += '</div>';
	customNameField.innerHTML = html;
	var healthHolder = document.createElement("div");
	var healthTxtGrey = document.createElement("h4"); 
	var healthTxt = document.createTextNode("Health (hp): ");
	healthTxtGrey.appendChild(healthTxt);
	var healthTxtVal = document.createTextNode(""+health+" / "+totalHealth);
	healthHolder.appendChild(healthTxtGrey);
	healthHolder.appendChild(healthTxtVal);
	var nextLevelTxt = "";
	if(nextLevelUp > 0)	{
		nextLevelTxt = "(Next Lvl "+(Number(level)+1)+": "+nextLevelUp+" xp)";
	}
	var levelHolder = document.createElement("div");
	var levelTxtGrey = document.createElement("h4"); 
	var levelTxt = document.createTextNode("Level: ");	
	levelTxtGrey.appendChild(levelTxt);
	var levelTxtVal = document.createTextNode(level+" "+nextLevelTxt);			
	levelHolder.appendChild(levelTxtGrey);
	levelHolder.appendChild(levelTxtVal);
	var expHolder = document.createElement("div");
	var expTxtGrey = document.createElement("h4"); 
	var expTxt = document.createTextNode("Experience (xp): ");	
	expTxtGrey.appendChild(expTxt);
	var expTxtVal = document.createTextNode(""+experiance);			
	expHolder.appendChild(expTxtGrey);
	expHolder.appendChild(expTxtVal);
	var attackHolder = document.createElement("div");
	var attackTxtGrey = document.createElement("h4"); 
	var attackTxt = document.createTextNode("Attack: ");
	attackTxtGrey.appendChild(attackTxt);
	var attackTxtVal = document.createTextNode(""+attack+attackSkill);
	attackHolder.appendChild(attackTxtGrey);
	attackHolder.appendChild(attackTxtVal);
	var defenceHolder = document.createElement("div");
	var defenceTxtGrey = document.createElement("h4"); 
	var defenceTxt = document.createTextNode("Defence: ");
	defenceTxtGrey.appendChild(defenceTxt);
	var defenceTxtVal = document.createTextNode(""+defence+defenceSkill);
	defenceHolder.appendChild(defenceTxtGrey);
	defenceHolder.appendChild(defenceTxtVal);
	var condHolder = document.createElement("div");
	var condTxtGrey = document.createElement("h4"); 
	var condTxt = document.createTextNode("Condition: ");	
	condTxtGrey.appendChild(condTxt);
	var condTxtVal = document.createTextNode(condition);			
	condHolder.appendChild(condTxtGrey);
	condHolder.appendChild(condTxtVal);
	var powerHolder = document.createElement("div");
	var powerTxtGrey = document.createElement("h4"); 
	var powerTxt = document.createTextNode(powerName+" power: ");	
	powerTxtGrey.appendChild(powerTxt);
	var powerValDiv = document.createElement("div");
	powerValDiv.className = "statValue";
	var powerTxtVal = document.createTextNode(powerRecharge);		
	powerHolder.appendChild(powerTxtGrey);
	powerValDiv.appendChild(powerTxtVal);
	powerHolder.appendChild(powerValDiv);
	var specialPowerHolder = document.createElement("div");
	var specialPowerTxtGrey = document.createElement("h4"); 		
	var specialPowerTxt = document.createTextNode(specialPowerName+" power: ");			
	specialPowerTxtGrey.appendChild(specialPowerTxt);
	var specialPowerDivVal = document.createElement("div");
	specialPowerDivVal.className = "statValue";
	var specialPowerTxtVal = document.createTextNode(""+specialRecharge);
	specialPowerHolder.appendChild(specialPowerTxtGrey);
	specialPowerDivVal.appendChild(specialPowerTxtVal);
	specialPowerHolder.appendChild(specialPowerDivVal);
	var itemListHolder = undefined;
	if(itemList == "none"){
		itemListHolder = document.createElement("div");
		var itemListTxtGrey = document.createElement("h4"); 
		var itemListTxt = document.createTextNode("Items: ");	
		itemListTxtGrey.appendChild(itemListTxt);
		var itemListTxtVal = document.createTextNode("none");			
		itemListHolder.appendChild(itemListTxtGrey);
		itemListHolder.appendChild(itemListTxtVal);
	}else{
		var dataArray = new Array();
		var firstStage = itemList.split("[@@]");
		for(var i = 0; i < firstStage.length; i++){
			var secondStage = firstStage[i].split("[@]");//split id and name
			if(secondStage.length > 1){
				var id = secondStage[0].split("=");
				var name = secondStage[1].split("=");
				var buttons = secondStage[2].split("=");
				var amount = secondStage[3].split("=");
				var info = secondStage[4].split("=");
				dataArray.push(new Array(id[1],name[1],buttons[1],amount[1],amount[0],info[1]));
			}
		}
		itemListHolder = document.createElement("div");
		itemListHolder.className ="gashaponItemsLists";
		var itemListTxtGrey = document.createElement("h3"); 
		var itemListTxt = document.createTextNode("GASHAPON ITEMS");	
		itemListTxtGrey.appendChild(itemListTxt);
		itemListHolder.appendChild(itemListTxtGrey);
		var itemListDropDown = document.createElement("div");
		itemListHolder.appendChild(itemListDropDown);
		var html = "<div class=\"gashaponItems\">";
		html += '<span>Use the below drop down list to manage your gashapons items.</span>';
		html += '<form method="post" style="margin:0px;padding:0px;" name="emailform" target="_self" id="resurrectForm">';	
		html += '<select name="list" id="gashaponItemList" style="margin:4px;width:140px" onchange="showSelectedItem(this.options[this.selectedIndex].value)">'
		html += '<option value="default">Select Item</option>';
		for(var g = 0; g < dataArray.length; g++){
			var storeValue = ""+dataArray[g][0]+"@@"+dataArray[g][2]+"@@"+dataArray[g][4]+"@@"+dataArray[g][3]+"@@"+dataArray[g][5];//id, buttonInterface, amountName, amount, description
			html += '<option value="'+storeValue+'">'+dataArray[g][1]+'</option>'
		}
		html += '</select>';
		html += '</form>';
		html += '</div>';
		itemListDropDown.innerHTML = html;
		var selectedItem = document.createElement("div");
		selectedItem.setAttribute("id","selectedItemStats");
		itemListHolder.appendChild(selectedItem);
	}	
	
	infoDataDiv.appendChild(levelHolder);
	infoDataDiv.appendChild(expHolder);
	infoDataDiv.appendChild(healthHolder);
	if(attack > 0){
		infoDataDiv.appendChild(attackHolder);
	}
	infoDataDiv.appendChild(defenceHolder);
	if(condition != "stable"){
		infoDataDiv.appendChild(condHolder);
	}
	var rechargeTitle =  document.createElement("h5");
	infoDataDiv.appendChild(powerHolder);
	if(specialPowerName != "none"){
		infoDataDiv.appendChild(specialPowerHolder);
	}
		infoDataDiv.appendChild(customNameHolder);
	if(itemListHolder != undefined){
		infoDataDiv.appendChild(itemListHolder);
	}
	statsDiv.appendChild(infoDataDiv);
	titleContentDiv.appendChild(statsDiv);
}
function showSelectedItem(selectedItem)
{
	var selectedItemDiv = document.getElementById("selectedItemStats");
	var selectedItemInfo = document.getElementById("selectedItemInfo");
	if(selectedItemInfo != undefined){
		selectedItemDiv.removeChild(selectedItemInfo);
	}
	if(selectedItem != "default"){
		selectedItemInfo = document.createElement("div");
		selectedItemInfo.setAttribute("id","selectedItemInfo");
		selectedItemInfo.className = "selectedItemInfo";
		var info = selectedItem.split("@@");
		var subHtml = "<div style=\"text-align:center\">"+info[4]+"</div>";
		if(info[2] != undefined){
		subHtml += "<h4>"+info[2]+": </h4>"+info[3];			
		}
		var hovOver = "\'button_ThinLong button_ThinLong_Hover\'";
		var hovOut = "\'button_ThinLong\'";
		var itemID = "\'"+info[0]+"\'";
		if(info[1].indexOf("use") >= 0)	{
			subHtml += '<input type="button" style="margin:2px;font-size:10px" name="useItem" id="useItemBtn" onclick="useSelectedItem('+itemID+')" class="button_ThinLong" value="Use Item" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
		}
		if(info[1].indexOf("transfer") >= 0){
			subHtml += '<input type="button" style="margin:2px;font-size:10px" name="transferItem" id="transferItemBtn" onclick="transferSelected('+itemID+')" class="button_ThinLong" value="Transfer Item" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
		}
		selectedItemDiv.appendChild(selectedItemInfo);
		selectedItemInfo.innerHTML = subHtml;
		var itemErrorDiv = document.createElement("div");
		itemErrorDiv.setAttribute("id","itemErrorDiv");
		selectedItemInfo.appendChild(itemErrorDiv);
	}
}
function useSelectedItem(itemID)
{
	var transferItemBtn = document.getElementById("transferItemBtn");
	if(transferItemBtn != undefined){
		transferItemBtn.style.visibility = "visible";
	}
	xmlHttpStats = getAjaxObjectXML();			
	if(xmlHttpStats != null){
		xmlHttpStats.open("GET","../assets/functions/gEngineCommunicate.php?method=useGashaponItem&itemID="+itemID+"",true);				
		xmlHttpStats.send(null);
		xmlHttpStats.onreadystatechange = xmlHttpResponseUsedItem;
	}
}
function xmlHttpResponseUsedItem()
{
	if (xmlHttpStats.readyState==4){				
		var xmlDoc = xmlHttpStats.responseXML;		
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var success = xmlNodes[0].childNodes[0].nodeValue;
		if(success == "true"){
			showGashaponStats();
		}else{
			var errorResponse = document.getElementById("itemErrorDiv");
			errorResponse.innerHTML = "<span>Unable to use item. If a potion, gashapons stat(such as health) value may already be maxed out.</span>";
		}
	}			
}
function transferSelected(itemID)
{
	xmlHttpStats = getAjaxObjectXML();			
	if(xmlHttpStats != null){
		xmlHttpStats.open("GET","../assets/functions/gEngineCommunicate.php?method=transferGashaponItem&itemID="+itemID+"",true);				
		xmlHttpStats.send(null);
		xmlHttpStats.onreadystatechange = xmlHttpResponseTransferItem;
	}
}
function xmlHttpResponseTransferItem()
{
	if (xmlHttpStats.readyState==4){		
		var xmlDoc = xmlHttpStats.responseXML;		
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var success = xmlNodes[0].childNodes[0].nodeValue;
		var dataString = xmlNodes[1].childNodes[0].nodeValue;
		var selectedItem = xmlNodes[2].childNodes[0].nodeValue;
		if(success == "true"){
			var transferItemBtn = document.getElementById("transferItemBtn");
			transferItemBtn.style.visibility = "hidden";
			var dataArray = new Array();
			var firstStage = dataString.split("||");
			for(var i = 0; i < firstStage.length; i++){
				var secondStage = firstStage[i].split("@@");
				if(secondStage.length > 1){
					var id = secondStage[0].split("=");
					var name = secondStage[1].split("=");
					var level = secondStage[2].split("=");
					dataArray.push(new Array(id[1],name[1],level[1]));
				}
			}			
			var errorResponse = document.getElementById("itemErrorDiv");
			var html = 'Select one of your gashapons from the drop down list to transfer this item to.';
			html += '<div id="resurrectError" class="menuErrorText"></div>';
			html += '<form method="post" style="margin:0px;padding:0px;text-align:center" name="emailform" target="_self" id="resurrectForm">';	
			html += '<select name="list" id="gashaponResurrectList" style="width:140px">'
			html += '<option value="default">Select Gashapon</option>';
			for(var g = 0; g < dataArray.length; g++){
				html += '<option value="'+dataArray[g][0]+'">'+dataArray[g][1]+' (Lv: '+dataArray[g][2]+')</option>'
			}
			html += '</select>';
			var hovOver = "\'button_ThinLong button_ThinLong_Hover\'";
			var hovOut = "\'button_ThinLong\'";
			var selectedItemVal = "\'"+selectedItem+"\'";
			html += '<input type="button" style="margin:10px;font-size:10px" name="resurrect" id="resurrectBtn" onclick="transferSelectedItemGashapon('+selectedItemVal+')" class="button_ThinLong" value="TRANSFER ITEM" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
			html += '<input type="button" style="margin:0 10px 10px 10px;font-size:10px" name="cancelresurrect" id="cancelresurrectBtn" onclick="cancelGashaponItemTransfer()" class="button_ThinLong" value="CANCEL" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
			html += '</form>';
			html += '</div>';
			errorResponse.innerHTML = html;
		}else{
			var errorResponse = document.getElementById("itemErrorDiv");
			errorResponse.innerHTML = "<span>Failed to build gashapon list.</span>";
		}
	}
}
function transferSelectedItemGashapon(selectedItem)
{
	var transferList = document.getElementById("gashaponResurrectList");
	var selected = transferList.options[transferList.selectedIndex].value;
	xmlHttpStats = getAjaxObjectXML();			
	if(xmlHttpStats != null){
		xmlHttpStats.open("GET","../assets/functions/gEngineCommunicate.php?method=transferItemToGashapon&itemID="+selectedItem+"&gashaponID="+selected,true);				
		xmlHttpStats.send(null);
		xmlHttpStats.onreadystatechange = xmlHttpResponseTransferItemToGashapon;
	}
}
function xmlHttpResponseTransferItemToGashapon()
{
	if (xmlHttpStats.readyState==4){
		var xmlDoc = xmlHttpStats.responseXML;		
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var success = xmlNodes[0].childNodes[0].nodeValue;
		if(success == "true"){
			showGashaponStats();
		}else{
			var errorResponse = document.getElementById("itemErrorDiv");
			errorResponse.innerHTML = "<span>Failed to transfer selected item.</span>";
		}
	}
}
function cancelGashaponItemTransfer()
{
	var errorResponse = document.getElementById("itemErrorDiv");
	errorResponse.innerHTML = "";
	var transferItemBtn = document.getElementById("transferItemBtn");
	transferItemBtn.style.visibility = "visible";
}
function validateNameNumeric()
{
   // Get ASCII value of key that user pressed
   var key = window.event.keyCode;
 // Was key that was pressed a numeric character (0-9)?
   if ( key > 47 && key < 58 )
	  return; // if so, do nothing
   else
	  window.event.returnValue = null; // otherwise, 
								   // discard character
}
function enterGashaponUserName(textField, e, activeGashaponID, oldName)
{
	//only allow alphanumeric characters
	var characterCode;
	if(e && e.which){
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}else{
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	var pattern = /[0-9|a-z|A-Z]/;
	var char = String.fromCharCode(characterCode);
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		updateGashaponUserName(textField, activeGashaponID, oldName);
	}else if(characterCode != 8){
		if (pattern.test(char)){
		}else{
			if(navigator.userAgent.indexOf("MSIE")!=-1){
				e.returnValue = null;
			}else{
				e.preventDefault();//firefox
			}
		}
	}
}
function buttonGashaponUserName(activeGashaponID, oldName)
{
	var textField = document.getElementById("gashaponCustomName");
	updateGashaponUserName(textField, activeGashaponID, oldName)
}
function updateGashaponUserName(textField, activeGashaponID, oldName)
{
	var checkName = textField.value;
	if(checkName.length > 0 && checkName != "Enter name" && checkName != "updating..." && checkName != oldName){
		xmlHttpStats = getAjaxObjectXML();			
		if(xmlHttpStats != null){
			var gashaponCustomName = document.getElementById("gashaponCustomName");
			gashaponCustomName.value = "updating...";
			xmlHttpStats.open("GET","../assets/functions/gEngineCommunicate.php?method=updateGashaponName&gashaponID="+activeGashaponID+"&name="+checkName+"",true);				
			xmlHttpStats.send(null);
			xmlHttpStats.onreadystatechange = xmlHttpResponseUpdateName;
		}
	}
}	
function xmlHttpResponseUpdateName()
{
	if (xmlHttpStats.readyState==4){
		var xmlDoc = xmlHttpStats.responseXML;		
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var success = xmlNodes[0].childNodes[0].nodeValue;
		var newName = xmlNodes[1].childNodes[0].nodeValue;
		var humanName = xmlNodes[2].childNodes[0].nodeValue;
		var description = xmlNodes[2].childNodes[0].nodeValue;
		var gashaponCustomName = document.getElementById("gashaponCustomName");
		newName = newName.replace("/'","");
		gashaponCustomName.value = newName;
		if(success == "true"){					
			var titleDiv = document.getElementById("gashaponTitle");
			var className = document.getElementById("gashaponClassName");
			var changeName = document.getElementById("gashaponCustomUserName");
			if(changeName != null){
				changeName.firstChild.data = newName;
			}else{
				var titleNameField = document.createElement("h3");
				titleNameField.setAttribute("id","gashaponCustomUserName");
				var tempNameText = document.createTextNode(newName);
				titleNameField.appendChild(tempNameText);
				titleDiv.insertBefore(titleNameField,className);
			}				
		}else{
			alert("Failed to update gashapon name. Please re-enter and try again.");
		}
	}
}
function displayGashaponTeaserInfo()
{
	var gashaponCont = document.getElementById("gEngineHolder");
	var titleDiv = document.getElementById("gashaponTitle");
	var titleContentDiv = document.getElementById("titleContentDiv");
	var statsDiv = document.getElementById("gashaponStats");
	if(statsDiv != undefined){				
		titleContentDiv.removeChild(statsDiv);
	}	
	statsDiv = document.createElement("div");
	statsDiv.setAttribute("id","gashaponStats");
	var statsTitle =  document.createElement("h3");
	statsTitle.setAttribute("id","gashaponStatsTitle");
	var tempText = document.createTextNode("TEASER INFO");			
	statsTitle.appendChild(tempText);
	statsDiv.appendChild(statsTitle);	
	var teaserHolder = document.createElement("div");
	var teaserTxt = document.createTextNode("This gashapon is a sample teaser only. Register and login into a user account to gain access to more features like special powers, experience and levels and the chance to build your own unique gashapon collections.");	
	teaserHolder.appendChild(teaserTxt);
	teaserHolder.style.textAlign = "justify";
	statsDiv.appendChild(teaserHolder);
	titleContentDiv.appendChild(statsDiv);
}
var gEngineBrowserInfo = new Array();
function javaMousePos(swfID)//called from flash starting a call back
{		
	var findPos;
	findPos = function(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
			return {x:curleft,y:curtop};
		 }
		 return {x:obj.offsetLeft,y:obj.offsetTop};
	}
	if (document.addEventListener != null) { 
		// e.g. Firefox, Opera, Safari
		document.addEventListener("mousemove", MouseMoveFunction, true);
	} else { 
		 // e.g. Internet Explorer (also would work on Opera)
		document.attachEvent("onmousemove", MouseMoveFunction);
	}
	var SWFOffset = undefined;
	function MouseMoveFunction()
	{				
		var swfObj = undefined;
		switch(true)//find swf across multi browser test
		{
			case (document[swfID].ReportMouseLoc != undefined):
				swfObj = document[swfID];
			break;
			case (document[swfID][0].ReportMouseLoc != undefined):
				swfObj = document[swfID][0];
			break;
			case (document[swfID][1].ReportMouseLoc != undefined):
				swfObj = document[swfID][1];
			break;
		}			
		if(SWFOffset == undefined){				
			SWFOffset = getPageElementPosition("gashaponSwf");
		}
		var e = arguments[0] || event;
		if(navigator.userAgent.indexOf("MSIE")!=-1)	{
			var scrollTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
			var scrollLeft = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
			var posX = event.clientX + scrollLeft;
			var posY = event.clientY + scrollTop;
			gEngineBrowserInfo["x"] = posX;
			gEngineBrowserInfo["y"] = posY;
			swfObj.ReportMouseLoc({x:posX,y:posY,swfX:SWFOffset.left ,swfY:SWFOffset.top} );
		}else{
			gEngineBrowserInfo["x"] = e.pageX;
			gEngineBrowserInfo["y"] = e.pageY;
			swfObj.ReportMouseLoc({x:e.pageX,y:e.pageY,swfX:SWFOffset.left ,swfY:SWFOffset.top} );
		}
	}
}
//START DAILY ZODIAC------------------------------------------------------------------
function referAFriend(targetEmailID, userID)//
{
	var referEmail = document.getElementById(targetEmailID).value;
	httpReferralObject = getAjaxObjectXML();
	if(httpReferralObject != null){
		httpReferralObject.onreadystatechange=xmlHttpResponse_referFriend;
		httpReferralObject.open("GET","../assets/functions/gEngineCommunicate.php?method=referFriend&email="+referEmail+"&userID="+userID+"",true);
		httpReferralObject.send(null);
	}
}
function xmlHttpResponse_referFriend()
{
	if (httpReferralObject.readyState==4){
		var xmlDoc = httpReferralObject.responseXML;
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var error = xmlNodes[0].childNodes[0].nodeValue;
		var message = xmlNodes[1].childNodes[0].nodeValue;
		var messageDiv = document.getElementById("referFriendError");			
		var textSpan = document.getElementById("referErrorMessage");
		if(textSpan != null){
			messageDiv.removeChild(textSpan);
		}
		textSpan = document.createElement("span");
		textSpan.setAttribute("id","referErrorMessage");		
		var textNode = document.createTextNode(message);
		textSpan.appendChild(textNode);
		messageDiv.appendChild(textSpan);
		if(error == "true")	{
			messageDiv.style.color = "#990000";	
		}else{
			messageDiv.style.color = "#FFFFFF";	
		}
	}
}
var zodiacTimeoutID = null;
function displayDailyQuote(gashaponID)
{
	var gashaponCont = document.getElementById("gEngineHolder");
	var gashaponInfo = document.getElementById("gashaNote");
	var zodiacDiv = document.getElementById("zodiacFeed");
	if(zodiacDiv != undefined){				
		gashaponCont.removeChild(zodiacDiv);
	}			
	zodiacDiv = document.createElement("div");
	zodiacDiv.setAttribute("id","zodiacFeed");
	var tempText = document.createTextNode("Loading daily quote...");
	zodiacDiv.appendChild(tempText);
	zodiacDiv.className = "gashaponQouteMessageLoad";			
	gashaponCont.insertBefore(zodiacDiv, gashaponInfo);
	xmlHttpZodiac = getAjaxObjectXML();
	if(xmlHttpZodiac != null){
		zodiacTimeoutID = setTimeout(zodiacError,20000);
		xmlHttpZodiac.onreadystatechange=xmlHttpResponseDisplayQuote;
		xmlHttpZodiac.open("GET","../assets/functions/gEngineCommunicate.php?method=performBasicXmlPower&gashaponID="+gashaponID+"",true);
		xmlHttpZodiac.send(null);
	}else{
		zodiacError("Daily quote feature is currently offline.");
	}
}
function displayZodiacPower(zodiac, gashaponID, updateExpVal)
{
	var gashaponCont = document.getElementById("gEngineHolder");
	var gashaponInfo = document.getElementById("gashaNote");
	var zodiacDiv = document.getElementById("zodiacFeed");
	if(zodiacDiv != undefined){				
		gashaponCont.removeChild(zodiacDiv);
	}			
	zodiacDiv = document.createElement("div");
	zodiacDiv.setAttribute("id","zodiacFeed");
	var tempText = document.createTextNode("Loading daily zodiac...");
	zodiacDiv.appendChild(tempText);
	zodiacDiv.className = "gashaponQouteMessageLoad";		
	gashaponCont.insertBefore(zodiacDiv, gashaponInfo);
	xmlHttpZodiac = getAjaxObjectXML();
	if(xmlHttpZodiac != null){
		zodiacTimeoutID = setTimeout(zodiacError,20000);
		xmlHttpZodiac.onreadystatechange=xmlHttpResponseDisplayZodiac;
		xmlHttpZodiac.open("GET","../assets/functions/gEngineCommunicate.php?method=getZodiac&gashaponID="+gashaponID+"&zodiacName="+zodiac+"&updateExpVal="+updateExpVal+"",true);
		xmlHttpZodiac.send(null);
	}else{
		zodiacError();
	}
}
function zodiacError(message)
{
	if(zodiacTimeoutID != null){
		clearTimeout(zodiacTimeoutID);
		zodiacTimeoutID = null;
	}
	var zodiacFeed = document.getElementById("zodiacFeed");
	if(zodiacFeed != undefined){
		zodiacFeed.firstChild.nodeValue = (message == undefined) ? "Daily zodiac feature is currently offline." : message;
		zodiacFeed.style.color = "#FF0000";
	}
}		
function xmlHttpResponseDisplayQuote()
{
	if (xmlHttpZodiac.readyState==4){
		if(zodiacTimeoutID != null){
			clearTimeout(zodiacTimeoutID);
			zodiacTimeoutID = null;
		}
		var xmlDoc = xmlHttpZodiac.responseXML;	
		var zodiacFeed = document.getElementById("zodiacFeed");
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var success = xmlNodes[0].childNodes[0].nodeValue;	
		if(success == "false"){
			zodiacError("Daily quote feature is currently offline.");
		}else{
			if(zodiacFeed != undefined){
				var titleVal = xmlNodes[1].childNodes[0].nodeValue;
				if(xmlNodes[3].childNodes[0].nodeValue == "false"){
					var array = eval(xmlNodes[2].childNodes[0].nodeValue);
					var quoteVal = array[6];
					var authorVal = array[0];
				}else{
					var quoteVal = xmlNodes[2].childNodes[0].nodeValue;
					var authorVal = xmlNodes[4].childNodes[0].nodeValue;
				}
				if(quoteVal != undefined){
					zodiacFeed.firstChild.nodeValue = titleVal;//title
					zodiacFeed.className = "gashaponQouteMessageTitle";
					var zodiacFeedDiv = document.createElement("div");
					var textNode = document.createTextNode("\""+quoteVal+"\"");//quote
					zodiacFeedDiv.className ="gashaponQouteMessageQuote";
					zodiacFeedDiv.appendChild(textNode);
					zodiacFeed.appendChild(zodiacFeedDiv);
					var zodiacDateDiv = document.createElement("div");
					var textNode = document.createTextNode(authorVal);//person quote owner
					zodiacDateDiv.className = "gashaponQouteMessageDate";
					zodiacDateDiv.appendChild(textNode);
					zodiacFeed.appendChild(zodiacDateDiv);						
				}else{
					zodiacError("Daily quote feature is currently offline.");
				}
			}else{
				zodiacError("Daily quote feature is currently offline.");
			}
		}
	}
}
function xmlHttpResponseDisplayZodiac()
{
	if (xmlHttpZodiac.readyState==4){
		if(zodiacTimeoutID != null)	{
			clearTimeout(zodiacTimeoutID);
			zodiacTimeoutID = null;
		}
		var xmlDoc = xmlHttpZodiac.responseXML;				
		var zodiacFeed = document.getElementById("zodiacFeed");
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var success = xmlNodes[0].childNodes[0].nodeValue;				
		if(success == "false"){
			zodiacError();
		}else{
			if(zodiacFeed != undefined){
				zodiacFeed.firstChild.nodeValue = xmlNodes[1].childNodes[0].nodeValue;//title
				zodiacFeed.className = "gashaponQouteMessageTitle";
				var zodiacDateDiv = document.createElement("div");
				var textNode = document.createTextNode(xmlNodes[2].childNodes[0].nodeValue);//date
				zodiacDateDiv.className = "gashaponQouteMessageDate";
				zodiacDateDiv.appendChild(textNode);
				zodiacFeed.appendChild(zodiacDateDiv);
				var zodiacFeedDiv = document.createElement("div");
				var textNode = document.createTextNode(xmlNodes[3].childNodes[0].nodeValue);//feed
				zodiacFeedDiv.className ="gashaponQouteMessageQuote";
				zodiacFeedDiv.appendChild(textNode);
				zodiacFeed.appendChild(zodiacFeedDiv);
				var teaserText = xmlNodes[4].childNodes[0].nodeValue;
				if(teaserText != "false"){
					var teaserDiv = document.createElement("div");
					var teaserTextNode = document.createTextNode(teaserText);
					teaserDiv.appendChild(teaserTextNode);
					zodiacFeed.appendChild(teaserDiv);
				}
			}
		}
	}
}
var currentGashaponName = "";
var currentGashaponMessage = "";
var currentGashaponCustomName = "";
function buildPowerEmailPanel(attackerID, gashaponName, gashaponMessage, gashaponCustomName, multiAttack)
{
	currentGashaponName = gashaponName;
	currentGashaponMessage = gashaponMessage;
	currentGashaponCustomName = gashaponCustomName;
	var gashaponCont = document.getElementById("gEngineHolder");
	var gashaponInfo = document.getElementById("gashaNote");
	var sidePanel = document.getElementById("sidePanel");
	var gashaponTitle = document.getElementById("gashaponTitle");
	var titleDiv = document.createElement("div");
	titleDiv.setAttribute("id","resurrectTitle");
	var titleText = document.createElement("h4"); 
	var tempText = document.createTextNode("ATTACK GASHAPON");
	titleText.appendChild(tempText);	
	titleDiv.appendChild(titleText);	
	titleDiv.style.color = "FFFFFF";
	var moreTasks = document.createElement("div");
	moreTasks.setAttribute("id","resurrectPowerInfo");
	moreTasks.style.textAlign = "justify";		
	moreTasks.style.fontSize = "10px";
	moreTasks.style.color = "999999";		
	titleDiv.appendChild(moreTasks);
	var titleContentDiv = document.getElementById("titleContentDiv");
	gashaponTitle.removeChild(titleContentDiv);
	gashaponTitle.appendChild(titleDiv);
	var powerMessage = 'Please specify a valid users email address or nickname inorder to attack one of their gashapons.';
	if(multiAttack != undefined){
		powerMessage = 'Please specify a valid users email address or nickname inorder to attack their gashapons.';
	}
	var html = powerMessage;
	html += '<div class="menuErrorText" id="attackGashError"></div>';
	html += '<div class="dynamicForm" style="height:auto;text-align:center;margin:0px;padding:0px;">';
	var hovOver = "\'button_ThinLong button_ThinLong_Hover\'";
	var hovOut = "\'button_ThinLong\'";
	var attackingID = "\'"+attackerID+"\'";
	html += '<input name="email" type="text" class="text" id="attackFriendEmail" size="18" onkeyup="validateEmailAddress(this)" value="Enter email or nickname">';
	html += '<input type="button" style="margin:10px;font-size:10px" name="attackNinja" id="attackNinjaBtn" onclick="attackUserGashapon('+attackingID+')" class="button_ThinLong" value="ATTACK" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
	html += '<input type="button" style="margin-bottom:10px;font-size:10px" name="cancelresurrect" id="cancelresurrectBtn" onclick="cancelExternalPowerList()" class="button_ThinLong" value="CANCEL" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
	html += '</div>';
	moreTasks.innerHTML = html;
}
function validateEmailAddress(email)
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(filter.test(email.value)){
		return true;
	}else{
		return false;
	}
}
function attackUserGashapon(attackerID)
{
	var attackEmailElement = document.getElementById("attackFriendEmail");
	var attackEmail = attackEmailElement.value;
	var validateUserEntry = false;
	var errorMessage = "Please enter a valid email address or nickname.";
	if(attackEmail.indexOf("@") != -1){
		if(validateEmailAddress(attackEmailElement)){	
			validateUserEntry = true;
		}
	}else{//nickname validates in php
		if(attackEmail.length > 0 && attackEmail != "Enter email or nickname"){
			validateUserEntry = true;
		}
	}	
	if(!validateUserEntry){
		var attackDiv = document.getElementById("attackGashError");
		var oldAttackSpan = document.getElementById("attackSpanError");
		if(oldAttackSpan != undefined){
			attackDiv.removeChild(oldAttackSpan);
		}
		var attackSpan = document.createElement("span");
		attackSpan.setAttribute("id","attackSpanError");
		var textNode = document.createTextNode(errorMessage);
		attackSpan.appendChild(textNode);
		attackSpan.style.color = "#990000";
		attackDiv.appendChild(attackSpan);
	}else{
		httpReferralObject = getAjaxObjectXML();
		if(httpReferralObject != null){
			httpReferralObject.onreadystatechange=xmlHttpResponse_attackedGashapons;
			httpReferralObject.open("GET","../assets/functions/gEngineCommunicate.php?method=attackUserGashapons&attackeeUserEmail="+attackEmail+"&gashaponID="+attackerID+"",true);
			httpReferralObject.send(null);
		}
	}
}
function xmlHttpResponse_attackedGashapons()
{
	if (httpReferralObject.readyState==4){
		
		var xmlDoc = httpReferralObject.responseXML;		
		//alert("-ATTACK: "+httpReferralObject.responseText+"_"+xmlDoc);
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;		
		var success = xmlNodes[0].childNodes[0].nodeValue;
		var message = xmlNodes[1].childNodes[0].nodeValue;		
		
		if(success == "true"){
			var rechargeTime = xmlNodes[2].childNodes[0].nodeValue;
			var attackMesageText = xmlNodes[3].childNodes[0].nodeValue;
			var attackCondition = xmlNodes[4].childNodes[0].nodeValue;
			var newLevel = xmlNodes[5].childNodes[0].nodeValue;
			var newExp = xmlNodes[6].childNodes[0].nodeValue;
			var expUpVal = xmlNodes[7].childNodes[0].nodeValue;
			if(document["gEngine_alpha"] != undefined && document["gEngine_alpha"] != null)	{
				var swfObj = undefined;
				switch(true)//find swf across multi browser test
				{
					case (document["gEngine_alpha"].ReportMouseLoc != undefined):
						swfObj = document["gEngine_alpha"];
					break;
					case (document["gEngine_alpha"][0].ReportMouseLoc != undefined):
						swfObj = document["gEngine_alpha"][0];
					break;
					case (document["gEngine_alpha"][1].ReportMouseLoc != undefined):
						swfObj = document["gEngine_alpha"][1];
					break;
				}
				swfObj.ReportMouseLoc({method:"ninjaCompleteAttack", sendToGashapon:"true", rechargeTime:rechargeTime, attackMessage:attackMesageText, condition:attackCondition, expVal:newExp, levelVal:newLevel, expUpVal:expUpVal});
			}
			displayGashaponName(currentGashaponName, currentGashaponMessage, currentGashaponCustomName);
		}else{
			var attackDiv = document.getElementById("attackGashError");
			var oldAttackSpan = document.getElementById("attackSpanError");
			if(oldAttackSpan != undefined){
				attackDiv.removeChild(oldAttackSpan);
			}
			var attackSpan = document.createElement("span");
			attackSpan.setAttribute("id","attackSpanError");
			var textNode = document.createTextNode(message);
			attackSpan.appendChild(textNode);
			attackSpan.style.color = "#990000";
			attackDiv.appendChild(attackSpan);
		}
	}
}
function buildDecorateListPanel(title, dataString,gashaponName, gashaponMessage, levelLimit,gashaponCustomName)
{
	currentGashaponName = gashaponName;
	currentGashaponMessage = gashaponMessage;
	currentGashaponCustomName = gashaponCustomName;
	var dataArray = new Array();
	var firstStage = dataString.split("||");
	for(var i = 0; i < firstStage.length; i++){
		var secondStage = firstStage[i].split("&&");//split id and name
		if(secondStage.length > 1){
			var id = secondStage[0].split("=");
			var name = secondStage[1].split("=");
			var level = secondStage[2].split("=");
			dataArray.push(new Array(id[1],name[1],level[1]));
		}
	}
	var gashaponCont = document.getElementById("gEngineHolder");
	var gashaponInfo = document.getElementById("gashaNote");
	var sidePanel = document.getElementById("sidePanel");
	var gashaponTitle = document.getElementById("gashaponTitle");
	titleDiv = document.createElement("h4");
	titleDiv.setAttribute("id","resurrectTitle");
	var tempText = document.createTextNode("DECORATE");
	titleDiv.appendChild(tempText);	
	var moreTasks = document.createElement("div");
	moreTasks.setAttribute("id","resurrectPowerInfo");
	titleDiv.appendChild(moreTasks);
	var titleContentDiv = document.getElementById("titleContentDiv");
	gashaponTitle.removeChild(titleContentDiv);
	gashaponTitle.appendChild(titleDiv);
	var buttonName = "";
	var sentanceEnd = "";
	var decorateLabel = "";
	var decorArray = new Array();
	switch(title)
	{
		case "DECORATE":
			buttonName = "DECORATE";
			sentanceEnd = "have it's platform decorated";
			decorArray = platformDecorationArray;
			decorateLabel = "Select Platform Type";
		break;
		case "DECORE":
			buttonName = "DECORATE";
			sentanceEnd = "have it's background changed";
			decorArray = backgroundDecorationArray;
			decorateLabel = "Select Background";
		break;
	}
	var html = 'Select one of your gashapons from the drop down list to '+sentanceEnd+'.';
	html += '<div id="resurrectError" class="menuErrorText"></div>';
	html += '<form method="post" style="margin:0px;padding:0px;" name="emailform" target="_self" id="resurrectForm">';	
	html += '<select name="list" id="gashaponResurrectList" style="margin-top:10px;width:140px">'
	html += '<option value="default">Select Gashapon</option>';
	for(var g = 0; g < dataArray.length; g++){
		html += '<option value="'+dataArray[g][0]+'">'+dataArray[g][1]+' (Lv: '+dataArray[g][2]+')</option>'
	}
	html += '</select>';
	html += '<select name="decoreList" id="platformDecorationList" style="margin-top:10px;width:140px">'
	html += '<option value="default">'+decorateLabel+'</option>';
	for(var d = 0; d < decorArray.length; d++){
		if(decorArray[d][2] <= levelLimit)
		{
			html += '<option value="'+decorArray[d][1]+'">'+decorArray[d][0]+'</option>'
		}
	}
	html += '</select>';
	var hovOver = "\'button_ThinLong button_ThinLong_Hover\'";
	var hovOut = "\'button_ThinLong\'";
	var methodStringVal = "\'"+title+"\'";
	html += '<input type="button" style="margin:10px;font-size:10px" name="resurrect" id="resurrectBtn" onclick="changeSelectedGashapon('+methodStringVal+')" class="button_ThinLong" value="'+buttonName+'" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
	html += '<input type="button" style="margin:0 10px 10px 10px;font-size:10px" name="cancelresurrect" id="cancelresurrectBtn" onclick="cancelExternalPowerList()" class="button_ThinLong" value="CANCEL" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
	html += '</form>';
	html += '</div>';
	moreTasks.innerHTML = html;
}
var gashaponItemOwnerName = "";
var powerItemListDescription = "";
var specialPowerItemName = "";
var gashaponItemOwnerID = "";
function collectActiveGashaponItems(gashaponID, gashaponName,gashaponMessage, specialPowerDescription, gashaponCustomName)
{
	currentGashaponName = gashaponName;
	currentGashaponMessage = gashaponMessage;
	currentGashaponCustomName = gashaponCustomName;
	gashaponItemOwnerName = gashaponName;
	powerItemListDescription = specialPowerDescription;
	gashaponItemOwnerID = gashaponID;
	xmlHttpStats = getAjaxObjectXML();			
	if(xmlHttpStats != null){
		xmlHttpStats.open("GET","../assets/functions/gEngineCommunicate.php?method=getGashaponStats&gashaponID="+gashaponID+"",true);				
		xmlHttpStats.send(null);
		xmlHttpStats.onreadystatechange = xmlHttpResponseDisplayItems;
	}
}
function xmlHttpResponseDisplayItems()
{
	if (xmlHttpStats.readyState==4){
		var xmlDoc = xmlHttpStats.responseXML;		
		var xmlNodes = xmlDoc.getElementsByTagName("data")[0].childNodes;
		var success = xmlNodes[0].childNodes[0].nodeValue;
		if(success == "true"){					
			var specialPowerName = xmlNodes[10].childNodes[0].nodeValue;
			var customName = xmlNodes[13].childNodes[0].nodeValue;		
			var activeGashaponID = xmlNodes[14].childNodes[0].nodeValue;					
			var gashaponItemList = xmlNodes[15].childNodes[0].nodeValue;
			showActiveGashaponItems(specialPowerName, activeGashaponID, gashaponItemOwnerName, powerItemListDescription, customName, gashaponItemList);
		}
	}
}
function showActiveGashaponItems(powerName, gashaponID, gashaponName, specialPowerDescription, gashaponCustomName, itemList)
{
	var gashaponCont = document.getElementById("gEngineHolder");
	var gashaponInfo = document.getElementById("gashaNote");
	var sidePanel = document.getElementById("sidePanel");
	var gashaponTitle = document.getElementById("gashaponTitle");
	titleDiv = document.createElement("h4");
	titleDiv.setAttribute("id","resurrectTitle");
	var tempText = document.createTextNode(powerName);
	titleDiv.appendChild(tempText);	
	var moreTasks = document.createElement("div");
	moreTasks.setAttribute("id","resurrectPowerInfo");
	titleDiv.appendChild(moreTasks);
	var titleContentDiv = document.getElementById("titleContentDiv");
	gashaponTitle.removeChild(titleContentDiv);
	gashaponTitle.appendChild(titleDiv);
	var dataArray = new Array();
	var firstStage = itemList.split("[@@]");
	for(var i = 0; i < firstStage.length; i++){
		var secondStage = firstStage[i].split("[@]");//split id and name
		if(secondStage.length > 1){
			var id = secondStage[0].split("=");
			var name = secondStage[1].split("=");
			var buttons = secondStage[2].split("=");
			var amount = secondStage[3].split("=");
			var info = secondStage[4].split("=");
			dataArray.push(new Array(id[1],name[1],buttons[1],amount[1],amount[0],info[1]));
		}
	}				
	var html = specialPowerDescription;
	html += '<div id="resurrectError" class="menuErrorText"></div>';
	html += '<form method="post" style="margin:0px;padding:0px;" name="emailform" target="_self" id="resurrectForm">';	
	html += '<select name="list" id="gashaponItemList" style="margin:4px;width:140px">'
	html += '<option value="default">Select Item</option>';
	for(var g = 0; g < dataArray.length; g++){
		var storeValue = ""+dataArray[g][0]+"@@"+dataArray[g][2]+"@@"+dataArray[g][4]+"@@"+dataArray[g][3]+"@@"+dataArray[g][5];//id, buttonInterface, amountName, amount, description
		html += '<option value="'+storeValue+'">'+dataArray[g][1]+'</option>'
	}
	html += '</select>';
	var hovOver = "\'button_ThinLong button_ThinLong_Hover\'";
	var hovOut = "\'button_ThinLong\'";
	var methodStringVal = "\'"+powerName.toUpperCase()+"\'";
	html += '<input type="button" style="margin:10px;font-size:10px" name="resurrect" id="resurrectBtn" onclick="changeSelectedItem('+methodStringVal+')" class="button_ThinLong" value="'+powerName.toUpperCase()+'" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
	html += '<input type="button" style="margin:0 10px 10px 10px;font-size:10px" name="cancelresurrect" id="cancelresurrectBtn" onclick="cancelExternalPowerList()" class="button_ThinLong" value="CANCEL" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
	html += '</form>';
	html += '</div>';
	moreTasks.innerHTML = html;
}
function changeSelectedItem(methodString)
{
	var resurrectBtn = document.getElementById("gashaponItemList");
	var selectedItemID = resurrectBtn.options[resurrectBtn.selectedIndex].value;
	var secondDropDown = true;
	var firstDropDown = true;
	var errorMessage = "";
	var decorateType = null;
	if(selectedItemID == null || selectedItemID == "default"){
		firstDropDown = false;
		errorMessage = "Please select a item from the drop down list.";
	}
	if(firstDropDown == true){
		if(document["gEngine_alpha"] != undefined && document["gEngine_alpha"] != null){
			var swfObj = undefined;
			switch(true)//find swf across multi browser test
			{
				case (document["gEngine_alpha"].ReportMouseLoc != undefined):
					swfObj = document["gEngine_alpha"];
				break;
				case (document["gEngine_alpha"][0].ReportMouseLoc != undefined):
					swfObj = document["gEngine_alpha"][0];
				break;
				case (document["gEngine_alpha"][1].ReportMouseLoc != undefined):
					swfObj = document["gEngine_alpha"][1];
				break;
			}
			//id, buttonInterface, amountName, amount, description
			var info = selectedItemID.split("@@");
			var returnVar = info[0];
			swfObj.ReportMouseLoc({method:"TRANSMUTE", sendToGashapon:"true",gashaponID:returnVar});
		}
		displayGashaponName(currentGashaponName, currentGashaponMessage, currentGashaponCustomName);
	}else{
		var attackDiv = document.getElementById("resurrectError");
		var oldAttackSpan = document.getElementById("attackSpanError");
		if(oldAttackSpan != undefined){
			attackDiv.removeChild(oldAttackSpan);
		}
		var attackSpan = document.createElement("span");
		attackSpan.setAttribute("id","attackSpanError");
		var textNode = document.createTextNode(errorMessage);
		attackSpan.appendChild(textNode);
		attackSpan.style.color = "#990000";
		attackDiv.appendChild(attackSpan);
	}
}
function buildPowerListPanel(title, dataString,gashaponName, gashaponMessage, specialDescription, gashaponCustomName)
{
	currentGashaponName = gashaponName;
	currentGashaponMessage = gashaponMessage;
	currentGashaponCustomName = gashaponCustomName;
	var dataArray = new Array();
	var firstStage = dataString.split("||");
	for(var i = 0; i < firstStage.length; i++){
		var secondStage = firstStage[i].split("&&");
		if(secondStage.length > 1){
			var id = secondStage[0].split("=");
			var name = secondStage[1].split("=");
			var level = secondStage[2].split("=");
			dataArray.push(new Array(id[1],name[1],level[1]));
		}
	}
	var gashaponCont = document.getElementById("gEngineHolder");
	var gashaponInfo = document.getElementById("gashaNote");
	var sidePanel = document.getElementById("sidePanel");
	var gashaponTitle = document.getElementById("gashaponTitle");
	titleDiv = document.createElement("h4");
	titleDiv.setAttribute("id","resurrectTitle");
	var tempText = document.createTextNode(title);
	titleDiv.appendChild(tempText);	
	var moreTasks = document.createElement("div");
	moreTasks.setAttribute("id","resurrectPowerInfo");
	titleDiv.appendChild(moreTasks);
	var titleContentDiv = document.getElementById("titleContentDiv");
	gashaponTitle.removeChild(titleContentDiv);
	gashaponTitle.appendChild(titleDiv);
	var buttonName = "";
	var sentanceEnd = "";
	switch(title)
	{
		case "RESURRECTION":
			buttonName = "RESURRECT";
			sentanceEnd = "resurrect";
		break;
		case "TRANSMUTE":
			buttonName = "TRANSMUTE";
			sentanceEnd = "transmute into a new gashapon";
		break;
		case "HEAL":
			buttonName = "HEAL";
			sentanceEnd = "to heal and restore health";
		break;
		case "SPECIAL POWER":
			buttonName = "SPECIAL";
			sentanceEnd = (specialDescription != undefined) ? specialDescription : "give 10 bonus experience point to";;
		break;
	}
	var html = 'Select one of your gashapons from the drop down list to '+sentanceEnd+'.';
	html += '<div id="resurrectError" class="menuErrorText"></div>';
	html += '<form method="post" style="margin:0px;padding:0px;" name="emailform" target="_self" id="resurrectForm">';	
	html += '<select name="list" id="gashaponResurrectList" style="margin-top:10px;width:140px">'
	html += '<option value="default">Select Gashapon</option>';
	for(var g = 0; g < dataArray.length; g++){
		html += '<option value="'+dataArray[g][0]+'">'+dataArray[g][1]+' (Lv: '+dataArray[g][2]+')</option>'
	}
	html += '</select>';
	var hovOver = "\'button_ThinLong button_ThinLong_Hover\'";
	var hovOut = "\'button_ThinLong\'";
	var methodStringVal = "\'"+title+"\'";
	html += '<input type="button" style="margin:10px;font-size:10px" name="resurrect" id="resurrectBtn" onclick="changeSelectedGashapon('+methodStringVal+')" class="button_ThinLong" value="'+buttonName+'" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
	html += '<input type="button" style="margin:0 10px 10px 10px;font-size:10px" name="cancelresurrect" id="cancelresurrectBtn" onclick="cancelExternalPowerList()" class="button_ThinLong" value="CANCEL" onmouseover="hov(this,'+hovOver+')" onmouseout="hov(this,'+hovOut+')"/>';
	html += '</form>';
	html += '</div>';
	moreTasks.innerHTML = html;
}
function cancelExternalPowerList()
{
	if(document["gEngine_alpha"] != undefined && document["gEngine_alpha"] != null){
		var swfObj = undefined;
		switch(true)
		{
			case (document["gEngine_alpha"].ReportMouseLoc != undefined):
				swfObj = document["gEngine_alpha"];
			break;
			case (document["gEngine_alpha"][0].ReportMouseLoc != undefined):
				swfObj = document["gEngine_alpha"][0];
			break;
			case (document["gEngine_alpha"][1].ReportMouseLoc != undefined):
				swfObj = document["gEngine_alpha"][1];
			break;
		}
		swfObj.ReportMouseLoc({method:"cancelExternalPowerList", sendToGashapon:"true"});
	}
	displayGashaponName(currentGashaponName, currentGashaponMessage, currentGashaponCustomName);
}
function changeSelectedGashapon(methodString)
{
	var resurrectBtn = document.getElementById("gashaponResurrectList");
	var gashaponID = resurrectBtn.options[resurrectBtn.selectedIndex].value;
	var secondDropDown = true;
	var firstDropDown = true;
	var errorMessage = "";
	var decorateType = null;
	if(methodString == "DECORATE" || methodString == "DECORE"){
		var decoreBtn = document.getElementById("platformDecorationList");
		decorateType = decoreBtn.options[decoreBtn.selectedIndex].value;
		if(decorateType == null || decorateType == "default"){
			secondDropDown = false;
			errorMessage = (methodString == "DECORE") ? "Please select a background from the drop down list." : "Please select a platform type from the drop down list.";
		}
	}
	if(gashaponID == null || gashaponID == "default"){
		firstDropDown = false;
		errorMessage = "Please select a gashapon from the drop down list.";
	}
	if(firstDropDown == true && secondDropDown == true){
		if(document["gEngine_alpha"] != undefined && document["gEngine_alpha"] != null){
			var swfObj = undefined;
			switch(true)
			{
				case (document["gEngine_alpha"].ReportMouseLoc != undefined):
					swfObj = document["gEngine_alpha"];
				break;
				case (document["gEngine_alpha"][0].ReportMouseLoc != undefined):
					swfObj = document["gEngine_alpha"][0];
				break;
				case (document["gEngine_alpha"][1].ReportMouseLoc != undefined):
					swfObj = document["gEngine_alpha"][1];
				break;
			}
			swfObj.ReportMouseLoc({method:methodString, sendToGashapon:"true",gashaponID:gashaponID, decoreType:decorateType});
		}
		displayGashaponName(currentGashaponName, currentGashaponMessage, currentGashaponCustomName);
	}else{
		var attackDiv = document.getElementById("resurrectError");
		var oldAttackSpan = document.getElementById("attackSpanError");
		if(oldAttackSpan != undefined){
			attackDiv.removeChild(oldAttackSpan);
		}
		var attackSpan = document.createElement("span");
		attackSpan.setAttribute("id","attackSpanError");
		var textNode = document.createTextNode(errorMessage);
		attackSpan.appendChild(textNode);
		attackSpan.style.color = "#990000";
		attackDiv.appendChild(attackSpan);
	}
}
var xOffset = 60;
var yOffset = 60;
var gEnginePosition = 0;
var gEngineInstanceID = 0;
var currentFrameStep = -10;
var xPickUpStartPos = 0;
var yPickUpStartPos = 0;
var step = 0;
var frameDuration = 5;
var moveToIntervalID = null;
var dropIntervalID = 0;
var OldLeftPos = 0;
var OldTopPos = 0;
var velocityX = 0;
var velocityY = 0;
var gravity = 1;
var friction = 0.98;
var ceiling = -220;		
var dragStage = "static";
function dragActiveGashapon(fileUrl, xoffset, yoffset, gEngineID, xPickUpOffset, yPickUpOffset, health, totalHealth)
{
	disableAllSelectTags("hidden");	
	dragStage = "drag";	
	gEngineInstanceID = gEngineID;
	velocityX = 0;
	velocityY = 0;
	xOffset = xoffset;
	yOffset = yoffset;
	currentFrameStep = -10;
	var bodyRef = document.getElementsByTagName('body').item(0);
	gEnginePosition = getPageElementPosition('gashaponSwf');
	var dragGashapon = document.getElementById("externalGashapon");	
	dragGashapon.style.visibility = "visible";
	yPickUpOffset += 35;
	yPickUpStartPos = (gEnginePosition.top-yoffset)+yPickUpOffset;
	xPickUpStartPos = (gEnginePosition.left-xoffset)+xPickUpOffset;
	var xStep = ((gEngineBrowserInfo["x"]-xoffset) - xPickUpStartPos)
	var yStep = ((gEngineBrowserInfo["y"]-yoffset) - yPickUpStartPos);
	step = Math.sqrt(xStep*xStep + yStep*yStep) / frameDuration;
	dragGashapon.style.position = "absolute";		
	dragGashapon.style.top = yPickUpStartPos+"px";
	dragGashapon.style.left = xPickUpStartPos+"px";
	dragGashapon.style.zIndex = 100;
	moveToIntervalID = setInterval("gashaponMoveTo()",40);
	currentFrameStep+=1;
	var externalSwfID = "dragGashaponSwf";
	var swfExternalObj = null;		
	if (document[externalSwfID].ReportExternalMouseLoc != undefined){
		swfExternalObj = document[externalSwfID];
	}
	if(document[externalSwfID][0] != undefined){
		if(document[externalSwfID][0].ReportExternalMouseLoc != undefined){
			swfExternalObj = document[externalSwfID][0];
		}
	}
	if(document[externalSwfID][1] != undefined){
		if(document[externalSwfID][1].ReportExternalMouseLoc != undefined){
			swfExternalObj = document[externalSwfID][1];
		}
	}
	if(swfExternalObj != null){
		if(swfExternalObj.ReportExternalMouseLoc != undefined){			
			swfExternalObj.ReportExternalMouseLoc({method:"startExternalPickup", health:health,totalHealth:totalHealth});
		}
	}		
	if (document.addEventListener != null) { 
		// e.g. Firefox, Opera, Safari
		document.addEventListener("mousemove", mouseDragGashapon, true);
		document.addEventListener("mouseup", gashaponMouseDrop, true);
		bodyRef.style.MozUserSelect = "none";		
	} else { 
		 // e.g. Internet Explorer (also would work on Opera)
		document.attachEvent("onmousemove", mouseDragGashapon);			
		document.attachEvent("onmouseup", gashaponMouseDrop);
	}
	if(gEngineID != undefined){
		var swfObj = undefined;	
		if(document[gEngineID] != undefined){		
			switch(true)//find swf across multi browser test
			{
				case (document[gEngineID].sendEmbedStatus != undefined):
					swfObj = document[gEngineID];
				break;
				case (document[gEngineID][0].sendEmbedStatus != undefined):
					swfObj = document[gEngineID][0];
				break;
				case (document[gEngineID][1].sendEmbedStatus != undefined):
					swfObj = document[gEngineID][1];
				break;
			}
			swfObj.sendEmbedStatus({method:"setupExternalDrag",success:"true"});
		}
	}		
}	
function gashaponMoveTo()
{
	var dragGashDiv = document.getElementById("externalGashapon");	
	currentFrameStep += 1;			
	var posX = (gEngineBrowserInfo["x"])-xOffset;
	var posY = (gEngineBrowserInfo["y"])-yOffset;
	if(currentFrameStep > 0 && currentFrameStep < frameDuration){
		topPos = dragGashDiv.style.top.replace("px","");
		leftPos = dragGashDiv.style.left.replace("px","");
		var dx = (leftPos - posX);
		var dy = (topPos - posY);
		var radians = (Math.atan2(dy,dx));
		var vx = Math.cos(radians) * (step * (frameDuration - currentFrameStep));
		var vy = Math.sin(radians) * (step * (frameDuration - currentFrameStep));					
		posX += vx;
		posY += vy;
		dragGashDiv.style.left = posX+"px";
		dragGashDiv.style.top = posY+"px";			
	}
	if(currentFrameStep > frameDuration){
		clearInterval(moveToIntervalID);
		moveToIntervalID = null;
	}
}
function getExternalGashapon()
{
	var externalSwfID = "dragGashaponSwf";
	var swfExternalObj = null;		
	if (document[externalSwfID].ReportExternalMouseLoc != undefined){
		swfExternalObj = document[externalSwfID];
	}
	if(document[externalSwfID][0] != undefined){
		if(document[externalSwfID][0].ReportExternalMouseLoc != undefined){
			swfExternalObj = document[externalSwfID][0];
		}
	}
	if(document[externalSwfID][1] != undefined){
		if(document[externalSwfID][1].ReportExternalMouseLoc != undefined){
			swfExternalObj = document[externalSwfID][1];
		}
	}
	return swfExternalObj;
}
function mouseDragGashapon()
{
	if(currentFrameStep < 0)
	{
		currentFrameStep = 0;
	}
	var e = arguments[0] || event;
	var dragGashDiv = document.getElementById("externalGashapon");		
	var topPos = 0;
	var leftPos = 0;
	if(navigator.userAgent.indexOf("MSIE")!=-1){
		var scrollTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		var scrollLeft = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		var docHeight = (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		var dovWidth = (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		var posX = (event.clientX + scrollLeft)-xOffset;
		var posY = (event.clientY + scrollTop)-yOffset;					
		if(currentFrameStep > frameDuration){
			dragGashDiv.style.left = posX;
			dragGashDiv.style.top = posY;
		}			
		topPos = dragGashDiv.style.top.replace("px","");
		leftPos = dragGashDiv.style.left.replace("px","");
	}else{
		if(currentFrameStep > frameDuration){
			dragGashDiv.style.left = e.pageX-xOffset+"px";
			dragGashDiv.style.top = e.pageY-yOffset+"px";
		}
		topPos = dragGashDiv.style.top.replace("px","");
		leftPos = dragGashDiv.style.left.replace("px","");
		var docHeight = window.innerHeight + window.pageYOffset;			
	}
	velocityX = (Number(leftPos) - OldLeftPos)/1.3;
	velocityY = (Number(topPos) - OldTopPos)/1.3;
	if(velocityX > 25){velocityX = 25};
	if(velocityY > 25){velocityY = 25};
	if(velocityX < -25){velocityX = -25};
	if(velocityY < -25){velocityY = -25};
	OldLeftPos = Number(leftPos);
	OldTopPos = Number(topPos);
	gashaponMouseOut(e);
	var externalSWFOffset = undefined;
	if(document["dragGashaponSwf"] != undefined && document["dragGashaponSwf"] != null){
		var externalSwfID = "dragGashaponSwf";
		var swfExternalObj = null;		
		if (document[externalSwfID].ReportExternalMouseLoc != undefined){
			swfExternalObj = document[externalSwfID];
		}
		if(document[externalSwfID][0] != undefined){
			if(document[externalSwfID][0].ReportExternalMouseLoc != undefined){
				swfExternalObj = document[externalSwfID][0];
			}
		}
		if(document[externalSwfID][1] != undefined){
			if(document[externalSwfID][1].ReportExternalMouseLoc != undefined){
				swfExternalObj = document[externalSwfID][1];
			}
		}		
		if(externalSWFOffset == undefined && swfExternalObj != undefined){				
			externalSWFOffset = getPageElementPosition("dragGashaponSwf");
		}
		var dragGashDiv = document.getElementById("externalGashapon");		
		if(swfExternalObj != null && dragGashDiv.getAttribute("name") != "externalGashaponFalling"){
			if(navigator.userAgent.indexOf("MSIE")!=-1){
				var scrollTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
				var scrollLeft = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
				var posX = event.clientX + scrollLeft;
				var posY = event.clientY + scrollTop;
				swfExternalObj.ReportExternalMouseLoc({x:posX,y:posY,swfX:externalSWFOffset.left ,swfY:externalSWFOffset.top} );
			}else{
				swfExternalObj.ReportExternalMouseLoc({x:e.pageX,y:e.pageY,swfX:externalSWFOffset.left ,swfY:externalSWFOffset.top} );
			}
		}
		var gashaponCont = document.getElementById("gEngineHolder");
		var zodiacFeedDiv = document.createElement("div");
		var textNode = document.createTextNode("-"+document["dragGashaponSwf"].ReportExternalMouseLoc);
		zodiacFeedDiv.appendChild(textNode);	
	}
}
function gashaponMouseOut(e) 
{
	var outside = false;
	if(navigator.userAgent.indexOf("MSIE")!=-1){
		var scrollTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		var scrollLeft = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		var docHeight = (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		var dovWidth = (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		topPos = (event.clientY + scrollTop);
		leftPos = (event.clientX + scrollLeft);
		if((topPos-scrollTop) <= 10){
			outside = true;
		}
		if(topPos >= (docHeight-scrollTop-80)){
			outside = true;
		}
	}else{
		topPos = e.pageY;
		leftPos = e.pageX;
		var docHeight = window.innerHeight + window.pageYOffset;
		var bodyRef = document.getElementById('gEngineTitle');
		if((topPos) <= 10){
			outside = true;
		}
		if(topPos >= (docHeight-80)){
			outside = true;
		}
	}
	if(outside){
		velocityX = 0;
		velocityY = 0;
		gashaponMouseDrop();
	}
}
function gashaponMouseDrop()
{
	if(dragStage == "drag"){
		dragStage = "fall";
		if(moveToIntervalID != null){
			clearInterval(moveToIntervalID);
			moveToIntervalID = null;
		}
		var externalSwfID = "dragGashaponSwf";
		var swfExternalObj = null;
		if(document[externalSwfID] != undefined){		
			if (document[externalSwfID].ReportExternalMouseLoc != undefined){
				swfExternalObj = document[externalSwfID];
			}		
			if(document[externalSwfID][0] != undefined){
				if(document[externalSwfID][0].ReportExternalMouseLoc != undefined){
					swfExternalObj = document[externalSwfID][0];
				}
			}
			if(document[externalSwfID][1] != undefined){
				if(document[externalSwfID][1].ReportExternalMouseLoc != undefined){
					swfExternalObj = document[externalSwfID][1];
				}
			}
		}
		if(swfExternalObj != null){
			swfExternalObj.ReportExternalMouseLoc({method:"stopSpring"});
		}
		var dragGashDiv = document.getElementById("externalGashapon");
		dragGashDiv.setAttribute("name", "externalGashaponFalling");
		if (document.addEventListener != null) { 
		// e.g. Firefox, Opera, Safari
			document.removeEventListener("mousemove", mouseDragGashapon, true);
			document.removeEventListener("mouseup", gashaponMouseDrop, true);
		} else { 
			 // e.g. Internet Explorer (also would work on Opera)
			document.detachEvent("onmousemove", mouseDragGashapon);			
			document.detachEvent("onmouseup", gashaponMouseDrop);
		}
		dropIntervalID = setInterval("gashaponFall()", 30);
	}
}
function gashaponFall()
{
	var dragGashDiv = document.getElementById("externalGashapon");
	velocityY += gravity;
	velocityX *= friction;
	var hitBounds = false;//when to stop falling	
	var topPos = dragGashDiv.style.top.replace("px","");
	var leftPos = dragGashDiv.style.left.replace("px","");
	dragGashDiv.style.top = (Number(topPos) + velocityY)+"px";
	dragGashDiv.style.left = (Number(leftPos) + velocityX)+"px";
	if(navigator.userAgent.indexOf("MSIE")!=-1){
		var scrollTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		var scrollLeft = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		var docHeight = (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		var docWidth = (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		topPos = dragGashDiv.style.top.replace("px","");
		leftPos = dragGashDiv.style.left.replace("px","");
		if(Number(topPos) < ceiling){
			dragGashDiv.style.top = ceiling+"px";
			velocityY = 5;
		}
		if((Number(topPos)) >= (docHeight+scrollTop)){
			hitBounds = true;
		}
		if(Number(leftPos) <= -160){
			hitBounds = true;
		}
		if(Number(leftPos) <= -160){
			hitBounds = true;
		}
		if((Number(leftPos)) >= (docWidth+scrollLeft)){
			hitBounds = true;
		}
	}else{
		topPos = dragGashDiv.style.top.replace("px","");
		leftPos = dragGashDiv.style.left.replace("px","");
		var docHeight = window.innerHeight + window.pageYOffset;
		var docWidth = window.innerWidth + window.pageXOffset;
		if(Number(topPos) < ceiling){
			velocityY *= -0.5;
		}
		if(topPos >= (docHeight)){
			hitBounds = true;
		}
		if(Number(leftPos) <= -160){
			hitBounds = true;
		}
		if(leftPos >= (docWidth)){
			hitBounds = true;
		}
	}
	if(hitBounds){
		clearInterval(dropIntervalID);
		gashaponReturnPos();
	}
}
function gashaponReturnPos()
{
	dragStage = "static";
	disableAllSelectTags("visible");
	var bodyRef = document.getElementsByTagName('body').item(0);
	var dragGashDiv = document.getElementById("externalGashapon");
	var gashaEmbed = document.getElementById("dragGashaponSwf");
	dragGashDiv.setAttribute("name", "resting");
	gashaEmbed.blur();
	dragGashDiv.style.visibility = "hidden";
	var externalSwfID = "dragGashaponSwf";
	var swfExternalObj = null;		
	if (document[externalSwfID].ReportExternalMouseLoc != undefined){
		swfExternalObj = document[externalSwfID];
	}
	if(document[externalSwfID][0] != undefined){
		if(document[externalSwfID][0].ReportExternalMouseLoc != undefined){
			swfExternalObj = document[externalSwfID][0];
		}
	}
	if(document[externalSwfID][1] != undefined){
		if(document[externalSwfID][1].ReportExternalMouseLoc != undefined){
			swfExternalObj = document[externalSwfID][1];
		}
	}
	if(swfExternalObj != null){
		if(swfExternalObj.ReportExternalMouseLoc != null && swfExternalObj.ReportExternalMouseLoc != undefined){			
			swfExternalObj.ReportExternalMouseLoc({method:"stopExternalPickup"});
		}
	}
	if(gEngineInstanceID != undefined){
		var swfObj = undefined;			
		switch(true)
		{
			case (document[gEngineInstanceID].sendEmbedStatus != undefined):
				swfObj = document[gEngineInstanceID];
			break;
			case (document[gEngineInstanceID][0].sendEmbedStatus != undefined):
				swfObj = document[gEngineInstanceID][0];
			break;
			case (document[gEngineInstanceID][1].sendEmbedStatus != undefined):
				swfObj = document[gEngineInstanceID][1];
			break;
		}			
		swfObj.sendEmbedStatus({method:"externalReturn"});
	}
}
// -->
