function getXMLHttp()
{
  var xmlHttp
  try { xmlHttp = new XMLHttpRequest(); }
  catch(e)
  {
    try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e)
    {
      try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
      catch(e) { alert("Your browser does not support AJAX!"); return false; }
    }
  }
  return xmlHttp;
}

$(function() {

        $("#slider-images").jCarouselLite({
            btnNext: "#slider-next",
            btnPrev: "#slider-previous",
            			auto: 3000,
			            speed:600,
            visible:1,
            vertical:true
        });

        $("#slider-content").jCarouselLite({
            btnNext: "#slider-next",
            btnPrev: "#slider-previous",
            			auto: 3000,
			            speed:600,
            visible:1
        });	

    });


function change(id){

	for(i=65;i<=90;i++){
		$('#'+String.fromCharCode(i)).removeClass('selected_letter');
		$('#list_'+String.fromCharCode(i)).hide();
		$('#topics').hide();
	}
	
	$('#'+id).addClass('selected_letter');
	$('#list_'+id).fadeIn("slow");
}
function change_timeline(id){
	for (i=1;i<=20;i++){
		if(i!=id){
				$("#c"+i).hide();
				$("#controler"+i).removeClass('controler_hover').addClass('controler');
		}else{
				$("#c"+i).fadeIn("slow");
				$("#controler"+i).removeClass('controler').addClass('controler_hover');
		}
	}
}




function cycle(counter)
{
	var counter = counter+1;
	if (counter < 6)
	{
		cic = setTimeout('cycle('+counter+')', 5000);
	}
	else
	{
		if (counter == 7) counter = 0; 
		cic = setTimeout('cycle(0)', 5000);
	}

load_quote(counter);
}

function show_extra_search(id){
	if(id=='show'){$('#extra_search').fadeIn('slow');}
	if(id=='hide'){$('#extra_search').hide();}
}


function add_fav(id_quote) {
	//alert(window.location.hostname);//alert(rate);
	$("#q_"+id_quote).hide(); $("#loading_"+id_quote).fadeIn(); 
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/add_fav.php?id_quote="+id_quote, true);
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading_"+id_quote).hide(); document.getElementById("response_"+id_quote).innerHTML = http.responseText;  } }
  http.send(null);
}


function change_gallery(id){
	for (i=1;i<=444;i++){
		if(i!=id){
			$('#gb_'+i).hide();
		}else{
			$('#gb_'+i).fadeIn("slow");
				}
	}
	$('#av').hide();//for users gallery(hide avatar)
}




function next_page(id){
	var idd=id-1;
$('#p'+(idd)).hide();
$('#p'+(id)).fadeIn();
}

function pevious_page(id){
	var idd=id+1;
$('#p'+(idd)).hide();
$('#p'+(id)).fadeIn();
}



function next_fq_page(id){
	var idd=id-1;
$('#fq_p'+(idd)).hide();
$('#fq_p'+(id)).fadeIn();
}

function pevious_fq_page(id){
	var idd=id+1;
$('#fq_p'+(idd)).hide();
$('#fq_p'+(id)).fadeIn();
}


function next_fm_page(id){
	var idd=id-1;
$('#fm_p'+(idd)).hide();
$('#fm_p'+(id)).fadeIn();
}

function pevious_fm_page(id){
	var idd=id+1;
$('#fm_p'+(idd)).hide();
$('#fm_p'+(id)).fadeIn();
}


function next_fc_page(id){
	var idd=id-1;
$('#fc_p'+(idd)).hide();
$('#fc_p'+(id)).fadeIn();
}

function pevious_fc_page(id){
	var idd=id+1;
$('#fc_p'+(idd)).hide();
$('#fc_p'+(id)).fadeIn();
}



function next_f_page(id){
	var idd=id-1;
$('#fp'+(idd)).hide();
$('#fp'+(id)).fadeIn();
}

function pevious_f_page(id){
	var idd=id+1;
$('#fp'+(idd)).hide();
$('#fp'+(id)).fadeIn();
}


function next_inbox_page(id){
	var idd=id-1;
$('#ip'+(idd)).hide();
$('#ip'+(id)).fadeIn();
}

function pevious_inbox_page(id){
	var idd=id+1;
$('#ip'+(idd)).hide();
$('#ip'+(id)).fadeIn();
}


function next_sent_page(id){
	var idd=id-1;
$('#sp'+(idd)).hide();
$('#sp'+(id)).fadeIn();
}

function pevious_sent_page(id){
	var idd=id+1;
$('#sp'+(idd)).hide();
$('#sp'+(id)).fadeIn();
}

function become_fan(id) {
	//alert(window.location.hostname);//alert(rate);
	$("#q_"+id).hide(); $("#loading_"+id).fadeIn(); 
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/celebrities/become_fan.php?id="+id, true);
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading_"+id).hide(); document.getElementById("response_"+id).innerHTML = http.responseText;  } }
  http.send(null);
}

function become_fan_movie(id) {
	//alert(window.location.hostname);//alert(rate);
	$("#q_"+id).hide(); $("#loading_"+id).fadeIn(); 
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/become_fan_movie.php?id="+id, true);
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading_"+id).hide(); document.getElementById("response_"+id).innerHTML = http.responseText;  } }
  http.send(null);
}

function hide_div(id) {$("#"+id).hide();}

function show_div(id,id_celeb) {
	//alert(window.location.hostname);//alert(rate);
	
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/celebrities/edit_celebrity.php?id="+id_celeb, true);
  http.onreadystatechange=function() { if(http.readyState == 4) {document.getElementById(id).innerHTML = http.responseText; $("#"+id).show(); } }
  http.send(null);
}

function show_div_movies(id,id_celeb) {
	//alert(window.location.hostname);//alert(rate);
	
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/movies/edit_movie.php?id="+id_celeb, true);
  http.onreadystatechange=function() { if(http.readyState == 4) {document.getElementById(id).innerHTML = http.responseText; $("#"+id).show(); } }
  http.send(null);
}

function show_div_q(id,id_celeb) {
	$("#"+id).show(); 
}

function vote(selected_field,id,table,field,rate) {
	$('#vote').hide(); $('#voting_results').hide();
	$('#voting').show();setTimeout("$('#voting').hide()",1250);

var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/vote.php?selected_field="+selected_field+"&id="+id+"&table="+table+"&field="+field+"&rate="+rate, true);
  http.onreadystatechange=function() { if(http.readyState == 4) { document.getElementById(rate).innerHTML = http.responseText;  } }
  http.send(null);
  
 setTimeout("$('#voting_results').fadeIn()",1250);
  setTimeout("$('#voted').fadeIn()",1250);
}




function report_quote(id, id_reported) {
	//alert(window.location.hostname);//alert(rate);
	$("#qr_"+id).hide(); $("#loading_"+id).fadeIn(); 
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/quotes/abuse.php?id="+id+"&id_reported="+id_reported, true);
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading_"+id).hide(); document.getElementById("response_r"+id).innerHTML = http.responseText;  } }
  http.send(null);
}




function show_user_contributions(userid,module_name) {
	//alert(window.location.hostname);//alert(rate);

	$("f_c").fadeIn("slow"); $("loading").fadeIn(); 
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/users/user_contributions.php?userid="+userid+"&module_name="+module_name, true);
 
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading").hide(); document.getElementById("f_c").innerHTML = http.responseText;  } }
  http.send(null);
}


function show_user_favourite(userid,module_name) {
	//alert(window.location.hostname);//alert(rate);

	$("f_c").fadeIn("slow"); $("loading").fadeIn(); 
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/users/user_favourites.php?userid="+userid+"&module_name="+module_name, true);
 
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading").hide(); document.getElementById("f_c").innerHTML = http.responseText;  } }
  http.send(null);
}






function user_actions(from,to,action) {
	//alert(window.location.hostname);
	//alert(action);

	$("#"+action).hide(); $("#loading_"+action).fadeIn(); 
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/users/actions.php?from="+from+"&to="+to+"&action="+action, true);
 
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading_"+action).hide(); document.getElementById(action).innerHTML = http.responseText;$("#"+action).show();  } }
  http.send(null);
}




function change_content(action,id) {
	//alert(window.location.hostname);
	//alert(action);
	$("#new_message").removeClass('sel');$("#inbox").removeClass('sel');$("#sent").removeClass('sel');$("#personal_details").removeClass('sel');$("#manage_photos").removeClass('sel');$("#friends").removeClass('sel');$("#fans").removeClass('sel');$("#comments").removeClass('sel');$("#account_settings").removeClass('sel');
	
document.getElementById("to").value="";
	
	$("#show_email").hide();$("#show_email_sent").hide();$("#content_new_message").hide();$("#content_inbox").hide();$("#content_sent").hide();$("#content_personal_details").hide();$("#content_manage_photos").hide();$("#content_friends").hide();$("#content_fans").hide();$("#content_comments").hide();$("#content_account_settings").hide();
	
	
	
	$("#"+action).addClass('sel');$("#profile_content").hide();$("#content_"+action).hide();$("#loading").fadeIn(); 
/*	
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/quotes/users/manage_users_actions.php?id="+id+"&action="+action, true);
 
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading").hide(); document.getElementById("profile_content").innerHTML = eval("http.responseText"); $("#profile_content").show();  } }
  http.send(null);*/
  $("#loading").hide(); $("#content_"+action).show();
 
}


function show_mail(id) {
	//alert(window.location.hostname);
	//alert(action);
	
	$("#content_inbox").hide();
	
	$("#loading").fadeIn(); 

var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/users/do_manage_users_actions.php?show_email="+id, true);
 
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading").hide(); document.getElementById("show_email").innerHTML = eval("http.responseText"); $("#show_email").show();  } }
  http.send(null);
}

function show_mail_sent(id) {
	//alert(window.location.hostname);
	//alert(action);
	
	$("#content_sent").hide();
	
	$("#loading").fadeIn(); 

var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/users/do_manage_users_actions.php?show_email_sent="+id, true);
 
  http.onreadystatechange=function() { if(http.readyState == 4) {$("#loading").hide(); document.getElementById("show_email_sent").innerHTML = eval("http.responseText"); $("#show_email_sent").show();  } }
  http.send(null);
}


	

function stristr (haystack, needle, bool) {
    var pos = 0;
 
    haystack += '';
    pos = haystack.toLowerCase().indexOf( (needle+'').toLowerCase() );    if (pos == -1){
        return false;
    } else{
        if (bool) {
            return haystack.substr( 0, pos );        } else{
            return haystack.slice( pos );
        }
    }
}
function gallery_favorite(id_gallery) {
	//alert(id_gallery);//alert(rate);
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "http://"+window.location.hostname+"/celebrities/set_gallery_session.php?id_gallery="+id_gallery, true);
  http.send(null);
}

