// sido | functions.js

var DOM = (document.getElementById);

function onLoadActions() {
	discoverScript();
}

function onResizeActions() {
	//
}

function hiliteFriend(friend,modus) {
	if (modus == "on" || modus == "off") {
		setClass(friend, modus);
		// setClass(friend + "_title", "friends_title_" + modus);
	}
	if (modus == "click") {
		showProfile(friend);
	}
}

function showIframe(iframe_url,iframe_width) {
    Shadowbox.open({
        content:iframe_url,
        player:"iframe",
        title:"",
        width:iframe_width
    });
};


// ------------ audio + tracking  ------------ //

function getTrackname(id) {
	return document.getElementById(id).innerHTML;
}

function trackJWPlayer(section, modus, label) {
	_gaq.push(['_trackEvent', section, modus, label]);
	doLog(section + " | " + modus + " | " + label);
}

function playTrack(playerid,trackname,fileurl,nr) {
	// alert("playTrack(" + playerid + "," + trackname + "," + fileurl + "," + nr + ")");
	jwplayer("jwplayer_" + playerid).load( { file:fileurl } ).play();
	// active_track_count -> defined in music_content (around line 131)
	for (i = 1; i <= active_track_count; i++) {
		setClass("track" + i, "track_name_off");
	}
	setClass("track" + nr, "track_name_on");
	document.getElementById("trackname_" + playerid).innerHTML = trackname;
	trackJWPlayer("audio", "load", trackname);
}

/*
function playerStop(id) {
	var player = getFlashMovie(id);
	player.sendEvent("STOP","true");
}

function playerLoad(id,data) {
	// call with: playerLoad('videoplayer','http://www.youtube.com/watch?v=SkAPW7vEvbs');
	var player = getFlashMovie(id);
	player.sendEvent("LOAD",data);
	player.sendEvent("PLAY","true"); 
}
*/


// ------------ flash vs. js ------------ //

function fromFlash(txt) {
	alert(txt);
}

function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

function callToActionscript(flash, str) {
	// alert("callToActionscript: " + flash + ", " + str);
	getFlashMovie(flash).sendToActionscript(str);
}


// ------------ standard functions ------------ //

function winopen(url,name,style) { 
	// bsp: javascript:winopen('http://www.apple.com','apple_homepage','width=600,height=500,status=no,location=no,scrollbars=no,resizable=no');
	var newWin = window.open(url,name,style);
	newWin.focus();
}

function toggleDesc(id,style) {
	document.getElementById(id).style.display = style;
}

function toggleWithHandle(id, toggle_id, toggle_basename) {		
	if (DOM) {
		node = document.getElementById(id);

		if (node) {					
   			if (node.style.display == "") {
				// ausschalten
   				node.style.display = "none";
				if (document.images) {
					document.getElementById(toggle_id).src = "/images/icons/" + toggle_basename + "_off.png";
				}	
   			} else {
				// einschalten
   				node.style.display = "";
				if (document.images) {
					document.getElementById(toggle_id).src = "/images/icons/" + toggle_basename + "_on.png";
				}
  			}
 		}
	}
}

function setClass(id, classname) { 
	// alert("node= " + id + " classname= " + classname);
	node = document.getElementById(id);
	if (node) {
		document.getElementById(id).setAttribute("class", classname); 
		document.getElementById(id).setAttribute("className", classname); // ie fix
	}
}


// peace out
