// Bond Vigilantes JavaScript Document
(function($) {
	
	$(function(){
	
	$('.six .panel').each(function() {

		if ( $(this).find('.tabs').length > 0 ) {
    
			var sections = $(this).find('.section');
			sections.hide().eq(0).show();
			
			$(this).find('ul.tabs li a').click(function () {
				
				sections.hide();
				sections.filter(this.hash).show();
				$(this).parent().parent().find('a').removeClass('selected');
				$(this).addClass('selected');
				return false;
				
			}).eq(0).click();
	
		}
		
	});
	
	if ($("input.focus-clear").length > 0) {
		
		var defaulttext = [];
		
		$("input.focus-clear").each(function(index) {

		defaulttext[index] = $(this).val();
		
				$(this).focus(function() {
								
					if ($(this).val() == defaulttext[index]) {
						$(this).val('');
					}
				}).blur(function() {
					if ($(this).val() == '') {
						$(this).val(defaulttext[index]);
					}
				}).keypress(function() {
					$(this).removeClass("focus-clear");
				});
		});
		
	}

	
});

// /*validate email*/
// $("#mc_mv_EMAIL").validate({
//   rules: {
//     field: {
//       required: true,
//       email: true
//     }
//   }
// });



/*twitter feed widget*/
$(function(){
    $("#twitter-feed").tweet({
              avatar_size: 48,
              count: 5,
              username: "bondvigilantes",
              list: "vigilantes",
              loading_text: "loading list...",
            });
});

/*columns*/
$(function(){
  $('#archives-list-contributors ul').makeacolumnlists({cols:2,colWidth:0,equalHeight:false,startN:1});
});

$(function(){
  $('ul#archives-list-months').makeacolumnlists({cols:4,colWidth:0,equalHeight:false,startN:1});
});

function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}

jQuery(document).ready(function() {

jQuery('#mc_mv_EMAIL').keyup(function(){
var email = jQuery('#mc_mv_EMAIL').val();
 
if(email != 0)
{
if(isValidEmailAddress(email))
{
 
jQuery('#mc_mv_EMAIL').css({ "background-color": "green" });
 
} else {
 
jQuery('#mc_mv_EMAIL').css({ "background-color": "red" });
 
}
 
} else {
 
jQuery('#mc_mv_EMAIL').css({ "background-image": "none" });
 
}
});
});

/*scroller*/
$(function(){
    $('.list').vScroll({ speed: 500, upID: "#prevButton", downID: "#nextButton" });
});


/*lightbox*/
  $(function() {
      $('.post-content img').parent().lightBox();
  });
})(jQuery);
/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

var popupStatus = 0;  

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		jQuery("#backgroundPopup").css({
			"opacity": "0.7"
		});
		jQuery("#backgroundPopup").fadeIn("slow");
		jQuery("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		jQuery("#backgroundPopup").fadeOut("slow");
		jQuery("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = jQuery("#popupContact").height();
	var popupWidth = jQuery("#popupContact").width();
	//centering
	jQuery("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

	jQuery("#backgroundPopup").css({
		"height": windowHeight
	});
}


//CONTROLLING EVENTS IN jQuery
jQuery(document).ready(function(){
	//LOADING POPUP
	//centering with css  
	centerPopup();  
	//load popup  
	loadPopup();  

	//CLOSING POPUP
	//Click the x event!
	jQuery("#popupagree").click(function(){
		disablePopup();
	});
	jQuery("#popupContact").click(function(){
		disablePopup();
	});


});

