/** * * Additionial JavaScript for Moo * Author: Michael Kamleitner * */cmd=0;cmd_ar=new Array();addBox=new Array();function noop() {	}function toggleDisplay(id,val) {	if (val) {		if ($(id).style.display!='block')			$(id).style.display='block';		else			$(id).style.display='none';	} else {		$(id).style.display='none';	}}function setMaxLength() {		var x = document.getElementsByTagName('textarea');	var counter = document.createElement('div');	counter.className = 'counter';	for (var i=0;i<x.length;i++) {		if (x[i].getAttribute('maxlength')) {			var counterClone = counter.cloneNode(true);			counterClone.relatedElement = x[i];			counterClone.innerHTML = '<span>0</span> von '+x[i].getAttribute('maxlength')+ ' Zeichen';			counterClone.style.marginTop = '10px';			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];			x[i].onkeyup = x[i].onchange = checkMaxLength;			x[i].onkeyup();		}	}}function checkMaxLength() {	var maxLength = this.getAttribute('maxlength');	var currentLength = this.value.length;	if (currentLength > maxLength) {		this.value = this.value.substring(0,maxLength);		currentLength = this.value.length;		this.relatedElement.className = 'toomuch';	} else {		this.relatedElement.className = '';	}	this.relatedElement.firstChild.nodeValue = currentLength;	// not innerHTML}function initLightbox(id) {	var arrayPageSize = getPageSize();	$('overlay').style.width = arrayPageSize[0]+'px';	$('overlay').style.height = arrayPageSize[1]+'px';	$('overlay').onclick = function(e) {		new Effect.Fade(id, { duration: 0.2});		new Effect.Fade('overlay', { duration: 0.2});	}	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });	$(id).style.display = 'block';}function initAddbox (id, mode, clip_id) {	if ( typeof (addBox[id]) == "undefined" ) addBox[id] = '';	if (addBox[id]!='moving') {		if (addBox[id]=='') {		//if ($(id).style.display == 'none') {			request('/clips/ajax?mode='+mode+'&div='+id+'&id='+clip_id, 'receiveAddbox');			addBox[id] = 'moving';			new Effect.BlindDown(id, {afterFinish: function(b) { addBox[id] = mode; }});		} else {			if (addBox[id] == mode) {				addBox[id] = 'moving';				new Effect.BlindUp(id, {afterFinish: function(b) {addBox[id] = '';}});						} else {				new Effect.BlindUp(id, {afterFinish: function(c) {					request('/clips/ajax?mode='+mode+'&div='+id+'&id='+clip_id, 'receiveAddbox');					addBox[id] = 'moving';					new Effect.BlindDown(id, {afterFinish: function(b) { addBox[id] = mode; }});				}});			}		}	}}function initAddbox2 (id, mode, clip_id) {	if ($(id).style.display == 'none') {		request('/clips/ajax?mode='+mode+'&div='+id+'&id='+clip_id, 'receiveAddbox');	} else {	}}function receiveAddbox() {	if(http.readyState == 4){		var r = http.responseText;		parts = r.split("#");		$(parts[0]).innerHTML = parts[1];		if (parts[2]=='sms')			setMaxLength();	}}function receiveRecommendation () {	if(http.readyState == 4){		var r = http.responseText;		parts = r.split("#");		if (parts[0]=='ok') {				$(parts[1]).innerHTML = '<div style="padding:10px;"><p>'+language['message_sent']+'</p></div>';				window.setTimeout(function (a) {					addBox[parts[1]] = 'moving';					new Effect.BlindUp(parts[1], {afterFinish: function(b) {addBox[parts[1]] = '';}});					}, 1000);		}	}}function slideBox (id, override) {	if (($(id).style.display == 'none' && override=='') || override=='block') {		$(id).style.display = 'block';		$(id+'_button').innerHTML = '<a href="javascript:slideBox(\''+id+'\',\'\');"><img src="/img/raquo_up.gif"/></a>';	} else {		$(id).style.display = 'none';		$(id+'_button').innerHTML = '<a href="javascript:slideBox(\''+id+'\',\'\');"><img src="/img/raquo_down.gif"/></a>';	}}function getPageSize(){		var xScroll, yScroll;		if (window.innerHeight && window.scrollMaxY) {			xScroll = window.innerWidth + window.scrollMaxX;		yScroll = window.innerHeight + window.scrollMaxY;	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac		xScroll = document.body.scrollWidth;		yScroll = document.body.scrollHeight;	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari		xScroll = document.body.offsetWidth;		yScroll = document.body.offsetHeight;	}		var windowWidth, windowHeight;		if (self.innerHeight) {	// all except Explorer		if(document.documentElement.clientWidth){			windowWidth = document.documentElement.clientWidth; 		} else {			windowWidth = self.innerWidth;		}		windowHeight = self.innerHeight;	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode		windowWidth = document.documentElement.clientWidth;		windowHeight = document.documentElement.clientHeight;	} else if (document.body) { // other Explorers		windowWidth = document.body.clientWidth;		windowHeight = document.body.clientHeight;	}			// for small pages with total height less then height of the viewport	if(yScroll < windowHeight){		pageHeight = windowHeight;	} else { 		pageHeight = yScroll;	}	// for small pages with total width less then width of the viewport	if(xScroll < windowWidth){			pageWidth = xScroll;			} else {		pageWidth = windowWidth;	}	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 	return arrayPageSize;}function thisMovie(movieName) {	var isIE = navigator.appName.indexOf("Microsoft") != -1;	return (isIE) ? window[movieName] : document[movieName];}function makeCall(sts) {		for(var i=0; i<cmd_ar.length; i++) {		if('player_'+i != sts) {			thisMovie('player_'+i).updater();		}	}}function updateFunc(str) {	makeCall(str);}function uploadFinish() {	alert ('upload finished');		}function submitClip() {		if (document.getElementById('clip_filename').value == '' ||	    document.getElementById('clip_filename').value == null) {		document.getElementById('error_clip_original').style.display = 'block';			} else {		document.getElementById('form_clip').submit();	}}function submitUpload () {	if (document.getElementById('clip_original').value != '' && 	    document.getElementById('clip_original').value != null)	{				document.getElementById('wait_done').style.display = 'none';			document.getElementById('wait').className = 'show';			document.getElementById('form_upload').submit();					}	}function errorLogin(){	}function imageFinished (res, filename) {	$('profile_image').src = '/scripts/image.php?url=/images/'+filename;}	function uploadFinished (res, filename, title, artist, length) {	if (res) {		document.getElementById('clip_artist').value = artist;		document.getElementById('clip_title').value = title;		//document.getElementById('clip_length').value = length;		document.getElementById('clip_file'). value = filename;		document.getElementById('error_clip_type').style.display = 'none';		document.getElementById('submit_button_href').href = 'javascript:submitClip();';		document.getElementById('submit_button').src='/img/submit_but.gif';		document.getElementById('wait_done').style.display = 'block';			} else {		document.getElementById('clip_original').value = ''; 		document.getElementById('error_clip_type').style.display = 'block';		//document.getElementById('error_clip_type').innerHTML = "error: "+filename;		document.getElementById('submit_button_href').href = 'javascript:noop();';		document.getElementById('submit_button').src='/img/submit_but_inact.gif';		document.getElementById('wait_done').style.display = 'none';			}		document.getElementById('wait').className = 'hidden';	}function highField (o) {		if (!editState[o.id])		o.className = 'tag';	//$('edit_'+o.id).className = 'yellow';}function lowField (o) {	o.className = 'blank';	//$('edit_'+o.id).className = 'blank';}			function editField (o, table) {			if (!table)		table = 'clip';	if (!editState[o.id]) {								id = o.id;		o.className = 'blank';		o.style.backgroundImage='';		o.style.paddingRight='0px';		editPre[o.id] = o.innerHTML;						o.innerHTML = '<div class="input_large2"><input class="input_sl" id="field_'+o.id+'" type="text" value="'+o.innerHTML+'"/></div>'+		              '<input onmouseup="storeField(\''+o.id+'\',\''+table+'\',document.getElementById(\'field_'+o.id+'\').value,document.getElementById(\''+table+'_id\').value);" type="image" src="/img/ok_but.gif" style="padding-top:0px;"/>'+		              '<input onmouseup="cancelField(\''+o.id+'\');" type="image" src="/img/cancel_but.gif" style="padding-top:0px;"/>';				editState[o.id] = true;	}}function editArea (o, table, default_val) {		if (!table)		table = 'clip';	if (!editState[o.id]) {								id = o.id;		o.className = 'blank';		o.style.backgroundImage='';		o.style.paddingRight='0px';		editPre[o.id] = o.innerHTML;						o.innerHTML = '<div class="textarea_large" style="margin-bottom:10px;">'+									'<textarea class="textarea_l" id="field_'+o.id+'">'+o.innerHTML+'</textarea></div>'+		              '<p style="text-align:right;"><input onmouseup="storeField(\''+o.id+'\',\''+table+'\',document.getElementById(\'field_'+o.id+'\').value,document.getElementById(\''+table+'_id\').value);defaultArea(\''+o.id+'\',\''+default_val+'\');" type="image" src="/img/ok_but.gif" style="padding-top:0px;"/>'+		              '<input onmouseup="cancelField(\''+o.id+'\');defaultArea(\''+o.id+'\',\''+default_val+'\');" type="image" src="/img/cancel_but.gif" style="padding-top:0px;"/></p>';				editState[o.id] = true;	}}function defaultArea(id,val) {		if ($(id).innerHTML == '')		$(id).innerHTML = val;}function storeField (id,table,val,key) {	if (!callInProgress(http)) {	    http.open('get', '/'+table+'s/editSingle/'+key+'?field='+id+'&val='+encodeURIComponent(val),true);	    http.onreadystatechange = eval('updateField(id,val)');	    http.send(null);	}	}function request (url,callback) {	if (!callInProgress(http)) {	    http.open('get', url, true);	    http.onreadystatechange = eval(callback);	    http.send(null);	}		}function responseTags () {	if(http.readyState == 4){        var r = http.responseText;        parts = r.split(":");    	if (parts[0]=="del") {    		new Effect.Fade ($('tag_'+parts[1]));    	} else if (parts[0]=="add") {     		    		    		$('tag_field').value = '';    		separator = '';    		if ($('tags').innerHTML.replace(/^\s+|\s+$/g, '') != '' &&    				$('tags_none').style.display=='none') {    			separator = ", ";    		}    		$('tags_none').style.display='none';		    		$('tags').innerHTML += '<span style="display:none;" id="tag_'+parts[1]+'">'+separator+    								 '<span class="tag"><a href="/tags/'+parts[4]+'">'+parts[3]+'</a>'+    							   '&nbsp;<a style="color:#FFFFFF;" href="javascript:request(\'/clips/delTag/'+parts[2]+'?tag_id='+parts[1]+'\',\'responseTags\');">&nbsp;x&nbsp;</a></span></span>';			new Effect.Appear ($('tag_'+parts[1]));    	}    }	}function responseRating () {	if(http.readyState == 4){  	var r = http.responseText;    eval(r);        	}	}function cancelField (id) {		o = document.getElementById(id);	o.style.backgroundImage='url(/img/edit.gif)';	o.style.paddingRight='15px';	if (editPrefix[o.id]) {		o.innerHTML = editPrefix[o.id] + editPre[o.id];	} else {		o.innerHTML = editPre[o.id];	}	editState[o.id] = false;	lowField (o);}function updateField (id,val) {	if(http.readyState == 4){  	var response = http.responseText;  }  	o = document.getElementById(id);	o.style.backgroundImage='url(/img/edit.gif)';	o.style.paddingRight='15px';	if (editPrefix[o.id])		val = editPrefix[o.id] + val;	o.innerHTML = val;	editState[o.id] = false;	lowField (o);}function buildRating (clip_id, rating, prefix) {	res = '';	stars = Array();	for (i = 0; i < 5; i++) {		img = '';		if (rating > i && rating <= (i + 0.5))			img = "_yellow_half";		else if (rating > i)			img = "_yellow_full";				stars[i] = img;			}	for (i = 0; i < 5; i++) {		out = "";		over = "";		for (j = 0; j <= i; j++) {			over += 'if ($(\'star_'+prefix+clip_id+'_'+j+'\').src!=\'/img/star_red_full.gif\') $(\'star_'+prefix+clip_id+'_'+j+'\').src=\'/img/star_red_full.gif\';';			out  += 'if ($(\'star_'+prefix+clip_id+'_'+j+'\').src!=\'/img/star'+stars[j]+'.gif\') $(\'star_'+prefix+clip_id+'_'+j+'\').src=\'/img/star'+stars[j]+'.gif\';';		}		res += '<a href="javascript:request(\'/clips/addRating/'+clip_id+'?rating='+(i+1)+'&amp;prefix='+prefix+'\',\'responseRating\');">';					res += '<img src="/img/star'+stars[i]+'.gif" alt="Star" id="star_'+prefix+clip_id+'_'+i+'" onmouseover="'+over+'" onmouseout="'+out+'"/>';		res += '</a>';	}	return res;}function createRequestObject() {    var xmlhttp;    try {        xmlhttp = new XMLHttpRequest();    } catch (e) {        var MSXML_XMLHTTP_PROGIDS = new Array(          'MSXML2.XMLHTTP.5.0',          'MSXML2.XMLHTTP.4.0',          'MSXML2.XMLHTTP.3.0',          'MSXML2.XMLHTTP',          'Microsoft.XMLHTTP');        var success = false;        for (var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) {            try {                xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);                success = true;            } catch (e) {}        }        if (! success) {            //alert ('No AJAX-Support for this browser :(!');        }    }    return xmlhttp;}function callInProgress(xmlhttp) {    switch ( xmlhttp.readyState ) {        case 1:              case 2:              case 3:            return true;        break;        default:            return false;        break;    }}var http = createRequestObject();var editState = Array();var editPre = Array();var editPrefix = Array();var flagRated = false;