// JavaScript Document

function toggle_content_input(id,type,hide)  {
	
	elem=id+'.'+type;
	vanish=id+'.'+hide;
	enter=id+'.submit';
    document.getElementById(vanish).style.display="none";
	document.getElementById(elem).style.display="block";
	document.getElementById(enter).style.display="block";
}

function toggle_wrappable(avail) {
	set_wrappable();
	document.getElementById(avail).disabled=false;
	if(document.getElementById(avail).checked==false)
	  reset_wrappable();
}

function deleted(url,desc)
{
  var answer = confirm("Are you sure that you want to completely remove this "+desc+"?")
	if (answer)
	  window.location = url;
	else return true;
}

function remove_block(url)
{
	window.location = url;
	return true; 
}

function set_wrappable() {
	var dynamic=0;
	for(y=0;y<document.forms['update_format'].elements.length;y++) {
	  if(document.getElementById('wrap_'+ dynamic)) {
	    document.getElementById('wrap_'+ dynamic).disabled=true;
		dynamic++;
	  }
	}
}

function reset_wrappable() {
	var dynamic=0;
	for(y=0;y<document.forms['update_format'].elements.length;y++) {
	  if(document.getElementById('wrap_'+ dynamic)) {
	    document.getElementById('wrap_'+ dynamic).disabled=false;
		dynamic++;
	  }
	}
}



function create_link() {
	the_title=document.getElementById('link_title').value;
	the_link=document.getElementById('link_page').value;
	document.getElementById('link_display').value='<a href="' + the_link + '" title="' + the_title + '">' + the_title + '</a>';
	document.getElementById('link_copy').style.visibility="visible";
}

function loadCategories(value) {
	current_href=location.href.split('&');
	if(current_href.length==1) args='&site=' + value;
	if(current_href.length>1)  { 
	  args = '&' + current_href[1] + '.' + value;
	  //else 
	}
	
	//alert(current_href[0] + args);
    window.location=current_href[0] + args;
 
}


function loadEditPage(value) {
	current_href=location.href.split('&');
	if(current_href.length==2) args='&' + current_href[1] + '&site=' + value;
	if(current_href.length>2)  { 
	  args = '&' + current_href[1] + '&' + current_href[2] + '.' + value;
	  //else 
	}
	window.location=current_href[0] + args;
	
	//alert(current_href[0] + args); 
}

function deletePage(id)
{
  var answer = confirm("Are you sure that you want to completely remove the page: "+id+"?")
	if (answer) {
	   document.getElementById('1').value=id;
	   document.forms[0].submit();
	}	 
}

