// JavaScript Document
//var juancho = "juan";
$(function() {

			$('.splash').meerkat({
				background: '#f7fcfa url(/images_v3/bg-splash.png) repeat-x left top',
				height: '100%',
				width: '100%',
				position: 'bottom',
				dontShowAgain: '#closesplash',
				animationIn: 'fade',
				animationOut: 'fade',
				animationSpeed: 500,
				timer: splashseconds,
				cookieExpires: 1
			});

  

  if(pl == 1){
  	$(".PageLayout11").mask("Porfavor ingrese or registrece");
	$(".loadmask-msg").css({"margin-top": '100px'});
	$("#login_w").center();
	$("#login_f").hide();
	$("#cancellogin").show();
  }
  
  
   		$('#login_submitb').click(function() {
				var maskdiv = $(this).attr('rel');
				
				var email = $('#email').val();
				var password = $('#password').val();
								
			if( email == "" || password == "" ){
				
				if( email == ""){
					$('#email').css("border","1px solid red");
				} else {
					$('#email').css("border","0px");
				}
				
				if(password == ""){
					$('#password').css("border","1px solid red");
				} else {
					$('#password').css("border","0px");
				}
				
			
			return false;
				
			} else {
				
				$('#email').css("border","0px");
				$('#password').css("border","0px");
				
			}
			
			

				var urllogin ='/_v3includes/regular_login.inc.php?login=1&username=' + email + '&password=' + password 
				
				$("#loginfw").mask("Ingresando...");
				$.get(urllogin, function(data) {
										 
						if(data == 1){
							window.location	  = "index.php";
						}
						if(data == 0){
							$('#loginfw').unmask();
							$("#loginfw").mask("error login in...");	
							$('#password').val('');
						}
						if(data == 2){
							$('#loginfw').unmask();
							$("#loginfw").mask("Porfavor active su cuenta.<br><center><a href=\"javascript:;\" onClick=\"sedactivation()\" style=\"color:#000000\">Haga click aca para recibir de nuevo el email de activacion</a></center>");	
							$('#password').val('');
						}
					  showResponse0(data);
					});
				
				return false;
			});
			
			function showResponse0(data) {
				var data;
				if(data == 2){
				setTimeout("$('#loginfw').unmask();", 12000);
				} else {
				setTimeout("$('#loginfw').unmask();", 6000);	
				}
			}
			
					

			$('.long_tiny :checkbox').iphoneStyle({ checkedLabel: 'Sitios', uncheckedLabel: 'Galerias' });

  
});
			
			function logoutnow(){
					
					var urllogout ='includes/regular_login.inc.php?logout=1';
					
					$.get(urllogout, function(data) {
							
							if(data == 1){
								window.location	 = "index.php";
								FB.logout()
								
							}
					});
			}
			
			function sedactivation(){
					var email = $('#email').val();
					var urllogout ='_v3includes/regular_login.inc.php?sendactivation=1&user='+email;
					
					$.get(urllogout, function(data) {
							
							if(data == 1){
								$('#loginfw').unmask();
								$("#loginfw").mask("Porfavor revise su email por el email de activacion");	
							}
					});
			}
			
			
			
			function post_to_wall(url, url2, photo, gallery){
				
					var actionurl = 'share_options.inc.php?option=1&url='+url+'&url2='+url2+'&photo='+photo+'&gallery='+gallery;
					$("#wallpost").html('<img src="images_v3/loading.gif" />');
					$.get(actionurl, function(data) {
						
						$("#wallpost").html(data);
					});				
				
			}
			
			function upload_photo(photo, gallery){
				
					var actionurl = 'share_options.inc.php?option=2&photo='+photo+'&gallery='+gallery;
					$("#uploadphoto").html('<img src="images_v3/loading.gif" />');
					$.get(actionurl, function(data) {
						
						$("#uploadphoto").html(data);
					});				
				
			}
			
			
function cancellogin(){
	$("#login_w").css({float:'left', margin:0, top: '0px', left:'0px'});
	$("#login_w").removeAttr("style");
	$("#login_f").show();
	$("#cancellogin").hide();
	$(".PageLayout11").unmask();
}

(function($){
    $.fn.extend({
        center: function () {
            return this.each(function() {
                var top = ($(window).height() - $(this).outerHeight()) / 2;
                var left = $(this).width() / 2;
                $(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: '50%', "margin-left": -(left > 0 ? left : 0)+'px'});
            });
        }
    }); 
})(jQuery);

// JavaScript Document

$(document).ready(function(){

	$("#searchbox, #display, .search").hover( function(){
		clearTimeout(timeroff);
		if($("#searchbox").val() != "" && $("#searchbox").val() != "Busqueda"){
			$("#display").show();
		} else {
			$("#display").hide(); 	
		}
	},function(){ 
			timeroff = setTimeout( function(){ 
			$("#display").hide(); 	
			}, 3000 ); 
	});


    //setup before functions
    var typingTimer;                //timer identifier
    var doneTypingInterval = 2000;  //time in ms, 5 second for example


	//on keyup, start the countdown
    $(".search").keyup(function(){
        typingTimer = setTimeout(doneTyping, doneTypingInterval);
    });
    
    //on keydown, clear the countdown 
    $(".search").keydown(function(){
        clearTimeout(typingTimer);
    });

	
	
						   

	
});

    function doneTyping () {
		
		var totalc = $(".search").val().length ;
		if(totalc >= 3){
			var searchbox = $(".search").val();
			var dataString = 'searchword='+ searchbox +"&x=" + (new Date()).getTime() ;
			if(searchbox==''){
				$("#display").html('').hide();	
			}else{
			//$("#searchtop").mask("buscando...");	
				$.ajax({
				type: "POST",
				url: "/_v3includes/searchtop.inc.php",
				data: dataString,
				cache: false,
				success: function(html)
				{
					//$("#searchtop").unmask();
					if(html != ""){
						$("#display").html(html).show();
					} else {
						$("#display").html('').hide();
					}
				}
				});
			}
			return false;
		} else {
			$("#display").html('').hide();
		}
	}

	function searchcancel(){
		$("#display").html('').hide();	
		$("#searchbox").val('');
	}
	


jQuery.fn.idle = function(time){
	var i = $(this);
	i.queue(function(){
		setTimeout(function(){
			i.dequeue();
		}, time);
	});
};

  function getfriends(fbid, fbtoken){
  var friends_listmain = $.ajax({
                    type: "GET",
                    url: '/taging_friends_get.php?uid='+fbid+'&access_token='+fbtoken,
                    async: false,
                    dataType: "json"
					}).responseText;
  return friends_listmain;
  }

