function submit_dropdown(id){
	var index;
	index=eval("this.document.dropdown" + id + ".list" + id + ".selectedIndex");
	self.location=eval("this.document.dropdown" + id + ".list" + id + ".options["+index+"].value");
	return false;
}


function open_win(url, name, param) {
        var win = window.open(url, name, param);
        win.focus();
}
//+ " , resizable=yes, scrollbars=yes"
function openloginpop() {
        loginpopup = window.open('','loginpopup','width=700,height=700,scrollbars=yes');
        loginpopup.focus();
        return true;
}


function supersizeWin(path, name) {
        screenWidth = screen.availWidth;
        screenHeight = screen.availHeight;

        browser=navigator.userAgent;
        if ((browser.indexOf("MSIE")!=-1)) {
                width = screenWidth - 12;
                height = screenHeight - 40;
        } else {
                width = screenWidth;
                height = screenHeight;
        }
        window.open(path+"?width="+width+"&height="+height,"Supersize","width=" + width + ",height=" + height + ",left=0,top=0,location=no,menubar=noscrollbars=auto,status=no,toolbar=no,resizable=yes");
        //return false;
}


function maske_go(id){
	var index;
	index=eval("this.document.dropdown" + id + ".list" + id + ".selectedIndex");
	self.location=eval("this.document.dropdown" + id + ".list" + id + ".options["+index+"].value");
	return false;
}
function maske_go_blank(id){
	var index;
	index=eval("this.document.dropdown" + id + ".list" + id + ".selectedIndex");
	URL=eval("this.document.dropdown" + id + ".list" + id + ".options["+index+"].value");
	window.open(URL);
	return false;
}

function loginpopup() {
	window.open("","loginwin","width=795,height=560,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes");
return true;
}


function check_weight_input(form) {
	var x = eval("document.forms['"+form+"'].elements");

        //var x = document.forms['daten'].elements;
        var ok = 1;
	var text = "";
        browserType = navigator.appName;
        if (browserType.indexOf('Explorer') > -1 ) {
                var ie = 1
        } else {
                var ie = 0
        }

	if (form == 'bewertung') {
		var radio_selected = false;
	} else {
		var radio_selected = true;
	}

        for (var i=0; i<x.length; i++) {
		var type = x[i].type;
		var name = x[i].name;
		var value = x[i].value;

		if (form == 'bewertung' && type=="radio") {
			if (x[i].checked == true) {
				radio_selected = true;
                	}
		}

                if (x[i].getAttribute('required') ) {
                        if (ie) {
                                var cl = x[i].getAttribute('className');
                                x[i].setAttribute("className", cl.replace(/input_field_error/gi,""), "false");
                        } else {
                                var cl = x[i].getAttribute('class');
                                x[i].setAttribute("class", cl.replace(/input_field_error/gi,""), "false");
                        }
                }

		if (x[i].name == "age") {
			if ( x[i].value < 17 || x[i].value > 70 ) {
				var text = text + "Der BMI wird nur f&uuml;r Personen zwischen 17 und 69 ermittelt.<br>";
				var ok = 0;

        	                if (ie) {
	                                var cl = x[i].getAttribute('className');
                                	x[i].setAttribute("className", cl + " input_field_error", "false");
                        	} else {
                	                var cl = x[i].getAttribute('class');
        	                        x[i].setAttribute("class", cl + " input_field_error", "false");
	                        }
			}
  		}


		if (x[i].getAttribute('number') && isNaN(x[i].value)  ) {
			var text = text + "Bei dezimalen Angaben bitte einen '.' benutzen.<br>";
			var ok = 0;
                        if (ie) {
                                var cl = x[i].getAttribute('className');
                                x[i].setAttribute("className", cl + " input_field_error", "false");
                        } else {
                                var cl = x[i].getAttribute('class');
                                x[i].setAttribute("class", cl + " input_field_error", "false");
                        }
		}

                if (x[i].getAttribute('required') && !x[i].value) {
                        if (ie) {
                                var cl = x[i].getAttribute('className');
                                x[i].setAttribute("className", cl + " input_field_error", "false");
                        } else {
                                var cl = x[i].getAttribute('class');
                                x[i].setAttribute("class", cl + " input_field_error", "false");
                        }
                        var ok = 0;
                }

        }

	if (form == 'bewertung') {
		var text="";
	}

	if (radio_selected == false) {
		var text ='Bitte w&auml;hlen Sie eine Bewertung!';
		ok = 0;
	}
	document.getElementById('warning_text').innerHTML=text;
	if (ok) eval("document.forms['"+form+"'].submit()");
}


/***
 * Javascript Flash Detection (14.02.2005)
 * (c) Oliver Nowak
 * http://www.deydesigns.com
 *
 *
 *
 * Nicht vergessen, credits where they are due.
 */

function flash_detection(required, max)
{
    var required_version = required;
    var max_version = max;
    var available_version = 0;


     if(typeof(navigator.plugins["Shockwave Flash"]) == "object")
    {
        var description = navigator.plugins["Shockwave Flash"].description;
        available_version = description.substr(16, (description.indexOf(".", 16) - 16));
    }
     else  if(typeof(ActiveXObject) == "function")
    {
         for(var i = 2; i < (max_version + 1); i ++)
        {
            try
            {
                 if(typeof(new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i)) == "object")
                {
                    available_version = i;
                }
           }
           catch(error)
           {
           }
        }
    }
    return [available_version, required_version];
}

var active = 'flnav_0';
function highlight(new_active){
	if(active!=0)document.getElementById(active).className = "";
	document.getElementById(new_active).className = "dark_grey";
	active = new_active;
}


function doPassVar(videoThumb,vid2play,stopp,videotitle,zoomURL,phpURL){
        var sendText = videoThumb;
        window.document.ar_flash.SetVariable("DSLVideo",  vid2play );
        window.document.ar_flash.SetVariable("ISDNVideo", vid2play );
        window.document.ar_flash.SetVariable("videoThumb",videoThumb);
        window.document.ar_flash.SetVariable("videoName",videotitle);
	window.document.ar_flash.SetVariable("zoomURL",zoomURL);
        window.document.ar_flash.SetVariable("pauseStatus",0);
//	window.document.ar_flash.SetVariable("phpURL",phpURL);
}

/* general window opening script */
function openwindow(url,wname,w,h,scroll,resize,statusbar,menubar,toolbar,locbar)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/4 : 0;
	settings =	'screenX=' + LeftPosition +
				', screenY=' + TopPosition +
				', left=' + LeftPosition +
				', top=' + TopPosition +
				', toolbar= ' + toolbar +
				', location=' + locbar +
				', directories=no ' +
				', status=' + statusbar +
				', menubar=' + menubar +
				', resizable=' + resize +
				', scrollbars=' + scroll +
				', height=' + h +
				', width=' + w;

	win = window.open(url,wname,settings);
	if(win.window.focus)
	{
		win.window.focus();
	}
}

function setHeight()
{
//???? document.getElementById("head").offsetHeight ist 0 ???
alert(document.getElementById("head").offsetHeight);
    var newHeight = document.getElementById("sp2").offsetHeight;
    //newHeight += document.getElementById("head").offsetHeight;
    newHeight += document.getElementById("subhead").offsetHeight;
    newHeight += document.getElementById("navigation").offsetHeight;
    newHeight += document.getElementById("sub_navigation").offsetHeight;
    newHeight += document.getElementById("artikel_navigation_page_linie").offsetHeight;
    newHeight += 17; // height of #head
    //newHeight += 120;
    newHeight += 20;
    //alert(newHeight);
    document.getElementById("subhome").style.height = newHeight+"px";
    alert(document.getElementById("subhome").style.height);
    //document.getElementById("subhome").style.background = "red";
     
}



function article_toggleImage(url, title, image_number)
{
    document.getElementById("article_pic").innerHTML = "<img src='"+url+"' height=\"151\" />";
    document.getElementById("artikel_bildunterschrift").innerHTML = title;
    var popup_link = document.getElementById("popup_link").href;
    document.getElementById("popup_link").href = popup_link.replace(/,.,/,","+image_number+",");
}

function article_rate(id, rating)
{
    var response = $.ajax({ url: "/ajax/rating.php?id="+id+"&rating="+rating, async: false }).responseText;
    var params = response.split(";");
    document.getElementById("div_rating").style.width = params[0]+"px";
    document.getElementById("times_rated").innerHTML = params[1];
}
