$(document).ready(function() {
	$("#searchinput").focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';
		}
	});
	
	$("#login-user").focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';
		}
	});
	
	$("#login-pwd").focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';
		}
	});
	
	$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
	
	$("#latest-albums").hide();
	$("#latest-news").hide();
	
	$("a.latesttab").click(function() {
		$(".selected").removeClass("selected");
		$(this).addClass("selected");
		$(".latest-content").hide();
		$(this).blur();
		
		var tab_show = $(this).attr("rel");
		$("#"+tab_show).show();
		
		return false;
	});
});

function popUp(url, size_w, size_h) {
	var winpops = window.open(url, "", "width=" + size_w + ", height=" + size_h + ",scrollbars=yes", 0);
}

function getObject(obj) {
	var theObj;
	
	if (document.all) {
		if (typeof obj=="string") {
			return document.all(obj);
		} else {
			return obj.style;
		}
	}
	
	if (document.getElementById) {
		if (typeof obj=="string") {
			return document.getElementById(obj);
		} else {
			return obj.style;
		}
	}
	
	return null;
}

function countChars(entrance, exit, text, characters) {
	var entranceObj = getObject(entrance);
	var exitObj = getObject(exit);
	var length = characters - entranceObj.value.length;
	
	if (length <= 0) {
		length = 0;
		text = '<span class="disable">' + text + '</span>';
		entranceObj.value = entranceObj.value.substr(0,characters);
	}
	
	exitObj.innerHTML = text.replace("{CHAR}", length);
}
