

// Adds a class 'js_on' to the <html> tag if JavaScript is enabled,
// also helps remove flickering...
document.documentElement.className += 'js_on';


// Add Cufon fonts
Cufon.set('fontFamily', 'eurofurence');
Cufon.replace('#slogan');
Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3:not(.portfolioThumbCaption h3)');
Cufon.replace('h4:not(#widget_latest_posts h4)');
Cufon.replace('h5');
Cufon.replace('h6');
Cufon.replace('#categoryLinks ul li');

// jQuery Cycle Plugin Slider
jQuery(document).ready(function($){
	$('.slideshow').cycle({
	    fx:			'fade, curtainY, turnDown, wipe, fade, scrollVert, growY, scrollDown',
	    pause:		1,
	    randomizeEffects:	false,
	    sync:		true,
	    speedIn:		1000,
	    speedOut:		500,
	    timeout:		5000,
	    delay:		-2000
	});
});


/**
 * CoolInput Plugin
 *
 * @version 1.5 (10/09/2009)
 * @requires jQuery v1.2.6+
 * @author Alex Weber <alexweber.com.br>
 * @author Evan Winslow <ewinslow@cs.stanford.edu> (v1.5)
 * @copyright Copyright (c) 2008-2009, Alex Weber
 * @see http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
 *
 * Distributed under the terms of the GNU General Public License
 * http://www.gnu.org/licenses/gpl-3.0.html
 */
jQuery(document).ready(function($){
    $.fn.coolinput=function(b){
	var c={
	    hint:null,
	    source:"value",
	    blurClass:"blur",
	    iconClass:false,
	    clearOnSubmit:true,
	    clearOnFocus:true,
	    persistent:true
	};if(b&&typeof b=="object")
	    $.extend(c,b);else
	    c.hint=b;return this.each(function(){
	    var d=$(this);var e=c.hint||d.attr(c.source);var f=c.blurClass;function g(){
		if(d.val()=="")
		    d.val(e).addClass(f)
		    }
	    function h(){
		if(d.val()==e&&d.hasClass(f))
		    d.val("").removeClass(f)
		    }
	    if(e){
		if(c.persistent)
		    d.blur(g);if(c.clearOnFocus)
		    d.focus(h);if(c.clearOnSubmit)
		    d.parents("form:first").submit(h);if(c.iconClass)
		    d.addClass(c.iconClass);g()
		}
	    })
	}
    });
jQuery(document).ready(function($){
	// first input box is a search box, notice passing of a custom class and an icon to the coolInput function
	$('#search_field').coolinput({
		blurClass: 'inputbox',
		iconClass: 'search_icon'
	});
});


// initialise Superfish Menu
jQuery(document).ready(function($){
    $("ul.sf-menu").supersubs({
	minWidth:    12,   // minimum width of sub-menus in em units
	maxWidth:    27,   // maximum width of sub-menus in em units
	extraWidth:  1     // extra width can ensure lines don't sometimes turn over
			   // due to slight rounding differences and font-family
    }).superfish({	   // call supersubs first, then superfish, so that subs are not display:none when measuring. Call before initialising containing tabs for same reason.
	delay:       500,  // the delay in milliseconds that the mouse can remain outside a submenu without it closing
	autoArrows:  false,
	dropShadows: false
    });
});


// ThumbCaption script
jQuery(document).ready(function($){
    $(".portfolioImgThumb").hover(function(){
	    var info=$(this).find(".hover-opacity");
	    info.stop().animate({opacity:0.7},300);
    },
    function(){
	    var info=$(this).find(".hover-opacity");
	    info.stop().animate({opacity:1},600);
    });
});



// jQuery Validate
jQuery(document).ready(function($){
    $("#contato_form").validate({
	rules: {
		nome: {
			required: true,
			minlength: 2
		},
		email: {
			required: true,
			email: true
		},
		msg: { required: true }
	},
	messages: {
		nome: {
			required: "<span style='color:red'>Por favor preencha o nome</span>",
			minlength: "<br /><span style='color:red'>Deve conter no mínimo 2 caracteres</span>"
		},
		email: "<span style='color:red'>Por favor digite um e-mail valido</span>",
		msg: "<br /><span style='color:red'>Por favor a mensagem é requerida</span>"
	}
    });
});

jQuery(function($){
   $("#contato_cel").mask("(99) 9999-9999");
   $("#contato_res").mask("(99) 9999-9999");
});

function validaFrmComentario(form){
	
	$("#resp").show();
	if(form.nome.value==""){
		$("#resp").html("Por favor, preencha o campo NOME!");
		form.nome.focus();
		return false;
	}
	if(form.email.value==""){
		$("#resp").html( "Por favor, preencha o campo EMAIL!");
		form.email.focus();
		return false;
	}else{
		if(!validaEmail(form.email.value)){
			$("#resp").html("Por favor, informe um EMAIL V&Aacute;LIDO!");
			form.email.focus();
			return false;
		}
	}	
	if(form.comentario.value==""){
		$("#resp").html("Por favor, preencha o campo MENSAGEM!");
		form.comentario.focus();
		return false;
	}

	$("#resp").load('ctrlImplementa.php?'+$("#frmComentario").formSerialize());
	return false;
}

function validaEmail(email){
	ER = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]{2,64}(\.[a-z0-9-]{2,64})*\.[a-z]{2,4}$");
	if (ER.test(email)){
		return true;
	}else{
		return false;
	}
}
function cadNews(email){
	if(email=="Digite seu e-mail" || email==""){
		alert("Informe seu e-mail");
		//return false;
	}else{
		if(!validaEmail(email)){
			alert("E-mail invalido!");
			//return false;
		}else{
			$("#iframecontato").load("ctrlImplementa.php?acao=addNews&email="+email);
		}
	}
}

