//LOSE IE6 FLICKER BUG
//--------------------

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

//CALL FUNCTIONS ONDOMREADY
//-------------------------

function onDomReady() {
	//call functions on page load.
};

//POPUP
//-----

function popUp(URL, width, height) {

	var day = new Date();
	var id = day.getTime();
	
	var offsetWidth = (screen.width / 2) - (width / 2);
	var offsetHeight = (screen.height / 2) - (height / 2);

	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = "+offsetWidth+",top = "+offsetHeight+"');");
	return false;
	
}

//FONT SIZE FUNCTIONALITY
//-----------------------

function fontSize(percentage) {

	document.getElementsByTagName("body")[0].style.fontSize = percentage+"%";
	
	if (!xmlHttp) {
		return false;
	};
	
	xmlHttp.open("get", "/inc/fontsize.php?percentage="+percentage, true);
	xmlHttp.send(null);
	
	xmlHttp.onreadystatechange = function() {		
		if (xmlHttp.readyState == 4 ) {
		 	//alert(xmlHttp.responseText);
		};
	};
	
	return false;

}

//AJAX OBJECT CREATE
//------------------

var xmlHttp;
try {
	// Firefox, Opera 8.0+, Safari
	xmlHttp = new XMLHttpRequest();
} catch (e) {
	// Internet Explorer
	try	{
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e)	{
		try	{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e)	{
			alert("Your browser does not support AJAX!");
		};
	};
};

//JAVASCRIPT FLASH INSERTION
//--------------------------

function flash(url, img, width, height, flashversionuser) {

    if (!flashversionuser) {
        flashtest = 6;
    } else {
        flashtest = parseInt(flashversionuser);
    }; 
    
    //alert("Flash installed (2=yes): "+FlashDetect.installed);
    //alert("Flash version installed: "+FlashDetect.major);    
    //alert("Testing for: "+flashtest);        

    if (FlashDetect.installed == true && FlashDetect.major >= flashtest) {
        
        document.write('<object width="'+width+'" height="'+height+'" align="middle" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">');
        document.write('<param value="sameDomain" name="allowScriptAccess" />');
        document.write('<param value="'+url+'" name="movie" />');
        document.write('<param value="high" name="quality" />');
        //document.write('<param value="noscale" name="scale" />');
        document.write('<param value="transparent" name="wmode" />');
        document.write('<param value="lt" name="salign" />');
        document.write('<param value="#ffffff" name="bgcolor" /><embed width="'+width+'" height="'+height+'" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="sameDomain" wmode="transparent" bgcolor="#ffffff" salign="lt" quality="high" src="'+url+'">');
        document.write('</embed>');
        document.write('</object>');
    } else {
        document.write('<img src="'+img+'" width="'+width+'" height="'+height+'" alt="" />');
    };
    
    flashtest == null;

}

//JAVASCRIPT MOV INSERTION
//------------------------

function mov(url, width, height) {

	width = parseInt(width);
	height = parseInt(height);

	document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+height+'" width="'+width+'">');
	document.write('<param name="correction" value="full">');
	document.write('<param name="cache" value="true">');
	document.write('<param name="src" value="/media/qt/'+url+'">');
	document.write('<param name="autoplay" value="true">');
	document.write('<param name="controller" value="true">');
	document.write('<embed width="'+width+'" height="'+height+'" pluginspage="http://www.apple.com/quicktime/download/" src="/media/qt/'+url+'" type="video/quicktime" controller="true" autoplay="true" cache="true" correction="full"></embed>');
	document.write('</object>');
	
};

//ONDOM READY FUNCTION
//--------------------
function onDomReadyLoad() {

	//quit if this function has already been called
	if (arguments.callee.done) return;
	
	//flag this function so we don't do the same thing twice
	arguments.callee.done = true;
	
	//kill the timer
	if (_timer) {
		clearInterval(_timer);
		_timer = null;
	};
	
    onDomReady();
    
};

//CALL ONDOMREADY FUNCTION
//for Mozilla
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", onDomReadyLoad, false);
};

/*for Internet Explorer*/
/*@cc_on @*/
/*@if (@_win32)
	document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
	var script = document.getElementById("__ie_onload");
	script.onreadystatechange = function() {
		if (this.readyState == "complete") {
			onDomReadyLoad(); // call the onload handler
		};
	};
/*@end @*/

//for Safari
if (/WebKit/i.test(navigator.userAgent)) {
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			onDomReadyLoad();
		};
	}, 10);
};

//for other browsers
window.onload = onDomReadyLoad;