//	spacefest.js
//
//	collection of site wide functions
var lIsIE = navigator.appVersion.indexOf("MSIE") >= 0;

function page_onload() {
	if (lIsIE) {
		opage = document.getElementById('page');
		oheader = document.getElementById('header');
		osidebar = document.getElementById('sidebar');
		ocontent = document.getElementById('content');
		ofooter = document.getElementById('footer');
	}
}

function getQuery(cName) {
	// cName is the name of a query value to return
	var search = document.location.search.substr(1);
	var aNames = search.split("&");
	for (i=0;i<aNames.length;i++) {
		if (aNames[i].indexOf(cName+'=') == 0) {
			cValue = decodeURI(aNames[i].substr(cName.length+1));
			cValue = cValue.replace(/\+/g,' ');
			return cValue;
		}
	}
	return '';
}

function ajaxFunction(sUrl,sTitle)
{
var xmlHttp;
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;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById('content').innerHTML=xmlHttp.responseText;
	urchinTracker(sUrl );
	document.getElementById('semitransparent').style.display='block';
      }
    }
  xmlHttp.open("GET",sUrl,true);
  xmlHttp.send(null);
  if (sTitle != undefined) { document.title = 'Spacefest 2009 ' + sTitle }
}

function Slideshow_Previous()
{
    if (slideshow_current == 0)
    {
        slideshow_current = 4;
    }
    document['slideshow_image'].src = images[(--slideshow_current)];
    document.getElementById('slideshow_description').innerHTML = descriptions[slideshow_current];
}

function Slideshow_Next()
{
    if (slideshow_current == 4 -1)
    {
        slideshow_current = -1;
    }
    document["slideshow_image"].src = images[(++slideshow_current)];
    document.getElementById("slideshow_description").innerHTML = descriptions[slideshow_current];
}

var slideshow_current = 0;
var images = new Array(4);
var descriptions = new Array(4);

images[0] = 'http://www.sandiego.org/images/display.php?id=245&max_width=200&max_height=125&background=ffffff';
descriptions[0] = 'Downtown Skyline';
images[1] = 'http://www.sandiego.org/images/display.php?id=345&max_width=200&max_height=125&background=ffffff';
descriptions[1] = 'Balboa Park';
images[2] = 'http://www.sandiego.org/images/display.php?id=1737&max_width=200&max_height=125&background=ffffff';
descriptions[2] = 'Cruise ship in San Diego Bay';
images[3] = 'http://www.sandiego.org/images/display.php?id=1738&max_width=200&max_height=125&background=ffffff';
descriptions[3] = 'San Diego\'s coastline';


function sumArtForm() {
	myForm = document.forms['artshow'];
	// space calculate
	myForm.areatotal.value = myForm.sqft.value * 1.50 ;
	// non-attending?
	if (myForm.notattend.checked == true) {
		myForm.nacharge.value = 50;
	}
	else {
		myForm.nacharge.value = 0;
	}

	myForm.grandtotal.value = parseFloat(myForm.areatotal.value) + parseInt(myForm.nacharge.value);

	// fill in purchase details
	myForm.price.value = myForm.grandtotal.value ;
	var attend = myForm.notattend.checked == true ?'Not Attending':'Attending' ;
	myForm.comments.value = myForm.name.value + "\n" + myForm.sqft.value + " sq ft\n" + attend;
}

