var opacity = 0.85;
var toOpacity = 1;
var duration = 100;
function quita_espaciossugerencias(texto)
{
 var i;
 var texto_nuevo = "";
 for(i=0;i<=texto.length;i++)
 {
 if (texto.substring(i, i+1) != " ")
 {
 texto_nuevo = texto_nuevo+texto.substring(i, i+1);
 }
 }
 return texto_nuevo;
} 
function validasugerencia()
{
	
 var nombre =$('#nombre').get(0).value;
 $('#email').get(0).value=quita_espaciossugerencias($('#email').get(0).value) ;											   
 var email = $('#email').get(0).value;
 var comentarios = $('#comentarios').get(0).value;

 if (nombre != '')
 {
 if ((email != '') && (emailvalido()))
 {
 if (comentarios != '')
 {
 	return true;
	
 }
 else
 {
 alert('Por favor introduce tus comentarios');
 	$('#comentarios').focus();
	return false;
 }

 }
 else
 {
 alert ('Direcci�n de correo electr�nico no v�lida');
 	$('#email').focus();
	return false;
 }
 }
 else
 {
 alert ('Por favor introduce tu nombre');
  	$('#nombre').focus();
	return false;
  	
 }

}


function emailvalido()
{
 var email = $('#email').get(0).value;
 var pattern =/^[A-Za-z][A-Za-z0-9_.-]+[A-za-z]*@[A-Za-z0-9_-]+\.[A-Za-z0-9_.-]+[A-za-z]$/;
 flag = pattern.test(email);

 if(flag)
 {
 return true;
 }
 else
 {
 return false;
 }
} 

function ajax(stringData, connect, funcion){
	if (connect!=''){
	$.ajax({
                    url: connect,
                    data: stringData,
                    type: 'POST',
                    async: true,
        			beforeSend: function(objeto){					
			        },					
                    success: function(data){
                        funcion(data);
                    }
	});// fin de .ajax
	}else{
			//alert(stringData);
		}	
}
function set_zero(data){

}
function send_oficce(dat){
	//alert(dat);
	var send='op=chat&usr='+dat;
	ajax(send, 'services/base.php', set_zero);
}
$(document).ready(function(){					   						   
	$('#lngiros').live('click',function(event){	
		$("#photos").remove();
		
		document.getElementById('gallery').innerHTML='<div id="photos" class="galleryview">'+s+'</div>';
		$('#photos').galleryView({
            panel_width: 800,
            panel_height: 300,
            frame_width: 60,
            frame_height: 60,
			background_color:  'black'
        });
	});	
						
	$('#op').click(function(){		
		_back();
	});	
	$('#loader').css({
					top : Math.round( ($(window).height()/2) - ( $('#loader').height() ) )+'px',
					left: Math.round( ($(window).width()/2) - ( $('#loader').width()/2 ) )+'px'
	}).ajaxStart(function(){
					$('.overlay').fadeIn();
					$(this).fadeIn();
	}).ajaxComplete(function(){
					$(this).fadeOut();
					$('.overlay').fadeOut();
	});					
});

$(document).ready(function(){						   						   						   						   						   						   						   						   						   
    $(".float").fadeTo("slow", 0.5); 
    $(".float").hover(function(){
        $(this).fadeTo("slow", 1.0); 
    }, function(){
        $(this).fadeTo("slow", 0.5);
    });
});

function close_tick(data){
	alert(data);
	$('#nombre').get(0).value="";
	$('#empresa').get(0).value="";
	$('#email').get(0).value="";
	$('#telefonos').get(0).value="";
	$('#comentarios').get(0).value="";	
	$('#comment').hide("slow");
}

$('#send_coment').live('click',function(event){
	if(validasugerencia()){
		var send='nombre='+$('#nombre').get(0).value+'&email='+$('#email').get(0).value+'&emp='+$('#empresa').get(0).value+'&tel='+$('#telefonos').get(0).value+'&com='+$('#comentarios').get(0).value;
		ajax(send, 'save_coment.ws.php', close_tick);	
	}							   
});

$('#lcomment').live('click',function(event){
	$('#comment').toggle("slow");  	
});
function set_foro(data){
	$('#contenido').html(data);
}

$('#lforo').live('click',function(event){
		$('body').append("<div id='TB_overlay'></div>");								  
		var send='';
		ajax(send, 'foro/index.php', set_foro);						   
});
function set_temas(data){
	$('#cont_foro').html(data);
}
$('.ltitulos').live('click',function(event){
		var send='id='+this.id;
		ajax(send, 'foro/foro.php', set_temas);
});


$('#lforini').live('click',function(event){
		var send='';
		ajax(send, 'foro/index.php', set_foro);
});
//respuesta.php
function set_respuesta(data){
	$('#cont_foro').html(data);
}
$('#lforres').live('click',function(event){
	
		var send='';
		ajax(send, 'foro/respuesta.php', set_respuesta);
});

//foro/agregar.php
$('#enviamsg').live('click',function(event){	

	var send='autor='+$('#autor').get(0).value+'&titulo='+$('#titulo').get(0).value+'&mensaje='+$('#mensaje').get(0).value+'&identificador='+$('#identificador').get(0).value;
			
		ajax(send, 'foro/agregar.php', set_foro);
});

//href="respuesta.php?id=<?=$id?>&citar=1">
//lcontesta

$('.lcontesta').live('click',function(event){	
	var send=''			
	var send='id='+this.id+'&citar=1';
	ajax(send, 'foro/respuesta.php', set_respuesta);
});

function centro(data){
	$('#TB_overlay').remove();
	$('#contenido').html('');
}
$('#lforsalir').live('click',function(event){	

	var send=''
	var send='';
	ajax(send, 'foro/foro.php', centro);
});
function send_dat(){
alert('ok');	
}

function set_result(data){
	$('body').append("<div id='TB_overlay'></div>");
	$('#contenido').html(data);
}
$('#ldistris').live('click',function(event){
												 
		var send='';
		ajax(send, 'distributors/format.php', set_result);						   
});

$('.clear').live('click',function(event){	
									  
	centro('');
});



function get_usr(){
		if ((document.getElementById('usr').value)!=''){			
			try {
				document.getElementById('chat').className="visto";	
				document.getElementById('p1').value='chat/chat.swf?usuario='+document.getElementById('usr').value+'&conectados=0';
				document.getElementById('p2').src='chat/chat.swf?usuario='+document.getElementById('usr').value+'&conectados=0';		   	
				send_oficce(document.getElementById('usr').value);
			}catch(err){
				   //alert("Error detectado: " + err.description)
				   var dd=document.getElementById('chat');
				   dd.innerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="300" height="300" ><param name="movie" value="chat/chat.swf?usuario='+document.getElementById('usr').value+'&conectados=0"  id="p1" /><embed  id="p2" src="chat/chat.swf?usuario='+document.getElementById('usr').value+'&conectados=0" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="310" height="300"></embed></object>';
			}	
			
			
		}
		else{
				document.getElementById('chat').className="oculto";
				alert('Introduzca su nombre por favor');
				var a=document.getElementById('usr');
				a.focus();
			}
}

$('#lchat').live('click',function(event){
		var send='';
		ajax(send, 'services/chat.php', set_result);						   
});

$('#lquien').live('click',function(event){
          
            	var send='op=0';
            ajax(send, 'videos/videos.php', set_result);
           
           
            
});


function set_vid(s){
	$('#contenido').append(s);
	//alert('ya');
}
function delay(){	
//alert('ok');
$('#markvid').fadeIn();
$('#loader').fadeOut();
}

$('.vid').live('click',function(event){
	var dir=this.rel;
	var pagesize = TB_getPageSize();	
	TB_WIDTH = pagesize[0] - 90;
	TB_HEIGHT=pagesize[1] - 50;
		
	$('body').append("<div id='C_overlay'></div><div id='TB_window'></div>");	
	$(window).scroll(TB_position);
	TB_overlaySize();	
	var s='<div class="voverlay" style="z-index: 10100;" id="markvid"><div class="close" style="z-index: 10101;"></div><div id="vcontainer"><div id="video_overlay"><embed height="360" width="480" style="display: block;" src="'+dir+'" bgcolor="#ffffff" allowfullscreen="true" autostart="1" id="emovie"></div><div style="position: absolute; right: 38px; top: 38px; padding: 0pt;"></div></div></div>';
	$('#TB_window').append(s);
	TB_position();			
	$("#TB_window").css({display:"block"});
	$("#markvid").css({display:"block"})		
	$(window).resize(TB_position);

});

$('.vidf').live('click',function(event){
	
	var dir=this.rel;
	var pagesize = TB_getPageSize();	
	TB_WIDTH = pagesize[0] - 50;
	
	TB_HEIGHT=pagesize[1] + 100;
		
	$('body').append("<div id='C_overlay'></div><div id='TB_window'></div>");	
	$(window).scroll(TB_position);
	TB_overlaySize();	
	var s='<div class="voverlay" id="markvid"><div class="close" style="z-index: 10000;"></div><div id="vcontainer"><div id="video_overlay"><embed height="360" width="580" style="display: block;" src="'+dir+'" bgcolor="#ffffff" allowfullscreen="true" autostart="1" id="emovie"></div><div style="position: absolute; right: 38px; top: 38px; padding: 0pt;"></div></div></div>';	
	$('#TB_window').append(s);
	TB_position();			
	$("#TB_window").css({display:"block"});
	$("#markvid").css({display:"block"})		
	$(window).resize(TB_position);

});

//
$('.close').live('click',function(event){

	$('#TB_window,#C_overlay,#TB_HideSelect').remove();
	
});

$('#lcur').live('click',function(event){          
            	var send='';
            ajax(send, 'cursos/cursos.php', set_result);                                 
});

$('#des_fase1').live('click',function(){          
	var send='op=1';
	//ajax(send, 'inc_des.ws.php', centro); 						
	TB_remove;	
	
	//var dir='download.php?TB_iframe=true&height=300&width=450&op=sopor';
	var dir='registro.php?TB_iframe=true&height=480&width=550&op=sopor';
	TB_show('Descargas', dir,null);
});
$('#boton_down').live('click',function(){          
	
	//var dir='services/download.php?TB_iframe=true&height=300&width=450&op=sopor';
	var dir='services/registro.php?TB_iframe=true&height=480&width=550&op=sopor';
	TB_show('Descargas', dir,null);
});

//<a id="lcursos"   href="cursos/Cursos.pdf" target="_blank" title="Programaci�n de Cursos">
//lcursos
$('#lcursos').live('mouseover',function(event){          
	$('#desplega').html('');
	//$('#desplega').append('<div class="fila"><div class="sub"><a id="linscur"  href="#" title="Clic para inscribirte">Inscripcion</a></div>  </div><div class="fila"><div class="sub"><a href="cursos/Cursos.pdf" target="_blank" title="Programacion de Cursos">Calendario de cursos</a></div></div>');

	$('#desplega').append('<div class="fila"><div class="sub"><a href="http://www.visorus.com/tv?tab=3&vid=installpunvta.flv" target="_blank" title="Cursos en linea">video cursos</a></div></div>');		
	$("#desplega").css({display:"block"});
	var x=$('#lcursos').position().left;
	//alert(x);
	$("#desplega").css("left", x)
//	alert($('#lcursos').position().left);
});




$('#contenido,#lchat,#lgiros,#tblcentro').live('mouseover',function(event){  				   
//	alert('ok');
      $("#desplega").css({display:"none"})
	  
});

$("#curso").change(function(){
        //si estas trabajando con php recorda cambiar .asp por .php
        $.post("carga_select2.asp",{ id:$(this).val() },function(data){$("#select2").html(data);})
});
function curso(){
	 $.post("services/get_cursos.php",{ op:'c'},function(data){$("#scursos").html(data);get_curfecha();})
}



$('#linscur').live('click',function(event){          
	var send='op=1';
	ajax(send, 'cursos/registro.php', set_result); 
});

function get_curfecha(){
	$('#sfecha').html('<option selected>Cargando</option>');           
	var id= $('#scursos').val();
	var toLoad= 'services/get_cursos.php?op=f&cr='+ id;	
	$.post(toLoad,function (responseText){$('#sfecha').html(responseText);get_curhora();});
}
function get_curhora(){
	$('#shorario').html('<option selected>Cargando</option>');           
	var idc= $('#scursos').val();
	var idf= $('#sfecha').val();
	var toLoad= 'services/get_cursos.php?op=h&idc='+ idc+'&idf='+idf;	
	$.post(toLoad,function (responseText){$('#shorario').html(responseText);
		$('#hcurso').val($("#scursos option:selected").text());
		$('#hfecha').val($("#sfecha option:selected").text());
		$('#hhora').val($("#shorario option:selected").text());
	});
	
	

}
$("#scursos").change(function(){	
	$('#sfecha').html('');
	$('#shorario').html('');							  							  							  
	get_curfecha();
	
	
	
});
$("#sfecha").change(function(){
	$('#shorario').html('');							 
	get_curhora();
});
$("#shorario").change(function(){
	$('#hhora').val($("#shorario option:selected").text());
});

$('.down_fase1').live('click',function(event){          
            	
				//alert(this.href);
					var send='op=1&link='+this.href;
				
				ajax(send, 'inc_des.ws.php', centro);
	//$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').remove();});
	//$("#TB_load").remove();

	//alert(this.href);
	
});

$('#opdown').live('click',function(event){          
        $("#down_mod").toggle("slow");
    	
});

$('#facelec').live('click',function(event){
	 var txt='   <h1> <img src="http://www.visorus.com.mx/CSS/images/Entourage.png" width="45">Facturación electrónica (CFD) con VisorUS</h1><ul type="circle">    <li class="cfd" id="boxcfd"><img src="CSS/images/docs.png" width="100px">Proceso de ventas/capacitación de la facturación electrónica (CFD).</li>    <li class="cfd"  id="logincfd"><img src="CSS/images/Keychain.png" width="80px" >Ingresar a carga de sellos y firmas digitales.</li></ul><div class="next" id="2" ></div>';
	
	$('#dson').html('<div style="z-index: 10101;" class="exit"></div>'+txt);
	

	$("#dC_overlay").css({display:"block"});
	
	$("#dson").css({top : Math.round( ($(window).height()/2) - ( $('#dson').height()/2 ) )+'px', left: Math.round( ($(window).width()/2) - ($('#dson').width()/2 ) )+'px'});
	
	$("#dson").css({display:"block"});
									
        //$("#down_mod").toggle("slow");
    	
});

$('.exit,#dC_overlay').live('click',function(event){
	$("#dson").css({display:"none"});
	$("#dC_overlay").css({display:"none"});
});


$('#boxcfd').live('click',function(event){
						   
	//document.location=("http://www.visorus.com/box.php");
	var dir='box.php?TB_iframe=true&height=480&width=810';
	TB_show('  ', dir,null);

//	window.open('box.php','title','toolbar=yes,location=yes,status=yes');


});
$('#logincfd').live('click',function(event){						   
	document.location=("facvisor/index.php");
	//var alto=TB_getPageSize()[1];
	//var ancho=TB_getPageSize()[0];
	//var dir='facvisor/index.php?TB_iframe=true&height='+(alto-30)+'&width='+(ancho-60);
	//TB_show('v', dir,null);
//	window.open('box.php','title','toolbar=yes,location=yes,status=yes');
});