$(document).ready(function(){
	$(".text-normal a").click(function(){
		var href	= $(this).attr("href");
		if(href.lastIndexOf(".flv") != -1){
			var link	= "flashplayer_2.php?f=" + href + "&iframe=true&width=518&height=400";
			$.prettyPhoto.open(link, '', '');
			return false;
		}
	});
	
    
    
    $("#subscribe").click(function(){
        $("#div-subscribe-result").html("");
        $("#dialog").dialog({
		   	    resizable: false,
    			height:400,
		    	modal: true,
    			buttons: {
    				'Subscribe': function() {
			             $("#ajax-loader").show();
                         $("#formulario_subscribe").hide();
                         var parametros = $("#formulario-subscribe-letter").serialize() + "&ajax=1";
                         $.ajax({         
                             dataType: "json",
                             cache:false,
                             data:parametros,
                             type:"post",
                             url:"ajax/subscribe-news.php",
                             success:function(data){
                                 if(data.error==true) {
                                     $("#ajax-loader").hide();
                                     $("#formulario_subscribe").show();
                                     $("#div-subscribe-result").html(data.msg);
                                 }else if(data.error==false){ 
                                     $("#dialog").dialog('close');
                                     $("#ajax-loader").hide();
                                     $("#formulario_subscribe").show();
                                 } else {
                                     $("#ajax-loader").hide();
                                     $("#formulario_subscribe").show();
                                     $("#div-subscribe-result").html("Unknow Error");
                                 }
                    	     }
                    	 });
    				},
    				Cancel: function() {
    					$(this).dialog('close');
    				}
    			}
	   });
       
       $("#dialog").dialog("open");
    })
    
	$("a.prettyModal").prettyPhoto();
	
	$("a[rel^='prettyPhoto']").livequery(function(){
		$(this).prettyPhoto();
	});
	
	$('#content-pics').cycle({
		fx			: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout		: 8000,
		speed		: 2000
	});
	
	$(".content-client-stories").hover(
		function () {
			$(this).addClass("content-client-stories-hover");
			$(".content-client-stories-description .content-description .title", this).css("text-decoration", "underline");
		}, 
		function () {
			$(this).removeClass("content-client-stories-hover");
			$(".content-client-stories-description .content-description .title", this).css("text-decoration", "none");
		}
	);
    
    
    $(".content-client-stories").click(function(){
        location.href   = $(this).attr("href");
    });
    
    
	
	
	
	$('#form_subscribe').ajaxForm({
		beforeSubmit: function(){
			$("#div-subscribe-result").html("");
			$("#ajax-loader").css("display", "block");
		},		
        success		: function(data){
			//alert(data); return;
			$("input[name='email_subscribe']").attr("rel", "E-mail address ...");
			$("input[name='email_subscribe']").val("");
			$("input[name='email_subscribe']").blur();
			$("#ajax-loader").css("display", "none");
			$("#div-subscribe-result").html(data);
			mensajeSubscribe($("#div-subscribe-result"));
		}
	});
	
	$('.autoclear').clearField({
		blurClass	: 'textbox-subscribe-default'
	});
	
	
	altoBody();
	
	//$(".menu-vertical-item-child").not(".menu-vertical-item-child:last").css("border-bottom", "1px solid #CBCAC5");
	$("ul.menu-vertical li").not("li.menu-vertical-item-parent").css("border-top", "1px solid #CBCAC5");
	
	$("input:text").bind("keypress", function(e) {
		if (e.keyCode == 13) {
			return false;
		}
	});
	

});


function mensajeSubscribe(obj){
	obj.children(".div-subscribe-msg").stopTime();
	obj.children(".div-subscribe-msg").fadeIn("slow", function(){
		if(!$.support.opacity)
			$(this).get(0).style.removeAttribute('filter');
			
		obj.children(".div-subscribe-msg").oneTime(2000, function() {
			$(this).fadeOut("normal");
		});
	});	
}


function altoBody(){
	if($(".div-subscribe-other").length > 0){
		$(".div-subscribe-other").appendTo("#the-sheet-bottom");		
	}
	
	if($(".div-event").length > 0){
		$("#the-sheet-bottom").css("padding-bottom", "50px");	
	}
}


/* Aplicando tipografia */
var monotype = { src: 'flashplayer/rockwell.swf' };
sIFR.activate(monotype);
sIFR.replace({ src: 'flashplayer/rockwell.swf', 
			   selector: "h2", 
			   css: [".sIFR-root {color: #82796A;font-size: 25px;}"],
			   forceSingleLine  : true, 
			   wmode : 'transparent',
			   tuneHeight : -4
			});


sIFR.replace({ src: 'flashplayer/rockwell.swf', 
			   selector: "h3", 
			   css: [".sIFR-root {color: #82796A;font-size: 18px;}"],
			   forceSingleLine  : true, 
			   wmode : 'transparent'
			   
			});










