/* DHTML Library
   the original DHTML Library can be found at:
   http://www.netzwelt.com/selfhtml/dhtml/beispiele/dhtml_bibliothek.htm
*/
var DHTML = 0, DHTML_DOM = 0, DHTML_MS = 0, DHTML_NS = 0, DHTML_OP = 0;

function DHTML_init() {
    if (window && window.opera) { DHTML_OP = 1; }
    if(document.getElementById) { DHTML = 1; DHTML_DOM = 1; }
    if(document.all && !DHTML_OP) { DHTML = 1; DHTML_MS = 1; }
    if (window && window.netscape && window.screen && !DHTML_DOM && !DHTML_OP){ DHTML = 1; DHTML_NS = 1; }
}

function DHTML_getElem(p1,p2,p3) {
    var Elem;
    if(DHTML_DOM) {
        if(p1.toLowerCase()=="id") { if (typeof document.getElementById(p2) == "object") Elem = document.getElementById(p2); else Elem = void(0); return(Elem); }
        else if(p1.toLowerCase()=="name") { if (typeof document.getElementsByName(p2) == "object") Elem = document.getElementsByName(p2)[p3]; else Elem = void(0); return(Elem); }
        else if(p1.toLowerCase()=="tagname") { if (typeof document.getElementsByTagName(p2) == "object" || (DHTML_OP && typeof document.getElementsByTagName(p2) == "function")) Elem = document.getElementsByTagName(p2)[p3]; else Elem = void(0); return(Elem); }
        else return void(0);
    } else if(DHTML_MS) {
        if(p1.toLowerCase()=="id") { if (typeof document.all[p2] == "object") Elem = document.all[p2]; else Elem = void(0); return(Elem); }
        else if(p1.toLowerCase()=="tagname") { if (typeof document.all.tags(p2) == "object") Elem = document.all.tags(p2)[p3]; else Elem = void(0); return(Elem); }
        else if(p1.toLowerCase()=="name") { if (typeof document[p2] == "object") Elem = document[p2]; else Elem = void(0); return(Elem); }
        else return void(0);
    } else if(DHTML_NS) {
        if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name") { if (typeof document[p2] == "object") Elem = document[p2]; else Elem = void(0); return(Elem); }
        else if(p1.toLowerCase()=="index") { if (typeof document.layers[p2] == "object") Elem = document.layers[p2]; else Elem = void(0); return(Elem); }
        else return void(0);
    }
}

DHTML_init();
/* END - DHTML Library */

function SCM_standingsInit() {
    if(typeof(SCN_HEADLINES_LOCATION) == "undefined") {
        SCN_HEADLINES_LOCATION = '';
    }

    // prevent script from running on Macintosh OS
    if (navigator.userAgent.indexOf("Mac") != -1) {
        // return;
    }
    ++SCM_ST_INIT_COUNT;
    if(SCM_ST_INITIALIZED) {
//		window.status = "ST reinit rejected " + SCM_ST_INIT_COUNT;
        return;
    } +  "\n";
//	window.status = "Standings Status: " + SCM_ST_INITIALIZED;
    if(SCM_ST_ARRAY.length < 1) {
        return;
    }

    var SCM_S_ARRAY_BUFFER = SCM_ST_ARRAY[0];

    var SCM_STANDINGS_STANDING_COUNT = 0;
    var SCM_ST_ROWCLASS		= 1;
    var SCM_STANDING_LINE	= '';
    var SCM_STANDINGS_TMP	= '<table width="' + SCM_STANDING_WIDTH + '" cellspacing="0" cellpadding="2" border="0">' + "\n";
    SCM_STANDINGS_TMP		+= '<tr>' + "\n";

    SMM_url	= location.href;
    SCM_STANDINGS_TMP		+= '<td class="SCM_ST_TABLE_HEAD" colspan="2"><a href="http://www.sportal.at/" target="_blank"><img src="http://www.sportal.at/content/images/at/logo_konfig1.gif" align="left" border="0"></a></td>' + "\n";

    SCM_STANDINGS_TMP		+= '<td class="SCM_ST_TABLE_HEAD" align="center">SP</td>' +  "\n";
    SCM_STANDINGS_TMP		+= '<td class="SCM_ST_TABLE_HEAD" align="center">S</td>' +  "\n";
    if(SCM_S_ARRAY_BUFFER[4] != '') {
        SCM_STANDINGS_TMP		+= '<td class="SCM_ST_TABLE_HEAD" align="center">U</td>' +  "\n";
    }
    SCM_STANDINGS_TMP		+= '<td class="SCM_ST_TABLE_HEAD" align="center">N</td>' +  "\n";
    SCM_STANDINGS_TMP		+= '<td class="SCM_ST_TABLE_HEAD" align="center">T</td>' +  "\n";
    SCM_STANDINGS_TMP		+= '<td class="SCM_ST_TABLE_HEAD" align="center">DIFF</td>' +  "\n";
    SCM_STANDINGS_TMP		+= '<td class="SCM_ST_TABLE_HEAD" align="center">PKT</td>' +  "\n";
    SCM_STANDINGS_TMP		+= '</tr>' +  "\n";
    SCM_STANDINGS_STANDING_COUNT = SCM_ST_ARRAY.length;

    SCM_URL		= 'sportal';
    SCM_LINK2	= '</a>'
    switch(SCM_STANDINGS_RESSORT) {
      case 'buli1': //1. Bundesliga
         SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/1bundesliga/teams.html" class="SCM_STANDINGS_LINK_1" target="_blank">';
         break;
		case 'buli2':	//2. Bundesliga
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/2bundesliga/index.html" class="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'rln':		//Regionalliga Nord
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/" class="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'rls':		//Regionalliga Süd
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/" class="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'hbb':		//Handball-Bundesliga
			SCM_LINK1	= '<a href="http://www.sportal.at/at/handball/1bundesliga/teams.html" class="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'hbemvc':		//Handball-EM
			SCM_LINK1	= '<a href="http://www.sportal.at/at/handball/em_2008/ergebnisse.html" class="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'bbb':		//Basketball Bundesliga
			SCM_LINK1	= '<a href="http://www.sportal.at/at/basketball/bbl/ergebnisse.html" class="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'del': 	//Deutsche Eishockeyliga
         SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/eishockey/index.html" class="SCM_STANDINGS_LINK_1" target="_blank">';
         break;		
      case 'tur1':	//Süper Lig Türkei
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/international/ergebnisse_tur.html" class="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'ned1':	//Eredivisie Niederlande
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/international/ergebnisse_ned.html" CLASS="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'oebl':	//T-Mobile Bundesliga Österreich
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/tmobile_liga/ergebnisse.html" CLASS="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'esp1':	//Primera Division (Spanien)
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/international/ergebnisse_esp.html" CLASS="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'ita1':	//Serie A (Italien)
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/international/ergebnisse_ita.html" CLASS="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'eng1':	//Premier League (England)
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/international/ergebnisse_eng.html" CLASS="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'chsl':	//Premier League (Schweiz)
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/international/ergebnisse_chsl.html" CLASS="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		case 'fra1':	//Ligue (Frankreich)
			SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/at/fussball/international/ergebnisse_fra.html" CLASS="SCM_STANDINGS_LINK_1" target="_blank">';
			break;
		default:
         SCM_LINK1	= '<a href="http://www.' + SCM_URL + '.at/" CLASS="SCM_STANDINGS_LINK_1" target="_blank">';
		   break;
    }

    for(var i=0;i<SCM_STANDINGS_STANDING_COUNT;i++) {
        SCM_S_ARRAY_BUFFER = SCM_ST_ARRAY[i];

        SCM_STANDING_LINE = '';
        SCM_STANDINGS_TMP += '<tr>' + "\n";

        SCM_STANDING_LINE += '<td class="SCM_STANDINGS_' + SCM_ST_ROWCLASS + '" align="right">';
        SCM_STANDING_LINE += SCM_S_ARRAY_BUFFER[0];
        SCM_STANDING_LINE += '&nbsp;</td>' + "\n";

        SCM_STANDING_LINE += '<td class="SCM_STANDINGS_' + SCM_ST_ROWCLASS + '" align="left">' + SCM_LINK1;
        SCM_STANDING_LINE += SCM_S_ARRAY_BUFFER[1];
        SCM_STANDING_LINE += SCM_LINK2 + '&nbsp;</td>' + "\n";

        SCM_STANDING_LINE += '<td class="SCM_STANDINGS_' + SCM_ST_ROWCLASS + '" align="center">';
        SCM_STANDING_LINE += SCM_S_ARRAY_BUFFER[2];
        SCM_STANDING_LINE += '&nbsp;</td>' + "\n";

        SCM_STANDING_LINE += '<td class="SCM_STANDINGS_' + SCM_ST_ROWCLASS + '" align="center">';
        SCM_STANDING_LINE += SCM_S_ARRAY_BUFFER[3];
        SCM_STANDING_LINE += '&nbsp;</td>' + "\n";

        if(SCM_S_ARRAY_BUFFER[4] != '') {
            SCM_STANDING_LINE += '<td class="SCM_STANDINGS_' + SCM_ST_ROWCLASS + '" align="center">';
            SCM_STANDING_LINE += SCM_S_ARRAY_BUFFER[4];
            SCM_STANDING_LINE += '&nbsp;</td>' + "\n";
        }

        SCM_STANDING_LINE += '<td class="SCM_STANDINGS_' + SCM_ST_ROWCLASS + '" align="center">';
        SCM_STANDING_LINE += SCM_S_ARRAY_BUFFER[5];
        SCM_STANDING_LINE += '&nbsp;</td>' + "\n";

        SCM_STANDING_LINE += '<td class="SCM_STANDINGS_' + SCM_ST_ROWCLASS + '" align="center">';
        SCM_STANDING_LINE += SCM_S_ARRAY_BUFFER[6];
        SCM_STANDING_LINE += '&nbsp;</td>' + "\n";

        SCM_STANDING_LINE += '<td class="SCM_STANDINGS_' + SCM_ST_ROWCLASS + '" align="center">';
        SCM_STANDING_LINE += SCM_S_ARRAY_BUFFER[7];
        SCM_STANDING_LINE += '&nbsp;</td>' + "\n";

        SCM_STANDING_LINE += '<td class="SCM_STANDINGS_' + SCM_ST_ROWCLASS + '" align="center">';
        SCM_STANDING_LINE += SCM_S_ARRAY_BUFFER[8];
        SCM_STANDING_LINE += '&nbsp;</td>' + "\n";

        SCM_STANDINGS_TMP += SCM_STANDING_LINE;
        SCM_STANDINGS_TMP += '</tr>' + "\n";
        if(SCM_ST_ROWCLASS == 1) {
            SCM_ST_ROWCLASS = 2;
        } else {
            SCM_ST_ROWCLASS = 1;
        }
    }
    SCM_STANDINGS_TMP += '<tr>' + "\n";
    SCM_STANDINGS_TMP += '<td class="SCM_ST_TABLE_HEAD" colspan="9" width="' + SCM_STANDING_WIDTH + '">&nbsp;</td>' + "\n";
    SCM_STANDINGS_TMP += '</tr>' + "\n";
    SCM_STANDINGS_TMP += '</table>';

     if (DHTML_DOM) {
        SCM_STANDINGS_OBJECT = document.getElementById("SCM_OBJ_STANDINGS_TEXT");
        if(!SCM_STANDINGS_OBJECT) {
            window.setTimeout("SCM_standingsInit()",1000);
        } else {
            // set content of the ticker
            SCM_STANDINGS_OBJECT.innerHTML = SCM_STANDINGS_TMP;
        }
    } else {
        SCM_STANDINGS_OBJECT = document.SCM_STANDINGS_PARENT.document.SCM_OBJ_STANDINGS_TEXT;
        // set content of the ticker
        SCM_STANDINGS_OBJECT.document.open();
        SCM_STANDINGS_OBJECT.document.write(SCM_STANDINGS_TMP);
        SCM_STANDINGS_OBJECT.document.close();
    }
    SCM_ST_INITIALIZED = 1;
//	window.status = "Standings Status: " + SCM_ST_INITIALIZED;
}

function SCM_styleSheet () {
    var ST_TABLE_HEAD_CSS	= '.SCM_ST_TABLE_HEAD {' +
                          'font-weight:' 	+ SCM_STANDINGS_HEAD_FONT_BOLD + ';' +
                          'font-size:'		+ SCM_STANDINGS_HEAD_FONT_SIZE + SCM_STANDINGS_FONT_MEASURE + ';' +
                          'font-family:'	+ SCM_STANDINGS_FONT + ';' +
                          'color:'			+ SCM_STANDINGS_FONT_COLOR + ';' +
                          'background-color:' + SCM_STANDINGS_BG_COLOR + ';}';
    var STANDINGS_CSS_1	= '.SCM_STANDINGS_1 {' +
                          'font-weight:' 	+ SCM_STANDINGS_FONT_BOLD + ';' +
                          'font-size:'		+ SCM_STANDINGS_FONT_SIZE + SCM_STANDINGS_FONT_MEASURE + ';' +
                          'font-family:'	+ SCM_STANDINGS_FONT + ';' +
                          'color:'			+ SCM_STANDINGS_FONT_COLOR_1 + ';';
                        if(SCM_STANDINGS_TRANSPARENT == 0) {
                              STANDINGS_CSS_1	+= 'background-color:' + SCM_STANDINGS_BG_COLOR_1 + ';';
                        }
                          STANDINGS_CSS_1 += '}';
    var STANDINGS_CSS_2	= '.SCM_STANDINGS_2 {' +
                          'font-weight:' 	+ SCM_STANDINGS_FONT_BOLD + ';' +
                          'font-size:'		+ SCM_STANDINGS_FONT_SIZE + SCM_STANDINGS_FONT_MEASURE + ';' +
                          'font-family:'	+ SCM_STANDINGS_FONT + ';' +
                          'color:'			+ SCM_STANDINGS_FONT_COLOR_2 + ';';
                        if(SCM_STANDINGS_TRANSPARENT == 0) {
                              STANDINGS_CSS_2	+= 'background-color:' + SCM_STANDINGS_BG_COLOR_2 + ';';
                        }
                          STANDINGS_CSS_2 += ';}';
						  
	var LINK_CSS_1		= 'A.SCM_STANDINGS_LINK_1 {' + 
						  'font-weight:' 		+ SCM_STANDINGS_FONT_BOLD + ';' +
						  'font-size:'			+ SCM_STANDINGS_FONT_SIZE + SCM_STANDINGS_FONT_MEASURE + ';' +
						  'font-family:'		+ SCM_STANDINGS_FONT + ';' +
						  'text-decoration:		none;' +
						  'color:'				+ SCM_STANDINGS_FONT_COLOR_1 + ';}';
	var LINK_CSS_2		= 'A.SCM_STANDINGS_LINK_2 {' + 
						  'font-weight:' 		+ SCM_STANDINGS_FONT_BOLD + ';' +
						  'font-size:'			+ SCM_STANDINGS_FONT_SIZE + SCM_STANDINGS_FONT_MEASURE + ';' +
						  'font-family:'		+ SCM_STANDINGS_FONT + ';' +
						  'text-decoration:		none;' +
						  'color:'				+ SCM_STANDINGS_FONT_COLOR_1 + ';}';
	var VISITED_CSS_1	= 'A.SCM_STANDINGS_LINK_1:visited {' +
						  'font-weight:' 		+ SCM_STANDINGS_FONT_BOLD + ';' +
						  'font-size:'			+ SCM_STANDINGS_FONT_SIZE + SCM_STANDINGS_FONT_MEASURE + ';' +
						  'font-family:'		+ SCM_STANDINGS_FONT + ';' + 
						  'text-decoration:		none;' +
						  'color:'				+ SCM_STANDINGS_FONT_COLOR_1 + ';}';
	var VISITED_CSS_2	= 'A.SCM_STANDINGS_LINK_2:visited {' +
						  'font-weight:' 		+ SCM_STANDINGS_FONT_BOLD + ';' +
						  'font-size:'			+ SCM_STANDINGS_FONT_SIZE + SCM_STANDINGS_FONT_MEASURE + ';' +
						  'font-family:'		+ SCM_STANDINGS_FONT + ';' + 
						  'text-decoration:		none;' +
						  'color:'				+ SCM_STANDINGS_FONT_COLOR_1 + ';}';
	var HOVER_CSS_1		= 'A.SCM_STANDINGS_LINK_1:hover {' +
						  'font-weight:' 		+ SCM_STANDINGS_FONT_BOLD + ';' +
						  'font-size:'			+ SCM_STANDINGS_FONT_SIZE + SCM_STANDINGS_FONT_MEASURE + ';' +
						  'font-family:'		+ SCM_STANDINGS_FONT + ';' +
						  'text-decoration:		none;' +
						  'color:'				+ SCM_STANDINGS_FONT_COLOR_1 + ';}';
	var HOVER_CSS_2		= 'A.SCM_STANDINGS_LINK_2:hover {' +
						  'font-weight:' 		+ SCM_STANDINGS_FONT_BOLD + ';' +
						  'font-size:'			+ SCM_STANDINGS_FONT_SIZE + SCM_STANDINGS_FONT_MEASURE + ';' +
						  'font-family:'		+ SCM_STANDINGS_FONT + ';' +
						  'text-decoration:		none;' +
						  'color:'				+ SCM_STANDINGS_FONT_COLOR_1 + ';}';						  

    document.writeln("\n\n<STYLE>");

    document.writeln(ST_TABLE_HEAD_CSS);
    document.writeln(STANDINGS_CSS_1);
    document.writeln(STANDINGS_CSS_2);
	document.writeln(LINK_CSS_1);
	document.writeln(LINK_CSS_2);
	document.writeln(VISITED_CSS_1);
	document.writeln(VISITED_CSS_2);
	document.writeln(HOVER_CSS_1);
	document.writeln(HOVER_CSS_2);	

    document.writeln("</STYLE>\n\n");
}

/* Standings variables declaration */
/* other variables */
var SCM_ST_HTTP_ROOT		= 'http://www.sportal.at/nncs/dlc/';	// prefix string for inclusion of scripts
var SCM_ST_RANDOM			= new String (Math.random());	// random string
var SCM_ST_ARRAY			= new Array();
var SCM_ST_LINK_PREFIX		= 'http://www.sportal.at/';	// prefix string for inclusion of scripts
var SCM_ST_INITIALIZED		= 0;
var SCM_ST_INIT_COUNT		= 0;
/* END - Standings variables declaration */

if (typeof SCM_STANDINGS_RESSORT == "undefined") {
    // define default scale factor
    var SCM_STANDINGS_RESSORT = '';
}

if (typeof SCM_STANDINGS_FONT_MEASURE == "undefined") {
    // define default scale factor
    var SCM_STANDINGS_FONT_MEASURE = 'px';
}

if(SCM_STANDINGS_RESSORT == '') {
    document.writeln('<SCRIPT LANGUAGE="Javascript" SRC="' +
                   SCM_ST_HTTP_ROOT +
                   'standings.js?' +
                   SCM_ST_RANDOM +
                   '" type="text/javascript"></SCRIPT>');

} else {
    document.writeln('<SCRIPT LANGUAGE="Javascript" SRC="' +
                   SCM_ST_HTTP_ROOT +
                   'standings_' + SCM_STANDINGS_RESSORT + '.js?' +
                   SCM_ST_RANDOM +
                   '" type="text/javascript"></SCRIPT>');
}

SCM_BROWSER_POS = 'relative';
if (DHTML_NS) {
    // Netscape layer workaround. Positioning has to be 'absolute'!
    // Otherwise it will not work properly.
    SCM_BROWSER_POS = 'absolute';
}

var SCM_STANDINGS_OBJECT_STRING	 = '';	// string which will be included for displaying the ticker
// if this browser does not support DOM object model
if (!DHTML_DOM) {
    SCM_STANDINGS_OBJECT_STRING	+= '<ILAYER NAME="SCM_STANDINGS_PARENT">';
    SCM_STANDINGS_OBJECT_STRING	+= '<LAYER NAME="SCM_OBJ_STANDINGS_TEXT" CLASS="SCM_STANDINGS"></LAYER>&nbsp;</ILAYER>';
} else {
    // Ticker Object: initially hidden DIV with no content so far
    // Content will be added in function SCM_tickerInit().
    SCM_STANDINGS_OBJECT_STRING	+= '<DIV ID="SCM_OBJ_STANDINGS_TEXT" CLASS="SCM_STANDINGS"></DIV>';
}

SCM_styleSheet();
// include div which will contain the ticker
document.writeln(SCM_STANDINGS_OBJECT_STRING);

// initialize standings after 0.1 seconds
window.setTimeout("SCM_standingsInit()",100);
// try again after 0.5, 1, 2, 5 and 10 seconds
window.setTimeout("SCM_standingsInit()",500);
window.setTimeout("SCM_standingsInit()",1000);
window.setTimeout("SCM_standingsInit()",2000);
window.setTimeout("SCM_standingsInit()",5000);
window.setTimeout("SCM_standingsInit()",10000);

