var arr_to_p=new Array(),on_to_p=false,num_to_p=-1;
function send_to_p(e){if(!e)e=window.event;if(e.keyCode==40){if(on_to_p){if((num_to_p+1)<arr_to_p.length) send_to_p_sel((num_to_p+1));}return false;}else if(e.keyCode==38){if(on_to_p){if((num_to_p-1)>=0) send_to_p_sel((num_to_p-1));}return false;}else if(e.keyCode==13){send_to_p_enter();return false;}else if(e.keyCode==27){if(on_to_p){send_to_p_close();}return false;}if(document.getElementById('send_input').value.length>2){JsHttpRequest.query('/ajax/to_parrent.php',{t:document.getElementById('send_input').value},function(result, errors){if(result.length>0){arr_to_p=new Array();var html='<table class=send_to cellSpacing=0 cellPadding=0>';for(i=0,max=result.length;i<max;i++){html+='<tr id=send_'+arr_to_p.length+' onmouseover=send_to_p_sel('+arr_to_p.length+') onclick=send_to_p_enter()><td>'+result[i]+'</td></tr>';arr_to_p[arr_to_p.length]=result[i];}html+='</table>';send_to_p_open(html);}},false);}return false;}
function send_to_p_open(html){document.getElementById('send_id').innerHTML=html;document.getElementById('send_div').style.display='';num_to_p=-1;on_to_p=true;}
function send_to_p_close(){if(on_to_p){document.getElementById('send_div').style.display='none';on_to_p=false;}}
function send_to_p_sel(id){if(num_to_p!=-1) document.getElementById('send_'+num_to_p).className='';document.getElementById('send_'+id).className='sel';num_to_p=id;}
function send_to_p_enter(){if(on_to_p){if(num_to_p!=-1) document.getElementById('send_input').value=arr_to_p[num_to_p];send_to_p_close();return false;}}

var arr_to_k=new Array(),on_to_k=false,num_to_k=-1;
function send_to_k(e){if(!e)e=window.event;if(e.keyCode==40){if(on_to_k){if((num_to_k+1)<arr_to_k.length) send_to_k_sel((num_to_k+1));}return false;}else if(e.keyCode==38){if(on_to_k){if((num_to_k-1)>=0) send_to_k_sel((num_to_k-1));}return false;}else if(e.keyCode==13){send_to_k_enter();return false;}else if(e.keyCode==27){if(on_to_k){send_to_k_close();}return false;}if(document.getElementById('send_input').value.length>2){JsHttpRequest.query('/ajax/to_kids.php',{t:document.getElementById('send_input').value},function(result, errors){if(result.length>0){arr_to_k=new Array();var html='<table class=send_to cellSpacing=0 cellPadding=0>';for(i=0,max=result.length;i<max;i++){html+='<tr id=send_'+arr_to_k.length+' onmouseover=send_to_k_sel('+arr_to_k.length+') onclick=send_to_k_enter()><td><img src="'+result[i][1]+'" width=50 height=50></td><td width=100%>'+result[i][0]+'</td></tr>';arr_to_k[arr_to_k.length]=result[i];}html+='</table>';send_to_k_open(html);}},false);}return false;}
function send_to_k_open(html){document.getElementById('send_id').innerHTML=html;document.getElementById('send_div').style.display='';num_to_k=-1;on_to_k=true;}
function send_to_k_close(){if(on_to_k){document.getElementById('send_div').style.display='none';on_to_k=false;}}
function send_to_k_sel(id){if(num_to_k!=-1) document.getElementById('send_'+num_to_k).className='';document.getElementById('send_'+id).className='sel';num_to_k=id;}
function send_to_k_enter(){if(on_to_k){if(num_to_k!=-1) document.getElementById('send_input').value=arr_to_k[num_to_k][0];send_to_k_close();return false;}}

function input_int(event){if(!event)event=window.event;var code=event.charCode?event.charCode:event.keyCode;if((code<48||code>57)&&code!=8&&code!=46&&code!=44&&code!=9&&code!=37&&code!=39)return false;}
function input_real(event){if(!event)event=window.event;var code=event.charCode?event.charCode:event.keyCode;if((code<48||code>57)&&code!=8&&code!=46&&code!=44&&code!=9&&code!=37&&code!=39)return false;}

window.onload=god;
function god(){
	JsHttpRequest.query(
	'/ajax/god.php',
	{},
	function(result, errors){
		if(result) alert(result);
		setTimeout("god()",15000);
	},
	true
	);
}

var resize_x,resize_y,mouseX,mouseY,graf_id,temp_left,temp_width;
function mouse_move(e){if(!e)e=window.event;if(e.pageX||e.pageY){mouseX=e.pageX;mouseY=e.pageY;}else if (e.clientX || e.clientY){	mouseX=e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)-document.documentElement.clientLeft;mouseY=e.clientY+(document.documentElement.scrollTop||document.body.scrollTop)-document.documentElement.clientTop;}}
function graf_move(id){
	document.onmouseup=graf_finish;
	resize_x=mouseX;
	graf_id=document.getElementById('graf_id_'+id);
	temp_left=parseInt(graf_id.style.left);
	temp_width=parseInt(graf_id.style.width);
	document.onmousemove=graf_hey;
}
function graf_finish(){
	document.onmouseup='';
	document.onmousemove=mouse_move;
}
function graf_hey(e){
	mouse_move(e);
	temp=temp_left-(resize_x-mouseX);
	if(temp>0) temp=0;
	if(temp-440+temp_width<0) temp=-temp_width+440;
	graf_id.style.left=temp;
}
document.onmousemove=mouse_move;

var gym_id=0;
function gym(){
	JsHttpRequest.query(
	'/ajax/gym.php?id='+gym_id,
	{},
	function(result, errors){
		if(result=='-1') document.location='/';
		else if(result!=gym_id) gym_id=result;
		setTimeout("gym()",5000);
	},
	true
	);
}

function forgot(){
	document.getElementById('forgot_cat').value=document.getElementById('mode').value;
	document.getElementById('forum_black').style.display='';
	document.getElementById('forgot_form').style.display='';
}

function forum_new(){
	document.getElementById('forum_zag').value='';
	document.getElementById('forum_txt').value='';
	document.getElementById('forum_error').style.display='none';
	document.getElementById('forum_black').style.display='';
	document.getElementById('forum_form').style.display='';
}

function forum_reply(str){
	document.getElementById('forum_zag').value='Re: '+str;
	document.getElementById('forum_txt').value='';
	document.getElementById('forum_new').innerHTML='Post Reply';
	document.getElementById('forum_error').style.display='none';
	document.getElementById('forum_black').style.display='';
	document.getElementById('forum_form').style.display='';
}

function forum_close(){
	document.getElementById('forum_form').style.display='none';
	document.getElementById('forum_black').style.display='none';
}

function forum_submit(){
	var ok=true;
	document.getElementById('forum_error_txt').innerHTML='';
	if(document.getElementById('forum_zag').value==''){
		ok=false;
		document.getElementById('forum_error_txt').innerHTML+='<br>Please input Subject';
	}
	if(document.getElementById('forum_txt').value==''){
		ok=false;
		document.getElementById('forum_error_txt').innerHTML+='<br>Please input Content';
	}
	if(!ok){
		document.getElementById('forum_error_txt').innerHTML='<font style=color:red;font-weight:bold>Error!</font>'+document.getElementById('forum_error_txt').innerHTML;
		document.getElementById('forum_error').style.display='';
		return false;
	}
	return true;
}

var picture_adds=new Array();
function upload_picture(id,n){
	document.getElementById('text_'+id+'_'+n).innerHTML='<div class=gl_ico_2></div><br>Uploading';
	JsHttpRequest.query(
	'/ajax/add_picture.php',
	{'file':document.getElementById('file_'+id+'_'+n)},
	function(result, errors){
		document.getElementById('file_'+id+'_'+n).disabled='none';
		if(result==0) document.getElementById('text_'+id+'_'+n).innerHTML='<div class=gl_ico_3></div><br>Upload error';
		if(result==1){
			document.getElementById('text_'+id+'_'+n).innerHTML='<div class=gl_ico_4></div><br>Upload complete!';
			add_picture();
		}
	},
	true
	);
}
function add_picture(){
	document.getElementById('id_bn').style.display='none';
	for(i=1;i<=10;i++){
		if(document.getElementById('file_'+i+'_1').value!=''&&typeof(picture_adds[i+'_1'])=='undefined'){
			picture_adds[i+'_1']=true;
			upload_picture(i,1);
			return true;
		}
		if(document.getElementById('file_'+i+'_2').value!=''&&typeof(picture_adds[i+'_2'])=='undefined'){
			picture_adds[i+'_2']=true;
			upload_picture(i,2);
			return true;
		}
	}
	alert('Moderator will check your pictures');
	document.location='/kids/my_picture/';
}

function fixPNG(element,crop){
	if(navigator.appName=="Microsoft Internet Explorer"){
		var src;
		if (element.tagName=='IMG'){
			if (/\.png$/.test(element.src)){
				src = element.src;
				element.src = "/file/x.gif"; 
			}
			if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='crop')";
		}
		else{
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
			if (src){
				src = src[1]; 
				element.runtimeStyle.backgroundImage="none"; 
			}
			if(typeof(crop)!='undefined'&&crop){if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='crop')";}
			else{if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";}
		}
	}
}

function w_open(URLStr,w,h,scr,target){if(target=='') target='_blank';if(scr)ShowScroll='yes';else ShowScroll='no';var width=w;var height=h;var left=0;var top=0;if (width>screen.availWidth){width=screen.availWidth-10;	ShowScroll='yes';}if (height>screen.availHeight){height=screen.availHeight-40;	ShowScroll='yes';}left=(screen.availWidth-width)/2-5;top=(screen.availHeight-height)/2-20;window.open(URLStr,target,'location=no,directories=no,toolbar=no,status=no,menubar=no,scrollbars='+ShowScroll+',copyhistory=yes,resizable='+ShowScroll+',width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');}

function check_all(){
	var ml=document.getElementById('Form1');
	var len=ml.elements.length;
	for(var i=0;i<len;i++) {
		var e=ml.elements[i];e.checked=true;
	}
}
function uncheck_all(){
	var ml=document.getElementById('Form1');
	var len=ml.elements.length;
	for(var i=0;i<len;i++) {
		var e=ml.elements[i];e.checked=false;
	}
}

function delete_photo(id){
	if(document.getElementById('inp_'+id).value!='0'){
		document.getElementById('td_'+id).style.backgroundColor='';
		document.getElementById('inp_'+id).value=0;
	}
	else{
		document.getElementById('td_'+id).style.backgroundColor='#ff0000';
		document.getElementById('inp_'+id).value=id;
	}
}

var avatar_n=1;
var avatar_max=0;
function avatar_prev(){
	if(avatar_n==1) return false;
	avatar_page((avatar_n-1));
}
function avatar_next(){
	if(avatar_n>=avatar_max) return false;
	avatar_page((avatar_n+1));
}
function avatar_page(n){
	avatar_n=n;
	JsHttpRequest.query(
	'/ajax/avatars.php',
	{'page':n},
	function(result, errors){
		document.getElementById('avatar_img').innerHTML=result['img'];
		document.getElementById('avatar_pages').innerHTML=result['pages'];
		for(i=0;i<result['arr'].length;i++){
			if(my_avatar==result['arr'][i]) set_avatar(my_avatar);
		}
	},
	false
	);
}

var my_avatar=0;
function set_avatar(id){
	if(my_avatar!=0&&document.getElementById('av_'+my_avatar)) document.getElementById('av_'+my_avatar).style.backgroundColor='';
	document.getElementById('av_'+id).style.backgroundColor='#ff9933';
	my_avatar=id;
	document.getElementById('avatar').value=id;
	document.getElementById('id_submit').style.display='';
}

if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		deconcept.SWFObject.doPrepUnload = true;
	}
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', false);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	useExpressInstall: function(path) {
		this.xiSWFPath = !path ? "expressinstall.swf" : path;
		this.setAttribute('useExpressInstall', true);
	},
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs[variablePairs.length] = key +"="+ variables[key];
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
};

deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){
		var axo = 1;
		var counter = 3;
		while(axo) {
			try {
				counter++;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
				PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
			} catch (e) {
				axo = null;
			}
		}
	} else { 
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always";
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
};
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
};
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
};
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if (param == null) { return q; }
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
};
deconcept.SWFObjectUtil.cleanupSWFs = function() {
  try{
	var objects=document.getElementsByTagName("OBJECT");
	for (var i=objects.length-1;i>=0;i--) {
    objects[i].style.display='none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
  }catch(e){}
};
if (!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];}}
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject;
var SWFObject = deconcept.SWFObject;