function showTip(c,div){if(c.value.length == 0){try{$(div).fadeIn();}catch(e){}}}
function hideTip(div){$(div).fadeOut();}
function showTip1(div){$(div).slideDown();}

function submitComment(){

stop = 0;
$('#postCommentForm input[@type="text"]').each(function(index,obj){if(obj.value == ""){stop =1;}});

$('#postCommentForm textarea').each(function(index,obj){if(obj.value == ""){stop =1;}});
if(stop == 1){$('#loading').empty();$('#loading').append("<font size=2 face=arial color=red><B>Please fillup all the fields</B></font>");$('#loading').show();return false;}
$('#loading').empty();$('#loading').append("<font size=2 face=arial color=green>Posting your comments, please wait...</font>");
$('#loading').show();$.post('/hindilyrics/ajaxphp/postcomments.php',$('#postCommentForm').serialize(),function(data){
data = data.replace('\\','');
$('#loading').html('<font size=2 face=arial color=green>Thank you very much for your comments</font>');$('#cph').html(data);$('#comment_form_table').fadeOut('slow');$('#cph').slideDown('slow');$('#com_titie').hide();});return false;}


function digg(page_url,anc,lnk){$.post('/hindilyrics/ajaxphp/digg.php','page_url='+page_url,function(data){$(anc).html(data);$(anc).fadeIn('slow');$(lnk).fadeOut('fast');$(lnk).html('<font size=1 face=verdana color=#FF128D>Thank you</font>');$(lnk).fadeIn('slow');});}
function showLoginForm(){$('#lld').hide();$('#lfd').fadeIn('slow');$('#email').focus();}
function loginTryAgain(){$('#loading').hide();$('#lfd').fadeIn('slow');$('#email').focus();}
function login1(){$('#lfd').hide();var myDate=new Date();t=myDate.getTime();$.ajax({type: "POST",url: "ajaxphp/login.php",data: $('#lf').serialize()+"&rand="+t,cache: false,success: function(data){if(data==1){window.location.reload(true);}else{$('#loading').html(data);$('#loading').show();}}});}
function addToFav(container,story){if(arguments.length == 1){frac = arguments[0];fracpart = frac.split("favlink_");if(typeof(fracpart[1])!="undefined"){qs = "?ptopic="+escape(fracpart[1]);}else{qs = "";}$(arguments[0]).html('<a href="http://hindilyrics.bollysite.com/login.html'+qs+'" title="Login"><font size=1 face=arial color="#0063DC"><B>Login</B></font></a><font size=1 face=arial color="#444444"> or </font><a href="http://hindilyrics.bollysite.com/register.html'+qs+'" title="Register"><font size=1 face=arial color="#0063DC"><B>Register</B></font></a>');}else{	dataToSent = "topic="+escape(story)+"&ret=ajax";$.get('http://hindilyrics.bollysite.com/addtofav.html',dataToSent,function(data){$(container).html(data).wrap('<span style="font-size:11px;font-family:Tahoma"></span>');});}}
function removeFromFav(container,container1,container2,story){if(confirm('Are you sure, you want to remove this story from your favourites?')){dataToSent = "topic="+escape(story)+"&ret=ajax";$.get('http://hindilyrics.bollysite.com/removefromfav.html',dataToSent,function(data){if(data == "done"){$(container).hide();$(container1).hide();$(container2).hide();}});}}
function showDC(obj){$(obj).slideToggle('slow');}
function hidelogin(){$('#lfd').hide();$('#lld').fadeIn();}
function showChooseUserNameForm(){$('#screenform').html("<form id='screenform' style='display:inline'><input type='text' onkeyup='checkUNAvail(this);'  name='username' id='username' value=''><input disabled  id='username_submit' type='button' value='Confirm' onclick='JavaScript:saveUserName();' ></form>");$('#username').focus();}
function gobyid(o){if(document.getElementById){return document.getElementById(o);}else if(document.all){return document.all[o];}}
function checkUNAvail(obj){if(obj.value.length > 4){jQuery.ajax({type: "POST",url:"ajaxphp/screennameavail.php",data:$('#screenform').serialize(),beforeSend: function(){$('#loadingMsg1').show();},cache: false,success: function(data){if(data==1){$('#loadingMsg1').html("&nbsp;<font color=green><B>"+ gobyid('username').value +"</B> is available.</font>");gobyid("username_submit").disabled = false;}else{$('#loadingMsg1').html("&nbsp;<font color=red><B>"+ gobyid('username').value +"</B> is not available.</font>");gobyid("username_submit").disabled = true;}}});}else{$('#loadingMsg1').html("<font color=red size=2>Must be min 5 characters long.</font>");gobyid("username_submit").disabled = true;}} 
function saveUserName(){if(confirm("Are you sure, to keep " + gobyid('username').value + "as your screen name?\n\nOnce you click 'OK', it won't be changed ever.")){$.ajax({type: "POST",url: "/hindilyrics/ajaxphp/saveusername.php",data: $('#screenform').serialize(),beforeSend: function(){$('#loading').show();},cache: false,success: function(data){if(data==1){if(typeof(window.postpage) == "undefined"){$('#loadingMsg1').hide();$('#screenform').html(gobyid('username').value);}else{window.location.reload(true);}}else{alert(data);}}});}}

function commentvote(id,vtype){
if(arguments.length != 2)return;
params = 'id='+id+"&vtype="+vtype;
fdiv = "#"+vtype+id;
fdiv1 = "#points"+id;
ni = new Image();
ni.src = "/images/ok.png";
data1 = "<img src='"+ni.src+"'>";
$.post('/hindilyrics/ajaxphp/votecomment.php',params,function(data){
if(data != 0){
$(fdiv).html(data1);
$(fdiv1).html(data);
}
});
}

function logSearch(){
tag = document.forms['gs'].q.value;
dataToSent = "tag="+tag;
document.forms['gs'].sa.value = "Wait a second...";
$.get('/hindilyrics/ajaxphp/log_search.php',dataToSent,function(data){
document.forms['gs'].sa.value = "Google Search";
return true;
});
}

function saveCorrection(){
jQuery.ajax({type: "POST",url:"/hindilyrics/ajaxphp/correctlyrics.php",data:$('#lyrics_correct_form').serialize(),beforeSend: function(){
$('#cl_form').hide();
$('#cl_loading').show();
},cache: false,success: function(data){if(data==1){

jQuery.facebox('<font size=3 face=arial color="#FF128D"><B>Thank you very much for your request</B></font><BR><BR><font size=2 face=arial>Once your correction get approved, you will get it here.</font><BR><BR><input type="button" value="Okay" onclick="jQuery(document).trigger(\'close.facebox\')" class="s_btn">');

}}});
}

function showPreivew(){
$('#p_toname').html($('#toname').val());
$('#p_message').html(nl2br($('#message').html()));
$('#p_yourname').html($('#yourname').val());
$('#cl_form').hide();
$('#cl_preview').fadeIn();
}

function hidePreivew(){
$('#cl_preview').hide();
$('#cl_form').fadeIn();
}

function nl2br( str ) {
    return str.replace(/([^>])\n/g, '$1<br/>');
}

function sendLyrics(){

from_name = $('#yourname').val();
from_email = $('#youremail').val();



to_name = $('#toname').val();
to_email = $('#toemail').val();
message = $('#message').val();
page_url = $('#page_url').val();

errors = "Please correct the following error(s)<BR>";

if(from_name == ""){
errors += "Your name must not be empty<BR>";

}
if(from_email == ""){
errors += "Your email must not be empty<BR>";
}
if(from_email != ""){
filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if(!filter.test(from_email)){
errors += "Your email is invalid.<BR>";
}
}
if(to_name == ""){
errors += "Your someone's name must not be empty<BR>";

}
if(to_email == ""){
errors += "Your someone's email must not be empty<BR>";
}

if(to_email != ""){
filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if(!filter.test(to_email)){
errors += "Your someone's email is invalid.<BR>";
}
}

if(errors != "Please correct the following error(s)<BR>"){
$('#lsf_errors').html(errors);
return false;
}

qs = "from_name="+from_name+"&from_email="+from_email+"&to_name="+to_name+"&to_email="+to_email+"&page_url="+escape(page_url)+"&message="+escape(message);

jQuery.ajax({type: "POST",url:"/hindilyrics/ajaxphp/sendlyrics.php",data:qs,beforeSend: function(){
$('#cl_form').hide();
$('#cl_loading').show();
},cache: false,success: function(data){if(data==1){

jQuery.facebox('<font size=3 face=arial color="#FF128D"><B>Your message is sent to </B></font><BR><BR><font size=2 face=arial>Thank you for using bollysite.</font><BR><BR><input type="button" value="Okay" onclick="jQuery(document).trigger(\'close.facebox\')" class="s_btn">');

}}});
}
var xr = "";
var ACTIVE_X_IDENTS = [
  "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0",
  "MSXML2.XMLHTTP", "MICROSOFT.XMLHTTP.1.0", "MICROSOFT.XMLHTTP.1",
  "MICROSOFT.XMLHTTP" ];
var ieProgId = undefined;

var XML_READY_STATE_UNINITIALIZED  = 0;
var XML_READY_STATE_LOADING        = 1;
var XML_READY_STATE_LOADED         = 2;
var XML_READY_STATE_INTERACTIVE    = 3;
var XML_READY_STATE_COMPLETED      = 4;

function XmlHttpInit() {

  if (typeof XMLHttpRequest == 'undefined' &&
      typeof ActiveXObject != 'undefined') {
    for (var i = 0; i < ACTIVE_X_IDENTS.length; i++) {
      var candidate = ACTIVE_X_IDENTS[i];

      try {
        new ActiveXObject(candidate);
        ieProgId = candidate;
        break;
      } catch (e) {
      }
    }

  }
}


XmlHttpInit();

function XmlHttpCreate() {
  if (ieProgId !== undefined) {
    return new ActiveXObject(ieProgId);
  } else {
	
    return new XMLHttpRequest();
  }
}

function XmlHttpGET(xmlhttp, url, handler) {
  xmlhttp.onreadystatechange = handler;
  xmlhttp.open("GET", url, true);
  XmlHttpSend(xmlhttp, null);
}

function XmlHttpSend(xmlhttp, data) {
  try {
    xmlhttp.send(data);
  } catch (e) {
  }
}


function getAlbums(start){



xr = XmlHttpCreate();
xr.open("GET",'/getAlbum.php?start='+start,true);
		// Success
xr.onreadystatechange = function(){handleServerResponseForAlbums();}
xr.setRequestHeader("Connection", "close");
xr.send(null);

	function handleServerResponseForAlbums()
	{

			 if (xr.readyState == 4) {
				 if (xr.status == 200) {
					//console.log(xr.responseText);
					if(xr.responseText != null){
					data = eval('(' + xr.responseText + ')');
					counter = 0;
					menu = "<div width='100%' style='border-bottom:1px solid #EEEEEE'><font size=3 face=arial>&nbsp;&nbsp;&nbsp;All albums/movie starting with letter &raquo;<font style='color:#FF128D'><B> "+start+"</B></font></font></div>";
					menu += "<table bgcolor='#FAFAFA' width='100%' border=0 cellpadding=5 cellspacing=0>";
					for(i in data){
					if(counter == 0){
					menu += "<tr>";
					}
					if(((counter) % 4) == 0){
					menu += "</tr><tr>";
					}					
					menu += "<td style='padding-left:10px'><a href="+i+"><font style='font-size:13px' face='arial,sans-serif' color='#0063dc'>"+data[i]+"</font></a></td>";
					counter++;
}
					menu += "</tr></table>";

document.getElementById('albummenu').innerHTML = menu;
document.getElementById('albummenu').style.width = "100%";
document.getElementById('albummenu').style.overflow = "auto";
var mloadiv = document.getElementById('mloadiv');
var mloadimg = document.getElementById('mloadimg');
mloadiv.style.display = "none";
mloadimg.style.display = "none";
document.getElementById('albummenu').style.display = "";
if(counter > 24){
					document.getElementById('albummenu').style.height = "180px";
					}


					}
				 }
			 }
	}
}


alpha = ['home','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];


function loadLyricsMenu(chr){

document.getElementById('albummenu').style.display = "none";
var mloadiv = document.getElementById('mloadiv');
var mloadimg = document.getElementById('mloadimg');



if(chr != "home"){
letter1 = document.getElementById('letter');


letter1.innerHTML = chr;



}else{



mloadiv.style.display = "none";
mloadimg.style.display = "none";
var ctab = document.getElementById('tab_'+chr);

for(i=0;i<alpha.length;i++){
tab = document.getElementById('tab_'+alpha[i]);
tab.className = 'tab';
}
ctab.className = "tab active";
return;
}


ctab = document.getElementById('tab_'+chr);
mloadiv.style.display = "";
mloadimg.style.display = "";
for(i=0;i<alpha.length;i++){
tab = document.getElementById('tab_'+alpha[i]);
tab.className = 'tab';
}
ctab.className = "tab active";

getAlbums(chr);
}

function showReplyDiv(divid){
$(divid).show();
$(divid + " textarea").focus();
}

function hideReplyDiv(divid){
$(divid).hide();
}

function saveReply(divid){
console.log(divid);
textobj = "comment_reply_"+divid;
reply = document.getElementById(textobj).value
console.log(textobj);
console.log(document.getElementById(textobj).value);
sr = $('#postCommentForm').serialize()+"&reply="+reply+"&parent_id="+divid;
console.log(sr);
$.post('ajaxphp/postreply.php',sr,function(data){
if(data == 1){
location.reload(true);
}else{
alert("Unable to post reply...Please try after some time.");
}
});
return false;
}
function downloadJS(url){var elem = document.createElement("script");elem.src = url;document.body.appendChild(elem);}
downloadJS('http://www.google.com/uds/api?file=uds.js&v=1.0');