function postRes(div,src,param){	
	var xmlHttp = false;
	if(window.XMLHttpRequest){
		xmlHttp = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var obj = document.getElementById(div);
	if(xmlHttp){
		xmlHttp.open("GET",src,true);
		//xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8;");
		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 1 || xmlHttp.readyState == 2){
				obj.innerHTML = "";
			}
			else if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
				obj.innerHTML = xmlHttp.responseText;
			}			
		}	
		xmlHttp.send(null);
	}
	return false;
}

function FloatTopDiv()
	{
		k = 0;
		var ns = (navigator.appName.indexOf("Netscape") != -1);
		if(!ns)
		{
			// modified of hoa@april.com.vn
			// chinh sua o cac cho co so "91;//263;" ben duoi  
			// end of modified of hoa@april.com.vn

			startLX = ((document.body.clientWidth -1230)/2) + 110 , startLY = 263;
			//startRX = ((document.body.clientWidth -770)/2) + 770 +2 , startRY = 62;
			startRX = ((document.body.clientWidth)/2) + 390 , startRY = 263;
			startSY=document.body.clientHeight-168;
			startSX=startLX;
		}
		else
		{
			startLX = ((document.body.clientWidth -1230)/2) + 107 , startLY = 263;			
			//startRX = ((document.body.clientWidth -770)/2) + 763 , startRY = 3;
			startRX = ((document.body.clientWidth)/2) + 380 , startRY = 263;
			startSY=document.body.clientHeight-168;
			startSX=startLX;
		}
		var d = document;
		function ml(id)
		{
			var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			// modified of hoa@april.com.vn
			//el.sP=function(x,y){this.style.left=x;this.style.top=y;};
			var left_april = 0;
			if (document.all) {
				// for IE
				left_april = ((document.body.clientWidth - 860)/2)+790;
			}
			else
			{
				left_april = ((document.body.clientWidth - 860)/2)+790;
			}
			
			el.sP=function(x,y){this.style.left=left_april;this.style.top=y;};
			// end of modified of hoa@april.com.vn	
			el.x = startRX;
			el.y = startRY;
			return el;
		}
		function m2(id)
		{
			var e2=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			e2.sP=function(x,y){this.style.left=x;this.style.top=y;};
			e2.x = startLX;
			e2.y = startLY;
			return e2;
		}
		
		window.stayTopLeft=function()
		{
			
			if (document.documentElement && document.documentElement.scrollTop)
				var pY =  document.documentElement.scrollTop;
			else if (document.body)
				var pY =  document.body.scrollTop;
			
			if (document.body.scrollTop > 70){
				/*if(document.body.scrollTop != k){
					alert(document.body.scrollTop);
				}
				k = document.body.scrollTop;*/
				
				startLY = 120;//263;
				startRY = 155;//263;
				startSY=document.body.clientHeight-168;
				
				
				if(document.body.scrollTop > 70 && document.body.scrollTop < 290) {
					pY = 0;
				}else{
					if(document.body.clientHeight / 2 > pY){
						pY = pY + 263;
					}else{
						pY = pY - 263;
					}
				}
				
			} else {
					startLY = 91;//263;
					startRY = 91;//263;
					
					startSY=document.body.clientHeight-168;
					
					
			};
			
			
			
			ftlObj.y += (pY+startRY-ftlObj.y)/16;						
			ftlObj.sP(ftlObj.x, ftlObj.y);
			
			ftlObj2.y += (pY+startLY-ftlObj2.y)/16;
			ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			
			setTimeout("stayTopLeft()", 1);
		}
		ftlObj = ml("divAdRight");
		//stayTopLeft();
		ftlObj2 = m2("divAdLeft");
		
		stayTopLeft();
	}
	
	function ShowAdDiv()
	{
		var objAdDivRight = document.getElementById("divAdRight");
		var objAdDivLeft = document.getElementById("divAdLeft");
					
		
		if (document.body.clientWidth < 980)
		{
		    objAdDivRight.style.display = "none";
			objAdDivLeft.style.display = "none";
			
		}
		else
		{
			objAdDivRight.style.display = "block";
			objAdDivLeft.style.display = "block";
			
			FloatTopDiv();
		}
	}
	
	
var theloaiOverBgImage = '';
var theloaiOverTxt = '';
function theloaiOver (sr) {
	sr.style.backgroundImage=theloaiOverBgImage;
	if (sr.childNodes && theloaiOverTxt && theloaiOverTxt!='') {
		var i, imax = sr.childNodes.length;
		for (i=0; i<imax; i++) {
			sti = sr.childNodes.item(i).style;
			if (sti) sti.color=theloaiOverTxt;
		}
	}
}
function theloaiOut (sr) {
	sr.style.backgroundImage='';
	if (sr.childNodes && theloaiOverTxt && theloaiOverTxt!='') {
		var i, sti, imax = sr.childNodes.length;
		for (i=0; i<imax; i++) {
			sti = sr.childNodes.item(i).style;
			if (sti) sti.color='';
		}
	}
}

	theloaiOverBgImage = 'url(http://'+ location.host+'/Music/templates/funnycolors/img/sub_content_menu_hover.gif)';
	theloaiOverTxt = 'FFFFFF';
	
	
/*function theloaiOver (sr,img_over,color_over) {	
	sr.style.backgroundImage=img_over;
	sr.color=color_over;
	if (sr.childNodes && color_over && color_over!='') {
		var i, imax = sr.childNodes.length;
		for (i=0; i<imax; i++) {
			sti = sr.childNodes.item(i).style;
			if (sti) sti.color=color_over;
		}
	}
}*/

function chinaOver (sr,img_over,color_over) {	
	sr.style.backgroundImage=img_over;
	//sr.color=color_over;
	if (sr.childNodes && color_over && color_over!='') {
		var i, imax = sr.childNodes.length;
		for (i=0; i<imax; i++) {
			sti = sr.childNodes.item(i).style;
			if (sti) sti.color=color_over;
		}
	}
}

/*function theloaiOut (sr,color_out) {
	sr.style.backgroundImage='';
	sr.color=color_out;
	if (sr.childNodes && color_out && color_out!='') {
		var i, sti, imax = sr.childNodes.length;
		for (i=0; i<imax; i++) {
			sti = sr.childNodes.item(i).style;
			if (sti) sti.color=color_out;
		}
	}
}*/

function selectOption(obj,val,img_selected){
	var keyType = document.getElementById('searchType');
	var img_song = document.getElementById('img_song');
	var img_singer = document.getElementById('img_singer');
	var img_album = document.getElementById('img_album');
	switch(obj.id){
		case "img_song":
			img_singer.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/casy.gif';
			img_album.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/album.gif';
			break;
		case "img_singer":
			img_song.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/baihat.gif';
			img_album.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/album.gif';
			break;
		case "img_album":
			img_song.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/baihat.gif';
			img_singer.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/casy.gif';
			break;
		
	}
	keyType.value = val; 
	obj.src = img_selected;
}

function selectOptionBottom(obj,val,img_selected){
	var keyType = document.getElementById('searchTypeBottom');
	var img_song = document.getElementById('img_song_bottom');
	var img_singer = document.getElementById('img_singer_bottom');
	var img_album = document.getElementById('img_album_bottom');
	switch(obj.id){
		case "img_song_bottom":
			img_singer.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/casy.gif';
			img_album.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/album.gif';
			break;
		case "img_singer_bottom":
			img_song.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/baihat.gif';
			img_album.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/album.gif';
			break;
		case "img_album_bottom":
			img_song.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/baihat.gif';
			img_singer.src = 'http://'+ location.host+'/Music/templates/funnycolors/img/search/casy.gif';
			break;
		
	}
	keyType.value = val; 
	obj.src = img_selected;
}

function chooseTab(tab,p_song,p_singer,p_album,p_composer,p_lyric,p_searchType){
	var song = document.getElementById(p_song);
	var singer = document.getElementById(p_singer);
	var album = document.getElementById(p_album);
	
	var composer = document.getElementById(p_composer);
	var lyric = document.getElementById(p_lyric);
	
	var searchType = document.getElementById(p_searchType);
	
	 if(navigator.appName == "Netscape")
	{
		 switch(tab){
			case 1:			
				/*For song*/
				song.setAttribute("class", "search_active");
				singer.setAttribute("class", "search_invisibe");
				album.setAttribute("class", "search_invisibe");
				composer.setAttribute("class", "search_invisibe");
				lyric.setAttribute("class", "search_invisibe");
				searchType.value = 'song';
				break;
			case 2:
				/*For singer*/
				song.setAttribute("class", "search_invisibe");
				singer.setAttribute("class", "search_active");
				album.setAttribute("class", "search_invisibe");
				composer.setAttribute("class", "search_invisibe");
				lyric.setAttribute("class", "search_invisibe");
				searchType.value = 'singer';
				break;
			case 3:
				/*For album*/
				song.setAttribute("class", "search_invisibe");
				singer.setAttribute("class", "search_invisibe");
				album.setAttribute("class", "search_active");
				composer.setAttribute("class", "search_invisibe");
				lyric.setAttribute("class", "search_invisibe");
				searchType.value = 'album';
				break;
			case 4:
				/*For composer*/
				composer.setAttribute("class", "search_active");
				lyric.setAttribute("class", "search_invisibe");
				song.setAttribute("class", "search_invisibe");
				singer.setAttribute("class", "search_invisibe");
				album.setAttribute("class", "search_invisibe");
				searchType.value = 'composer';
				break;
			case 5:
				/*For lyric*/
				composer.setAttribute("class", "search_invisibe");
				lyric.setAttribute("class", "search_active");
				song.setAttribute("class", "search_invisibe");
				singer.setAttribute("class", "search_invisibe");
				album.setAttribute("class", "search_invisibe");
				searchType.value = 'lyric';
				break;
		}
	}
	
	 if(navigator.appName == "Microsoft Internet Explorer")
	{
		switch(tab){
			case 1:			
				/*For song*/
				song.className =  "search_active";
				singer.className = "search_invisibe";
				album.className = "search_invisibe";
				composer.className = "search_invisibe";
				lyric.className = "search_invisibe";
				searchType.value = 'song';
				break;
			case 2:
				
				/*For singer*/
				song.className = "search_invisibe";
				singer.className = "search_active";
				album.className =  "search_invisibe";	
				composer.className = "search_invisibe";
				lyric.className = "search_invisibe";
				searchType.value = 'singer';
				
				break;
			case 3:
				/*For album*/
				song.className = "search_invisibe";
				singer.className = "search_invisibe";
				album.className = "search_active";
				composer.className = "search_invisibe";
				lyric.className = "search_invisibe";
				searchType.value = 'album';
				break;
			case 4:			
				/*For composer*/
				song.className =  "search_invisibe";
				singer.className = "search_invisibe";
				album.className = "search_invisibe";
				composer.className = "search_active";
				lyric.className = "search_invisibe";
				searchType.value = 'composer';
				break;
			case 5:			
				/*For lyric*/
				song.className =  "search_invisibe";
				singer.className = "search_invisibe";
				album.className = "search_invisibe";
				composer.className = "search_invisibe";
				lyric.className = "search_active";
				searchType.value = 'lyric';
				break;
		}
	}
}


function CreateBookmarkLink() {

 title = "Nhac.vui.vn"; 
 url = "http://nhac.vui.vn";


	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }

