function changeFontSize(inc)
{
	var p = document.getElementsByTagName('p');
	for(n=0; n<p.length; n++) 
	{
		if (inc != 0)
		{
			if(p[n].style.fontSize) 
			{
				var size = parseInt(p[n].style.fontSize.replace("px", ""));
			} 
			else 
			{
				var size = 12;
			}
			p[n].style.fontSize = size+inc + 'px';
		}
		else
			p[n].style.fontSize = '11px';
	}
}

function initialize() 
{
	dhtmlHistory.initialize(); 
	dhtmlHistory.addListener(historyChange);
	
	if (dhtmlHistory.isFirstLoad()) 
	{
		//dhtmlHistory.add("view:" + id, "Hello World Data");
		//dhtmlHistory.add("view:" + id, id);
		if (historyStorage.get("html") != null)
		{
			//alert("IT IS : " + historyStorage.get("html"));
			show(0, historyStorage.get("html"), 0, 'asc', 'name');
		}
		else
			historyChange;
	}	
	else
		show(0, historyStorage.get("html"), 0, 'asc', 'name');
}

function historyChange(newLocation, historyData) 
{
	//alert();
	if (historyData != null)
		show(0, historyData, 0, 'asc', 'name');
	else 
		if (historyStorage.get("html") != null)
			show(0, historyStorage.get("html"), 0, 'asc', 'name');
		//else
			//show('a');
	//debug("A history change has occurred: " + "newLocation="+newLocation + ", historyData="+historyData, true);
}

var xmlHttp;
var content;
var cnt = 0;
var listFile = "";
var nimage = "";

function show(x, id, maxx, s, sfield)
{
	try
	{
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	  // Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}

		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	if (s == "")
		s = "ASC";
	
	if (sfield == "")
		sfield = "name";
		
	content = "";
	url = "listInventories.php";
	url = url + "?sect_id=" +  id;
	url = url + "&k=" + x;
	url = url + "&max=" + maxx;
	url = url + "&sort=" + s;
	url = url + "&sfield=" + sfield;
	//var ds2 = new Spry.Data.HTMLDataSet(url, "listTable", {firstRowAsHeaders:false});
	
	//section_id = id;

	if (x != 'a')
	{
		xmlHttp.onreadystatechange = state_Change;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	else
		document.getElementById("dva").style.display = ''; 

	if (x == 'a')
	{
		//mainfadeIn.start();
		//floorfade.start();
		//document.getElementById("dva").style.display = ''; 
		//document.getElementById('floor_plan').innerHTML =  '<img src="ADMIN/uploads/' + osection + '/' + oimage + '" width="' + 701 + '" height="'+ 320 +'" border="0" />';
		//document.getElementById('floor_plan').style.border ='#000000 1px solid';
		//document.getElementById("dv").style.display = 'none'; 
		window.location.href = 'index.php?camp_id=' + camp_id;
	}
	else
	{
		// dhtmlHistory.add("view:" + id, id);
		document.getElementById("dva").style.display = 'none';
		document.getElementById("breadcrumbs").innerHTML = '';
		document.getElementById('bcline').style.display = 'none';
		document.getElementById("dv").style.display = ''; 
		//document.getElementById("dv").innerHTML = 'test' + x + document.getElementById('dum').value;
	}
}

function state_Change()
{
	if (xmlHttp.readyState==4)
	{// 4 = "loaded"
		if (xmlHttp.status==200)
		{// 200 = "OK"
			//document.getElementById('dum').value = xmlHttp.responseText; //getAllResponseHeaders();
			//doit();
			
			document.getElementById('dv').innerHTML = xmlHttp.responseText; //getAllResponseHeaders();
			jQuery(document).ready(function($) 
			{
				$('a[rel*=facebox]').facebox()
			});
			document.getElementById('load').style.display = 'none';
			document.getElementById('load').innerHTML = "";
			
			
			if (document.getElementById('txtact').value)
			{
				var section = document.getElementById('txtsection').value; //var -> Block Microsoft IE's stupidity
				nimage = document.getElementById('txtimage').value;
				var height = 320; //document.getElementById('txtheight').value;
				//floorfade.start();
				//document.getElementById("floor_plan").innerHTML = '<img src="ADMIN/uploads/maps/' + section + '/' + nimage + '" width="' + 701 + '" height="'+ 320 +'" border="0" />';
				document.getElementById('breadcrumbs').innerHTML = document.getElementById('bc').value;
				document.getElementById('bcline').style.display = '';
				//document.getElementById('floor_plan').style.border = '#000000 1px solid';
			}
			else
			{
				//floorfade.start();
				//document.getElementById('floor_plan').innerHTML =  '<img src="ADMIN/uploads/' + osection + '/' + oimage + '" width="' + 701 + '" height="'+ 320 +'" border="0" />';
				//document.getElementById('floor_plan').style.border ='#000000 1px solid';
			}
		}
		else
		{
			alert("Problem retrieving data:" + xmlHttp.statusText);
		}
	}
	else
	{
		//document.getElementById('dv').innerHTML = "Loading...";
		document.getElementById('load').style.display = '';
		document.getElementById('load').innerHTML = "<img src='/images/ajax-loader.gif' width='25' border='0' alt='Loading...'>";
	}
}	


function switchTab(obj)
{
	
	fadeIn.start();
	//floorfade.start();
	//mouseOut();
	//obj.style.color = "#FFF";
	//obj.blur();
}


function collapse(element)
{
	if (document.getElementById('cp' + element).style.display == 'none')
	{
		document.getElementById('cp' + element).style.display = '';
		document.getElementById('icn' + element).innerHTML = '<img src="/images/minus.jpg" border=0 />';
	}
	else
	{
		document.getElementById('cp' + element).style.display = 'none';
		document.getElementById('icn' + element).innerHTML = '<img src="/images/plus.jpg" border=0>';
	}
}


/*****************************************************************************/

	var xmlHttp2;
	var oldContent;
	function mouseOver(section_id)
	{
		try
		{
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp2=new XMLHttpRequest();
		}
		catch (e)
		{
		  // Internet Explorer
			try
			{
				xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
			}

			catch (e)
			{
				try
				{
					xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		
		url = "mouseover.php?section_id=" + section_id;
		xmlHttp2.onreadystatechange = displayimage;
		xmlHttp2.open("GET",url,true);
		xmlHttp2.send(null);
	}
	
	function displayimage()
	{
		if (xmlHttp2.readyState==4)
		{// 4 = "loaded"
			if (xmlHttp2.status==200)
			{// 200 = "OK"
				oldContent = document.getElementById("floor_plan").innerHTML;
				floorfade.start();
				document.getElementById("floor_plan2").innerHTML = xmlHttp2.responseText; //getAllResponseHeaders();
			}
			else
			{
				alert("Problem retrieving data:" + xmlHttp.statusText);
			}
		}
		else
		{
			//document.getElementById('dv').innerHTML = "Loading...";
			//document.getElementById('load').style.display = '';
			document.getElementById('floor_plan2').innerHTML = "<img src='images/ajax-loader.gif' style=\"margin-top: 160px; margin-left: 350px\" width='25' border='0' alt='Loading...'>";
		}
	}
	
	function mouseOut()
	{
		//floor2fade.start();
		//document.getElementById("floor_plan").innerHTML = '';
		//document.getElementById("floor_plan2").innerHTML = '';
		//if (nimage == "")
			//document.getElementById("floor_plan").innerHTML = oldContent;
	}
	
	function collapseExpand(id, inv)
	{
		//var btn = document.getElementById(id).style.backgroundImage;
		var btn = document.getElementById(id).className;
		//alert(btn);
		//if (btn == "" || btn == "url(../images/left-nav-main-btn-collapse.jpg)")

		if (inv != 1)
		{
			if (btn.match("left-nav-main-btn-collapsed"))
			{
				//document.getElementById(id).style.backgroundImage = "url(../images/left-nav-main-btn-expand.jpg)";
				document.getElementById(id).className = "left-nav-main-btn";
			}
			else
			{
				document.getElementById(id).className = "left-nav-main-btn-collapsed";
			}
			if (id == "campuses_btn")
			{
				galleries_collapse.close();
				document.getElementById('galleries_btn').className = "left-nav-main-btn-collapsed";
			}
			if (id == "galleries_btn")
			{
				campuses_collapse.close();
				document.getElementById('campuses_btn').className = "left-nav-main-btn-collapsed";
			}
		}
		else
		{
			if (id == "naming_btn")
			{
				if (camp_id == 1) //Downtown
				{
					if (document.getElementById('naming_btn').className.match("left-nav-inv-expand-Downtown"))
						document.getElementById('naming_btn').className = "left-nav-inv-collapse-Downtown";
					else
						document.getElementById('naming_btn').className = "left-nav-inv-expand-Downtown";
				}
						
				if (camp_id == 2) //Sherman
				{
					if (document.getElementById('naming_btn').className.match("left-nav-inv-expand-Sherman"))
						document.getElementById('naming_btn').className = "left-nav-inv-collapse-Sherman";
					else
						document.getElementById('naming_btn').className = "left-nav-inv-expand-Sherman";
				}
				if (camp_id == 3) //Lebovic
				{
					if (document.getElementById('naming_btn').className.match("left-nav-inv-expand-Lebovic"))
						document.getElementById('naming_btn').className = "left-nav-inv-collapse-Lebovic";
					else
						document.getElementById('naming_btn').className = "left-nav-inv-expand-Lebovic"
				}
			}
		}
	}
	
	
/**********************************************************************************************************/


function appendSubNav(navItem)
{
	var myDiv = document.getElementById('top-sub-nav');
	for (var i = 0; i < myDiv.childNodes.length; i++)
	{
		if (myDiv.childNodes[i].id != null && typeof(myDiv.childNodes[i].id) == "string")
		{
			var id = myDiv.childNodes[i].id;
			//alert (id);
			if (myDiv.childNodes[i].nodeType == 1 && id.match("nav_"))
			{
				if (id != "" && id != null)
					document.getElementById(id).style.display = 'none';
			}
			if (myDiv.childNodes[i].nodeType == 1 && id.match("nav_" + navItem))
				document.getElementById(id).style.display = '';
		}
	}
}

xmlHttp = "";
function initAJAX()
{
	try
	{
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	  // Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}

		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
}


function loadBanner(thumbId)
{
	initAJAX();
	var url = "loadBanner.php";
	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
	//alert("camp is:" + camp_id);
	xmlHttp.onreadystatechange = loadBannerProgress;
	xmlHttp.open("post", url, true);
	xmlHttp.setRequestHeader("Content-Type", contentType);
	xmlHttp.send("thumbId=" + thumbId);

}

function loadBannerProgress()
{
	if (xmlHttp.readyState==4)
	{// 4 = "loaded"
		if (xmlHttp.status==200)
		{// 200 = "OK"
			//alert(xmlHttp.responseText); //getAllResponseHeaders();
			document.getElementById('banner_image').innerHTML = xmlHttp.responseText;
			//document.getElementById('banner_image').innerHTML = "";
		}
		else
		{
			alert("Problem retrieving data:" + xmlHttp.statusText);
		}
	}
	else
	{
		document.getElementById('banner_image').innerHTML = "<img src='images/ajax-loader.gif' width='25' border='0' alt='Loading...'>";
	}

}

function initBanner(camp_id)
{
	//alert("HELLO");
	initAJAX();
	var url = "loadBanner.php";
	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
	xmlHttp.onreadystatechange = loadBannerProgress;
	xmlHttp.open("post", url, true);
	xmlHttp.setRequestHeader("Content-Type", contentType);
	xmlHttp.send("camp_id=" + camp_id);
}

