///////////////////////////////////////
//	Vportal - hotsite                //
//	Autor: Fernando Siggelkow        //
//	E-mail: fernando@netmaker.com.br //
//	Data: 26/07/2010                 //
///////////////////////////////////////

function starModal() 
{	
	
	
	windMod();		
	
	
	// slide
	$(".main_image .desc").show(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
	
	$(".image_thumb ul li:first").addClass('active'); //Add the active class (highlights the very first list item by default)
	$(".image_thumb ul li").click(function(){
	    //Set Variables
	    var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
	    var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
	    var imgDesc = $(this).find('.block').html();  //Get HTML of the "block" container
	    var imgDescHeight = $(".main_image").find('.block').height(); //Find the height of the "block"
	
	    if ($(this).is(".active")) {  //If the list item is active/selected, then...
	        return false; // Don't click through - Prevents repetitive animations on active/selected list-item
	    } else { //If not active then...
	        //Animate the Description
	        $(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() { //Pull the block down (negative bottom margin of its own height)
	            $(".main_image .block").html(imgDesc).animate({ opacity: 0.85,  marginBottom: "0" }, 250 ); //swap the html of the block, then pull the block container back up and set opacity
	            $(".main_image img").attr({ src: imgTitle , alt: imgAlt}); //Switch the main image (URL + alt tag)
				$("#bt_compre").animate({ opacity: 0.85,  marginBottom: "0" }, 250 );
				windMod();	           
	        });
	    }
	    //Show active list-item
	    $(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all list-items
	    $(this).addClass('active');  //Add class of 'active' on the selected list
	    return false;
			
	
	}) .hover(function(){ //Hover effects on list-item
	    $(this).addClass('hover'); //Add class "hover" on hover
	    }, function() {
	    $(this).removeClass('hover'); //Remove class "hover" on hover out
	    
	});
	
	
	$("a.collapse").click(function(){
	    $(".main_image .block").slideToggle(); //Toggle the description (slide up and down)
	    $("a.collapse").toggleClass("show"); //Toggle the class name of "show" (the hide/show tab)
	    //window.alert($("#link").attr('class'));
	});
};

function windMod()
{	

	// modal
	$('a[name=modal]').unbind("click");
	$('a[name=modal]').click(function(e) {
		e.preventDefault();
		
		var id_obj = $(this).attr('href');
	
		var id_total = id_obj.split("#");
		
		var id = "#"+id_total[1];
	
		$(id+' iframe').attr('src',$(id+' iframe').attr('name'));
	
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		$('#mask').css({'width':maskWidth,'height':maskHeight});

		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
        
		//$(id).show();
		//window.alert(id);
		
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		$(id).fadeIn(2000); 
	
	});
	
	$('.window .close').click(function (e) {
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	$('#mask').click(function () {
		//e.preventDefault();
		
		$(this).hide();
		$('.window').hide();
	});
	//window.alert('daniboy');
}

