// JavaScript Document
function getAjax()
	{
	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;
	}
 function Insert_rating(vid) {
	var rating=document.frmrating.rating.options[document.frmrating.rating.selectedIndex].value;
	var url= 'http://latestbollywood.net/members/ratevideo.php?vid='+vid+'&rate='+rating;
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById('msg').innerHTML=req.responseText;
	}
	}
	req.open('get', url , true );
	req.send( null );
 }	
  function ValidateEmail(email) {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if (reg.test(email) == false)
        return false;
    return true;
}
 function showcommentsbox()
 {
	 document.getElementById('commentbox').style.display="";
 }
 function hidecommentbox(textbox)
 {
 document.getElementById('commentbox').style.display="none";
 document.getElementById(textbox).value="";
 return false;
}
// Removes leading whitespaces
function LTrim( value ) {	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

function pageUp() {
 		 if (window.scrollBy)
    		window.scrollBy(0, window.innerHeight ? -window.innerHeight : -document.body.clientHeight);
		}
function pageDown() {
 		 if (window.scrollBy)
    		window.scrollBy(0, window.innerHeight ? window.innerHeight : document.body.clientHeight);
		}
		

// Removes leading and ending whitespaces
function triming( value ) {
	return LTrim(RTrim(value));
}
function go_to_private_page(pagelink)
{
   window.location=pagelink;
}

function refineSearchText(text)
{
	text=text.replace('  ','')
	strarray=text.split(" ");
	var refinetext=strarray[0];
	if(strarray.count()>1){
	for(i=1 ; i<strarray.count(); i++)
	{
	if(strarray[i]!="")
	refinetext=refinetext+"-"+triming(strarray[i]);
	}
	}
	return refinetext;
}
Array.prototype.count = function() {
	return this.length;
};

function checkstr(mystr){
  var outstr = ((mystr.charAt(mystr.length-1,1) == ",") ? mystr.substring(0,mystr.length-1) : mystr);
  return outstr;
}	
 function IsNumeric(PossibleNumber)
{
	var PNum = new String(PossibleNumber);
	var regex = /[^0-9]/;
	return !regex.test(PNum);
}
function showreplybox(rep)
{
document.getElementById(rep).style.display="";	
}

function hiderepcommentbox(box)
{
document.getElementById(box).style.display="none";	
}

/*function validatecomment()
{
if(document.getElementById('comment').value=="")
	{
		alert("please Enter comments");
		return false;
	}	
}
function postComments(vid)
{
	var url='postcomment.php?vid='+vid+'&com='+document.getElementById('comment').value;
	alert(url);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById('cmsg').innerHTML=req.responseText;
	}
	}
	req.open('post', url , true );
	req.send( null );
	document.getElementById('commentbox').style.display="none";
} */
function getUrl()
{
url=document.location.href;
return url;
}
function showfavMsg()
{
	document.getElementById('fav_msg').style.display="";
}
function showflagMsg()
{
	document.getElementById('flag_msg').style.display="";
}
function showfav_bMsg(span)
{
	document.getElementById(span).style.display="";
}
function hideFlagReason(reason,darrow,rarrow)
{
	document.getElementById(reason).style.display="none";
	document.getElementById(darrow).style.display="none";
    document.getElementById(rarrow).style.display="";
}
function showFlagReason(reason,darrow,rarrow)
{

	document.getElementById(reason).style.display="";
	document.getElementById(darrow).style.display="";
	document.getElementById(rarrow).style.display="none";
}
function close_fav_bmsg(span)
{
document.getElementById(span).style.display="none";	
}

function close_flagmsg()
{
document.getElementById('flag_msg').style.display="none";	
}
function close_favmsg()
{
document.getElementById('fav_msg').style.display="none";	
}
function close_element(element)
{
document.getElementById(element).style.display="none";	
}
function display_element(element)
{
document.getElementById(element).style.display="";	
}
function showMoreInfo()
{
document.getElementById('moreinfo').style.display="";
document.getElementById('minfo').style.display="none";
document.getElementById('linfo').style.display="";
}
function lessInfo()
{
document.getElementById('moreinfo').style.display="none";
document.getElementById('minfo').style.display="";
document.getElementById('linfo').style.display="none";
}
function showrelvideo()
{
document.getElementById('rel_video').style.display="";
document.getElementById('down_arrow').style.display="";
document.getElementById('right_arrow').style.display="none";
}
function hiderelvideo()
{
document.getElementById('rel_video').style.display="none";
document.getElementById('down_arrow').style.display="none";
document.getElementById('right_arrow').style.display="";
}
function showfeatvideo()
{
document.getElementById('feat_video').style.display="";
document.getElementById('f_down_arrow').style.display="";
document.getElementById('f_right_arrow').style.display="none";
}
function hidefeatvideo()
{
document.getElementById('feat_video').style.display="none";
document.getElementById('f_down_arrow').style.display="none";
document.getElementById('f_right_arrow').style.display="";
}
function AddtoFavorite(vid,act)
{
	ajaxloader('fmsg');
	var url='http://latestbollywood.net/members/addtofavorite.php?vid='+vid+'&action='+act;
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById('fmsg').innerHTML=req.responseText;	
	}
	}
	req.open('post', url , true );
	req.send( null );
	showfavMsg();
	
}
function postflag(vid,act)
{
	ajaxloader('flag_msg');
	var reason=document.getElementById(_gel('flag_id').value).innerText;
	var url='http://latestbollywood.net/members/postflag.php?vid='+vid+'&action='+act+'&reason='+reason;
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById('flag_msg').innerHTML="This video Flaged by you Successfully";
		//document.getElementById('flag_msg').innerHTML=req.responseText;	
	}
	}
	req.open('post', url , true);
	req.send( null );
}
function getSubCat(span,url,subcatDropdownName)
{
	var span=document.getElementById(span);
	var subcatDropdown=null;
	
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {		
		var subcat=req.responseText.split('*');
		if(subcat[1]=="0")
		{			
		span.innerHTML=subcat[0];		
		subcatDropdown=document.getElementById(subcatDropdownName);	
		subcatDropdown.disabled=true;
		}
		else
		{
		span.innerHTML=subcat[0];
		}
	}
	}
	req.open('post', url , true );
	req.send( null );
}
function AddtoFav_browse(vid,act)
{
	
	var url='http://latestbollywood.net/members/addtofavorite.php?vid='+vid+'&action='+act+'&fb=y';
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		//document.getElementById('fmsg'+vid).innerHTML=req.responseText;	
		//alert(req.responseText);
	}
	}
	req.open('post', url , true );
	req.send( null );
	//alert('fav_msg'+vid);
	//showfav_bMsg('fav_msg'+vid);
	
}
function DelFromFavorite(vid,act)
{
	ajaxloader('fmsg');
	var url='http://latestbollywood.net/members/addtofavorite.php?vid='+vid+'&action='+act;
	//alert(url);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById('fmsg').innerHTML=req.responseText;
		
	}
	}
	req.open('post', url , true );
	req.send( null );
	close_favmsg();
}
function manageFlag(vid,act,msgbox)
{
	var url='http://latestbollywood.net/members/manageflags.php?vid='+vid+'&action='+act;
	//alert(url);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById(msgbox).innerHTML="";
		document.getElementById(msgbox).innerHTML=req.responseText;
		//alert(document.getElementById(msgbox).innerHTML);
	}
	}
	req.open('post', url , true );
	req.send( null );
}
function ajax_comment_paging(page) {
	var queryString=''; 
	var curenttab='tab'+currentselected
	var url= 'http://latestbollywood.net/members/watchvideo.php?';
	//alert(url);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 && req.status == 200 ) {
		document.getElementById('pageinner_'+currentselected).innerHTML=req.responseText;
		}
	}
	req.open( 'GET', url , true );
	req.send( null );
	return false;
 }
 function hide(element,d_arrow,r_arrow)
 {
document.getElementById(element).style.display="none";
document.getElementById(d_arrow).style.display="none";
document.getElementById(r_arrow).style.display="";	 
 }
 function show(element,d_arrow,r_arrow)
 {
	 
document.getElementById(element).style.display="";
document.getElementById(d_arrow).style.display="";
document.getElementById(r_arrow).style.display="none";
	 
 }
 function voidfunction()
 {
 	 test=Math.random()*100000;
	 for(i=0; i<10000 ; i++)
	 {
		 
	 }
 }
 function getStateSndSubrub(cval)
 {
	  getdatato('http://latestbollywood.net/members/pcode.php?country='+cval+'&timeid='+(Math.random()*100000),'states',cval); 
 }
 
 function getStateAndSubrubForReg(cval)
 {
	  getStatesData('http://latestbollywood.net/members/pcode.php?country='+cval+'&timeid='+(Math.random()*100000),'states',cval);
 }
function getdata(url,msgbox)
{ 
ajaxloader(msgbox);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById(msgbox).innerHTML="";		
		document.getElementById(msgbox).innerHTML=req.responseText;
	}
}
	req.open('post', url , true );
	req.send( null );
}
function getdatato(url,msgbox,cval)
{ 
ajaxloader(msgbox);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById(msgbox).innerHTML="";
		document.getElementById(msgbox).innerHTML=req.responseText;
		//alert(document.getElementById(msgbox).innerHTML);
		 getdata('http://latestbollywood.net/members/pcode.php?st=st&countryid='+cval,'tdsuburbs');
	}
}
	req.open('post', url , true );
	req.send( null );
}

function getStatesData(url,msgbox,cval)
{ 
ajaxloader(msgbox);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById(msgbox).innerHTML="";
		document.getElementById(msgbox).innerHTML=req.responseText;
		 getsubrubs('http://latestbollywood.net/members/pcode.php?st=st&countryid='+cval,'tdsuburbs',cval);
	}
}
	req.open('post', url , true );
	req.send( null );
}


function getsubrubs(url,msgbox,cval)
{ 
ajaxloader(msgbox);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById(msgbox).innerHTML="";		
		document.getElementById(msgbox).innerHTML=req.responseText;
	//	alert(document.getElementById(msgbox).innerHTML);
		//getCountryPrefix('http://latestbollywood.net/members/getcountryprefix.php?country='+cval);
	}
}
	req.open('post', url , true );
	req.send( null );
}

function getTimeZone(url,msgbox)
{ 
ajaxloader(msgbox);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById(msgbox).innerHTML="";
		document.getElementById(msgbox).innerHTML=req.responseText;
		//alert(document.getElementById(msgbox).innerHTML);
	}
	}
	req.open('post', url , true );
	req.send( null );
}

function getCountryPrefix(url)
{ 
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		getTimeZone('http://latestbollywood.net/members/timezones.php?country='+triming(req.responseText),'tdtimezone');
	}
	}
	req.open('post', url , true );
	req.send( null );
}



function getsubrub(url,msgbox)
{ 
//ajaxloader(msgbox);
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById(msgbox).innerHTML="";
		document.getElementById(msgbox).innerHTML=req.responseText;
		//alert(document.getElementById(msgbox).innerHTML);
	}
	}
	req.open('post', url , true );
	req.send( null );
}
 function hidesmallshowbig(selement,belement,d_arrow,r_arrow)
 {
document.getElementById(selement).style.display="none";
document.getElementById(belement).style.display="";
document.getElementById(d_arrow).style.display="";
document.getElementById(r_arrow).style.display="none";	 
 }
 function showsmallhidebig(selement,belement,d_arrow,r_arrow)
 {
document.getElementById(selement).style.display="";
document.getElementById(belement).style.display="none";
document.getElementById(d_arrow).style.display="none";
document.getElementById(r_arrow).style.display=""; 
 }
 function showLoadScreen(element)
		{
	var loading = "<div style=\"text-align:center;vertical-align:middle;\"><img src=\"http://latestbollywood.net/members/images/ajax-bar.gif\" alt=\"Loading ...\" /></div>";
			ajaxarea = document.getElementById(element);
			ajaxarea.innerHTML = loading ;		
}
function ajaxloader(element)
	{
//	var loading = "<div style=\"text-align:center;vertical-align:middle;\"><img src=\"http://latestbollywood.net/members/images/ajax-loader.gif\" alt=\"Loading...\" /></div>";
var loading="Loading...."
			ajaxarea = document.getElementById(element);
			ajaxarea.innerHTML = loading ;		
}
function ValidateEmail(email)
{
 if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
 }
 function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}
function pageUp() {
 		 if (window.scrollBy)
    		window.scrollBy(0, window.innerHeight ? -window.innerHeight : -document.body.clientHeight);
		}
		
// ajax function		
function ajaxcall(url,msgbox)
{ 
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById(msgbox).innerHTML="";
		document.getElementById(msgbox).innerHTML=req.responseText;
	}
}
	req.open('get', url , true );
	req.send( null );
}

function ajaxcontactscall(url,msgbox)
{ 
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
		document.getElementById(msgbox).innerHTML="";
		document.getElementById(msgbox).innerHTML=req.responseText;
		document.getElementById('invite').style.display="";
	}
}
	req.open('post', url , true );
	req.send( null );
}

/*function logout()
{
	alert('calling in function');
	var url='logout.php?logout=ok';
	req = getAjax();
	req.onreadystatechange = function(){
	if( req.readyState == 4 ) {
	}
	}
	req.open('post', url , true );
	req.send( null );
	
}  */