/** 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.de";
var initialmsg	= "Schau Dir mal diese Seite an: "+window.location;
var good;

/** id wird bei Aufruf im Link "Artikel kommentieren" verwendet (Funktion add_comment)*/
function get_article_liveid() {
	var id 		= 0;
	try {
		var url 		= window.location.href;
		var temp_array 	= url.split('/');
		var last_split 	= temp_array[temp_array.length-1];
		if(last_split.indexOf(".") != -1) {
			var temp_array2 = last_split.split('.');
			id 				= temp_array2[0]; //Artikel-ID
		}
		else id = "index";
	}
	catch(e) {
	//	alert( e.toString() );
	}
	return id;
}
var article_liveid  = get_article_liveid(); //execute

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 -->


/** Video - POPUP Start **/
function popup_video(url) {
	// NEU: Neuen Fensternamen für jedes MC!
	var omc_wname = Math.floor(Math.random()*1000000000000);
	var default_window_width = 748;
	var default_window_height = 550;
	var default_scrollbars = "no";
	
	var screen_height = screen.height;
	if (isNaN(screen_height)) {
		screen_height = 700;		
	}
	var max_window_height = Math.floor(screen_height-50);
		
	// Default
	var window_height = 550;
	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");
}
/** Video - POPUP End**/


/** Video - Inhouse POPUP Start **/
function popup_video_new(url) {
	// NEU: Neuen Fensternamen für jedes MC!
	var omc_wname = Math.floor(Math.random()*1000000000000);
	var default_window_width = 920;
	var default_window_height = 790;
	var default_scrollbars = "no";
	
	var screen_height = screen.height;
	if (isNaN(screen_height)) {
		screen_height = 750;		
	}
	var max_window_height = Math.floor(screen_height-50);
		
	// Default
	var window_height = default_window_height;
	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");
}
/** Video - Inhouse POPUP End**/


/** Video - Inhouse POPUP Start **/
function popup_video_new_ms(url) {
	// NEU: Neuen Fensternamen für jedes MC!
	var omc_wname = Math.floor(Math.random()*1000000000000);
	var default_window_height = 700;
	var default_window_width = 1000;
	var default_scrollbars = "no";
	
	var screen_height = screen.height;
	if (isNaN(screen_height)) {
		screen_height = 750;		
	}
	var max_window_height = Math.floor(screen_height-50);
		
	// Default
	var window_height = default_window_height;
	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");
}
/** Video - Inhouse POPUP 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 = "/sportal/images/icons/schrift_minus_inaktiv.gif";
			break;
		case 2:
			document.getElementById("fsplus").src = "/sportal/images/icons/schrift_plus_inaktiv.gif";
			break;
		default:	
			document.getElementById("fsplus").src = "/sportal/images/icons/schrift_plus.gif";
			document.getElementById("fsminus").src = "/sportal/images/icons/schrift_minus.gif";
			break;					
	}
}
//<!-- Textgroesse ende -->

//<!-- Kontaktformular anfang -->
function open_kontakt() {
	kontaktWindow = window.open("/de/sportal/service/kontakt/kontakt.php?", "poppage", "width=440,height=590,top=155,left=350,scrollbars=no,resizable=no");
}
//<!-- Kontaktformular 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.sportal.de/sportal/service/newsletter/outlook.htm", "poppage", "width=300,height=325,top=10,left=10,scrollbars=no,resizable=no");
}
//<!-- VideoPlayerPopup ende -->

//<!-- VideoPlayer anfang -->
function openNewWindow2(winurl, winname, winx, winy) {
	newWindow = window.open(winurl, winname, "width="+winy+",height="+winx+",toolbar=no,scrollbars=no");
}
//<!-- VideoPlayer ende -->

/** 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) {
	try {
       	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;
		}
	}
	catch (e) {
		alert(e);
	}
}

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) {
  try {
    
    // NEU: Neuen Fensternamen für jedes MC!
	var omc_wname 				= Math.floor(Math.random()*1000000000000);
	var default_window_height 	= 761; //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);
    /** *************** Olympiade ********************* */
	if (url.indexOf("olympia") != -1) {
		if(url.indexOf("konferenz") != -1) {
			var window_height 	= 690;
			var window_width 	= 950;
		} else if (url.indexOf("fussball") != -1) {
			var window_height 	= 675;
			var window_width 	= 927;
		} else if (url.indexOf("radsport") != -1) {
			var window_height 	= 724;
			var window_width 	= 960;
		} else if (url.indexOf("tennis") != -1) {
			var window_height 	= 724;
			var window_width 	= 960;	
		} else if (url.indexOf("handball") != -1) {
			var window_height 	= 768;
			var window_width 	= 960;
		} else if (url.indexOf("basketball") != -1) {
			var window_height 	= 768;
			var window_width 	= 960;
		}
	}
    /** ************************************************* */

/** Eishockey */
//hier 'if', weil sonst die eishockey/olympia-qualifikation übergangen wird [20090526 wschleiwies]
	if(url.indexOf("eishockey/del") != -1) {			// Neues Design! 
		var window_height 	= 671;
		var window_width 	= 994;
	} else if(url.indexOf("eishockey/eishockey-wm") != -1) {	/* MC 5*/
		var window_height 	= 680;
		var window_width 	= 1000;
	} else if(url.indexOf("eishockey/olympia-qualifikation") != -1) {	
		var window_height 	= 671;
		var window_width 	= 990;
	} else if(url.indexOf("eishockey") != -1) {	/* default Eishockey*/	
		var window_height 	= 661;
		var window_width 	= 1000;
	} 
/** ********* */
/** Fussball */
	else if(url.indexOf("fussball/laenderspiel") != -1) {				
		var window_height 	= 661;
		var window_width 	= 1000;
	} 
    else if(url.indexOf("fussball/regionalliga") != -1) {				 
		var window_height 	= 700;
		var window_width 	= 1000;
	} 
    else if(url.indexOf("fussball/em") != -1) {						
		var window_height 	= 761;
		var window_width 	= 968;
	} 
    /* *************** MC 5 ******************** */
    else if(url.indexOf("fussball/wm-qualifikation") != -1) {	// 
		var window_height 	= 700;
		var window_width 	= 990;
	} else if(url.indexOf("fussball/champions-league") != -1) {		
		var window_height 	= 700;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/uefa-cup") != -1) {				
		var window_height 	= 700; 
		var window_width 	= 1000;	
	} else if(url.indexOf("fussball/europaleague") != -1) {			
		var window_height 	= 700; 
		var window_width 	= 1000;	
	} else if(url.indexOf("fussball/1bundesliga") != -1) {	 	 
		var window_height 	= 700;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/2bundesliga") != -1) {	 	 
		var window_height 	= 700;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/dritte-liga") != -1) { 
		var window_height 	= 700;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/frauen-em") != -1) { 
		var window_height 	= 700;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/dfb-pokal") != -1) {	 	 
		var window_height 	= 700;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/u21-em") != -1) {			
		var window_height 	= 690;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/confederations-cup") != -1) {
		var window_height 	= 690;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/testspiel") != -1) {         
		var window_height 	= 690;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/serie-a") != -1) {           
		var window_height 	= 695;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball/premier-league") != -1) {           
		var window_height 	= 695;
		var window_width 	= 1000;
	} else if(url.indexOf("fussball") != -1) { 	/** defaultFussball */
		var window_height 	= 732;
		var window_width 	= 1000;
	} else if (url.indexOf("olympia") != -1) {
		var window_height 	= 695;
		var window_width 	= 1000;
	}
/** ***** Handball ***** */
	else if(url.indexOf("handball/handball-wm") != -1) {				// niedrigeres  Fenster
		var window_height 	= 710;
		var window_width 	= 1000;
	} 
/** ******************** */

/** ***** Motorsport ***** */
	 else if(url.indexOf("motorsport/formel1") != -1) {		/* mc 5 */			// Wallpaper: Größeres Fenster
		var window_height 	= 670;
		var window_width 	= 1000;
	} else if(url.indexOf("motorsport/motorrad") != -1) {				// Wallpaper: Größeres Fenster
		var window_height 	= 721;
		var window_width 	= 1000;
	} else if(url.indexOf("motorsport/dtm") != -1) { // niedrigeres  Fenster
		var window_height 	= 731;
		var window_width 	= 1000;
	}
/** ******************** */

	else if(url.indexOf("boxen") != -1) {					// niedrigeres  Fenster
		var window_height 	= 720;         /* MC 5 */
		var window_width 	= 1000;
	} else if(url.indexOf("radsport") != -1) {				// Wallpaper: Größeres Fenster
		var window_height 	= 670;
		var window_width 	= 1000;
	}   
    else if(url.indexOf("basketball") != -1) {               // Wallpaper: Größeres Fenster
		var window_height 	= 690;
		var window_width 	= 1000;
	} else if(url.indexOf("golf") != -1) {		/* MC 5*/	// niedrigeres  Fenster
		var window_height 	= 710;
		var window_width 	= 1000;
	} else if(url.indexOf("tennis") != -1) {	/* MC 5*/	// Wallpaper: Größeres Fenster
		var window_height 	= 670;
		var window_width 	= 1000;
	} else if(url.indexOf("wintersport/biathlon") != -1) { // Wallpaper: Größeres Fenster
		var window_height 	= 690;
		var window_width 	= 1000;
	} else if(url.indexOf("wintersport") != -1) {
		var window_height 	= 731;
		var window_width 	= 1000;
	}  else if(url.indexOf("leichtathletik") != -1) {               // Wallpaper: Größeres Fenster
		var window_height 	= 690;
		var window_width 	= 1000;
	}  else if(url.indexOf("handball/bundesliga") != -1) {               // Wallpaper: Größeres Fenster
		var window_height 	= 690;
		var window_width 	= 1000;
	} else if(url.indexOf("handball/handball-em") != -1) {				// niedrigeres  Fenster
		var window_height 	= 690;
		var window_width 	= 1000;
	} 

/** Default */ 
	 else {											
		var window_height 	= default_window_height;
		var window_width  	= default_window_width;
    }

/*	if(navigator.appVersion.indexOf("MSIE 7.0") != -1) {
		window_height += 20; //wg. der titleleiste oben
	} */	
	if (window_height > max_window_height) {
		window_height 		= max_window_height;
		default_scrollbars 	= "yes";
		window_width 		= Math.floor(window_width+20);
	}
	parameters = "width=" +(window_width)+ ",height=" +(window_height)+ ",top=50,left=50,scrollbars=" +(default_scrollbars)+ ",resizable=no,toolbar=no,location=no";
    window.open(url, omc_wname, parameters);
  }
  catch(e) {
  //nix
  }
  //alert(window_height);   // DEBUG
}
/** MC - POPUP End**/

function open_mc_move(url) {
	var window_height 	= 770;
	var window_width 	= 1000;
	var omc_wname 		= Math.floor(Math.random()*1000000000000);
	var default_scrollbars 		= "no";
	fenster = window.open(url, omc_wname, "width=" +(window_width)+ ",height=" +(window_height)+ ",top=50,left=50,scrollbars=" +(default_scrollbars)+ ",resizable=no");
	fenster.moveTo(30,30);
}

function border_scroll() {
	var scroll_y = 0;
	if(document.all) {
		scroll_y = document.body.scrollTop;
	} else {
		scroll_y = window.pageYOffset;
	}
	return scroll_y;
}

function object_place(object, pos_x, pos_y) {
	if(document.all) {
		window.document.all[object].style.left	= pos_x;
		window.document.all[object].style.top	= pos_y;
	} else {
		window.document.getElementById(object).style.left	= pos_x;
		window.document.getElementById(object).style.top	= pos_y;
	}
}

function add_comment(art_liveid) {
	//dummy
}

function dummy() {
	//dummy
}

// Popunder Funktion
function doPopUnder(pfile,ptarget,width,height,left,top) {
	popunder = window.open(pfile,"pu","width="+width+",height="+height+",left="+left+",top="+top);
	popunder.blur();
	window.focus();
		
	window.location.href = ptarget;
}

// TNT PopUp öffnen
function pop_tnt() {
	var tntpopup	= window.open("/sportal/sportnachrichten/pop-up/index.html", "sportalTNTPopup", "width=515,height=561,top=50,left=50,resizable=no,toolbar=no,location=no,menubar=no"); 
	tntpopup.focus();
}

// Open livescores
function livescoresPopupTeaser(sport) {
    window.open("/sportal/live-ergebnisse/index.php?sport=" + sport, "livescores", "width=1022,height=690,top=0,left=0,scrollbars=auto,resizable=no,toolbar=no,location=no");
}

var random_dc   = Math.round(Math.random() * 1000000000);//9stellig
