

function popup (url, name, width, height, scrollbars)
{
	left_pos = (screen.width / 2) - (width / 2);
	top_pos = (screen.height / 2) - (height / 2);

	window.open(url, name, 'resizable=1,scrollbars='+scrollbars+',status=no,toolbar=no,menubar=no,width=' + width + ',height=' + height + ',left=' + left_pos + ',top=' + top_pos);	
	return false;
}


function externalLinks()
{
	$$('a').each(
		function (anchor) {
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
				anchor.target = "_blank";
		}
	);
}
Event.onDOMReady(externalLinks);


function streamLinks()
{
	$$('a.stream-link').each(
		function (link) {
			Event.observe(link, 'click', function (e) {
				popup(link.href, "stream", 470, 376, false);
				Event.stop(e);
			});
		}
	);
}
Event.onDOMReady(streamLinks);


function emptyfield (field, defaultval, blur)
{
	if ( blur == true ) {
		if (field.value == '') {
			field.value = defaultval;
		}
	} else {
		if (field.value == defaultval) {
			field.value = '';
		}
	}
}


function showStream(url, width, height, autoStart)
{
	autoStart = autoStart ? 1 : 0;

	var showControls = 1;
	var showDisplay = 0;
	var showStatusBar = 1;

	document.write(
		'<object id="mediaPlayer" width="' + width + '" height="' + height + '"' +
		' classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"' +
		' codebase="http://activex.microsoft.com/activex/controls/ mplayer/en/nsmp2inf.cab#Version=5,1,52,701"' +
		' standby="Loading Stream..." type="application/x-oleobject">' +
		' <param name="fileName" value="' + url + '">' +
		' <param name="animationatStart" value="1">' +
		' <param name="transparentatStart" value="1">' +
		' <param name="autoStart" value="'+autoStart+'">' +
		' <param name="ShowControls" value="'+showControls+'">' +
		' <param name="ShowDisplay" value="'+showDisplay+'">' +
		' <param name="ShowStatusBar" value="'+showStatusBar+'">' +
		' <param name="loop" value="0">' +
		'<embed type="application/x-mplayer2"' +
		' pluginspage="http://microsoft.com/windows/mediaplayer/en/download/"' +
		' id="mediaPlayer_embed"'+
		' name="mediaPlayer"'+
		' displaysize="4"'+
		' autosize="0"' +
		' bgcolor="darkblue"'+
		' showcontrols="'+showControls+'"'+
		' showtracker="1"' +
		' showdisplay="'+showDisplay+'"'+
		' showstatusbar="'+showStatusBar+'"'+
		' videoborder3d="0"'+
		' width="' + width + '"'+
		' height="' + height + '"' +
		' src="' + url + '"'+
		' autostart="'+autoStart+'"'+
		' designtimesp="5311"'+
		' loop="0">' +
		'</embed>' +
		'</object>'
	);
}


function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}


/**
 * Outsmarting the Google Toolbar
 * 
 * http://code.jenseng.com/google/
 */
  if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }

