function popup_getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function popup_getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}


function popup_setContent() {

	var container = document.getElementById('vahaudio_popup');
	var windowHeight = popup_getWindowHeight();
	var windowWidth = popup_getWindowWidth();

	container.style.height = popup_getWindowHeight()+"px";
	container.style.width = popup_getWindowWidth()+"px";	
			

	var contentElement = document.getElementById('vahaudio_centerpopup');
	var contentHeight = contentElement.offsetHeight;
	var contentWidth = contentElement.offsetWidth;
	contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
	contentElement.style.left = ((windowWidth / 2) - (contentWidth / 2)) + 'px';
	
	
}



function showPopup(url){	
	if(document.getElementById('vahaudio_popup') == null)
	{
		div = document.createElement("div");
		//div.setAttribute("id", "vahaudio_popup");
		div.innerHTML= '<div id="vahaudio_popup" ></div><div id="vahaudio_centerpopup"><div id="vahaudio_centerpopup_header"><a href="javascript:hiddenPopup()"><img src="/images/cancel_f2.png"/></a></div><iframe width="100%" height="515px" id="vahaudio_iframe" style="border:0px;"></iframe></div>';
		document.body.appendChild(div); 
		//document.body.innerHTML = document.body.innerHTML + '<div id="vahaudio_popup" ></div><div id="vahaudio_centerpopup"><div id="vahaudio_centerpopup_header"><a href="javascript:hiddenPopup()"><img src="images/cancel_f2.png"/></a></div><iframe width="100%" height="515px" id="vahaudio_iframe" style="border:0px;"></iframe></div>';
		
		window.onresize = function() {
			popup_setContent();
		}
				
	}
	
	var container = document.getElementById('vahaudio_popup');
	container.style.display='block';
	document.getElementById('vahaudio_centerpopup').style.display='block';
	document.getElementById('vahaudio_iframe').src=url;
	popup_setContent();
	
}

function hiddenPopup(){

	var container = document.getElementById('vahaudio_popup');
	container.style.display='none';
	
	document.getElementById('vahaudio_centerpopup').style.display='none';

}









function playaalbum(id){
	var data={
		format:'raw',
		view:'audio',
		task:'playaalbum',
		option:'com_vahaudio',
		albid:id
	};
	var objRequest = new VahAudio(globalOption,data,"playarea");
	objRequest.loadHTML(playasong_respone);
}

function playasong_respone(res){
	document.getElementById("playarea").innerHTML = res;
}



function playasong(id){
	var data={
		format:'raw',
		view:'audio',
		task:'playasong',
		option:'com_vahaudio',
		id:id
	};
	var objRequest = new VahAudio(globalOption,data,"playarea");
	objRequest.loadHTML(playasong_respone);
}

function playasong_respone(res){
	document.getElementById("playarea").innerHTML = res;
	document.getElementById("playarea").style.display='block';
}


function playaplaylist(){
	var data={
		format:'raw',
		view:'audio',
		task:'playaplaylist',
		option:'com_vahaudio'
	};
	var objRequest = new VahAudio(globalOption,data,"playarea");
	objRequest.loadHTML(playasong_respone);	
}

function addtoplaylist(id){

	var data={
		format:'raw',
		view:'audio',
		task:'addtoplaylist',
		id:id,
		option:'com_vahaudio',
		tab:'pl'
	};
	var objRequest = new VahAudio(globalOption,data,"vahaudio_pl");
	objRequest.loadHTML(addtoplaylist_respone);


}

function addtoplaylist_respone(res){
	document.getElementById("vahaudio_pl").innerHTML = res;
	
}

var rating_elementid;
function vahaudio_makerating(id,score,eid){

	if (eid == '')
		return;
	rating_elementid = eid;
	var data={
		format:'raw',
		view:'audio',
		task:'rating',
		id:id,
		option:'com_vahaudio',
		score:score
	};
	var objRequest = new VahAudio(globalOption,data,eid);
	objRequest.loadHTML(rating_response);	
}

function rating_response(res){
	document.getElementById(rating_elementid).innerHTML = res;
}


function downloadfile(id){
	window.location=globalOption.url+"index.php?option=com_vahaudio&view=audio&task=download&id="+id;
}

function getCheckboxValue(id){
	if (document.getElementById(id).checked)
		return 1;
	else
		return 0;
}
	
