//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
function sj_show(menuId,imgId,imgBase)
{
	if( !document.getElementById )
	{
		return;
	}

	mainMenu	= document.getElementById("m" + menuId + "0");

	if( imgId != 'NULL' )
	{
		imgObj	= document.getElementById( imgId );
		imgObj.setAttribute( 'base', imgBase );
		imgObj.setAttribute( 'src', imgBase );
	}
	
	mainMenu.style.display	= "inline";
}

function sj_hide(menuId,imgId,imgBase)
{
	if( !document.getElementById )
	{
		return;
	}

	mainMenu	= document.getElementById("m" + menuId + "0");

	if( imgId != 'NULL' )
	{
		imgObj	= document.getElementById( imgId );
		imgObj.setAttribute( 'base', imgBase );
		imgObj.setAttribute( 'src', imgBase );
	}
	
	mainMenu.style.display	= "none";
}

//#########################################################################################################
//
//	Public AJAX functions
//
//#########################################################################################################
//---------------------------------------------------------------------------------------------------------
//	Load an object dynamiclly with a source page
//---------------------------------------------------------------------------------------------------------
function loadDivContents( url, div )
{
 	 	try {
			//document.getElementById('the_movie').Stop();
			document.the_movie.Stop();
			//alert('stopped');
		} catch (E) {
			//alert('no mov continue');
		}
	objNumber = 0;
	
	//	Have we used the div object before?
	for( i=1; i<= HTTPObjects.length; i++ )
	{
		if (HTTPObjects[i] == div)
		{
			objNumber = i
		}
	}

	//	Not found?
	if(!objNumber)
	{
		objNumber				= HTTPObjects.length;
		HTTPObjects[objNumber]	= div;
	}

	//	Generate the div object pointer
	var divObj = eval( 'document.getElementById("' + div + '");' );
	
	eval( 'http' + objNumber + ' = initHTTPObject();' );
	eval( 'if (!http' + objNumber + '){window.location=\'/site/compatability.php\';}' );
	eval( 'http' + objNumber + '.open("GET", url, true );');
	eval( 'http' + objNumber + '.onreadystatechange = function() { if (http' + objNumber + '.readyState == 4) {divObj.innerHTML = http' + objNumber + '.responseText;}};');
	eval( 'http' + objNumber + '.send(null);');
}

//#########################################################################################################
//
//	Private AJAX functions
//
//#########################################################################################################
//---------------------------------------------------------------------------------------------------------
//	Define the elements
//---------------------------------------------------------------------------------------------------------
var HTTPObjects = Array();	//	Track all the used HTTP objects on the page
var objNumber   = null;

//---------------------------------------------------------------------------------------------------------
//	Initialize a new HTTP object
//	PRIVATE
//---------------------------------------------------------------------------------------------------------
function initHTTPObject() 
{
	var xmlhttp;
	
	try {
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
 	 	try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
			xmlhttp = false;
 		}
	}

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
  			xmlhttp = new XMLHttpRequest();
		} catch (e) {
  			xmlhttp = false;
		}
	}

	return xmlhttp;
}

//	Javascript provided by client
function checkRes(theURL,winName)
{
	var screenHeight = screen.height;
	var screenWidth = screen.width;
	
	if (screenWidth == 640)
	{
		 features = "width=600,height=460,top=0,left=0"
		 window.open(theURL,winName,features);
	}
	else
	{
	   var screenY = (screenHeight-490)/2;
	   var screenX = (screenWidth-600)/2;
	
		features = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=620,height=350,top="+screenY+",left="+screenX';
		window.open(theURL,winName,features);
	}
}


//	Flash & Quicktime
function InsertMovie(file,type,height,width,color,controller)
{
	 if(type == 'mov')
	 {
	 	controller = controller ? controller : false;
		/*
		foo = '';

		foo += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"';
    	foo += 'width="' + width + '" height="' + height + '" align="middle">';
		foo += '<param name="src" value="' + file + '" />';
		foo += '<param name="autoplay" value="true" />';
		foo += '<embed src="' + file + '" autoplay="true" width="' + width + '"';
		foo += ' height="' + height + '" align="middle" bgcolor="black"';
		foo += 'pluginspage="http://www.apple.com/quicktime/download/">';
		foo += '</embed></object>';
		
		alert( foo );
		*/
		if(controller != false)
		{
			height = parseInt(height);
			height = height + 16;
			controllervalue = 'true'
		}
		else
		{
			controllervalue = 'false';
		}
		
		document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"');
    	document.write('width="' + width + '" height="' + height + '" align="middle">');
		document.write('<param name="src" value="' + file + '" />');
		document.write('<param name="autoplay" value="true" />');
		document.write('<param name="controller" value="' + controllervalue + '">');
		document.write('<embed src="' + file + '" autoplay="false" width="' + width + '"');
		document.write(' controller="' + controllervalue + '"');
		document.write(' height="' + height + '" align="middle" bgcolor="black"');
		document.write(' pluginspage="http://www.apple.com/quicktime/download/">');
		document.write('</embed></object>');
	 }
	 else
	 {
		  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '" align="middle">');
		  document.write('<param name="allowScriptAccess" value="sameDomain" />');
		  document.write('<param name="movie" value="' + file + '" /><param name="quality" value="high" /><embed src="' + file + '" quality="high" width="' + width + '" height="' + height + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		  document.write('</object>');
	  }
}

// Function: setup_after_navs
// used by the proff page
function setup_after_nav_links()
{
	var after_nav_links = document.getElementById('after_nav_links');

	after_nav_links.style.display = 'inline';
}


