 // menu  efecto		
/* $(function() {
            $("#menuslide").lavaLamp({
                fx: "backout", 
                speed: 1000,
                click: function(event, menuItem) {
              	 return true;
                }
            });
        });
 */
		jQuery(function() {
        jQuery('#menuslide').lavaLamp();
    });
// baner efecto		
/*		jQuery(document).ready(function() {		
		jQuery('.portaimg').cycle({
		fx:		'fade',
		speed:	2500
		});	
		});
*/

// JavaScript Document
	jQuery(document).ready(function() {
			jQuery('a[href="#FormDer"]').click(function(event){
					event.preventDefault();
					jQuery('.iform1 input[name="name"]').removeClass("idleField").addClass("focusField");
					jQuery('.iform1 input[name="name"]').focus();
					});
			
			
			jQuery('.iform1 input[type="text"]').addClass("idleField");
       		jQuery('.iform1 input[type="text"]').focus(function() {

       			jQuery(this).removeClass("idleField").addClass("focusField");

//    		    if (this.value == this.defaultValue){ 
				if (this.value == ''){ 
    		    	this.value = '';

				}

//				if(this.value != this.defaultValue){
				if(this.value != ''){
	    			this.select();

	    		}

    		});

    		jQuery('.iform1 input[type="text"]').blur(function() {

    			jQuery(this).removeClass("focusField").addClass("idleField");

    		    if (jQuery.trim(this.value) == ''){

			    	this.value = (this.defaultValue ? this.defaultValue : '');

				}

    		});
			    		});
	
		jQuery(document).ready(function() {
			jQuery('.iform1 textarea').addClass("idleField_text");
       		jQuery('.iform1 textarea').focus(function() {

       			jQuery(this).removeClass("idleField_text").addClass("focusField_text");

    		    if (this.value == this.defaultValue){ 

    		    	this.value = '';

				}

				if(this.value != this.defaultValue){

	    			this.select();

	    		}

    		});

    		jQuery('.iform1 textarea').blur(function() {

    			jQuery(this).removeClass("focusField_text").addClass("idleField_text");

    		    if (jQuery.trim(this.value) == ''){

			    	this.value = (this.defaultValue ? this.defaultValue : '');

				}

    		});
			    		});
			
			
			//--------------------------------------------------------------------
			//--------------------------------------------------------------------
			//--------------------------------------------------------------------
		
function validacorreo(){

if(document.iform.correo.value.indexOf('@', 0) == -1){

	  return false;

  }

  return true;

}

function valida_envia(){

//valida el nombre

//	alert(document.iform.nombre.value);

	if(document.iform.nombre.value == "NOMBRES"){

	alert("tiene que escribir su nombre")

	document.iform.nombre.focus()

	return false;

	}

	if(document.iform.apellido.value == "APELLIDOS"){

	alert("tiene que escribir su Apellido")

	document.iform.apellido.focus()

	return false;

	}

	if(validacorreo(document.iform.correo.value) == false){

	alert("escribe tu correo")

	document.iform.correo.focus()

	return false;

	}

	if(document.iform.telefono.value == "TELEFONO CELULAR"){

	alert("tiene que escribir su Telefono")

	document.iform.telefono.focus()

	return false;

	}

	if(document.iform.comentario.value == "CUAL ES SU PREGUNTA"){

	alert("tiene que escribir su Comentario")

	document.iform.comentario.focus()

	return false;

	}

	if(document.iform.empresa.value == "EMPRESA"){

		document.iform.empresa.value = "";

	}

	if(document.iform.website.value == "WEBSITE"){

		document.iform.website.value = "";

	}

	if(document.iform.palabrasclaves.value == "PALABRAS CLAVES"){

		document.iform.palabrasclaves.value = "";

	}



}

function trim(s){

	s = s.replace(/^\s+|\s+$/gi, ''); //sacar espacios blanco principio y final

	return s;

}

function delSpacio(s){

	s = s.replace(/\s+/gi, ''); //sacar espacios repetidos dejando solo uno

return s;

}

function isNombre(text, maxText){

	//var text = trim(text);

	if( !maxText ){maxText = 45}

	if( text.length > maxText ){

		return false

	}else if(!isNaN(text)){

		return false;
	}else if(text.search(/[<\/\\>?¿\[\]!¡{}()%$&|=*+."",;:]/) > -1 ){
//	}else if(text.search(/[<\/\\>?¿!¡{}()%$&|=."",;:]/) > -1 ){

		return false;

	}else{

		return text

	}

}

function isApellido(text, maxText){

	var text = trim(text);

	if( !maxText ){maxText = 45}

	if( text.length > maxText ){

		return false

	}else if(!isNaN(text)){

		return false;

	}else if(text.search(/[<\/\\>?¿!¡{}()%$&|=."",;:]/) > -1 ){

		return false;

	}else{

		return text

	}

}

function isTelefono(text, maxText){
	var text = trim(text);

	if( !maxText ){maxText = 15}

	if( text.length > maxText ){

		return false

	}else if(isNaN(text)){

		return false;

	}else{

		return text

	}

}

function isEmail(text, maxText){

	var text = trim(text);

	if( !maxText ){maxText = 50}

	if( text.length > maxText ){

		return false;
	}else if(text.search(/[<\/\\>?¿\[\]!¡{}()%$&|="",;:]/) > -1 ){
//	}else if(text.search(/[<\/\\>?¿!¡{}()%$&|="",;:]/) > -1 ){

		return false;

	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(text)){

		return false;

	}else{

		return text

	}

}

function isMensaje(text, maxText){

	var text = delSpacio(trim(text));

	if( !maxText ){maxText = 250}

	if( text.length > maxText ){

		return false
	}else if(text.search(/[<\\>\[\]\{\}\\=\/\"\;'&|]/) > -1 ){
//	}else if(text.search(/[<\\>&|]/) > -1 ){

		return false;

	}else{

		return text;

	}

}



function validarForm(e){

	var form = e;



	if(!isNombre(form.name.value) || form.name.value == "NOMBRES"){

		alert("Nombre invalido")

		form.name.focus()

		return false;

	}
/*
	if(!isApellido(form.apellidos.value) || form.apellidos.value == "APELLIDOS"){

		alert("Apellido invalido")

		form.apellidos.focus()

		return false;

	}	*/

	if(!isEmail(form.email.value) || form.email.value == "EMAIL"){

		alert("Email invalido")

		form.email.focus()

		return false;

	}	

	if(!isTelefono(form.telefono.value) || form.telefono.value == "TELEFONO CELULAR"){

		alert("Telefono invalido")

		form.telefono.focus()

		return false;

	}		

	if(!isMensaje(form.mensaje.value) || form.mensaje.value == "CUAL ES SU PREGUNTA"){

		alert("Pregunta invalida")

		form.mensaje.focus()

		return false;

	}	

	if(form.empresa.value == "EMPRESA"){

		form.empresa.value = "";

	}

	if(form.website.value == "WEBSITE"){

		form.website.value = "";

	}

	if(form.keywords.value == "PALABRAS CLAVES"){
		form.keywords.value = "";
	}

	

}

/********************** tabs *********************/
function showElement(strElementID) 
{
	objElement = document.getElementById(strElementID);
	if (objElement != null) {	
		objElement.style.visibility = "visible";
		objElement.style.display = "block";
	}
}

function hideElement(strElementID) 
{
	objElement = document.getElementById(strElementID);
	
	if (objElement != null) {	
		objElement.style.visibility = "hidden";
		objElement.style.display = "none";
	}
}

function showTab(strElementID)
{
	//hide all
	hideAllTabs();

	// show 1
	showElement(strElementID) 
	
	// change tab state
	setClassName(strElementID + "-tab", "active")
}


function hideAllTabs(strElementID)
{
	//reset tab content
	hideElement("fragment-1");
	hideElement("fragment-2");
	hideElement("fragment-3");
	/*hideElement("video");
	hideElement("press");
	hideElement("download");*/
	
	//reset tab state
	setClassName("fragment-1-tab", "")
	setClassName("fragment-2-tab", "")
	setClassName("fragment-3-tab", "")
	/*setClassName("video-tab", "")
	setClassName("press-tab", "")
	setClassName("download-tab", "")*/
}

function setClassName(strElementID, strClassName)
{
	objElement = document.getElementById(strElementID)
	if (objElement != null) {
		objElement.className = strClassName;
	}
}
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 

(function socializa( $ ) {
  $(document).ready(function() { 
    var url = window.location.href;
    var host =  window.location.hostname;
    var title = $('title').text();
    title = escape(title); //clean up unusual characters
 
    var twit = 'http://twitter.com/home?status='+title+'%20'+url;
    var facebook = 'http://www.facebook.com/sharer.php?u='+url
	//var digg = 'http://digg.com/submit?phase=2&url='+url+'&amp;title='+title;
	var linkedin = 'https://www.linkedin.com/cws/share?url='+url+'&amp;title='+title;
	var googleplus = 'https://m.google.com/app/plus/x/?v=compose&content='+url;
	//var googleplus = 'https://m.google.com/app/plus/x/?v=compose&content='+url+'&amp;title='+title;
    var tuenti = 'http://www.tuenti.com/share?url='+url+'&amp;title='+title;
    /*var stumbleupon = 'http://stumbleupon.com/submit?url='+url+'&amp;title='+title;
    var buzz = 'http://www.google.com/reader/link?url='+url+'&amp;title='+title+'&amp;srcURL='+host;
    var delicious  = 'http://del.icio.us/post?url='+url+'&amp;title='+title;*/
 
    var tbar = '<div id="socializethis"><span>Compartir<br /><a href="#min" id="minimize" title="Minimizar"> <img src="img/minimize.png" /> </a></span><div id="sicons">';
    tbar += '<a href="#" onclick="PopupCenter(\''+twit+'\',\''+title+'\',400,400)" id="twitter" title="Compartir en twitter"><img src="img/twitter.png" alt="Share on Google+" width="32" height="32" /></a>';
    tbar += '<a href="#" onclick="PopupCenter(\''+facebook+'\',\''+title+'\',400,400)" id="facebook" title="Compartir en Facebook"><img src="img/facebook.png"  alt="Compartir en Facebook" width="32" height="32" /></a>';
    tbar += '<a href="#" onclick="PopupCenter(\''+linkedin+'\',\''+title+'\',400,400)" id="linkedin" title="Compartir en linkedin"><img src="img/linkedin.png"  alt="Compartir en Digg" width="32" height="32" /></a>';
    tbar += '<a href="#" onclick="PopupCenter(\''+googleplus+'\',\''+title+'\',400,400)" id="googleplus" title="Compartir en googleplus"><img src="img/googleplus.png"  alt="Compartir en Digg" width="32" height="32" /></a>';
    tbar += '<a href="#" onclick="PopupCenter(\''+tuenti+'\',\''+title+'\',400,400)" id="tuenti" title="Compartir en tuenti"><img src="img/tuenti.png"  alt="Compartir en Digg" width="32" height="32" /></a>';
    tbar += '</div></div>';
 
    // Add the share tool bar.
    $('body').append(tbar);
    $('#socializethis').css({height:'35px', width:'280px', opacity: 1}, 300); 
	$('#socializethis img').css('display', 'inline');

    function minshare(){
      $('#socializethis').animate({height:'15px', width: '55px', opacity: .7}, 300); 
      $('#socializethis img').css('display', 'none');
      return false;
    }  
  });
})(jQuery);
