/* Initialize Tabs for Scores */
var myTabs = new YAHOO.widget.TabView("ergebnisse"); 
                        
/* Function for Table Scrolling */
/*
function ScrollThatTable(where) {   
    save = 1*(YAHOO.util.Dom.getStyle('scrolltable', 'marginLeft').replace(/px/,""));             
    if (where=='left') {                                              
        var attributes = {
           marginLeft: { to: 2 }
        };             
    } else if(where=='right') {                              
        var attributes = {
           marginLeft: { to: (-diff-17) }
        };                           
    } else if(where=='moreright') {                     
        if (save+17<-Math.floor(0.5*diff)) {    
            var attributes = {
               marginLeft: { to: (-diff-17) }
            };
        } else {
            var attributes = {
               marginLeft: { by: -Math.floor(0.5*diff) }
            };   
        }
    } else if(where=='moreleft') {    
        if ((-save-Math.floor(0.5*diff))<2) {    
            var attributes = {
               marginLeft: { to: 2 }
            };
        } else {
            var attributes = {
               marginLeft: { by: Math.floor(0.5*diff) }
            };
        }
    }     
    var myAnim = new YAHOO.util.Anim('scrolltable', attributes, .2);    
    myAnim.animate();   
}                */             

/* Initialize Tables for Scrolling */
/*
if (document.getElementById('scrolltable')) {    

    diff = document.getElementById('scrolltable').offsetWidth-document.getElementById('scrolldiv').offsetWidth;  
    stns = YAHOO.util.Dom.getElementsByClassName('scrolltablenav');                                     
    
    if(diff<10) {    
        YAHOO.util.Dom.setStyle('scrolldiv', 'overflow', 'visible');             
     } else if(diff<200) {       
        contents = '<a href="#" onclick="ScrollThatTable(\'left\');return false;" class="anfang">&#8592;<span> Anfang</span></a><a href="#" onclick="ScrollThatTable(\'right\');return false;" class="ende"><span>Ende </span>&#8594;</a>';         
        stns[1].innerHTML = contents;
        stns[0].innerHTML = contents;        
        YAHOO.util.Dom.addClass(stns, 'twolinks');                   
        YAHOO.util.Dom.setStyle('scrolldiv', 'overflow', 'hidden');        
    } else {
        contents = '<a href="#" onclick="ScrollThatTable(\'left\');return false;" class="anfang">&#8592;<span> Anfang</span></a><a href="#" onclick="ScrollThatTable(\'moreleft\');return false;" class="zurueck">&#8672;<span> Zurück</span></a><a href="#" onclick="ScrollThatTable(\'moreright\');return false;" class="weiter"><span>Weiter </span>&#8674;</a><a href="#" onclick="ScrollThatTable(\'right\');return false;" class="ende"><span>Ende </span>&#8594;</a>';         
        stns[1].innerHTML = contents;
        stns[0].innerHTML = contents;    
        YAHOO.util.Dom.addClass(stns, 'fourlinks');       
        YAHOO.util.Dom.setStyle('scrolldiv', 'overflow', 'hidden');        
    }                    

}            
*/
function twitterCallback(obj) {
	var twitters = obj;
	var statusHTML = "";
	var username = "";
	for (var i=0; i<twitters.length; i++){
		username = twitters[i].user.screen_name
		statusHTML += ('<li><span>'+twitters[i].text+'</span> <a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id+'">'+relative_time(twitters[i].created_at)+'</a></li>')
	}
	document.getElementById('twitter_update_list').innerHTML = statusHTML;
}

function relative_time(time_value) {
  var values = time_value.split(" ");
  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
  var parsed_date = Date.parse(time_value);
  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
  delta = delta + (relative_to.getTimezoneOffset() * 60);

  if (delta < 60) {
    return 'vor weniger als einer Minute';
  } else if(delta < 120) {
    return 'vor etwa einer Minute';
  } else if(delta < (60*60)) {
    return 'vor ' + (parseInt(delta / 60)).toString() + ' Minuten';
  } else if(delta < (120*60)) {
    return 'vor etwa einer Stunde';
  } else if(delta < (24*60*60)) {
    return 'vor etwa ' + (parseInt(delta / 3600)).toString() + ' Stunden';
  } else if(delta < (48*60*60)) {
    return 'vor einem Tag';
  } else {
    return 'vor ' + (parseInt(delta / 86400)).toString() + ' Tagen';
  }
}         

// Splintered striper 1.3
// reworking of Zebra Tables and similar methods which works not only for tables and even/odd rows,
// but as a general DOM means of assigning any number of classes to children of a parent element.
// Patrick H. Lauke aka redux / www.splintered.co.uk
// Distributed under the Creative Commons Attribution-ShareAlike license - http://creativecommons.org/licenses/by-sa/2.0/


/*
 * Summary:      Core experiment function that applies any number of classes to all child elements
 *               contained in all occurences of a parent element (either with or without a specific class)
 * Parameters:   parentElementTag - parent tag name
 *               parentElementClass - class assigned to the parent; if null, all parentElementTag elements will be affected
 *               childElementTag -  tag name of the child elements to apply the styles to
 *               styleClasses - comma separated list of any number of style classes (using 2 classes gives the classic "zebra" effect)
 * Return:       none
 */
function striper(parentElementTag, parentElementClass, childElementTag, styleClasses)
{
	var i=0,currentParent,currentChild;
	// capability and sanity check
	if ((document.getElementsByTagName)&&(parentElementTag)&&(childElementTag)&&(styleClasses)) {
		// turn the comma separate list of classes into an array
		var styles = styleClasses.split(',');
		// get an array of all parent tags
		var parentItems = document.getElementsByTagName(parentElementTag);
		// loop through all parent elements
		while (currentParent = parentItems[i++]) {
			// if parentElementClass was null, or if the current parent's class matches the specified class
			if ((parentElementClass == null)||(currentParent.className == parentElementClass)) {
				var j=0,k=0;
				// get all child elements in the current parent element
				var childItems = currentParent.getElementsByTagName(childElementTag);
				// loop through all child elements
				while (currentChild = childItems[j++]) {
					// based on the current element and the number of styles in the array, work out which class to apply
					k = (j+(styles.length-1)) % styles.length;
					// add the class to the child element - if any other classes were already present, they're kept intact
					currentChild.className = currentChild.className+" "+styles[k];
				}
			}
		}
	}
}             
                                
function stripe() {
     striper('tbody','striped','tr','odd,even');
 }                               

YAHOO.util.Event.onDOMReady(stripe); 