var fade_speed=1000;


$(document).ready(function(){

	$("#form_contact").validate();
	
	$("#bg_popin").css("opacity", "0.6");
	
	// function to open popins when link with class "popin" is clicked
	$(".popin").bind("click", function(e) {
		$("body").css('overflow', 'hidden');							   	
		$("#bg_popin").width("100%").height("100%").fadeIn(300);
		$("#"+this.rel).fadeIn(500);
	});	


	// function to close open popins when link with class "close" is clicked
	$(".close").bind("click", function(e) {
		$("#"+this.rel).fadeOut(500);
		$("#bg_popin").fadeOut(300);
		$("body").css('overflow', 'auto');	

		return false;						
	});	


	// function to activate projects code
	$(".a_projects").bind("click", function(e){
		$('.column').fadeOut(400);
		$('#projects').toggle(400);
	});	


	$("#projects > ul > li > a").bind("click", function(e){

		project_number=this.rel;//.substr(this.rel.length-1, 1);
		$('#video_container').fadeOut(fade_speed, function() {
											   
			// blade old project content variables
			$('#flv_player').children().remove();
			$('#project_title').children().remove();
			$('#project_description').children().remove();
			$('#project_thumbs').children().remove();
															  
			$('#video_container').fadeIn(fade_speed, function() {
				// load in flash
				var flashvars = { video: 'proj_'+project_number }	
				var params = { bgcolor: "#3b3d3d", wmode: "opaque" }	
				var attributes = {  }	
				swfobject.embedSWF("/wp/wp-content/themes/vero/flash/flv_player.swf", "flv_player", "450", "338", "9.0.0","expressInstall.swf", flashvars, params, attributes);
				
				// insert new project content variables
				$('#project_title').append(project_title[project_number]);
				$('#project_description').append(project_description[project_number]);
				$('#project_thumbs').append(project_thumbs[project_number]);
			})
		})

	})


	$('#popin_image').bind("click", function(e) {
		$("#popin_image").fadeOut(500);
		$("#bg_popin").fadeOut(300);
		$("body").css('overflow', 'hidden');
		$("#popin_image").children().remove();

	});

	$('div.col1 > ul > li > a').bind('click', function() {
		if ($(this).next('u').is(':visible')) {
			$(this).removeClass('activate').css('color','#29a4b2');
			$(this).next('u').hide(400)
		} else {
			$('div.col1 > ul > li > a').removeClass('activate').css('color','#29a4b2');
			$('div.col1 > ul > li > u').hide(400);
			$(this).next('u').show(400);
			$(this).addClass('activate').css('color','black');
		}
	});


});


// function to open img popin
function zoom(img_id) {
	$("body").css('overflow', 'hidden');							   	
	$("#bg_popin").width("100%").height("100%").fadeIn(300);
	$("#popin_image").fadeIn(500);
	$("#popin_image").append('<img id="pop_img" src="/wp/wp-content/themes/vero/img/'+img_id+'.jpg" width="400" height="300" />');
}


