function SetFocus() {
  if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i=0; i<field.length; i++) {
      if ( (field.elements[i].type != "image") && 
           (field.elements[i].type != "hidden") && 
           (field.elements[i].type != "reset") && 
           (field.elements[i].type != "submit") ) {

        document.forms[0].elements[i].focus();

        if ( (field.elements[i].type == "text") || 
             (field.elements[i].type == "password") )
          document.forms[0].elements[i].select();
        
        break;
      }
    }
  }
}
function confirmLink(theLink, confirmMsg)
{
    var is_confirmed = confirm(confirmMsg);

    return is_confirmed;
}

function CheckAll(id, checked) {
	count = document.all.length;
	for (i=0; i<count;i++) {
		if (document.all[i].id == id) 
			document.all[i].checked = checked;
	}
}

function CheckAllSub(id, checked) {
	var str;	
	var count = document.all.length;
	var len = id.length;

	for (i=0; i<count;i++) {
		str = document.all[i].id;
		if (str.substr(0,len) == id) 
			document.all[i].checked = checked;
	}
}

function ShowAll(id, bShow) {
	if (navigator.appName=='Netscape') {
		document.getElementById(id).style.left = 0; 
		document.getElementById(id).style.visibility=(bShow?"visible":"hidden");

	} else {
	count = document.all.length;
	for (i=0; i<count;i++) {
		if (document.all[i].id == id) 
			document.all[i].style.display = (bShow ? 'block' : 'none');
	}
}
}

function object_show(name, id)
{	
	count = document.all.length;
	for (i=0; i<count;i++) {
		if (document.all[name+i]) {
			document.all[name+i].style.display='none';
		}
	}
	if (document.all[name+id]) {
		document.all[name+id].style.display='block';
	}
}

function checkFields(formobj, $req, $desc){
	// name of mandatory fields
	var fieldRequired = $req;
	// field description to appear in the dialog box
	var fieldDescription = $desc;
	// dialog message
	var alertMsg = "";

	var l_Msg = alertMsg.length;

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];

		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}
	
	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}
function setPointer(theRow, thePointerColor, theNormalBgColor)
{
    var theCells = null;

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var currentColor = null;
    var newColor     = null;
    // Opera does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        } // end for
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = newColor;
        }
    }

    return true;
}
function getclip()
{
top.name = "main_window"
var popurl = "/stream/video/news/video.php?bantyp=1"
var popup = window.open(popurl,"nvideo",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=200,height=275');
if(navigator.appName.substring(0,8) == "Netscape")
{
popup.location = popurl;
popup.opener = self;
}
}
function getclip2()
{
top.name = "main_window"
var popurl = "/stream/video/news/video.php?bantyp=2"
var popup = window.open(popurl,"nvideo2",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=320,height=370');
if(navigator.appName.substring(0,8) == "Netscape")
{
popup.location = popurl;
popup.opener = self;
}
}
function getclip3(video){
	top.name = "main_window"
	var popurl = "/stream/video/news/video.php?video="+video;
	var popup = window.open(popurl,"nvideo3",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=320,height=370');
	if(navigator.appName.substring(0,8) == "Netscape"){
		popup.location = popurl;
		popup.opener = self;
	}
}
function getclip4(video){
	top.name = "main_window"
	var popurl = "/stream/video/news/video.php?url=1&video="+video;
	var popup = window.open(popurl,"nvideo3",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=320,height=370');
	if(navigator.appName.substring(0,8) == "Netscape"){
		popup.location = popurl;
		popup.opener = self;
	}
}
function getradio(){
	top.name = "main_window"
	var popurl = "http://www.rumir.de/radio/index.php";
	var popup = window.open(popurl,'Radio','width=200,height=175,directories=no,toolbar=no,location=no,menubar=no,scrollbars=no,status=no,resizable=no,dependent=no,fullscreen=no');
	if(navigator.appName.substring(0,8) == "Netscape"){
		popup.location = popurl;
		popup.opener = self;
	}
}
function gethandy(url){
	top.name = "main_window"
	var popurl = url;
	var popup = window.open(popurl,"handy",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=400');
	if(navigator.appName.substring(0,8) == "Netscape"){
		popup.location = popurl;
		popup.opener = self;
	}
}
function make_popup(url){
	top.name = "main_window"
	var popurl = url;
	var popup = window.open(popurl,"handy",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=565');
	if(navigator.appName.substring(0,8) == "Netscape"){
		popup.location = popurl;
		popup.opener = self;
	}
}
function setCookie_sb(){
	document.all.small_banner_form.submit();
}

function get_player_x(id,start){
	var deid=decode_x(id);
	var player = '<embed src="http://www.rumir.de/stream/'+deid+'.asx" width="190" height="25" autostart="'+start+'" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" id="mp" name="mp"> </embed>';
	document.write(player);
}
var base64s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
function decode_x(encStr){
	var bits;
	var decOut = '';
	var i = 0;
	for(; i<encStr.length; i += 4){
		bits = (base64s.indexOf(encStr.charAt(i)) & 0xff) <<18 |
			 (base64s.indexOf(encStr.charAt(i +1)) & 0xff) <<12 |
			 (base64s.indexOf(encStr.charAt(i +2)) & 0xff) << 6 |
			  base64s.indexOf(encStr.charAt(i +3)) & 0xff;
		decOut += String.fromCharCode((bits & 0xff0000) >>16, (bits & 0xff00) >>8, bits & 0xff);
	}
	if(encStr.charCodeAt(i -2) == 61){
		return(decOut.substring(0, decOut.length -2));
	}else if(encStr.charCodeAt(i -1) == 61){
		return(decOut.substring(0, decOut.length -1));
	}else {
		return(decOut)
	};
}

