function toggleId(id){
	if (document.getElementById(id).style.display == 'none'){
		if (document.getElementById(id).tagName == 'TR' && !document.all){
			document.getElementById(id).style.display = "table-row";
		} else if ((navigator.userAgent.indexOf("Opera")!=-1 || navigator.userAgent.indexOf("Opera/")!=-1) && document.getElementById(id).tagName == 'TR') {
			document.getElementById(id).style.display = "table-row";
		} else {
			document.getElementById(id).style.display = 'block';
		}
	} else {
		document.getElementById(id).style.display = 'none';
	}
	return(false);
}

function checkNewalbum(ref){
	a = document.getElementById('newalbum');
	b = document.getElementById('newalbum_priv');
	if (a.style.display != 'none')
	{
		a.style.display = 'none';
		b.style.display = 'none';
	}
	if (ref.value == '0' && a.style.display == 'none')
	{
		toggleId('newalbum');
		toggleId('newalbum_priv');
	}
}

function addNewsize(nid){
	toggleId('link' + nid);
	toggleId('newsize' + nid);

	return false;
}

function showFrontLogin() {
	toggleId('front_loginbox');
	
	return false;
}

function pop(ref,w,h){
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;

	var page = ref;
	windowprops = "height="+h+",width="+w+",top="+ wint +",left="+ winl +",location=no,"
	+ "scrollbars=auto,menubars=no,toolbars=no,resizable=no,status=yes";
	popwin = window.open(page, "Popup", windowprops);
	if (window.focus) {popwin.focus()}
	return false;
}


// ask for user input and send it to given url
function prompt_and_get(prompt_text, default_text, goto_url){
	var answer=prompt(prompt_text, default_text);
	if(answer != undefined){
		window.location=goto_url + escape(trim(answer));
	}
}

function confirm_checkbox(ref, prompt_text) {
	if (ref.checked == true) {
		return confirm_link(prompt_text);
	}
	else {
		return true;
	}
}

function confirm_link(prompt_text) {
	if(!prompt_text) prompt_text="Are you sure?";
	var agree=confirm(prompt_text);
	if (agree)
		return true ;
	else
		return false ;
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

