

/***************************************************/
//Setup nav buttons
function brochelleNavs( clsName, imgPath, stuffName ) {
	
	//Find objects
	navObjs = document.getElementsByClassName( clsName );
	
	//Die
	if( navObjs.length == 0 ){ return true; }
	
	//Loop found items
	for( i=0; i < navObjs.length; i++ ) {

		//Get object
		nObj = $(""+navObjs[i].id+"");

		
		//Assign events
		nObj.onclick = new Function(""+stuffName+".loadPage('','"+nObj.id+".php'); "+stuffName+".currentEleId = '"+nObj.id+"';");
		nObj.onmouseover = new Function("$('"+nObj.id+"Btn').src = '"+imgPath+"/"+nObj.id+"_over.gif';");
		nObj.onmouseout = new Function("$('"+nObj.id+"Btn').src = '"+imgPath+"/"+nObj.id+".gif';");
		
	}
}



/***************************************************/
// Reload the current page, with the url in the location
function brochelleHardRefresh( prePend ) {
//pageLoaders[eId].url
	
	//Default pageLoader
	pLoader = xxStuff.defaultPageLoader;
	
	//alert(xxStuff.pageLoaders[pLoader].url);

	//Reload URL HERE
	reloadUrl = prePend + escape(xxStuff.pageLoaders[pLoader].url);

	self.location = reloadUrl;
	
}


/***************************************************/
function runFlashHeader( flashPath ) {
	//Flash VAr

	/* OLD FLASH INTRO

	flashWrite = "";
	flashWrite +="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='800' height='523'>";
	flashWrite +="<param name='allowScriptAccess' value='sameDomain' />";
	flashWrite += "<param name='movie' value='"+flashPath+"'>";
	flashWrite += "<param name='quality' value='high'>";
	flashWrite += "<embed src='"+flashPath+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='800' height='523'></embed>";
	flashWrite += "</object>";
	*/
	
	flashWrite = "";
	flashWrite +="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='100%' height='100%'>";
	flashWrite +="<param name='allowScriptAccess' value='sameDomain' />";
	flashWrite += "<param name='movie' value='"+flashPath+"'>";
	flashWrite += "<param name='quality' value='high'>";
	flashWrite += "<embed src='"+flashPath+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='100%' height='100%'></embed>";
	flashWrite += "</object>";

	//Write header
	document.write(flashWrite);
}




/***************************************************/
// Open a window for a video file
function openMediaVideo( videoId ) {
	
	
}



function writeWMP (src, w, h) {
	videoWrite = '';
	videoWrite += '<OBJECT id="VIDEO" width="'+w+'" height="'+h+'" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">';
	videoWrite += '<PARAM NAME="URL" VALUE="'+src+'"> <PARAM name="uiMode" value="full"> <PARAM name="stretchToFit" value="true"> <PARAM NAME="AutoStart" VALUE="True">';
	videoWrite += '<EMBED TYPE="application/x-mplayer2" src="'+src+'"   NAME="MediaPlayer" uiMode="full" stretchToFit="true"  WIDTH="'+w+'"  HEIGHT="'+h+'"></EMBED>';
	videoWrite += '</OBJECT>';

	//Return the string to be written
	//document.write(videoWrite);
	return videoWrite;
}








//Global pop image cache 
var popImageCaches = new Array();
var popImageCurrent = false;
var popImageState = true;

/***************************************************/
//Start preloading pop images
function popImageCache( imageName, imageSrc ) {
	
	//Check to see if this is already cached
	if( popImageCaches[imageName] ){ return true; }
	
	//Create new cache item
	popImageCaches[imageName] = new Image();
	popImageCaches[imageName].cached = false;
	popImageCaches[imageName].onload = function(){ popImageCacheLoaded(imageName); }
	popImageCaches[imageName].src = imageSrc;
	
	//return
	return true;
}

//Cache the default loading image
popImageCache("default", "/site/images/popup_default.jpg");


/***************************************************/
//Sets a property to signal that the image is done caching
function popImageCacheLoaded( imageName ) {

	//Check to see if the imageName is registered yet.. 
	if( ! popImageCaches[imageName] ) { return true; }
	
	//Set cached to true signaling that it is done.
	popImageCaches[imageName].cached = true;
	
	//If it has an autoOpen then show it now.
	if( popImageCaches[imageName].autoOpen == true ) {
		popImageInit(imageName, popImageCaches[imageName].autoOpenTxt );
	}
	
	return true;
}

/***************************************************/
//Show the cached pop image
function popImageInit( imageName, imgTxt) {

	if( ! $("popImageContainer")) { return true; }
	
	// if this is the same one that's already there.. just return
	if( imageName == popImageCurrent ) { return true; }
		
	//Hide the container if opened
	if( Element.visible("popImageContainer")) {
		Element.hide($("popImageContainer"));	
	}
	
	//Check to see if this image is cached yet.
	if( popImageCaches[imageName].cached != true ) { 		
		
		//Set value so it will auto open when done caching
		popImageCaches[imageName].autoOpen = true;
		popImageCaches[imageName].autoOpenTxt = imgTxt;
		
		//Show loading window
		popImageLoading();	
		
		return true;
	}
	
	//reset text
	Element.update("popImageDesc", imgTxt);

	//Show the cached image
	$("popImage").src = popImageCaches[imageName].src;
	$("popImage").onload = function(){ popImageShow(); }
	
	//Set the current image pointer
	popImageCurrent = imageName;
	
	
	return true;
}

/***************************************************/
function popImageShow() {


	//Show the pop image container
	Effect.Appear($("popImageContainer"));
	
	//Fade the body a bit
	if( $("pageView").faded != true ) {
		new Effect.Opacity("pageView", {duration:0.5, from:1.0, to:0.3});
		$("pageView").faded = true;
	}

}


/***************************************************/
//Show the pop image window with a loading dialog
function popImageLoading() {

	//Hide the container if opened
	if( Element.visible("popImageContainer")) {
		Element.hide($("popImageContainer"));	
	}
	
	//Set default image
	$("popImage").src = popImageCaches["default"].src;
	
	//Set text
	Element.update("popImageDesc", "Images are still Loading... Please wait.");

	
	popImageShow();
}


/***************************************************/
function popImageHide() {
	if( ! $("popImageContainer") ) { return true; }
	
	//Hide the container
	Element.hide($("popImageContainer"));
	
	
	//reset the opacity for the pageView
	if( $("pageView").faded == true ) {
		new Effect.Opacity("pageView", {duration:0.5, from:0.3, to:1.0});
		$("pageView").faded = false;
	}
	
	popImageCurrent = false; 

	return true;
}




