var UA = navigator.userAgent.toLowerCase();
var OS = detectOS();
var BRW = detectBrowser();

//alert('OS: '+OS+' - BRW: '+BRW);

function detectOS() {
	if (checkIt('linux')) return "LINUX";
	else if (checkIt('x11')) return "UNIX";
	else if (checkIt('mac')) return "MAC"
	else if (checkIt('win')) return "WIN"
	else return "UNKNOWN";		
}

function detectBrowser() {
	if (checkIt('msie')) return "IE";
	else if (checkIt('firefox')) return "FIREFOX";
	else if (checkIt('safari')) return "SAFARI";
	else if (checkIt('opera')) return "OPERA";			
	else return "UNKNOWN";		
}

function checkIt(str) {	
	return UA.indexOf(str) + 1; 
}


//
// POPUP WINDOW
// 

function popWin(url,h,w,resize,scrollbar) {
	if (!h) h = 400;
	if (!w) w = 600;
	if (!resize) resize = 0;
	if (!scrollbar) scrollbar = 0;
	l = (screen.width-w)/2; 
	t = (screen.height-h)/2;	
	var winId = window.open(url,"_blank","toolbar=0,scrollbars="+scrollbar+",location=0,status=0,menubar=0,resizable="+resize+",width="+w+",height="+h+",left="+l+",top="+t);	
	winId.focus();	
}


//
// FLASH OBJECT
//

function attachFlashMovie(swfMovie,bgColor,w,h) {
	flashMovieSurfix = swfMovie.substr(0,3);
	if (!bgColor) bgColor = '#000000';	
	if (!w) w = '100%';
	if (!h) h = '100%';
	document.write('<object id="flashMovie' + flashMovieSurfix + '" width="' + w + '" height="' + h + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="' + swfMovie + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="' + bgColor + '" />');
	document.write('<param name="FlashVars" value="' + window.location.search.substring(1) + '" />');
	document.write('<embed src="' + swfMovie + '" id="flashMovieEmbed' + flashMovieSurfix + '" width="' + w + '" height="' + h + '" FlashVars="' + window.location.search.substring(1) + '" quality="high" bgcolor="' + bgColor + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}	


//
// TOGGLE SHOW / HIDE
//

function toggleContent(id) {
	var obj = document.getElementById(id);
	obj.style.display = (obj.style.display == 'none') ? '' : 'none';
}