function homeHeader() {
	beforehtml = '<div id=\"bannercabecalho_nav\">';
	$('#bannercabecalho ul').before(beforehtml).cycle({ 
    fx:     'scrollHorz', 
    speed:  800,
    timeout: 15000,
    pager:  '#bannercabecalho_nav' 
	});
}


function featProject(pid) {
	$('#portfolio_featured li').hide();
	$('#portfolio_featured_nav li').removeClass('active');
	$('.portfeat_nav'+pid).addClass('active');
	$('#portfeat'+pid).fadeIn(200);

}

function portFilter(wtid,pg,leavehash) {
	if (typeof leavehash == 'undefined') location.hash = '';	
	portheight = $('#portfolio').height() + 27;
	$('#portfolio').addClass('loading').html('').css('height',portheight);
	$.ajax({
		url: "..\\inc\\modules\\portfolio\\portfolio_ajax.php.html",
		global: false,
		type: "POST",
		data: "wtid=" + wtid + "&pg=" + pg,
		dataType: "html",
		success: function(msg) {
			$('#portfolio').css("height", 'auto').removeClass('loading').html(msg);
		}
	});

}

function portSelect(pid,testimonial) {
	$('#portfolio_overlay_cover, #portfolio_overlay').removeClass('notest').show();
	if (testimonial == 'false') $('#portfolio_overlay').addClass('notest');
	$('#portfolio_overlay').html('<div class="loading"></div>').show();
	
	$.ajax({
		url: "../inc/ajax/ajax_item.php",
		global: false,
		type: "POST",
		dataType: "html",
		data: "pid=" + pid,
		success: function(result){
			$('#portfolio_overlay').html(result);
		}
	});
}

function portClose() {
	$('#portfolio_overlay_cover').hide();
	$('#portfolio_overlay').html('').removeClass('notest').hide();
}

function ajaxPost(formid, errmsg_id, success_id, success_file, errorcheck_file) {
	formdata = $('#'+formid).serialize();
	if (typeof errorcheck_file != 'undefined') formdata += "&errorcheck_file=" + errorcheck_file;
	$('#botaoFormulario').hide();
	$('#enviandoFormulario').show();
	$.ajax({
		url: "../inc/ajax/post_form.php",
		global: false,
		type: "POST",
		dataType: "html",
		data: formdata,
		success: function(result) {
			$('#'+success_id).html(result);
			$('#enviandoFormulario').hide();
			$('#'+success_id).show();
			$('#botaoFormulario').hide();
			window.setTimeout(function(){
                   $('#'+success_id).hide();
				   $('#enviandoFormulario').hide();
				   $('#botaoFormulario').show();
				   $('#'+formid + ' input:text').val('');
				   $('#'+formid + ' textarea').val('');
				   $('#'+formid + ' input').attr('checked',false);
            },3000);
		}
	});
	
}

function postNewsletter() {
	formdata = $('#rodape_social_form').serialize();
	$.ajax({
		url: '../inc/ajax/newsletter.php',
		global: false,
		type: "POST",
		dataType: "html",
		data: formdata,
		success: function(result) {
			$('#news_response').html(result);
		}
	});	
}

$(document).ready(function() {
	// All http links / rel="external" links open in a new window
	$('a[rel*=external]').click(function() {
		window.open(this.href);
		return false;
	});
		
	$(document).pngFix(); 
	
	
	$('#rodape_social_email').click(function() {
		if ($(this).val() == 'Digite seu email...') $(this).val('');
	}).blur(function() {
		if ($(this).val() == '') $(this).val('Digite seu email...');
	});

	$('#rodape_social_form').submit(function() {
		postNewsletter(); return false;
	});
	$('#rodape_social_ok').click(function() {
		postNewsletter(); return false;
	});
});
