
					
$(document).ready(function() {
						   
	$(function() {
        $("div#controller").jFlow({
            width: "1002px",
            height: "370px",
			controller: ".jFlowControl", // must be class, use . sign
			slideWrapper : "#jFlowSlider", // must be id, use # sign
			slides: "#slides",  // the div where all your sliding divs are nested in
			duration: 400,  // time in miliseconds to transition one slide
			prev: ".jFlowPrev", // must be class, use . sign
			next: ".jFlowNext", // must be class, use . sign
			auto: true	
        });
    });
	
	
	$(function() {
        $("div#side-controller").jFlow({
            width: "334px",
            height: "370px",
			controller: ".jFlowControl", // must be class, use . sign
			slideWrapper : "#side-slideshow", // must be id, use # sign
			slides: "#side-slides",  // the div where all your sliding divs are nested in
			duration: 400,  // time in miliseconds to transition one slide
			prev: ".jFlowPrev", // must be class, use . sign
			next: ".jFlowNext", // must be class, use . sign
			auto: true	
        });
    });
	
	
	if ($("#tweet-container").length > 0) getTwitters();
	
	$('#labelLoginBox').click(function() {
		$('#divLoginBox').toggle();
		$('#divForgotPassBox').hide();
	});
	
	$('#labelForgotPassBox').click(function() {
		$('#divForgotPassBox').toggle();
		$('#divLoginBox').hide();
	});
	
	
	$('#divLoginBox').hide();
	$('#divForgotPassBox').hide();
	
	
	doInitFormNewsLetter();
	
	$("#tabs").tabs();

	
	$('a.lightbox').lightBox({
		fixedNavigation:true,
		imageBtnClose: 'img/btn-fechar-lightbox.png',
		imageLoading: 'img/loader.gif'
	});
	
	//$('a[@rel*=lightbox]').lightBox();
	
	
	$('.qt-field').change(function() {
		//if ($(this).val() == "Digite seu e-mail") {
		//	$(this).val("");
		//}
		$elid = ($(this).attr('id')).substr(3);
		$val = $(this).val();
		//get the id
		$idtochange = $("#qt-id-" + $elid).val();
	
		//alert ($val);
		$.ajax({
			type: "POST",
			url: "inc/changeShoppingCart.php",
			data: "pk=" + $idtochange + "&qt=" + $val,
			success: function(msg){
				alert(msg);
			}
		});
		
		
	});
	
	$('#qt-field').blur(function() {
		//if ($(this).val() == "") {
			//$(this).val("Digite seu e-mail");
		//}
	});
	
	$('a[rel*=facebox]').facebox({
        loadingImage : '../js/facebox/loading.gif',
       closeImage   : '../js/facebox/closelabel.png'
     })
	
	
	// Footer newsletter
	$("#email").focus(function () {
		if ($("#email").val() == "Digite seu e-mail") {
			$("#email").val("");
		}
		//$(this).next("span").css('display','inline').fadeOut(1000);
	});

	$("#email").blur(function () {
		if ($("#email").val() == "") {
			$("#email").val("Digite seu e-mail");
		}
		//$(this).next("span").css('display','inline').fadeOut(1000);
	});



	
});



function doInitFormNewsLetter() {

	var options = { 
		target:        '.feedback-footer',
		beforeSubmit:  showRequest,
		success:       showResponse
	}; 
 
	function showRequest(formData, jqForm, options) { 
 		
 		//alert ($("#formVereador").valid())
		if ($("#formNews").valid() == false) {
			$(".feedback-footer").html("O campo de email &eacute; obrigat&oacute;rio.");
			return false;
		}
		
		$(".feedback-footer").html("enviando...");
    	return true; 
	} 
 
	// post-submit callback 
	function showResponse(responseText, statusText, xhr, $form)  { 
	    $(".feedback-footer").html("Cadastrado com Sucesso.");
		
	}
	// bind form using 'ajaxForm' 
	$('#formNews').ajaxForm(options); 

	$("#formNews").validate({
		messages: {
			email: {
				required: "",
				email: ""
			}
		}
	});
   
}






function openWindow(url, title, extra) {
	
	window.open (url,title,extra);
	
}


function addToSC(id) {
	
	$.ajax({
		type: "POST",
		url: "inc/addToShoppingCart.php",
		data: "fk=" + id,
		success: function(msg){
			//alert(msg);
			jQuery.facebox({ ajax: 'inc_shoppingcart.php' });
		}
	});
	
	
}


function removeFromSC(id) {
	
	$.ajax({
		type: "POST",
		url: "inc/removeFromShoppingCart.php",
		data: "pk=" + id,
		success: function(msg){
			alert(msg);
		}
	});
	
	
}

function keepBuying() {
	
	$(document).trigger('close.facebox');
	
}

function showPrdPage(url) {
	
	$(document).trigger('close.facebox');
	document.location = url;
	
}
