// iTERRA 3.0 template JavaScript include: XHTML (c) 2007 by evanto media AG

function doEditor (xhtmlname) 
{
  if (document.getElementById)
  {
	dialog = document.getElementById(xhtmlname + "_editor");
	if (dialog)
	{  		
		defWidth = 650;
		defHeight = 500;
			
		dialog.style.width = defWidth + "px";
		dialog.style.height = defHeight  + "px";
		
		// IE
		if (document.documentElement.clientWidth && window.navigate)
		{
			// dialog.style.left = (window.event.clientX + document.documentElement.scrollLeft - defWidth) + "px";
			// dialog.style.top  = (window.event.clientY + document.documentElement.scrollTop - offsety) + "px";
			dialog.style.left = ((document.documentElement.clientWidth - defWidth) / 2) + "px";
			dialog.style.top  = ((document.documentElement.clientHeight - defHeight) / 2) + "px";
		}

		// Mozilla, Opera
		if (window.netscape)
		{
			dialog.style.left = ((window.innerWidth - defWidth) / 2) + "px";
			dialog.style.top  = ((window.innerHeight - defHeight) / 2) + "px";
		}
		
		dialog.style.display = ""; 
	}
	else
	  alert ("Editor Dialog not found!");
  }
  return false;
}

function closeEditor (xhtmlname) 
{
  if (document.getElementById)
  {
	dialog = document.getElementById(xhtmlname + "_editor");
	if (dialog)
	{  				
		dialog.style.display = "none"; 
	}
	else
	  alert ("Editor Dialog not found!");
  }
  return false;
}

function doUpload (xhtmlname) 
{
  if (document.getElementById)
  {
	dialog = document.getElementById(xhtmlname + "_upload");
	if (dialog)
	{  		
		defWidth = 650;
		defHeight = 250;
			
		dialog.style.width = defWidth + "px";
		dialog.style.height = defHeight  + "px";
		
		// IE
		if (document.documentElement.clientWidth && window.navigate)
		{
			dialog.style.left = ((document.documentElement.clientWidth - defWidth) / 2) + "px";
			dialog.style.top  = ((document.documentElement.clientHeight - defHeight) / 2) + "px";
		}

		// Mozilla, Opera
		if (window.netscape)
		{
			dialog.style.left = ((window.innerWidth - defWidth) / 2) + "px";
			dialog.style.top  = ((window.innerHeight - defHeight) / 2) + "px";
		}
		
		dialog.style.display = ""; 
	}
	else
	  alert ("Upload Dialog not found!");
  }
  return false;
}

function showImage (repid, width, height) 
{
  if (document.getElementById)
  {
	dialog = document.getElementById("large_image");
	if (dialog)
	{  		
		// repid = repid.replace(/´/g, "'");
		
		defWidth = width + 4; // frame
		defHeight = height + 26; // frame + header
			
		dialog.style.width = defWidth + "px";
		dialog.style.height = defHeight  + "px";
		
		// IE
		if (document.documentElement.clientWidth && window.navigate)
		{
			dialog.style.left = ((document.documentElement.clientWidth - defWidth) / 2) + "px";
			dialog.style.top  = ((document.documentElement.clientHeight - defHeight) / 2) + "px";
		}

		// Mozilla, Opera
		if (window.netscape)
		{
			dialog.style.left = ((window.innerWidth - defWidth) / 2) + "px";
			dialog.style.top  = ((window.innerHeight - defHeight) / 2) + "px";
		}
		
		img = document.getElementById("large_image_src");
		if (img)
		{  		
			img.src = "/ps/ps.dll/repository?rid=" + repid;
		}
		else
			alert ("Image Dialog Source Image not found!");

		// show dialog
		dialog.style.display = ""; 
	}
	else
	  alert ("Image Dialog not found!");
  }
  return false;
}

function closeUpload (xhtmlname) 
{
  if (document.getElementById)
  {
	dialog = document.getElementById(xhtmlname + "_upload");
	if (dialog)
	{  				
		dialog.style.display = "none"; 

		img = document.getElementById("large_image_src");
		if (img)
		{  		
			img.src = "/images/spacer.gif";
		}
		else
			alert ("Image Dialog Source Image not found!");
	}
	else
	  alert ("Upload Dialog not found!");
  }
  return false;
}

function closeImage () 
{
  if (document.getElementById)
  {
	dialog = document.getElementById("large_image");
	if (dialog)
	{  				
		img = document.getElementById("large_image_src");
		if (img)
		{  		
			img.src = "/images/spacer.gif";
		}
		else
			alert ("Image Dialog Source Image not found!");

		dialog.style.display = "none"; 
	}
	else
	  alert ("Image Dialog not found!");
  }
  return false;
}

function showDiv (divname) 
{
  if (document.getElementById)
  {
	div = document.getElementById(divname);
	if (div)
	{  			
		if (div.style.display == "none") 
		{
			div.style.display = "block"; 
		}
		else
			div.style.display = "none"; 
	}
	else
	  alert ("DIV container " + divname + " not found!");
  }
  return false;
}

function WaitOn()
{
	bodyPage.style.cursor="wait"; 
	
	return true;
}
