 $(document).ready(function(){
							
	$(document).pngFix();
 
 	$("#descContent").hide();
 	$("#descContent2").hide();
	
	$('.popUp').popupWindow({ width:350, height:300, centerBrowser:1 }); 
	$('.btnNewsletter').popupWindow({ width:745, height:375, centerBrowser:1, toolbar:0 }); 
 
   	$("p.readMore a").toggle(function(){
		$("#descContent").show('slow');
	},function(){
		$("#descContent").hide('fast');
	});

   	$("p.readMore2 a").toggle(function(){
		$("#descContent2").show('slow');
	},function(){
		$("#descContent2").hide('fast');
	});
	
	function initTabs(element, scenesvillage){
		if(scenesvillage == "2"){
			var tabIndex = {'j1-2':0,'j2-2':1,'j3-2':2, 'j4-2':3, 'j5-2':4}
		} else if(scenesvillage == "3"){
			var tabIndex = {'j1-3':0,'j2-3':1,'j3-3':2, 'j4-3':3, 'j5-3':4}
		} else {
			var tabIndex = {'j1':0,'j2':1,'j3':2, 'j4':3, 'j5':4}
		}
	  
	  var match = window.location.hash.replace('#', '');
	
	  for (key in tabIndex) {
		  
		if (match == key) {
		  selectedTab = tabIndex[key];
		  break;
		}
		else selectedTab = 0;
	  }
	  tabs = $(element).tabs({selected:selectedTab}); // render the tabs
			tabs.bind('tabsshow', function(event, ui) { // when tab is shown update the URL
			var re = /#w+$/;
			var url = document.location.toString();
			// to make bookmarkable
			document.location = url.replace(re, "#"+ui.panel.id);
			});
	}

	initTabs('#sceneTab > ul');
	initTabs('#sceneTab-2 > ul', '2');
	initTabs('#sceneTab-3 > ul', '3');
	
	$('#tabHome > ul').tabs({});
	$('#tabIndex > ul').tabs({ selected: 1 });
	
	//OPEN / CLOSE NEWS
	$("#newsContainer .newsContent").hide();

    $("p.readMoreNews a").click( function () {
		
        if ($(this).parent().parent().next(".newsContent:visible").length != 0) {
            $(this).parent().parent().next(".newsContent").slideUp("normal");
        } else {
            $("#newsContainer .newsContent").slideUp("normal");
            $(this).parent().parent().next(".newsContent").slideDown("normal");
        }
 
        return false;
    });
	
	$("a.addMesFrancos").click( function () {
										  
		var progra = $(this).attr("rel");
		var furl = "inc/mf_add.inc.php";
		var element = $(this);
		
		$.ajax({
			type: "POST",
			url:furl,
			data:{ add:progra },
			dataType: "html",
			success:function(msg){
				 element.replaceWith('<span class="mesFrancosExist"><img src="images/accept.png" alt="Date existe" /></span>');
			},
			error:function(xhr,err,e){ alert( "Error: " + err ); }
		});
 
        return false;
    });
	
	
	$().ajaxSend(function(r,s){  
		$("#contentLoading").show();  
	});  
	
	$().ajaxStop(function(r,s){  
		$("#contentLoading").fadeOut("fast");  
	});
	
	$("a.printPage").click( function () {									
		window.print();								
		return false;
	}); 

	$("a.iframe").fancybox({ 'frameWidth': 800, 'frameHeight': 580, 'overlayOpacity': 0.8 }); 
	
	
 });