function collapse(id, f) {
	
	if(f == "collapse") {
		
		document.getElementById(id).style.display = "none";
		var href;
		href = "javascript:collapse('" + id + "', 'toggle')";
		var a;
		a = "a_" + id;
		document.getElementById(a).setAttribute("href", href);
		
	} else {
		
		document.getElementById(id).style.display = "block";
		var href;
		href = "javascript:collapse('" + id + "', 'collapse');";
		var a;
		a = "a_" + id;
		document.getElementById(a).setAttribute("href", href);
		
	}
	
}

var pnopacity = {
	
	opacity: function(id, opacStart, opacEnd, millisec) {
		
		document.getElementById('videoreportmes').style.display='block';
		document.getElementById('videoreportmes').style.visibility='visible';
		var speed = Math.round(millisec / 100);
		var timer = 0;
		
		if(opacStart > opacEnd) {
			
			for(i = opacStart; i >= opacEnd; i--) {
				
				setTimeout("pnopacity.changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
				
			}
			
		} else if(opacStart < opacEnd) {
			
			for(i = opacStart; i <= opacEnd; i++) {
				
				setTimeout("pnopacity.changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
				
			}
			
		}
	},

	opacitya: function(id, opacStart, opacEnd, millisec) {
		
		var speed = Math.round(millisec / 100);
		var timer = 0;
		if(opacStart > opacEnd) {
			
			for(i = opacStart; i >= opacEnd; i--) {
				
				setTimeout("pnopacity.changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
				
			}
			
		} else if(opacStart < opacEnd) {
			
			for(i = opacStart; i <= opacEnd; i++) {
				
				setTimeout("pnopacity.changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
				
			}
			
		}
	},
	
	changeOpac: function(opacity, id) {
		
		var object = document.getElementById(id).style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
	
	},
	
	alertContents: function() {
		
		pnopacity.opacity('videoreportmes', 0, 100, 2000);
		setTimeout("pnopacity.opacitya('videoreportmes', 100, 0, 500)",4500);
		setTimeout("document.getElementById('videoreportmes').style.display = 'none'",5000);
		
	}
	
}

function createRequestObject() {
  var ro;
  var browser = navigator.appName;
  if (browser == "Microsoft Internet Explorer") {
      ro = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
      ro = new XMLHttpRequest();
  }
  return ro;
}

var http = createRequestObject();

function reportVideo(id) {
	
    http.open('get', '/videoreport.php?id=' + id, true);
	http.onreadystatechange = handleResponse;
	http.send(null);
	
}

function handleResponse() {
	
	if (http.readyState == 4 && http.status == 200) {
		
		pnopacity.alertContents();
		document.getElementById('videoreportmes').innerHTML = http.responseText;
		
	}
	
}

function rateLyrics(id,rate) {
	
    http.open('get', '/ratelyrics.php?id=' + id + '&rate=' + rate, true);
	http.onreadystatechange = ratehandleResponse;
	http.send(null);

}

function ratehandleResponse() {
	
	if (http.readyState == 4 && http.status == 200) {
		
		pnopacity.alertContents();
		document.getElementById('videoreportmes').innerHTML = http.responseText;
		
	}
	
}

function watchVideo(id) {
	
    http.open('get', '/watchvideo.php?id=' + id, true);
	http.send(null);
	
}

function addBookmark(title,url) {
	
	if (window.sidebar) {
		
		window.sidebar.addPanel(title, url,"");
		
	} else if(document.all) {
		
		window.external.AddFavorite(url, title);
		
	} else if(window.opera && window.print) {
		
		return true;
		
	}
	
}

function setStyle(x)
{
	document.getElementById(x).style.borderColor="#FF8C03";
	document.getElementById(x).style.borderWidth="1px";
	document.getElementById(x).style.background="#ffffff";
	document.getElementById(x).style.borderStyle="solid"
}
function dropStyle(x)
{
	document.getElementById(x).style.borderColor="#B4B4B4";
	document.getElementById(x).style.borderWidth="1px";
	document.getElementById(x).style.background="#ffffff";
	document.getElementById(x).style.borderStyle="solid"
}

function showbannedlist() {
	
	document.getElementById("bannedlist").style.display = "block";
	document.getElementById("showlistbtn").innerHTML = "<a href=\"#\" onclick=\"hidebannedlist();\">Hide List</a>";
	
}
function hidebannedlist() {
	
	document.getElementById("bannedlist").style.display = "none";
	document.getElementById("showlistbtn").innerHTML = "<a href=\"#\" onclick=\"showbannedlist();\">Show List</a>";
	
}

function centra() {
	
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		
	}
	
	document.getElementById('lightbox').style.left = (myWidth - 482) / 2  + 'px';
	document.getElementById('lightbox').style.top  = (myHeight- 331) / 2  + 'px';
	
}

function disableSelection(target) {
	
	if (typeof target.onselectstart != "undefined") //IE route
	target.onselectstart = function() { return false }
	else if (typeof target.style.MozUserSelect != "undefined") //Firefox route
	target.style.MozUserSelect = "none"
	else //All other route (ie: Opera)
	target.onmousedown = function() { return false }
	target.style.cursor = "default"
}

function addEngine(url, img, name, desc) {
	
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
		
		window.sidebar.addSearchEngine (url,img,name,desc);
		
	} else {
		
		alert("You need a Mozilla based browser such as firefox to use this.");
		
	}
	
}

window.onresize = centra;