/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var loadstatustext="<img src='/images/loading.gif' /> Requesting content..."

var jsBlur = "";
var jsG1Ratio = "";
var jsG2Ratio = "";
var jsGSRatio = "";
var jsGelRatio = "";
var bkgndColor = "";

function ajaxpage(url, containerid){
	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
	page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
	return false
	document.getElementById(containerid).innerHTML=loadstatustext
	page_request.onreadystatechange=function(){
		loadpage(page_request, containerid)
	}
	page_request.open('GET', url, true)
	page_request.send(null)
}
//document.getElementById(containerid).innerHTML=loadstatustext

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	document.getElementById(containerid).innerHTML=page_request.responseText
}


function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
	var file=arguments[i]
	var fileref=""
	if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
			if (file.indexOf(".js")!=-1){ //If object is a js file
				fileref=document.createElement('script')
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			loadedobjects+=file+" " //Remember this object as being already added to page
		}
	}
}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function goboViz_DoFSCommand(command, args) {
	var goboVizObj = isInternetExplorer ? document.all.goboViz: document.goboViz;
	 if (command == "deleteGobo1") {
		ajaxpage('/gobodisplay?name=&number=', 'gobo1');
		gobo1Name = '';
		gobo1Title = '';
		gobo1Source = '';
	 }
	 if (command == "deleteGobo2") {
		ajaxpage('/gobodisplay?name=&number=', 'gobo2');
		gobo2Name = '';
		gobo2Title = '';
		gobo2Source = '';
	 }
	 if (command == "deleteGoboStatic") {
		ajaxpage('/gobodisplay?name=&number=', 'gobostatic');
		goboStaticName = '';
		goboStaticTitle = '';
		goboStaticSource = '';
	 }
	 if (command == "jsBlur") {
		jsBlur = args;
	}
	 if (command == "jsG1Ratio") {
		jsG1Ratio = args;
	}
	 if (command == "jsG2Ratio") {
		jsG2Ratio = args;
	}
	 if (command == "jsGSRatio") {
		jsGSRatio = args;
	}
	 if (command == "jsGelRatio") {
		jsGelRatio = args;
	}
	 if (command == "bkgndColor") {
		bkgndColor = args;
	}
	 if (command == "deleteGel") {
		gelColor = '';
		gelTitle = '';
	}
	 if (command == "deleteSplitGel") {
		gelSplitColor = '';
		gelSplitTitle = '';
	}
	 if (command == "shGobo1") {
		shGobo1 = args;
	}
	 if (command == "shGobo2") {
		shGobo2 = args;
	}
	 if (command == "shGoboStatic") {
		shGoboStatic = args;
	}
	 if (command == "IsFlipped1") {
		jsIsFlipped1 = args;
	}
	 if (command == "IsFlipped2") {
		jsIsFlipped2 = args;
	}
	 if (command == "IsFlippedStatic") {
		jsIsFlippedStatic = args;
	}
	 if (command == "save") {
		saveTitleItem = args;
		if((saveTitleItem == '') || (saveTitleItem == 'undefined')){
			alert('Please enter a title') ;
		}
		else {
			save(saveTitleItem);
		}
	}
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub goboViz_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call goboViz_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function filterGobo(){
	var goboManufacturer=document.getElementById? document.getElementById('goboManufacturer') : ""
	var goboQuery=document.getElementById? document.getElementById('goboQuery') : ""
	ajaxpage('/gobocatalog?man='+goboManufacturer.options[goboManufacturer.selectedIndex].value+'&query='+goboQuery.value+'&rr='+rrgobo, 'gobowindow')
	window.location.hash = "#gw";
}

function listenGoboEnter(e){
var key=e.keyCode || e.which;
	if (key==13){
	filterGobo();
	}
}

function resetGoboQuery() {
	var goboQuery=document.getElementById? document.getElementById('goboQuery') : ""
	goboQuery.value = '';
	filterGobo();
}

function resetGoboMan() {
	var goboManufacturer=document.getElementById? document.getElementById('goboManufacturer') : ""
	goboManufacturer.selectedIndex = 0;
	filterGobo();
}

function resetGoboCat() {
	var goboCategory=document.getElementById? document.getElementById('goboCategory') : ""
	goboCategory.selectedIndex = 0;
	filterGobo();	
}

function filterGel(){
	var gelLine=document.getElementById? document.getElementById('gelLine') : ""
	var gelQuery=document.getElementById? document.getElementById('gelQuery') : ""
	ajaxpage('/gelcatalog?line='+gelLine.options[gelLine.selectedIndex].value+'&query='+gelQuery.value+'&rr='+rrgel, 'gelwindow')
	window.location.hash = "#gw";
}

function listenGelEnter(e){
var key=e.keyCode || e.which;
	if (key==13){
	filterGel();
	}
}


function resetGelQuery() {
	var gelQuery=document.getElementById? document.getElementById('gelQuery') : ""
	gelQuery.value = '';
	filterGel();
}

function resetGelLine() {
	var gelLine=document.getElementById? document.getElementById('gelLine') : ""
	gelLine.selectedIndex = 0;
	filterGel();
}

//Flash interaction functions
function gobo1(file, title, name){
  
   gobo1Source = file;
   gobo1Name = name;
   gobo1Title = title;
   var gobo1Load = 1;
   
   window.document.goboViz.SetVariable("gobo1Soruce", gobo1Source+'.gif');
   window.document.goboViz.SetVariable("goboTitle1.goboTitleText", gobo1Title);
   window.document.goboViz.SetVariable("gobo1Load", gobo1Load);
   ajaxpage('/gobodisplay?name='+gobo1Name+'&number='+gobo1Source+'&title='+gobo1Title, 'gobo1');
}

function gobo2(file, title, name){
  
   gobo2Source = file;
   gobo2Name = name;
   gobo2Title = title;
   var gobo2Load = 1;
   
   window.document.goboViz.SetVariable("gobo2Soruce", gobo2Source+'.gif');
   window.document.goboViz.SetVariable("goboTitle2.goboTitleText", gobo2Title);
   window.document.goboViz.SetVariable("gobo2Load", gobo2Load);
      ajaxpage('/gobodisplay?name='+gobo2Name+'&number='+gobo2Source+'&title='+gobo2Title, 'gobo2');
}

function goboStatic(file, title, name){
  
  goboStaticSource = file;
  goboStaticName = name;
  goboStaticTitle = title;
  var goboStaticLoad = 1;
   
   window.document.goboViz.SetVariable("goboStaticSoruce", goboStaticSource+'.gif');
   window.document.goboViz.SetVariable("goboTitleStatic.goboTitleText", goboStaticTitle);
   window.document.goboViz.SetVariable("goboStaticLoad", goboStaticLoad);
   ajaxpage('/gobodisplay?name='+goboStaticName+'&number='+goboStaticSource+'&title='+goboStaticTitle, 'gobostatic');
}

function gel(colorNumber, name){
  
  gelColor = colorNumber;
  gelTitle = name;
  var gelLoad = 1;
   
   window.document.goboViz.SetVariable("gelColor", gelColor);
   window.document.goboViz.SetVariable("gelTitle", gelTitle);
   window.document.goboViz.SetVariable("gelLoad", gelLoad);
}

function gelSplit(colorNumber, name){
  
  gelSplitColor = colorNumber;
  gelSplitTitle = name;
  var gelSplitLoad = 1;
   
   window.document.goboViz.SetVariable("gelSplitColor", gelSplitColor);
   window.document.goboViz.SetVariable("gelSplitTitle", gelSplitTitle);
   window.document.goboViz.SetVariable("gelSplitLoad", gelSplitLoad);
}

function filterFixture(){
	var fixtureLine=document.getElementById? document.getElementById('fixtureLine') : ""
	var distance=document.getElementById? document.getElementById('distance') : ""
	var size=document.getElementById? document.getElementById('size') : ""
	ajaxpage('/fixture?line='+fixtureLine.options[fixtureLine.selectedIndex].value+'&distance='+distance.value+'&size='+size.value, 'fixture')
	//window.location.hash = "#beam";
}

//function save(){
//	ajaxpage('/save?title=&userid='+SessionUserID+'&action=save&a='+gelTitle+'&b='+gelColor+'&d='+bkgndColor+'&e='+jsBlur+'&f='+jsG1Ratio+'&g='+gobo1Source+'&h='+gobo1Title+'&j='+jsG2Ratio+'&k='+gobo2Source+'&l='+gobo2Title+'&n='+jsGSRatio+'&o='+goboStaticSource+'&p='+goboStaticTitle+'&r='+jsGelRatio+'&s='+gelSplitTitle+'&t='+gelSplitColor+'&z1='+gobo1Name+'&z2='+gobo2Name+'&z3='+goboStaticName+'&v='+shGobo1+'&w='+shGobo2+'&x='+shGoboStatic+'&y='+jsIsFlipped1+'&z='+jsIsFlipped2+'&aa='+jsIsFlippedStatic+'&sid='+SessionID, 'save')
//	window.location.hash = "#save";
//}

function save(saveTitleItem){
	//alert(saveTitleItem) ;
	ajaxpage('/save?title='+saveTitleItem+'&userid='+SessionUserID+'&action=save&a='+gelTitle+'&b='+gelColor+'&d='+bkgndColor+'&e='+jsBlur+'&f='+jsG1Ratio+'&g='+gobo1Source+'&h='+gobo1Title+'&j='+jsG2Ratio+'&k='+gobo2Source+'&l='+gobo2Title+'&n='+jsGSRatio+'&o='+goboStaticSource+'&p='+goboStaticTitle+'&r='+jsGelRatio+'&s='+gelSplitTitle+'&t='+gelSplitColor+'&z1='+gobo1Name+'&z2='+gobo2Name+'&z3='+goboStaticName+'&v='+shGobo1+'&w='+shGobo2+'&x='+shGoboStatic+'&y='+jsIsFlipped1+'&z='+jsIsFlipped2+'&aa='+jsIsFlippedStatic+'&sid='+SessionID, 'saveThisShit')
	window.location.hash = "#save";
}



function listenSaveTitleEnter(e){
var key=e.keyCode || e.which;
	if (key==13){
	saveTitle();
	}
}

function listenFixtureEnter(e){
var key=e.keyCode || e.which;
	if (key==13){
	filterFixture();
	}
}


function go(){
   window.location.hash = "#top";
}