// JavaScript Document
(function($){
	
		//Google Map Code
		
		var map_lati = $('.map_lati').text();
		var map_longi = $('.map_longi').text();
		var map_loc = $('.map_loc').text();
		
		$("#map_canvas").gMap({ markers: [{ latitude: map_lati,
						  longitude: map_longi,
						  html: map_loc,
						  popup: true }],
						  zoom: 13 });

		//__________________
		 
		 
		// Some Necessary CSS Targeting 
		
		$('.title-container ul li:last-child').css('padding-right','0px').css('border','none');
		$('.right-side-box ul li:last-child').css('border','none');
		$('.social-nav li:first-child').css('margin','0px');
		$('#searchform').parent('div').css('background','none').css('padding','0px').css('box-shadow','none').css('width','auto');
  		
		
		
		// Code for image frames
		
		$frame_center = $('div.aligncenter img').width();
		$('div.aligncenter').css('width',$frame_center);
		
		$frame_none = $('div.alignnone img').width();
		$('div.alignnone').css('width',$frame_none);
		
		var lbx_title = $('.lightbox a img').attr('title');
		$('.lightbox a').attr('rel','prettyPhoto').attr('title',lbx_title);
		
		// Code for info bars
		$('.close').click(function(){
			$(this).parent('div').animate({opacity:0},700,function(){
				$(this).hide(1000);	  
			});
			  //$(this).parent('div').fadeOut(500);
		});
		
		
		// Fancy Buttons Hover Code
		
		$('.dark-btn-small, .dark-btn-med, .dark-btn-big, .normal-btn-small, .normal-btn-med, .normal-btn-big, .light-btn-small, .light-btn-med, .light-btn-big, ').hover(function(){
			$(this).stop().animate({opacity:0.75},400);
		},function(){
			$(this).stop().animate({opacity:1},400);
		});
		
		
		
		// Main Menu

		$('.nav-container ul>li').hoverIntent(function(){
			$(this).children('ul').slideDown(300).css('z-index','5555');
		}, function(){
			$(this).children('ul').fadeOut(200);
		});
		 
		 
		$("ul.tabs").tabs("div.blocks > div"); 
		//set the accordion functionality
		jQuery('.accordion-container').each(function(){
			jQuery(this).tabs(jQuery(this).find('div.pane'), {tabs: 'h4', effect: 'slide', initialIndex: 0});
		});
		
		
		//NIVO SLIDER

		$('.nivoSlider').nivoSlider({
			effect:'boxRainGrow', // Specify sets like: fold,fade,sliceDown
			slices:12, // For slice animations
			boxCols: 8, // For box animations
			boxRows: 4, // For box animations
			animSpeed:900, // Slide transition speed
			pauseTime:3000, // How long each slide will show
			startSlide:0, // Set starting Slide (0 index)
			directionNav:true, // Next & Prev navigation
			directionNavHide:true, // Only show on hover
			controlNav:true, // circles navigation
		});
					
		//--------------------
  	
	// PretyPhoto 
	$("a[rel^='prettyPhoto']").prettyPhoto(); 
	
		
	
	// Cufon font replacement	
	Cufon.replace('.topbar-container p, .main-nav li a, .nav-container p, .title-container ul li a', {
		fontFamily: 'Droid Sans',
		hover: true,

	  });
	  
	  Cufon.replace('.title-container h3, .post-container h2, .title-content-col h2', {
		fontFamily: 'Droid Sans',
		textShadow: '1px 0px 1px #fff',
		hover: true,

	  });
	  
	  Cufon.replace('.special-text, .header-text-block p,  .col-discription h4, .tweet-box p, .project-info-box h4, .side-box-title, .title-content-col h3, .full-width h1, .full-width h2, .full-width h3, .full-width h4, .full-width h5, .full-width h6, .post-data h1, .post-data h2, .post-data h3, .post-data h4, .post-data h5, .post-data h5, .tweet-box ul li, .full-width .intro, .tabs li', {
		fontFamily: 'Droid Serif',
		hover: true,
		textShadow: '1px 1px 0px #ffffff',
		hoverables: { strong: true, em: true }
	  });
	   Cufon.replace('.slider-wrapper h2, .slider-wrapper h3', {
		fontFamily: 'Droid Serif',
		hover: true,
	  });
	
	
	//this function attached focus and blur events with input elements
	var addFocusAndBlur = function($input, $val){
		
		$input.focus(function(){
			if (this.value == $val) {this.value = '';}
		});
		
		$input.blur(function(){
			if (this.value == '') {this.value = $val;}
		});
	}
	//  code to attach the events
	addFocusAndBlur(jQuery('#author'),'Name');
	addFocusAndBlur(jQuery('#email'),'E-mail');
	addFocusAndBlur(jQuery('#url'),'Website');
	addFocusAndBlur(jQuery('#comment'),'Message');
	
	// Code for image to fade out
	$('.col-block .col-head-block img, .single-pic-wrapper img, .col-head-half img').mouseover(function(){
		$(this).stop().fadeTo('slow',0.6);	
	}).mouseout(function(){
		$(this).stop().fadeTo('slow',1);	
	});
	
	
	// Menu Scroll Control
	
	var topHeight = $('#header').height() + 105;
	
	
	jQuery(window).scroll( function() {
	
		if(jQuery(document).scrollTop() > topHeight - 72){
			
			jQuery('.left-nav-wrapper').css({position: 'fixed', marginTop: -topHeight + 24, top: 'auto'});
			
		}else{
			
			jQuery('.left-nav-wrapper').css({position: 'absolute', marginTop: -42});

		}

	});
	
	
	$.validator.setDefaults({
		submitHandler: function() 
			{ 
			
			$('.loading-img').fadeIn(500);
			
			var form = $( "#contactFrom" ),
				actionurl = form.attr( 'action' );
			
			$.ajax({
				type: 'GET',
				url: actionurl,
				data: form.serialize(),
				success: function(msg){
					$('#contactFrom').fadeOut(500);
					$('.loading-img').fadeOut(500,function(){
						$('#reponse_msg').html(msg).fadeIn(500);
					});
				}
			});
		    
		    return false;
		}
	});
	
	$("#contactFrom").validate();
	
	
	$('.col-block').hover(function(){
		$(this).stop().animate({boxShadow: '1px 1px 5px #aaa'},200);
	},function(){
		$(this).stop().animate({boxShadow: '1px 1px 2px #ddd'},100);
	});
	

	VideoJS.setupAllWhenReady();
	
	
})(jQuery);

Cufon.now();
