/*
############################
OUR AJAX CODE
*/
var comm_page = new onConnect( false, false, call_page );

function get_page( page, placement, misc1 )
	{
	//I use misc1 as a misc var to pass over to my body 
	//pages depending on what they made need.
	if ( misc1 == undefined )
		misc1 = '';
		
	var path = page + '?misc1=' + misc1;
	comm_page.misc = page;
	comm_page.placement = placement;

	ajax_send( path, true, 'GET', null, comm_page  );
	}

function call_page()
	{
	document.getElementById( comm_page.placement ).innerHTML = comm_page.response;
	//the code below changes the header background image
	if ( comm_page.misc == 'body_home.php' )
		{
		document.title = 'GShutter Studios Home';
		document.getElementById( 'header' ).className = 'header_bar_home';
		document.getElementById( 'footer' ).className = 'header_bar_home';
		}

	if ( comm_page.misc == 'body_corp.php' )
		{
		document.title = 'GShutter Studios Corporate';
		document.getElementById( 'header' ).className = 'header_bar_corp';
		document.getElementById( 'footer' ).className = 'header_bar_corp';
		get_movie( 'reg_movie', 'http://www.gshutter.com/videos/commercials/Klondike1.mov', 525, 295, 'false' );
		}
	
	if ( comm_page.misc == 'body_weddings.php' )
		{
		document.title = 'GShutter Studios Weddings';
		document.getElementById( 'header' ).className = 'header_bar_weddings';
		document.getElementById( 'footer' ).className = 'header_bar_weddings';
		//this loads the video player in the window with autoplay set to false. What this does is show the viewer there is a movie to be watched
		//get_movie( 'reg_movie', 'http://www.gshutter.com/videos/weddings/Pre-ErinBoyd1.mov', 525, 295, 'false' );
		}
	
	if ( comm_page.misc == 'body_weddings.php' )
		{
		document.title = 'GShutter Studios Weddings';
		document.getElementById( 'header' ).className = 'header_bar_weddings';
		document.getElementById( 'footer' ).className = 'header_bar_weddings';
		//this loads the video player in the window with autoplay set to false. What this does is show the viewer there is a movie to be watched
		get_movie( 'reg_movie', 'http://www.gshutter.com/videos/weddings/stacybrettner1.mov', 525, 295, 'false' );
		}

	if ( comm_page.misc == 'body_music.php' )
		{
		document.title = 'GShutter Studios Music';
		document.getElementById( 'header' ).className = 'header_bar_music';
		document.getElementById( 'footer' ).className = 'header_bar_music';
		//this loads the video player in the window with autoplay set to false. What this does is show the viewer there is a movie to be watched
		get_movie( 'reg_movie', 'http://www.gshutter.com/videos/MusicVideos/TimKelley/OlderWiser.mov', 525, 295, 'false' );
		}
	
	if ( comm_page.misc == 'body_instruction.php' )
		{
		document.title = 'GShutter Studios Instructional';
		document.getElementById( 'header' ).className = 'header_bar_instr';
		document.getElementById( 'footer' ).className = 'header_bar_instr';
		}
	
	if ( comm_page.misc == 'body_contact.php' )
		{
		document.title = 'GShutter Studios Contact';
		document.getElementById( 'header' ).className = 'header_bar_contact';
		document.getElementById( 'footer' ).className = 'header_bar_contact';
		}
	
	if ( comm_page.misc == 'body_audio_repair.php' )
		{
		document.title = 'GShutter Studios Audio';
		document.getElementById( 'header' ).className = 'header_bar_audio';
		document.getElementById( 'footer' ).className = 'header_bar_audio';
		}
	
	if ( comm_page.misc == 'body_sound.php' )
		{
		document.title = 'GShutter Studios Sound';
		document.getElementById( 'header' ).className = 'header_bar_sound';
		document.getElementById( 'footer' ).className = 'header_bar_sound';
		}
	
	if ( comm_page.misc == 'body_film.php' )
		{
		document.title = 'GShutter Studios Film';
		document.getElementById( 'header' ).className = 'header_bar_film';
		document.getElementById( 'footer' ).className = 'header_bar_film';
		//this loads the video player in the window with autoplay set to false. What this does is show the viewer there is a movie to be watched
		get_movie( 'reg_movie', 'http://www.gshutter.com/videos/misc/Soliterrorist.mov', 525, 295, 'false', 'The SoliTerrorist' );
		}
	
	if ( comm_page.misc == 'body_events.php' )
		{
		document.title = 'GShutter Studios Events';
		document.getElementById( 'header' ).className = 'header_bar_home';
		document.getElementById( 'footer' ).className = 'header_bar_home';
		//this loads the video player in the window with autoplay set to false. What this does is show the viewer there is a movie to be watched
		get_movie( 'reg_movie', 'http://www.gshutter.com/videos/Events/XC-battle.mov', 525, 295, 'false' );
		}

	//statcounter
	mystatcounter();
	}






var page = '';



function ajax_send( path, async, method, postFields, callback ) 
	{
	if (window.XMLHttpRequest) 
		{ // Mozilla, Safari, ...
	   var xmlcon = new XMLHttpRequest();
	 	}
	else 
		if (window.ActiveXObject) 
			{ // IE
		   var xmlcon = new ActiveXObject("Microsoft.XMLHTTP");
		 	}

	xmlcon.open(method, path, async);		

	if ( method == 'POST' )
		{
		xmlcon.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		}
	else
		postFields = null;


	xmlcon.onreadystatechange = 
		function() 
			{
			if ( xmlcon.readyState == 4 || xmlcon.readyState == 'complete' ) 
				{
				callback.response = xmlcon.responseText;
				callback.push();
				}
			}
		
		
	xmlcon.send( postFields );
	return false;
	}



//onReceive class called from ajax_send function
function onConnect( response, placement, callfunc, misc )
	{
	this.response = response;
	this.placement = placement;
	this.callfunc = callfunc;
	this.misc = misc;
	}
	
function push()
	{
	this.callfunc();
	}

onConnect.prototype.push = push;

/*
##################################
#################################
*/
function get_movie_details( film )
	{
	get_page( 'http://www.gshutter.com/film_desc.php', 'reg_desc', film );
	}


	
function get_movie( region, file, w, h, autoplay, onfilmpage)
	{
	if ( autoplay != 'false' )
		autoplay = 'true';

	//if we are on the film page, we then call our get_movie_details() to place the description
	//of the film in the span above the movie.
	if ( onfilmpage != undefined )
		get_movie_details( onfilmpage );

	h = h + 16; //add 16 for controller height
	document.getElementById( region ).innerHTML = '<embed src="' + file + '" autoplay="' + autoplay + '" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" width="' + w + '" height="' + h + '" controller="true">';
	}
	

function get_audio( region, file )
	{
	document.getElementById( region ).innerHTML = '<embed src="' + file + '" autoplay="true" height="16" type="application/x-quicktime-media-link" pluginspage="http://www.apple.com/quicktime/download/" controller="true">';
	}

/*
old divx code
function get_divx_movie( region, file, w, h, autoplay )
	{
	if ( autoplay != 'false' )
		autoplay = 'true';
		
	h = h + 20; //add 20 for controller height
	document.getElementById( region ).innerHTML = '<embed src="' + file + '" autoplay="' + autoplay + '" type="video/divx" pluginspage="http://go.divx.com/plugin/download/" width="' + w + '" height="' + h + '" controller="true">';

	}
*/

function statcounter()
{

}
