// $("#main-container").hide();
//
// jQuery(document).bind('elastic:beforeInitialize', function(){
//
//$("#main-container").fadeIn("slow");
$(".blogersub").hide();
$(".blogersub").fadeIn(3000);
  function sopas(obj) {
                                  

                                           var pag = $(obj).attr("title");
                                           var blog = $("#hiddenBlog").attr("value");

					   var valuePag = $("#valuePag").attr("value");
					   var typePag = $("#typePag").attr("value");

                                           multiple = valuePag.indexOf('|');

                                           valuess = valuePag.split('|');
                                           typess = typePag.split('|');


                                            var ajaxurl = dominio+'menu1.php?blog='+blog+'&ajax=1&pagec='+pag;



                                              if(valuePag==""&&typePag=="")
                                                  {
                                                    /**/
                                               $.ajax({
                                                    type: "GET",
                                                    url: ajaxurl,
                                                    async: true,
                                                    success: function(data){
                                                         $("#ajaxComents").attr("innerHTML","Loading...");


                                                         $("#ajaxComents").attr("innerHTML",data);
                                                    }
                                                });

                                                    /**/
                                                  // $("#ajaxComents").load(ajaxurl);

                                                  }


                                                    }
//});
//
//jQuery(document).bind('elastic::initialize', function(){
// $("#main-container").hide();
//});
jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", "0px");

    return this;
}

jQuery.fn.center2 = function () {
    this.css("position","absolute");
       this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
       this.css("left", ( $(window).width() - this.width() ) / 2 + "px");
 
 this.css("z-index", "99999999999999999");
    return this;
}
	
var linea = '<fb:fan profile_id="106411916065944" stream="0" connections="10" logobar="1" width="150" height="300"></fb:fan>';
 //   linea+=      '  <iframe src="http://www.facebook.com/plugins/activity.php?site=http%3A%2F%2Fwww.maotemagical.com&amp;width=300&amp;height=300&amp;header=true&amp;colorscheme=dark&amp;font=verdana&amp;recommendations=true" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:300px;" allowTransparency="true"></iframe>';
  function shareData(param){

       var linea = '<iframe src="http://www.facebook.com/plugins/like.php?href=http://maotemagical.com/blog/'+param+'&layout=standard&show_faces=true&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" height="80" style="border:none;overflow:hidden;width:450px;height:80px;"></iframe>';

    linea += '<div class="unit">';

//    linea += '      <div class="column">';
//   linea += '         <a href="http://bitacoras.com/anotaciones/http://maotemagical.com/blog/'+param+'">';
//linea += '		<img src="http://widgets.bitacoras.com/votar/normal/http://maotemagical.com/blog/'+param+'" alt="votar" title="Votar esta anotación en Bitacoras.com"/>';
//linea += '		</a>';
// linea += '       </div>';
 linea += '       <div class="column">';
 linea += '         <a href="http://twitter.com/share" class="twitter-share-button" data-url="http://maotemagical.com/blog/'+param+'" data-count="vertical" data-via="maotemagical">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>';
  linea += '      </div>';
  linea += '       <div class="column">';
 linea += '         <a name="fb_share" type="box_count" share_url="http://maotemagical.com/blog/'+param+'"></a>';
  linea += '          <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"';
  linea += '                  type="text/javascript">';
  linea += '          </script>';
 linea += '       </div>';
 linea += '       <div class="column">';
linea += '            <a title="Publica en Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-locale="es" data-url="http://maotemagical.com/blog/'+param+'"></a>';
linea += '<script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script>';
 linea += '       </div>';
linea += '        <div class="column">';
 linea += '           <a href="http://maotemagical.com/mail/'+param+'/"><img  alt="Email" title="Email" src="http://maotemagical.com/img/icons/email_16.png" class="iconSocial balloon"/></a>';
 linea += '       </div>';
 linea += '   </div>';
     document.write(linea);
    
 }
$(document).ready(function() {

if(screen.width<960){
    //width:960px; position:absolute; left:50%; margin-left:-480px;
    $("#main-container").css("position","0");
    $("#main-container").css("left","0px");
    $("#main-container").css("margin-left","0");
}
 //$("#main-container").draggable();
 $('#feedback').center();
 $(window).scroll(function(){
              $('#feedback').center();
			//  $('.iconSocialPack').center();
			

         });
 //$("#main-container").hide();
 function aleatorio(inferior,superior){
   	numPosibilidades = superior - inferior
   	aleat = Math.random() * numPosibilidades
   	aleat = Math.round(aleat)
	
   	return parseInt(inferior) + aleat;
} 
$("#loader").hide();
  dominio= $("#domain").attr('value');

        var src =  dominio+'img/fondo'+'.jpg';       // alert(dominio);
//src =  dominio+'img/fondo.jpg';
//alert(src);
$("body").css("backgroundImage",'url('+ src +')');
$("body").css("background-position",'top center');
//	alert('s');
$("body").css("background-attachment",'fixed');

function loadCSS(cssFile){
 var cssLink=document.createElement("link");
 cssLink.setAttribute("rel", "stylesheet");
 cssLink.setAttribute("type", "text/css");
cssLink.setAttribute("href", cssFile);
 document.getElementsByTagName("head")[0].appendChild(cssLink);
}


$("#estilos a").click(function(){
                hola = $(this).attr('href');
                
              document.cookie="path ="+hola+";";
		loadCSS(dominio+'css/estilos.php?path='+hola);
		return false;
	});

	function CargarCSS(CSSelegido ) {
		// obtener contenido del link </a>
		// la variable async servira para identificar contenido asyncrono
		$.get(CSSelegido.href+'&async',function(data){
			//jAlert(data);
			// cambiarmos atributo href del elemento hoja_estilo, obtenido de theme.php
			
			$('#linker').attr('href',dominio+'css/estilos.php?'+data);
		});
	}
                     
                                $(".iconSocial").mouseover(function() {
                                // get rid of the text decoration on all 4 thumbnails
 
  					var cambia = $(this).attr("src");		
					var cambia2 = cambia.replace("16","32");
					$(this).attr("src",function() {return cambia2;});
    
  
                                });
	
                                $(".iconSocial").mouseout(function() {
                                // get rid of the text decoration on all 4 thumbnails
 
  					var cambia = $(this).attr("src");		
					var cambia2 = cambia.replace("32","16");
					$(this).attr("src",function() {return cambia2;});
    
  
                                });
			
			
 
  				
					var ancho = screen.width-640;
					var alto = screen.width-640;
				
				 ancho = 960-640;
					 alto = 960-640;

					  ancho = (640/640)*520;
					 alto = (505/640)*520;
                                         alto = parseInt(alto);
                                        
				$(".youtubevideo").css({
				
					width : ancho,
					height : alto
                                });
                             
                                if(navigator.userAgent.indexOf('MSIE') == -1){
                                $(".youtubevideo").each(function(){

					var valor = ($(this).find("object").find("param[name=movie]").val());
                                            valor+="?fs=1&hl=es_ES&color1=0xe1600f&color2=0xfebd01";
                                            var htm = '<object width="100%" height="100%"><param name="movie" value="'+ valor+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+ valor+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="100%" height="100%"></embed></object>';
                                        $(this).html(htm);

                                        //   $(this).find("object").find("param[name=movie]").val(valor)
                                });
                                }
                                
                                /*Rating */
                                $(".rate").mouseover(function() {  				
                                var name = $(this).attr("id");
                                var img  = $(this).attr("src");
                               
                                
                              
                               
                                blog = $(this).closest("div").attr("id");
                                blog_id = blog.replace("rate","");
                                name2 = name.replace("rate","");
                                name2 = name2.replace("_"+ blog_id,"");                    
                                name2 = parseInt(name2);
                                i=5;

                                img = img.replace("rating-dis.png","rating.png");
                                img = img.replace("rating-half.png","rating.png");
                                var img2 = img.replace("rating.png","rating-dis.png");
                                    img2 = img2.replace("rating-half.png","rating-dis.png");
				
                                     for(i=1;i<=5;i++){
                                         si = "#rate"+i+"_"+blog_id;
                                         if(i<=name2)
                                         $(si).attr("src",function() {return img});
                                         else
                                         $(si).attr("src",function() {return img2});
                                     }

                                });


                                 $(".rate").mouseout(function() {


                                     var img  = $(this).attr("src");
                                     
                                     var img1 = img.replace("rating-dis.png","rating.png");
                                         img1 = img1.replace("rating-half.png","rating.png");

                                     var img2 = img.replace("rating.png","rating-dis.png");
                                         img2 = img2.replace("rating-half.png","rating-dis.png");

                                     var img3 = img.replace("rating.png","rating-half.png");
                                         img3 = img3.replace("rating-dis.png","rating-half.png");
                                        // img2 = img2.replace("rating-half.png","rating-dis.png");
                                     rating = $(this).attr("title");
                                     rating = rating.replace("Rating: ","");

                                     stars = parseInt(rating);
                                     half_stars = Math.ceil(rating-stars);
                                     dis_stars = 5-stars-half_stars;
                                     //jAlert(" "+stars+" "+half_stars+"  "+dis_stars);
                                     j=0;
                                     for(i=1;i<=stars;i++){
                                          j++;
                                          blog = $(this).closest("div").attr("id");
                                          blog_id = blog.replace("rate","");
                                          si = "#rate"+j+"_"+blog_id;

                                         $(si).attr("src",function() {return img1});
                                     }
                                     for(i=1;i<=half_stars;i++){
                                          j++;
                                          blog = $(this).closest("div").attr("id");
                                          blog_id = blog.replace("rate","");
                                          si = "#rate"+j+"_"+blog_id;

                                         $(si).attr("src",function() {return img3});
                                     }
                                      for(i=1;i<=dis_stars;i++){
                                          j++;
                                          blog = $(this).closest("div").attr("id");
                                          blog_id = blog.replace("rate","");
                                          si = "#rate"+j+"_"+blog_id;

                                         $(si).attr("src",function() {return img2});
                                     }

                                });

                                $(".rate").click(function() {

                                           var blog = $(this).closest("div").attr("id");
                                           blog_id = blog.replace("rate","");
                                           var name = $(this).attr("id");
                                           var name2 = name.replace("rate","");
                                               name2 = name2.replace("_"+ blog_id,"");
                                               name2 = parseInt(name2);
                                          
                                           //jAlert("rating.php?blog="+blog_id+"&rate="+name2);
                                            $("#"+blog).load(dominio+"rating.php?blog="+blog_id+"&rate="+name2);
                                           //jAlert(get);
                                     

                                });
								
				$(".pagblogs").click(function() {

                                           var pag = $(this).attr("title");
                                          
                                     		
					   var valuePag = $("#valuePag").attr("value");
					   var typePag = $("#typePag").attr("value");

                                           multiple = valuePag.indexOf('|');

                                           valuess = valuePag.split('|');
                                           typess = typePag.split('|');

                                           
                                           if(multiple==-1){
                                              if(valuePag==""&&typePag=="")
                                                  window.location = dominio+'page/'+pag+'/';
                                                  else
                                                  window.location = dominio+typePag+'/'+valuePag+'/page/'+pag+'/';
                                            }
                                            else
                                                window.location = dominio+typess[0]+'/'+valuess[0]+'/'+typess[1]+'/'+valuess[1]+'/page/'+pag+'/';

                                 });

                                      

                                                  
                                                 




                            
                                 	

                                 $("#btnSearch").click(function() {
                                        var search = $("#searchquery").attr("value");
                                            search = trim(search);
                                            reg = /\s+/;
                                            search = search.split(' ').join('+');
                                             search = search.split('ñ').join('(n)');
                                              search = search.split('á').join('(a)');
                                               search = search.split('é').join('(e)');
                                               search = search.split('í').join('(i)');
                                               search = search.split('ó').join('(o)');
                                               search = search.split('ú').join('(u)');
                                            
                                        var lang = document.getElementById('lang').value;

                                                 if(lang=='_esp')
                                                    errores_al = 'Ingrese un termino de b&uacute;squeda o sea mas espec&iacute;fico';
                                                    else
                                                    errores_al = 'Are you sure?';
                                             
                                        if(search==''||search.length<4)
                                         jAlert(errores_al);
                                         else
                                             
                                          window.location=dominio+"q/"+search+'/';


                                 });
								 
				$("#searchquery").keyup(function(e) {
																  
											if(e.keyCode == 13)	{				  
                                        var search = $("#searchquery").attr("value");
                                            search = trim(search);
                                            reg = /\s+/;
                                            search = search.split(' ').join('+');
                                               search = search.split('ñ').join('(n)');
                                               search = search.split('á').join('(a)');
                                               search = search.split('é').join('(e)');
                                               search = search.split('í').join('(i)');
                                               search = search.split('ó').join('(o)');
                                               search = search.split('ú').join('(u)');

											     var lang = document.getElementById('lang').value;

                                                 if(lang=='_esp')
                                                    errores_al = 'Ingrese un termino de b&uacute;squeda o sea mas espec&iacute;fico';
                                                    else
                                                    errores_al = 'Are you sure?';
                                             
                                        if(search==''||search.length<4)
                                         jAlert(errores_al);
                                         else
                                             
                                          window.location=dominio+"q/"+search+'/';
											}

                                 });	
								 
								 
								 
						 $("#btnEmail").click(function() {
                                                    var nombre1 = document.getElementById('name_1').value
						    var nombre2 = document.getElementById('name_2').value;
						    var comentario = document.getElementById('Comentarios').value;
      						    var email1 = document.getElementById('email_1').value;
						    var email2 = document.getElementById('email_2').value;
     						    var   nombre1_2 = trim(nombre1);
						    var   nombre2_2 = trim(nombre2);
						    var  comentario2 = trim(comentario);
                                                    var	errores='';
                                                    var errores_eng='';

                                                    if(nombre1_2.length<3){
                                                     errores = errores + "Nombre muy corto<br/>";
                                                     errores_eng = errores_eng+"Name too short<br/>";
                                                    }
                                                    if(nombre2_2.length<3){
                                                    errores = errores + "Nombre muy corto<br/>";
                                                    errores_eng = errores_eng+"Name too short<br/>";
                                                    }

													 if(!emaile(email1)){
                                                     errores = errores + "Email no valido<br/>";
                                                     errores_eng = errores_eng+"Invalid E-mail<br/>";
                                                     }
                                                     if(!emaile(email2)){
                                                     errores = errores + "Email no valido<br/>";
                                                     errores_eng = errores_eng+"Invalid E-mail<br/>";
                                                     }

                                                     if(comentario2.length==0){
                                                     errores = errores + "Comentario obligatorio<br/>";
                                                     errores_eng = errores_eng+"Comment too short<br/>";
                                                    }
                                                     if(comentario2.length>250){
                                                     errores = errores + "Comentario muy largo<br/>";
                                                     errores_eng = errores_eng+"Comment too long<br/>";
                                                     }
													   if(comentario2=='Texto Adicional'||comentario2=='Your text'){
                                                    errores = errores + "Comentario obligatorio<br/>";
                                                     errores_eng = errores_eng + "Must write a comment<br/>";
                                                    }
                                                    
														   var errores_al;

                                                 var lang = document.getElementById('lang').value;

                                                 if(lang=='_esp')
                                                    errores_al = errores;
                                                    else
                                                    errores_al = errores_eng;
                                                     if(errores_al!='')
                                                      jAlert(errores_al);
                                                      else{
                                                      document.getElementById('miform').submit();
                                                        }
                                                     });
						 
												 $("#btnPoll").click(function() {
													var forma = 	$("#pollForm").serialize();
													var forma2 = forma.indexOf("pollVote");
													
													if(forma2==-1)
													jAlert("Elija una opcion","Alerta");
													else{
														$("#pollLoad").load(dominio+"poll.php?"+forma);
														//alert(forma);
														}
												 });

												  $("#btnVisitor").click(function() {
													var forma = 	$("#visitorName").val();
												//	alert(forma);

													if(forma==""||forma.length<3||forma=="")
													jAlert("Escriba su Nombre","Alerta");
													else{
														$("#visitorLoad").html('');
														$("#visitorLoad").load(dominio+"visitor.php?name="+forma);
														$("#visitorLoad").css('height','20px');
														//alert(forma);
														}
												 });
                                                $("#btnCmt").click(function() {
                                                   var nombre1 = document.getElementById('name_1').value
                                                   var comentario = document.getElementById('Comentarios').value;
                                                   var email1 = document.getElementById('email_1').value;
                                                   var url1 = document.getElementById('url_1').value;
                                                   var   nombre1_2 = trim(nombre1);
                                                   var   email1_2 = trim(email1);
                                                   var  url1_2 = trim(url1);
                                                   var  comentario2 = trim(comentario);

                                                   var	errores='';
                                                   var	errores_eng='';
                                                   if(nombre1_2.length<3){
                                                   errores = errores + "Nombre muy corto<br/>";
                                                   errores_eng = errores_eng + "Name too short<br/>";
                                                   }

												    if(!emaile(email1_2)){
                                                     errores = errores + "Email no valido<br/>";
                                                      errores_eng = errores_eng + "Invalid E-mail<br/>";
                                                  }
                                                 if(!ver_url(url1_2)&&url1_2!=''){
                                                 errores = errores + "URL no valida<br/>";
                                                  errores_eng = errores_eng + "Invalid URL<br/>";
                                                 }
                                                   if(comentario2.length==0){
                                                   errores = errores + "Comentario obligatorio<br/>";
                                                    errores_eng = errores_eng + "Must write a comment<br/>";
                                                   }
                                                  if(comentario2.length>250){
                                                   errores = errores + "Comentario muy largo<br/>";
                                                    errores_eng = errores_eng + "Comment too long<br/>";
                                                    }
                                                  if(comentario2=='Tu comentario'||comentario2=='Your comment'){
                                                    errores = errores + "Comentario obligatorio<br/>";
                                                     errores_eng = errores_eng + "Must write a comment<br/>";
                                                    }
                                                   
                                                 
                                                 var errores_al;

                                                 var lang = document.getElementById('lang').value;

                                                 if(lang=='_esp')
                                                    errores_al = errores;
                                                    else
                                                    errores_al = errores_eng;

                                                if(errores_al!='')
                                                jAlert(errores_al);
                                                else{
                                                document.getElementById('miform').submit();
                                                }
                                             });
//
//											 $("#Comentarios").keypress(function(e){
//												    if(e.keyCode==13)
//													{
//                                                   var nombre1 = document.getElementById('name_1').value
//                                                   var comentario = document.getElementById('Comentarios').value;
//                                                   var email1 = document.getElementById('email_1').value;
//                                                   var url1 = document.getElementById('url_1').value;
//                                                   var   nombre1_2 = trim(nombre1);
//                                                   var   email1_2 = trim(email1);
//                                                   var  url1_2 = trim(url1);
//                                                   var  comentario2 = trim(comentario);
//
//                                                   var	errores='';
//                                                   var	errores_eng='';
//                                                   if(nombre1_2.length<3){
//                                                   errores = errores + "Nombre muy corto<br/>";
//                                                   errores_eng = errores_eng + "Name too short<br/>";
//                                                   }
//
//												    if(!emaile(email1_2)){
//                                                     errores = errores + "Email no valido<br/>";
//                                                      errores_eng = errores_eng + "Invalid E-mail<br/>";
//                                                  }
//                                                 if(!ver_url(url1_2)&&url1_2!=''){
//                                                 errores = errores + "URL no valida<br/>";
//                                                  errores_eng = errores_eng + "Invalid URL<br/>";
//                                                 }
//                                                   if(comentario2.length==0){
//                                                   errores = errores + "Comentario obligatorio<br/>";
//                                                    errores_eng = errores_eng + "Must write a comment<br/>";
//                                                   }
//                                                  if(comentario2.length>250){
//                                                   errores = errores + "Comentario muy largo<br/>";
//                                                    errores_eng = errores_eng + "Comment too long<br/>";
//                                                    }
//                                                  if(comentario2=='Tu comentario'||comentario2=='Your comment'){
//                                                    errores = errores + "Comentario obligatorio<br/>";
//                                                     errores_eng = errores_eng + "Must write a comment<br/>";
//                                                    }
//
//
//                                                 var errores_al;
//
//                                                 var lang = document.getElementById('lang').value;
//
//                                                 if(lang=='_esp')
//                                                    errores_al = errores;
//                                                    else
//                                                    errores_al = errores_eng;
//
//                                                if(errores_al!='')
//                                                jAlert(errores_al);
//                                                else{
//                                                document.getElementById('miform').submit();
//                                                }
//
//												}
//                                             });







                 $(".balloon").mouseover(function(event) {
							
                                var tipper  = $(this).attr("title");

                               showToolTip(event,tipper);
							  
                               });


                $(".balloon").mouseout(function() {

                               hideToolTip()
                               });
    });


