var _posf = 1;
var _pos = 1;
var sedanganimasi = false;
function focusloginarea(c, b, a) {
	$.scrollTo("#logusr", "slow", {
		easing: "swing"
	});
	$("#logusr").expose({
		closeOnClick: true,
		opacity: 0.75,
		loadSpeed: "fast"
	});
	$("#Login").focus()
}
$(function () {
	var konami = "38,38,40,40,37,39,37,39,66,65".split(',');
	var keyIndex = 0;
	$(document).keydown(function(ev) { (konami[keyIndex] == ev.keyCode) ? keyIndex++:keyIndex = 0;
		if (keyIndex == konami.length) {
			if ($("#konami").length == 0) {
				$("body").prepend ('<div id="konamicode"><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/J---aiyznGQ&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/J---aiyznGQ&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385" wmode="transparent"></embed></object></div>');
				$("#konamicode").fancybox({ 'width': 480, 'height': 385, 'overlayColor': '#000000', 'overlayOpacity': 0.75, 'onClosed': function () { $('#konamicode').hide (); } });
				$("#konamicode").trigger('click');
			}
			keyIndex = 0;
		}
	});
	
	$("#menu").lavaLamp({
		fx: "swing",
		speed: 500
	});
	$("#favgal a").tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fade: 150,
		bodyHandler: function () {
			return '<div class="ptt"><p><img src="' + this.href + '" alt="" /></p><p>' + this.tooltipText + "</p></div>"
		}
	});
	$("#favvid a").tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fade: 150,
		bodyHandler: function () {
			return '<div class="ptt vidl"><p><span class="ply"></span><img src="' + this.href + '" alt="" /></p><p>' + this.tooltipText + "</p></div>"
		}
	});
	$("#flshnws .paging .flshnum").empty();
	$(".numprop .pegprop").empty();
	$(".vidxxl img").before('<span class="ply"></span>');
	$(".vidxl img").before('<span class="ply"></span>');
	$(".vidl img").before('<span class="ply"></span>');
	$(".vidxm img").before('<span class="ply"></span>');
	$(".vidm img").before('<span class="ply"></span>');
	$(".vids img").before('<span class="ply"></span>');
	$(".pegprop").click(function () {
		if (sedanganimasi == false) {
			_pos = $(this).hasClass(".p1") ? 1 : $(this).hasClass(".p2") ? 2 : $(this).hasClass(".p3") ? 3 : $(this).hasClass(".p4") ? 4 : $(this).hasClass(".p5") ? 5 : 0;
			_pos--;
			if (_pos < 0) {
				_pos = 5
			}
			sedanganimasi = true
		}
		return false
	});
	$(".flshnum").click(function () {
		if (sedanganimasi == false) {
			_posf = $(this).hasClass(".f1") ? 1 : $(this).hasClass(".f2") ? 2 : $(this).hasClass(".f3") ? 3 : $(this).hasClass(".f4") ? 4 : $(this).hasClass(".f5") ? 5 : 0;
			_posf--;
			if (_posf < 0) {
				_posf = 5
			}
			sedanganimasi = true
		}
		return false
	});
	$("#showemo").click(function () {
		$(".emoticons").slideToggle("fast");
		return false
	});
	$("#btnkirim").click(function () {
		$.prompt("Anda harus login untuk mengirim " + $(this).attr("rel"), {
			callback: focusloginarea
		});
		return false
	});
	$("#bbbukakomen a").click(function () {
		$.prompt("Anda harus login untuk memberikan komentar", {
			callback: focusloginarea
		});
		return false
	});
	$("a.#bbjualbeli").click(function () {
		$.prompt("Anda harus login untuk mengisi artikel jual beli", {
			callback: focusloginarea
		});
		return false
	});
	$("a.#bbkirimdirektori").click(function () {
		$.prompt("Anda harus login untuk mengisi artikel direktori", {
			callback: focusloginarea
		});
		return false
	});
	$("a.#bbkirimfoto").click(function () {
		$.prompt("Anda harus login untuk mengirim foto", {
			callback: focusloginarea
		});
		return false
	});
	$("a.#kirimfotofra").click(function () {
		$.prompt("Anda harus login untuk mengirim foto", {
			callback: focusloginarea
		});
		return false
	});
	$("#bukakomen a").click(function () {
		$("#isikomen").slideDown("fast");
		$("#bukakomen").slideUp("fast");
		return false
	});
	$("#bukakomslide a").click(function () {
		$("#komslide").slideDown("slow");
		$("#komstatss").slideUp("fast");
		return false
	});
	if ($("#terekspos").length) {
		$("#terekspos").expose({
			closeOnClick: false,
			opacity: 0.75
		});
		$("#terekspos input:text:first:visible").focus();
		$.scrollTo("#terekspos", 1000, {
			easing: "swing"
		})
	}
	/*
	$("#forumdetail .message").each(function() {
		var $this = $(this);
		var t = $this.html();
		t = t.replace(/\s+&lt;/gi,"<");
		t = t.replace(/\s+&gt;/gi,">");
		$this.html(t);
	});
	*/
	$(":text").addClass("text");
	$(":password").addClass("text");
	$(":radio").addClass("radio");
	$(":checkbox").addClass("checkbox");
	$(":image").addClass("image");
	$(":submit").addClass("button submit");
	$(":reset").addClass("button reset");
	$(":button").addClass("button");
	$(":file").addClass("file");
	$("select option:visible:even").addClass("even");
	$("ul#searchul li:visible:even").addClass("even");
	$(".detpan div").append('<p class="clr"></p>');
	$(".detpan div:visible:even").addClass("even");
	$(".jblist ul li:visible:even").addClass("even");
	$(".items .item:visible:odd").addClass("even");
	$(".items .item:visible:first").addClass("first");
	$(".tabbing").corners("transparent");
	$(".flshcrsl").jCarouselLite({
		speed: 500,
		auto: 10000,
		easing: "swing",
		btnGo: [".paging .f1", ".paging .f2", ".paging .f3", ".paging .f4", ".paging .f5"],
		mouseWheel: false,
		afterEnd: function (c) {
			sedanganimasi = false;
			_posf++;
			if (_posf > 5) {
				_posf = 1
			}
			$(".flshnum").removeClass("cur");
			$(".f" + _posf).addClass("cur")
		}
	});
	if ($(".flshcrsldir ul > li").length > 0) {
		$(".flshcrsldir").jCarouselLite({
			speed: 500,
			auto: 10000,
			easing: "expoinout",
			vertical: true,
			btnGo: [".page .f1", ".page .f2", ".page .f3", ".page .f4", ".page .f5"],
			mouseWheel: false,
			afterEnd: function (c) {
				sedanganimasi = false;
				_posf++;
				if (_posf > 5) {
					_posf = 1
				}
				$(".flshnum").removeClass("cur");
				$(".f" + _posf).addClass("cur")
			}
		})
	}
	$(".propcarusel").jCarouselLite({
		visible: 2,
		scroll: 2,
		auto: 10000,
		speed: 500,
		easing: "swing",
		btnGo: [".num .p1", ".num .p1", ".num .p2", ".num .p1", ".num .p3", ".num .p1", ".num .p4", ".num .p1", ".num .p5"],
		mouseWheel: false,
		afterEnd: function (c) {
			sedanganimasi = false;
			_pos++;
			if (_pos > 5) {
				_pos = 1
			}
			$(".pegprop").removeClass("cur");
			$(".p" + _pos).addClass("cur")
		}
	});
	$(".carusel").jCarouselLite({
		btnNext: ".gnext",
		btnPrev: ".gprev",
		visible: 4,
		scroll: 4,
		speed: 500,
		easing: "swing",
		circular: false
	});
	$(".carusel2").jCarouselLite({
		btnNext: ".gnext2",
		btnPrev: ".gprev2",
		visible: 4,
		scroll: 1,
		speed: 150,
		easing: "swing",
		circular: false
	});
	if ($(".caruseldet ul > li").length > 4) {
		$(".caruseldet").jCarouselLite({
			btnNext: ".gnext",
			btnPrev: ".gprev",
			visible: 4,
			scroll: 1,
			speed: 150,
			easing: "swing"
		})
	} else { if ($(".caruseldet").length > 0) {
			$(".gnext").hide();
			$(".gprev img").hide()
		}
	}
	$(".listtwocdir").jCarouselLite({
		btnNext: ".dnext",
		btnPrev: ".dprev",
		visible: 2,
		auto: 10000,
		easing: "backinout"
	});
	/**$(".listtwocforum").jCarouselLite({
		auto: 0,
		vertical: true,
		easing: "backinout"
	});
	$(".listtwocblog").jCarouselLite({
		auto: 0,
		vertical: true,
		easing: "backinout"
	});*/
	$(".listtwocbloglist").jCarouselLite({
		visible: 1,
		auto: 10000,
		vertical: true,
		easing: "backinout"
	});
	$(".listkom").jCarouselLite({
		auto: 10000,
		vertical: false,
		easing: "backinout"
	});
	$(".konslist").jCarouselLite({
		auto: 10000,
		easing: "backinout"
	});
	$('#slide').tabs({ fxSlide: true, fxAutoHeight: true, fxFade: true, fxSpeed: 'fast', setTimeout: 100 });
	if ($(".listdir ul > li").length > 2) {
		$(".listdir").jCarouselLite({
			btnNext: ".dsnext",
			btnPrev: ".dsprev",
			visible: 2,
			auto: 10000,
			easing: "backinout",
			circular: false
		})
	} else { if ($(".listdir").length > 0) {
			$(".dsnext img").hide();
			$(".dsprev img").hide()
		}
	}
	$("#exposeMask").everyTime(1000, function () {
		$(this).height($(document).height())
	});
	if ($('#komslide').length) {
		$("#komslide .det:contains('(mario)')").each(function () { $(this).html($(this).html().replace(/\(mario\)/g, '<img alt="Mario" src="http://i28.tinypic.com/33eljwh.png" width="" height="16"/>')) }); $("#komslide .det:contains('(luigi)')").each(function () { $(this).html($(this).html().replace(/\(luigi\)/g, '<img alt="Mario" src="http://i36.tinypic.com/2w4a712.jpg" width="" height="16"/>')) }); $("#komslide .det:contains('(yoshi)')").each(function () { $(this).html($(this).html().replace(/\(yoshi\)/g, '<img alt="Mario" src="http://i34.tinypic.com/25sv7sj.jpg" width="" height="16"/>')) }); $("#komslide .det:contains('(headspin)')").each(function () { $(this).html($(this).html().replace(/\(headspin\)/g, '<img alt="Head Spin" src="http://statics.plurk.com/b0b0596acce9ffc1f2a27548aa642eaf.gif" width="" height="16"/>')) }); $("#komslide .det:contains('(rock)')").each(function () { $(this).html($(this).html().replace(/\(rock\)/g, '<img alt="Rock" src="http://statics.plurk.com/1c890273544559b17f090d09238fa763.gif" width="" height="16"/>')) });
	}
	for (var g = document.embeds, f = 0, e; e = g[f]; f++) {
		e.setAttribute("wmode", "transparent");
		var a = e.nextSibling,
		b = e.parentNode;
		b.removeChild(e);
		b.insertBefore(e, a)
	}
});
function emoticon(c) {
	var a = document.komentar.comment_content;
	c = " " + c + " ";
	if (a.createTextRange && a.caretPos) {
		var b = a.caretPos;
		b.text = b.text.charAt(b.text.length - 1) == " " ? b.text + c + " " : b.text + c;
		a.focus();
		focusobject = a
	} else {
		a.value += c;
		a.focus();
		focusobject = a
	}
	return false
}
function replyquote(b) {
	$.scrollTo("#replyarea", "slow", {
		easing: "swing"
	});
	$("#replyarea").focus();
	$("#replyarea").text($(b + " .usr .usr").text() + ":\r<blockquote>\r" + $(b + " .message").html() + "\r</blockquote>\r\r");
	$("#replyarea").scrollTop(999999);
	return false
}
function fbs_click() {
	u = location.href;
	t = document.title;
	window.open("http://www.facebook.com/sharer.php?u=" + encodeURIComponent(u) + "&t=" + encodeURIComponent(t), "sharer", "toolbar=0,status=0,width=626,height=436");
	return false
} (function (b) {
	b(document).ready(function () {
		b(".styleswitch").click(function () {
			a(this.getAttribute("rel"));
			return false
		});
		var c = readCookie("style");
		if (c == null) {
			c = "2001";
			createCookie("style", c, 365)
		}
		if (c) {
			a(c)
		}
	});
	function a(c) {
		b("link[@rel*=style][title]").each(function (d) {
			this.disabled = true;
			if (this.getAttribute("title") == c) {
				this.disabled = false
			}
		});
		createCookie("style", c, 365)
	}
})(jQuery);
function createCookie(a, b, c) {
	if (c) {
		var e = new Date();
		e.setTime(e.getTime() + (c * 24 * 60 * 60 * 1000));
		var d = "; expires=" + e.toGMTString()
	} else {
		var d = ""
	}
	document.cookie = a + "=" + b + d + "; path=/"
}
function readCookie(f) {
	var b = f + "=";
	var e = document.cookie.split(";");
	for (var a = 0; a < e.length; a++) {
		var d = e[a];
		while (d.charAt(0) == " ") {
			d = d.substring(1, d.length)
		}
		if (d.indexOf(b) == 0) {
			return d.substring(b.length, d.length)
		}
	}
	return null
}
function eraseCookie(a) {
	createCookie(a, "", -1)
}
function text_counter(a, b, c) {
	if (a.value.length > c) {
		a.value = a.value.substring(0, c)
	} else {
		b.value = c - a.value.length
	}
}
function ajax_req(b, a, c) {
	ajax_loading(c);
	$("#" + a).load(b);
	return null
}
function ajax_loading(a) {
	$("#" + a).ajaxSend(function () {
		$(this).show()
	});
	$("#" + a).ajaxStop(function () {
		$(this).hide()
	})
}
function search_property(c) {
	var d = $("#selprop select");
	var a = new Array("type", "location", "price", "lot", "footage");
	var b = "/(search)/true/";
	d.each(function (e, f) {
		b += "(" + a[e] + ")/" + $(f).val() + "/"
	});
	window.location = c + b
};
