/** Gewinnspiel **/
function test_form(formularname) {
	var checked = false;
	var send 		= true;
	var errormsg 	= "";
	var checkfieldarray = new Array("vorname", "nachname", "strasse", "plz", "ort", "email");
				for (i=0; i<document.forms[formularname].loesung.length; i++) {
					if (document.forms[formularname].loesung[i].checked) {
						checked = true;
					}
				}
				if (!checked) {
					errormsg = "Bitte geben Sie eine Lösung an\n";
				}
	for(var n=0; n<checkfieldarray.length; n++) {
		if(document.forms[formularname].elements[checkfieldarray[n]].value == "") {
			errormsg += "Bitte füllen Sie das Feld " + checkfieldarray[n].toUpperCase() + " aus\n";
		}
	}
	if(errormsg != "") {
		send = false;
		alert(errormsg);
	}
	else if(send == true) {
		document.forms['gewinnspiel'].submit();
	}
}
/** Gewinnspiel **/


//<!-- Begin
var initialsubj	= "Hallo, hier eine interessante Seite bei Sportal.ch";
var initialmsg	= "Schau Dir mal diese Seite an: "+window.location;

var good;

function get_article_liveid() {
	var id 		= 0;
	try {
		var url 	= window.location.href;
		var temp_array 	= url.split('/');
		var temp_array2 = temp_array[temp_array.length-1].split('.');
		id 		= temp_array2[0];
	}
	catch(e) {
		alert( e.toString() );
	}
	return id;
}

var article_liveid  = get_article_liveid();

function checkEmailAddress(field) {
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
	if (goodEmail) {
		good = true;
	}
	else {
		alert('Bitte eine Email Adresse eingeben');
		field.focus();
		field.select();
		good = false;
   }
}
u = window.location;
function mailThisUrl() {
	good = false;
	checkEmailAddress(document.eMailer.email);
	if (good) {
		//window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+document.title+" "+u;
		window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+initialmsg;
   }
}
//  End -->

//ecards
function open_ecard(id) {
	//http://www.sportal.de
	ecardsWindow = window.open("/sportal/service/ecards/ecard.php?" + id, "ECards", "width=660, height=640, top=50,left=50,scrollbars=no,resizable=no");
}
	
//<!-- Tell a friend -->
function win_tellafriend1() {    
	var url=window.location;
	//http://www.sportal.de
	tellafriendWindow=window.open("/scripts/tellafriend/tellafriend.php?url="+url, "win_tellafriend","height=400,width=450,left=350,top=155,scrollbars=no,resizable=no");    
}    

//<!-- Textgroesse anfang -->
var faktor = 0.15; 			
var start_groesse = 0.75; 		
var anz = 0; 					
function fontsizer(inc, reset) {
	if ((anz + inc >= 0) && (anz + inc <= 2)) {
		anz += inc;
		neue_groesse = anz * faktor + start_groesse;
		artikel_text = document.getElementById('content_artikel');
		artikel_text.style.fontSize = neue_groesse + "em";
	}
	switch (anz) {
		case 0:
			document.getElementById("fsminus").src = "/sportch/images/icons/schrift_minus_inaktiv.gif";
			break;
		case 2:
			document.getElementById("fsplus").src = "/sportch/images/icons/schrift_plus_inaktiv.gif";
			break;
		default:	
			document.getElementById("fsplus").src = "/sportch/images/icons/schrift_plus.gif";
			document.getElementById("fsminus").src = "/sportch/images/icons/schrift_minus.gif";
			break;					
	}
}
//<!-- Textgroesse ende -->

//<!-- Kontaktformular anfang -->
function open_kontakt() {
	kontaktWindow = window.open("/de/sportch/service/kontakt/kontakt.php?", "poppage", "width=440,height=590,top=155,left=350,scrollbars=no,resizable=no");
}
//<!-- Kontaktformular ende -->

//<!-- Kontaktformular Tour de Suisse anfang -->
function open_kontakt_tds() {
	kontaktWindow = window.open("/de/tourdesuisse/service/kontakt/kontakt.php?", "poppage", "width=460,height=590,top=155,left=350,scrollbars=yes,resizable=no");
}
//<!-- Kontaktformular Tour de Suisse ende -->

//<!-- Kontaktformular Tour de Suisse FR anfang -->
function open_kontakt_tds_fr() {
	kontaktWindow = window.open("/de/tourdesuisse/service/kontakt/kontakt_fr.php?", "poppage", "width=460,height=590,top=155,left=350,scrollbars=yes,resizable=no");
}
//<!-- Kontaktformular Tour de Suisse FR ende -->

//<!-- VideoPlayerPopup anfang -->
function open_video() {
	kontaktWindow = window.open("http://sportal.nunet.de/videonews/sportal-player.html", "poppage", "width=748,height=555,top=155,left=350,scrollbars=no,resizable=no");
}

function open_nl_help() {
	kontaktWindow = window.open("http://www.sport.ch/sportch/service/newsletter/outlook.htm", "poppage", "width=300,height=325,top=10,left=10,scrollbars=no,resizable=no");
}

//<!-- VideoPlayerPopup ende -->

//<!-- VideoPlayer anfang -->

function openNewWindow2(url, name, x, y) {
window.open(url, name, "height="+x+", width="+y+", toolbar=no, scrollbars=no");
}
//<!-- VideoPlayer ende -->

/** i.P. allgemeine Funktionen */
/** Bildergalerie start */ 
function trim_text(text, strlimit, wordlimit) { 
	if(text.length > strlimit) {
		textA		= text.split(" ");
		text_short	= "";
		for(w=0; w<wordlimit; w++) {
			text_short 	+= textA[w] + " "; 
		}
		text_short 	+= " ...";
	}
	else text_short = text;
	return text_short;
}

function change_div(div_id, content) {
	if(document.getElementById && document.getElementById(div_id)) {
		document.getElementById(div_id).innerHTML = content;
	} else if(document.all && document.all[div_id]) {
		document.all[div_id].innerHTML = content;
	}
}

function in_array(value, array_name) {
	found = false;
	for(n=0; n<array_name.length; n++) {
		if(array_name[n] == value) {
			found = true;
			break;
		}
	}
	return found;
}

function change_class(divname, class_name) {
	try {
		if(document.getElementById(divname)) {
			document.getElementById(divname).className = class_name;
		}
	}
	catch(e) {
	//	show_error(e + ": " + divname);
	}
}

function dummy() {
	//return;
}
/** Bildergalerie end */ 


/** MC - POPUP Start **/
function open_mc(url) {
	// NEU: Neuen Fensternamen für jedes MC!
	var omc_wname = Math.floor(Math.random()*1000000000000);
	var default_window_height = 790;
	var default_window_width = 840;
	var default_scrollbars = "no";
	
	var screen_height = screen.height;
	if (isNaN(screen_height)) {
		screen_height = 768;		
	}
	var max_window_height = Math.floor(screen_height-50);
	/*
	if ((url.indexOf("tennis") > 0) || (url.indexOf("radsport") > 0)) {
		var window_height = 735;
		var window_width = default_window_width;
	} else {
		if ((url.indexOf("fussball") > 0) && (url.indexOf("bundesliga") > 0)) {
			// Bundesliga: Wallpaper: Größeres Fenster
			*/
			var window_height = 830;
			var window_width = 1000;
			/*
		} else {
			// Default
			var window_height = 790;
			var window_width = default_window_width;
		}
	}
	*/
	if (window_height > max_window_height) {
		window_height = max_window_height;
		default_scrollbars = "yes";
		window_width = Math.floor(window_width+20);
	}
	window.open(url, omc_wname, "width=" +(window_width)+ ",height=" +(window_height)+ ",top=50,left=50,scrollbars=" +(default_scrollbars)+ ",resizable=no");
}
/** MC - POPUP End**/


function makeHomepage() { /* Variablen */ 
	var homepage_url 	= "http://www.sport.ch"; 
	var browser 		= navigator.appName; 
	var version 		= navigator.appVersion.substring(0,1); 
	if ((browser=='Netscape') && (version >= 4 && version < 5)) { 
		window.onerror=java_error; 
		netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesWrite');
		navigator.preference('signed.applets.codebase_principal_support', true);
		navigator.preference('browser.startup.homepage', homepage_url); 
		alert('Herzlichen Gl&uuml;ckwunsch, ' + homepage_url + ' ist nun Ihre Startseite.'); 
	} 
	else if ((browser=='Microsoft Internet Explorer') && (version >= 4)) { 
		/* MSIE 4.x, 5.x Version */ 
		document.body.style.behavior='url(#default#homepage)'; 
		document.body.setHomePage(homepage_url); 
	} 
	else { 
		/* Manuelle Einstellung noetig */ 
		alert('Bitte stellen Sie Ihre Startseite manuell ein.'); 
	} 
} 


function addNet(url,titel){if((typeof window.sidebar=="object") && (typeof window.sidebar.addPanel=="function")){window.sidebar.addPanel(titel,url,"");}else{alert("Sie nutzen eine veraltete Netscape Version!\nLesezeichen hinzufügen ist nicht möglich!");}}

function lesezeichen(){var url=window.location.href,t=document.title,ap=navigator.appName;
if(ap=="Microsoft Internet Explorer"){window.external.AddFavorite(url,t);}else{
if(ap=="Netscape"){addNet(url,t);}else{alert("Mit ihrem Browser ist kein Lesezeichen über Javascript möglich.\nBitte legen Sie das Lesezeichen manuell an.\nURL:"+url);};}};


function openwin(url,width,height)
{
	window.open(url, 'TdS08', "width=" + width + ",height=" + height + ",top=0,left=0,scrollbars=yes,resizable=no");
}