var killcache=1 //(1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var killcacheparam=""

function quorum_ajax(url, containerid){
	var page_request = false
	if (window.XMLHttpRequest) { 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; }
		page_request.onreadystatechange=function(){ 
			if(quorum_loadpage(page_request, containerid)) {
			initLightbox();
			resizeContent();
			}
			}
		if (killcache) { killcacheparam=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime(); }
		page_request.open('GET', url+killcacheparam, true);
		page_request.send(null);
		}
function quorum_loadpage(page_request, containerid){
	document.body.scrollTop = 0;
	if (page_request.readyState == 1) { 
	var contentDiv = containerid;
		contentDiv.innerHTML = '<img src="images/loading.gif" />';
		}		
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) {			
		document.getElementById(containerid).innerHTML=page_request.responseText					
		return true;
		}				
	}

function resizeContent() {
	var content = $('content');	
	var	contentHeight = Element.getHeight(content);
	var arrayPageSize = getPageSize();
	var windowHeight = arrayPageSize[3];	
	if(contentHeight > 500) { content.style.paddingBottom = (windowHeight-600)+"px"; }
	document.body.scrollTop = 0;
	}

function quorum_loadPageData ( contentTypeString, id ) { 
	quorum_ajax('script/ajax.php?contentType='+contentTypeString+'&id='+id, 'content');
	highlight(contentTypeString, id);
	document.body.scrollTop = 0;
	}
function redirection() {document.location = "./?sin=high";}

function highlight(section, sectionId) {	
	var i=0;
	var output = new Array();
	var subLinks = $$('a.accSubLink');
		subLinks.each(function(sLink){
			sLink.style.backgroundColor = "#333333";
			if(sLink.id.substr(0, section.length) == section) { output[i++] = sLink; }
			});

	if(sectionId=="none" || sectionId=="") {		
		if(section != "pix" && section != "music") { 
			sectionId = "main"; 
			var elem = $(section+'_id_'+sectionId); 
			}
		
		if(section == "pix" || section == "music") { 
			var elem = output[0]; 
			}
		}
	else { var elem = $(section+'_id_'+sectionId); }
	
	
	//alert(elem);
	
	if(section != "contact" && section != "bio") {
	/*
	var colorSwap =  new fx.Color(elem.id, {
		fromColor: "#333333", 
		toColor: "#555555"
	});
	
	colorSwap.toggle();	
	*/
		}
	

	return true;
	}


function initPage(section, id) {
	highlight(section, id);
	if(section == "pix") { initLightbox(); }
	initAccordion();
	}

function initAccordion(section) {	
		var stretchers = $$('div.accordion');
		stretchers.each(function(item){
			item.style.height = '0';
			item.style.overflow = 'hidden';
			});				
			var togglers = $$('h3.toggler a');
			
			var myAccordion = new Fx.Accordion(togglers, stretchers, { opacity: false, start: false, transition: Fx.Transitions.quadOut,				
				onActive: function(toggler, i){
					toggler.style.backgroundImage = "url(images/navButtonActive.png)";					
					},
				onBackground: function(toggler, i){
					toggler.style.backgroundImage = "url(images/navButton.png)";
					},
				onComplete: function(toggler) {
					
					}
			});
			function checkHash(){
				var found = false;
				$$('h3.toggler a').each(function(link, i){
					if (window.location.hash == link.hash){
						myAccordion.showThisHideOpen(i);
						found = true;
					}
				});
				return found;
			}
			if (!checkHash()) myAccordion.showThisHideOpen(0);
		};
///BOF MP3 Player Functions 		
/*function quorum_initMP3Player(url, title, streamType) {				
	var so = new SWFObject("flash/mp3player_trim.swf?id=0&audioTrack="+url+"&audioTitle="+title+"&streamType="+streamType, "flashMP3player", "212", "75", "8", "#222222", "transparent");
	so.write("mp3player");
	}*/
	
function quorum_initMP3Player(url, title, streamType) {								
	var flashMp3 = AC_FL_RunContent(
					"src", "flash/mp3player_trim?id=0&audioTrack="+url+"&audioTitle="+title+"&streamType="+streamType,
					"width", "212",
					"height", "75",
					"align", "middle",
					"id", "mp3Object",
					"quality", "high",
					"wmode", "transparent",
					"name", "SinesthetixMP3Player",
					"allowScriptAccess","sameDomain",
					"type", "application/x-shockwave-flash",
					"codebase", "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab",
					"pluginspage", "http://www.adobe.com/go/getflashplayer");
		var el = $('mp3player');
		el.innerHTML = flashMp3;	
		}														
																																					
function forceDownload(url, caption) { 
	var rand_no = Math.random();
	var href = "script/forceDownload.php?id="+rand_no+"&url="+url+"&caption="+caption;
	var assetText = window.open(href, 'assetText', 'width=100,height=40,scrollbars=no,resizable=no,status=no');
	}
function quorum_netStream (url, title) {
	quorum_initMP3Player(url, title, "radio");	
	}
function quorum_loadMusicDetail (group, serial, action, url, title) {	
	quorum_ajax('script/ajax.php?contentType=music&id='+group+'&track='+serial+'&action='+action, 'content');  
	if(action == "play") { quorum_initMP3Player(url, title, "stream"); }
	}	
///EOF MP3 Player Functions 		

function resetButton() {
	//var hexArray = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
	var b = $('body');
	var h = $('header');
	var m = $('mp3player');
	var oldColor = b.style.backgroundColor;	
	oldColor = oldColor.rgbToHex();
	var hexArray = new Array('0','1','2','3','4', '5', '6','7');
	var hexstring = "#";
	for(i=0; i<6; i++) {
		var ran_number=Math.floor(Math.random()*(hexArray.length));
		hexstring += hexArray[ran_number];
		}	
	var bgColorSwap =  new fx.Color(b, {
		fromColor: oldColor, 
		toColor: hexstring
		});
	var headerColorSwap =  new fx.Color(h, {
		fromColor: oldColor, 
		toColor: hexstring
		});
	var mp3ColorSwap =  new fx.Color(m, {
		fromColor: oldColor, 
		toColor: hexstring
		});	
	bgColorSwap.toggle();
	headerColorSwap.toggle();
	mp3ColorSwap.toggle();
	//document.body.style.backgroundColor = hexstring;
	//document.getElementById("header").style.backgroundColor = hexstring;
	//if (window.ActiveXObject) { } 
	//else { document.getElementById("mp3player").style.backgroundColor = hexstring; }
	//hexstring = "";
	}





function navigationHover(e, state) {
	var button = document.getElementById(e);				
	if(state == "over") { 
		var original = button.style.backgroundColor;
		var originalC = button.style.color;
		button.original = original;
		button.originalC = originalC;
		button.style.backgroundColor = '#222222'; 
		button.style.color = '#FFFFFF';
		}
	else { 
		button.style.backgroundColor = button.original; 
		button.style.color = button.originalC; 
		}
	}		

function quorum_loadGalleryImage(group, image) {
	quorum_ajax('script/ajax.php?contentType=pix&group='+group+'&image='+image, 'content');
	
	}
function imageSwap (url, width, height) { 
	var el = document.getElementById("swapMe");
	el.style.backgroundImage = "url(images/pix/"+url+")";
	el.style.width = width+"px";
	el.style.height = height+"px";
	}


//////////////BOF Contact Form Stuff//////////////
function quorumContactForm(name, email, message) {
	quorum_ajax('script/contactForm.php?contentType='+contentTypeString+'&id='+id, 'content');
	}
function submitContactForm() { 
		var name = document.getElementById("name");
		var email = document.getElementById("email");
		var subject = document.getElementById("subject");
		var message = document.getElementById("message");
		var errorMessage = new Array();
		var error = 0;
		if(name.value.length < 1) { errorMessage[0] = "You must enter a name\n"; error=1; }
		else { errorMessage[0] = ""; }
		if(email.value.length < 1) { errorMessage[1] = "You must enter a valid email address\n"; error=1;  }		
		else { errorMessage[1] = ""; }
		if(email.value.indexOf("@") <= 0 || email.value.indexOf("@") == (email.value.length-1)) { errorMessage[1] = "You must enter a valid email address\n"; error=1; }	
		else { 
			if(email.value.indexOf(".", email.value.indexOf("@")) <= 0 || email.value.indexOf(".", email.value.indexOf("@")) == (email.value.length-1)) 
			{ errorMessage[1] = "You must enter a valid email address\n"; error=1; } 
			else { errorMessage[1] = ""; }
		}
		if(message.value.length < 1) { errorMessage[2] = "You must enter a subject\n"; error=1;  }
		else { errorMessage[2] = ""; }
		
		if(message.value.length < 1) { errorMessage[3] = "You must enter a message\n"; error=1;  }
		else { errorMessage[3] = ""; }
		if(error==1) { alert(errorMessage[0]+errorMessage[1]+errorMessage[2]+errorMessage[3]); }
		else { 
		quorum_ajax('script/contactForm.php?name='+name.value+'&email='+email.value+'&subject='+subject.value+'&message='+message.value, 'content'); 
		}
		}
//////////////EOF Contact Form Stuff//////////////


function destroyVisuals() { 
	Element.remove('visuals');
	new Effect.Fade('visualsBox', { duration: 1.0, from: 1.0, to: 0.0 });
	}
function createVisuals() {
	var container = $('visualsBox');
	
	var visuals = document.createElement('div');
	visuals.id = "visuals";
	visuals.style.position = "relative";
	visuals.style.margin = "110px auto";			
	visuals.style.border = "10px solid #FFF";			
	visuals.style.backgroundColor = "#FFF";	
	visuals.style.width = "550px";	
	visuals.style.height = "450px";				
	
	var flash = AC_FL_RunContent(
			"src", "flash/visuals",
			"width", "550",
			"height", "450",
			"align", "middle",
			"id", "logo",
			"quality", "high",
			"bgcolor", "#222222",
			"name", "Visualizer",
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"codebase", "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab",
			"pluginspage", "http://www.adobe.com/go/getflashplayer"
			);
	
	visuals.innerHTML = flash;
	
	container.appendChild(visuals);
	}
function runVisuals() {
		var arrayPageSize = getPageSize();		
		Element.setHeight('visualsBox', arrayPageSize[1]);
		new Effect.Appear('visualsBox', { duration: 1.0, from: 0.0, to: 1.0,  afterFinish: createVisuals });
	}
