

var HTTPReq = null;

function GetXmlHttpObject(handler)
{ 
  var objXMLHttp=null;
  if (window.XMLHttpRequest)
  {
    objXMLHttp=new XMLHttpRequest();
  }
  else if (window.ActiveXObject)
  {
    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  return objXMLHttp;
}



function HideErrorBox()
{
	var dErrorBox = document.getElementById('dErrorBox');
	if (dErrorBox)
		dErrorBox.style.left = -1000 + 'px';
	else
		alert('Oh Crap');
}

function moveMenu(iLeft,iTop,iComponent,iPage,strFGColor,strBGColor,bRoundedCorners,bAutoScale,OtherOptions,bChild)
{

/*
	$strActionMenu .= "<a href=\"" . $PHPSELF . "?move=yes&amp;component=" . $arrayGetModules['componentid'] ."\">Move</a><br />";
	$strActionMenu .= "<a href=\"" . $PHPSELF . "?kill=yes&amp;component=" . $arrayGetModules['componentid'] ."\">Delete Component</a><br />";
	$strActionMenu .= "<a href=\"" . $PHPSELF . "?color=yes&amp;component=" . $arrayGetModules['componentid'] . "\">Border</a><br />";
	$strActionMenu .= "<a href=\"" . $PHPSELF . "?color=bg&amp;component=" . $arrayGetModules['componentid'] . "&amp;detail=" . $arrayGetModules['bgcolor'] . "\">Background</a><br />";
	$strActionMenu .= "<a href=\"" . $PHPSELF . "?color=fg&amp;component=" . $arrayGetModules['componentid'] . "&amp;detail=" . $arrayGetModules['fgcolor'] . "\">ForeGround</a><br />";
*/
	var componentEditBox = document.getElementById('ComponentEditBox');
	if (componentEditBox)
	{
		strMenu = iComponent + " (<a href=\"javascript:hideMenu()\"  >close</a>)<br /><br /><ul>";
		if (bChild == 0)
		{
		strMenu = strMenu +  
			   "<li><a href=\"index.php?page=" + iPage + "&amp;kill=yes&amp;component=" + iComponent + "\">Delete Component</a></li>";
		}
	
		strMenu = strMenu + "<li><a href=\"index.php?page=" + iPage + "&amp;color=yes&amp;component=" + iComponent + "\">Border</a></li>" +
			  "<li><a href=\"index.php?page=" + iPage + "&amp;color=bg&amp;component=" + iComponent + "&amp;detail=" + strBGColor +  "\">Background</a></li>" +
			  "<li><a href=\"index.php?page=" + iPage + "&amp;color=fg&amp;component=" +iComponent + "&amp;detail=" + strFGColor + "\">ForeGround</a></li>"; 

		if (bRoundedCorners == 1)
		{
			strMenu = strMenu + "<li><a href=\"index.php?page=" + iPage + "&amp;autoscale=no&amp;component=" + iComponent +  "\">Disable Auto Scale</a></li>";
		}
		else
		{
			strMenu = strMenu + "<li><a href=\"index.php?page=" + iPage + "&amp;autoscale=yes&amp;component="  + iComponent + "\">Enable Auto Scale</a></li>";
		}

		if (bAutoScale == 1)
		{
			strMenu = strMenu + "<li><a href=\"index.php?page=" + iPage + "&amp;roundedcorners=0&amp;component=" + iComponent + "\">Disable Rounded Corners</a></li>";
			strMenu = strMenu + "<li><a href=\"index.php?page=" + iPage + "&amp;modifycorners=1&amp;component=" + iComponent + "\">Choose Rounded Corners</a></li>";
		}
		else
		{
			strMenu = strMenu + "<li><a href=\"index.php?page=" + iPage + "&amp;roundedcorners=1&amp;component=" +iComponent + "\">Enable Rounded Corners</a></li>" +
			  "<li><a href=\"index.php?page=" + iPage + "&amp;cmpimg=upload&amp;component=" +iComponent + "\">Background Image</a></li>";
		}

		strMenu = strMenu + "<li><a href=\"index.php?page=" + iPage + "&amp;displaycomponent=" + iComponent + "\" >Display Component Details</a></li>";

		strMenu = strMenu + OtherOptions;

		strMenu = strMenu + "</ul>";
		componentEditBox.innerHTML = strMenu;

		if (bChild == 0)
		{
			componentEditBox.style.left = iLeft + "px";
			componentEditBox.style.top = iTop + "px";
		}
		else
		{
		}
		
	}
}

function mouseUpMenu(evt)
{
	var componentEditBox = document.getElementById('ComponentEditBox');
	var iLeft = -1000;
	var iTop = -1000;
	var iOffsetX;
	var iOffsetY;

	if (document.all)
	{
	        iOffsetX = document.documentElement.scrollLeft;
        	iOffsetY = document.documentElement.scrollTop;


		iLeft = 10 + iOffsetX;
		iTop = 80 + iOffsetY; 


	}
	else
	{
	        iOffsetX = window.pageXOffset;
        	iOffsetY = window.pageYOffset;

		iLeft = evt.clientX - 100 + iOffsetX;
		iTop = evt.clientY + 10 + iOffsetY;


	}

	if (componentEditBox)
	{
		componentEditBox.style.left = iLeft + 'px';
		componentEditBox.style.top = iTop + 'px';
	}
	document.onmouseup = null;

	
}

function prepUpMenu(bEdit)
{
	if (bEdit == 0)
	{
		document.onmouseup = mouseUpMenu;
		//;alert('BEEEEEEEEEEP');
	}
}

function clearUpMenu(bEdit)
{
	if (bEdit == 0)
	{
		document.onmouseup = null;
	}
}
	
function hideMenu()
{
	var componentEditBox = document.getElementById('ComponentEditBox');
	if (componentEditBox)
	{
		componentEditBox.style.left = "-10000px";
		componentEditBox.style.top = "-10000px";
	}
}

function showhtml(idtag)
{
	htmlbox = document.getElementById(idtag);
	if (htmlbox.style.visibility=='hidden')
	{
		htmlbox.style.width='250px';
		htmlbox.style.height='150px';
		htmlbox.style.visibility='visible';
	}
	else
	{
		htmlbox.style.width='0px';
		htmlbox.style.height='0px';
		htmlbox.style.visibility='hidden';

	}
}

function toggleAltMenu(strAltMenu)
{
	var AltMenu = document.getElementById('AltMenu');
	var SubMenu = document.getElementById(strAltMenu);

	var Items = new Array(2);

	Items[0] = "Navigation";
	Items[1] = "AltBrowse";

	if (AltMenu)
	{

		//is SubMenu visible?  if it is not, then hide all of the children of the AltMenu's list items
		if (SubMenu && SubMenu.style.visibility == 'hidden')
		{
			var i =0;
			for (i = 0; i < Items.length; i++)
			{
				Item = document.getElementById(Items[i]);
				if (Item)
				{
					Item.style.visibility = 'hidden';
					Item.style.width = '0px';
				}
			}
			AltMenu.style.visibility = 'hidden';

		}

		if (AltMenu.style.visibility == 'hidden')
		{
			AltMenu.style.visibility = 'visible';
			//Now Get the right menu and display
			if (SubMenu)
			{
				SubMenu.style.width = '680px';
				SubMenu.style.visibility = 'visible';
			}
			
		}
		else
		{
			AltMenu.style.visibility = 'hidden';
			if (SubMenu)
			{
				SubMenu.style.width = '0px';
				SubMenu.style.visibility = 'hidden';
			}
		}
	}
}


function ExpandPhoto(strImage,iWidth,iHeight,iLeft,iTop)
{
	
	//Time to Hack the Function and get the correct iWidth/iHeight of the image
	var imgImage = new Image();
	imgImage.src = strImage;
	if (imgImage.complete)
	{
		iWidth = imgImage.width;
		iHeight = imgImage.height;
	}


	//photobox.style.left = "1px";
	//photobox.style.top = "1px";

	//Check for Safari as a Browser
	/*
	if(!document.all)
	{
		photobox.className = "TB_overlayMacFFBGHack";//use png overlay so hide flash
	}	
	*/
	//imagebox.style.top = "1px";
	//imagebox.style.left = "1px";
	//imagebox.innerHTML="<a href=\"javascript:HidePhoto()\"><img src=\"" + strImage + "\" style=\"height:" + iHeight + "px;width:" + iWidth +  "px;margin-right:auto;margin-left:auto;display:block;margin-top:" + iTop + "px;\" /></a>";

	var imageBackground = document.getElementById('lightbox');
	var imageImage = document.getElementById('photobookimage');

	
	if (imageBackground)
	{
		var iWindowHeight,iWindowWidth,iOffSetX,iOffSetY;
		if (parseInt(navigator.appVersion)>3) 
		{
			/*
			if (navigator.appName=="Netscape") 
			{
				iWindowWidth = window.innerWidth;
				iWindowHeight = window.innerHeight;
		        	iOffSetX = window.pageXOffset;
        			iOffSetY = window.pageYOffset;

			}*/
				
			if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.appName.indexOf("8") == -1)  //For Microsoft Browsers before IE 8
			{
				iWindowWidth = document.body.offsetWidth;
				iWindowHeight = document.documentElement.clientHeight;
				iOffSetX = document.documentElement.scrollLeft;
        			iOffSetY = document.documentElement.scrollTop;				
			}
			else  //assume that the Browser Does Not Suck - Firefox, Opera, Safari, Chrome.......
			{
				iWindowWidth = window.innerWidth;
				iWindowHeight = window.innerHeight;
		        	iOffSetX = window.pageXOffset;
        			iOffSetY = window.pageYOffset;
			}
		}
		iWindowWidth = iWindowWidth - 3;
		iWindowHeight = iWindowHeight - 3;
		

	
		imageBackground.style.visibility = 'visible';
		imageBackground.style.height='7000px';
	

		//we need to make this thing the size of the client window
	}
	if (imageImage)
	{
		imageImage.style.height = iHeight + 'px';
		imageImage.style.width = iWidth + 'px';
		imageImage.src = strImage;
		imageImage.style.left = (iWindowWidth/2 - (iWidth / 2)) + iOffSetX + 'px';
		imageImage.style.top = (iWindowHeight/2 - (iHeight / 2)) + iOffSetY + 'px';
	}
}

function HidePhoto()
{
	

	var imageBackground = document.getElementById('lightbox');
	var imageImage = document.getElementById('photobookimage');
	
	
	if (imageBackground)
	{
		imageBackground.style.visibility = 'hidden';
		imageBackground.style.height='0px';
	}
	if (imageImage)
	{
		imageImage.style.height = 0 + 'px';
		imageImage.style.width = 0 + 'px';
		imageImage.style.top = -100 + 'px';
		imageImage.style.left = -100 + 'px';
	}

}	

function tb_detectMacXFF() 
{
	var userAgent = navigator.userAgent.toLowerCase();
	if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) 
	{
		return true;
	}
}

function bookmark(site)
{
	switch( site )
	{
		case "stumbleupon": 
			window.open("http://www.stumbleupon.com/submit?url=" + document.location.href + "&title=" + escape(document.title)); 
			return;
		case "digg": 
			window.open("http://digg.com/submit?phase=2&url=" + document.location.href + "&title=" + escape(document.title)); 
			return;
		case "delicious": 
			window.open("http://del.icio.us/post?url=" + document.location.href + "&title=" + escape(document.title)); 
			return;
		case "facebook": 
			window.open("http://www.facebook.com/sharer.php?u=" + document.location.href); 
			return;
		case "reddit": 
			window.open("http://reddit.com/submit?url=" + document.location.href + "&title=" + escape(document.title)); 
			return;
		case "newsvine": 
			window.open("http://www.newsvine.com/_wine/save?u=" + document.location.href); 
			return;	
		case "fark": 
			window.open("http://cgi.fark.com/cgi/fark/farkit.pl?h=" + escape(document.title) + "&u=" + document.location.href); 
			return;
		case "google": 
			window.open("http://www.google.com/bookmarks/mark?op=edit&bkmk=" + document.location.href + "&title=" + escape(document.title)); 
			return;
	}
}

