JMP = {
	counter: 0,
	init:function() {
		if(document.getElementById('loadmap')) {
			var so = new SWFObject("images/mapa.swf", "Logo", "410", "744", "9", "");
			so.addParam("quality", "hight");
			so.addParam("wmode", "transparent");
			so.addParam("menu", "false");
			so.addParam("scale", "noscale");
			so.addVariable("strTieude", "Chieu hom nay sao nhi?");
			so.addVariable("strNoidung", "Chieu hom nay se di nhau lien tuc toi nua dem cho tam hon sang khoai!");
			so.addVariable("strToado", "300:544");
			so.write("loadmap");
			this.counter = 0;
		} else {
			if(this.counter < 10000) {
				setTimeout('JMP.init()', 1000);
				this.counter += 1000;
			} else
				this.counter = 0;
		}
	}
}
JPT = {
	counter: 0,
	init:function() {
		if(document.getElementById('photos')) {
			jQuery(document).ready(function(){
				jQuery('#photos').galleryView({
					panel_width: 800,
					panel_height: 300,
					frame_width: 100,
					frame_height: 100,
					type: 'sequence',
					timeout: 2000,
					autostop: 0,
					autostopCount: 0
				});
			});
			this.counter = 0;
		} else {
			if(this.counter < 4000) {
				setTimeout('JPT.init()', 1000);
				this.counter += 1000;
			} else
				this.counter = 0;
		}
	}
}
JLB = {
	counter: 0,
	init:function() {
		if(document.getElementById('example0')) {
			$(document).ready(function(){
				$(".example0").colorbox({iframe:true, innerWidth:600, innerHeight:765});
				
				$("#click").click(function(){ 
					$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
					return false;
				});
			});
			this.counter = 0;
		} else {
			if(this.counter < 4000) {
				setTimeout('JLB.init()', 1000);
				this.counter += 1000;
			} else
				this.counter = 0;
		}
	}
}
JFL = {
	flash:function(filename, width, height, flashvars) {
		wmode=" wmode=transparent";
		window.document.write('<embed src="' + filename + '" menu=false quality=high width="' + width + '" height="' + height + '"' + wmode +' type="application/x-shockwave-flash" flashVars="' + flashvars + '" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>');
	}
}
Jmn = {
	show:function(m, x) {
		for(jj = 0; jj < 7; jj++) {
			if(m == jj) {
				document.getElementById("menuobj" + jj).style.display = "";
				document.getElementById("menuobj" + jj).style.left = x + "px";
			} else
				document.getElementById("menuobj" + jj).style.display = "none";
		}
	},
	show1:function(o) {
		ss = document.getElementById("testthuid1").style.width;
		xx = ss.substring(0, (ss.length - 2));
		document.getElementById("testthuid1").style.display = "";
		document.getElementById("testthuid1").style.left = ((o.offsetLeft - xx) + 100) + "px";
	}
}

//=======================POLL==========================
Jpv = {
	result:function(file, width, height) {
		attribute = "toolbar=no, scrollbars=2, directories=no, status=no, menubar=no, resizable=yes";
		attribute += ", width=" + width + ", height=" + height;
		window.open(file, 'voteWindow', attribute);
	},
	vote:function(url, p, c) {
		Today = new Date();
		Name = "Vote_Poll_IP_" + p + "_" + c + Today.getDate() + "_" + Today.getMonth() + "_" + Today.getYear();
		var NL = Jpv.gcookie(Name); 
		if(NL == null) {
			vote = Jpv.checked(document.forms['frmVote' + p + c].elements[p + "vote" + c]);
			if(vote > 0) {
				Jpv.scookie(Name, 'true', '', '');
				url += "&vt=123&vote=" + vote;
			}
		}
		Jpv.result(url, 600, 430);
	},
	scookie:function(cookieName, cookieValue, cookiePath, cookieExpires) { 
		cookieValue = escape(cookieValue); 
		if (cookieExpires == "") { 
			var nowDate = new Date(); 
			nowDate.setMonth(nowDate.getMonth() + 6); 
			cookieExpires = nowDate.toGMTString(); 
		}
		if (cookiePath != "") {
			cookiePath = ";Path=" + cookiePath; 
		} 
		document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;     
	},
	checked:function(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	},
	gcookie:function(name) { 
		var cookieString = document.cookie; 
		var index = cookieString.indexOf(name + "="); 
		if(index == -1)
			return null; 
		index = cookieString.indexOf("=", index) + 1; 
		var endstr = cookieString.indexOf(";", index); 
		if (endstr == -1)
			endstr = cookieString.length; 
		return unescape(cookieString.substring(index, endstr)); 
	},
	owin:function(URL, winName, width, height, scroll) {
		var winLeft = (screen.width - width) / 2;
		var winTop = (screen.height - height) / 2;
		winData = 'height='+height+',width='+width+',top='+winTop+',left='+winLeft+',scrollbars='+scroll+',resizable';
		win = window.open(URL, winName, winData);
		if (parseInt(navigator.appVersion) >= 4) { 
			win.window.focus(); 
		}
	}
}

JLE = {
	path:"/",
	myLike:function(id) {
		Today = new Date();
		Name = "Like_Emotion_IP_" + id + Today.getDate() + "_" + Today.getMonth() + "_" + Today.getYear();
		var NL = Jpv.gcookie(Name); 
		if(NL == null) {
			JAJAX.commit(JLE.path + "ajax.php?o=modules&n=emotions&f=emotions_like&idemotions=" + id, {'onComplete': JLE.complete});
		} else
			alert("Bạn đã click!");
	},
	voteILove:function(u, s) {
		JAJAX.commit(u, {'onComplete': JLE.complete});
	},
	photoLike:function(id, key) {
		Today = new Date();
		Name = "Photo_IP_" + id + "_" + key.substring(0, 5) + Today.getDate() + "_" + Today.getMonth() + "_" + Today.getYear();
		var NL = Jpv.gcookie(Name); 
		if(NL == null) {
			JAJAX.commit(JLE.path + "ajax.php?o=modules&n=photo&f=photo_like&idphoto=" + id + "&hkey=" + key, {'onComplete': JLE.complete});
		} else
			alert("Bạn đã click!");
	},
	complete:function(res) {
		var ss = res.split("#");
		if(ss[0] == 1) {
			alert(JSTR.replace(decodeURIComponent(ss[1]), "+", " "));
			Today = new Date();
			Name = "Like_Emotion_IP_" + ss[2] + Today.getDate() + "_" + Today.getMonth() + "_" + Today.getYear();
			Jpv.scookie(Name, 'true', '', '');
			window.location.href = window.location.href;
		} else 
		if(ss[0] == 5) {
			alert(JSTR.replace(decodeURIComponent(ss[1]), "+", " "));
			Today = new Date();
			Name = "Photo_IP_" + ss[2] + "_" + ss[3] + Today.getDate() + "_" + Today.getMonth() + "_" + Today.getYear();
			Jpv.scookie(Name, 'true', '', '');
			window.location.href = window.location.href;
		} else 
		if(ss[0] == 3) {
			alert(JSTR.replace(decodeURIComponent(ss[1]), "+", " "));
			window.location.href = window.location.href;
		} else {
			alert(JSTR.replace(decodeURIComponent(ss[1]), "+", " "));
		}
	}
}

JMPL = {
	path:"/",
	addlist:function(id) {
		JAJAX.commit(JMPL.path + "ajax.php?o=modules&n=playlist&f=playlist_cart&musicid=" + id, {'onComplete': JMPL.complete});
	},
	complete:function(res) {
		var ss = res.split("#");
		if(ss[0] == 1) {
			alert(JSTR.replace(decodeURIComponent(ss[1]), "+", " "));
			document.getElementById("numbermusicid").innerHTML = ss[2];
		} else
		if(ss[0] == 2) {
			alert(JSTR.replace(decodeURIComponent(ss[1]), "+", " "));
			window.location.href = ss[2];
		} else
		if(ss[0] == 3) {
			alert(JSTR.replace(decodeURIComponent(ss[1]), "+", " "));
			document.getElementById("createplaylistid").disabled = false;
		} else
			alert(JSTR.replace(decodeURIComponent(ss[1]), "+", " "));
	},
	find:function(o, v) {
		keyw = JSTR.replace(v, " ", "");
		if(keyw != "") {
			o.submit(); 
		}
	},
	move:function(id, v) {
		if(confirm(v))
			JAJAX.load(JMPL.path + "ajax.php?o=modules&n=playlist&f=playlistcart&cp=del&musicid=" + id, "buildlistmusic");
	},
	maxLength:function(o){  
		var maxLength = parseInt(o.getAttribute('maxlength'));  
		if(o.value.length > maxLength)
			o.value = o.value.substring(0, maxLength);  
		document.getElementById('ncharleft').innerHTML = maxLength - o.value.length;
	},
	create:function(o) {
		if(o.elements["playlistname"].value == "") {
			alert(o.elements["m_playlistname"].value + "!");
			o.elements["playlistname"].focus();
		} else
		if(o.elements["infoshare"].value == "") {
			alert(o.elements["m_infoshare"].value + "!");
			o.elements["infoshare"].focus();
		} else
		if(o.elements["numlistmusic"].value != 5) {
			alert(o.elements["m_numlistmusic"].value + "!");
		} else {
			JMPL.maxLength(o.elements["infoshare"]);
			o.elements['createplaylistid'].disabled = true;
			o.action = JMPL.path + 'ajax.php?o=modules&n=playlist&f=playlistsave&action=add';
			AIM.submit(o, {'onComplete': JMPL.complete});
			return true;
		}
		return false;
	}
}
