function cufon(){
	Cufon.set('fontFamily', 'Franklin Gothic Book', 'normal');


	//Cufon.replace('#nav a:hover',{
	//	fontFamily: 'Franklin Gothic Demi'	
//	});		
	Cufon.replace('.clients .tab-nav');
	Cufon.replace('.client-content h3');
	Cufon.replace('#nav a',{
		fontWeight: 'normal',
		hover: {
			color: '#fff'
		}
	});
	Cufon.replace('.s-about');
	Cufon.replace('.title');
	
}

function home_tabs(){
	$('.tabs .tab').hide();
	$('.tabs .tab').first().show().addClass('active');
	$('.tab-nav a').first().addClass('current');
	$('.tab-nav a').click(function(e){
		e.preventDefault();
		$('.tabs .tab').hide().removeClass('active');
		$('.tab-nav a').removeClass('current');
		$(this).addClass('current');
		$('#'+$(this).attr('id')+'_tab').show().addClass('active');
		show_client($('.clients .tabs .active .clients-list li span').first());
		Cufon.refresh();
	});
	
	
}

function clients(){
	
	show_client($('.clients .tabs .active .clients-list li span').first());
	$('.clients-list li span').click(function(){
		show_client(this);
	});
	
	
}

function show_client(a){
	$('.clients-list li span').removeClass('current');
	
	$(a).addClass('current');
	$('.clients .tabs .active .client-content').html($(a).parent().find('.c-con').html());	
	Cufon.refresh();
}

function headers(){
	var h = $('#header');
	var s = h.find('strong');
	var i = 306;
	h.addClass('header-bg');
	setInterval ( function(){
		h.css('background-position', '0px -'+i+'px');	
		s.fadeOut(1000, function(){
			s.css('background-position', '0px -'+i+'px').show();
			i+=306;
			if(i>612){i=0;}
		});	
	}, 5000 );

}

function print(){
	$('#t-print').click(function(e){
		e.preventDefault();
		$('#content').printElement();
	});
}

function font_size(){
	$('.font a').click(function(e){
		e.preventDefault();
		$('#content .news').css('font-size', $(this).attr('data-fontsize')+'em');
		console.log($(this).attr('data-fontsize'));
	});
}

function hoptop(){
	$('#t-top').click(function() {
		 $.scrollTo($("#top"), 700);
		 return false;
	 }); 
}

function go_back(){
	$('#t-back').click(function(){
		history.back();
		return false;
	});
	
}

function gallery(){
	if($('ul.gallery').length > 0){
		$('ul.gallery').gallery();
	} 
	
}

function contact_map() {
	  var LHC = new google.maps.LatLng(52.228608, 21.057690);
	  var options = {
	    zoom: 15,
	    center: LHC,
	    mapTypeId: google.maps.MapTypeId.ROADMAP
	  }
	  var map = new google.maps.Map(document.getElementById("map"), options);
	  
	  
	var ico = new google.maps.MarkerImage('lay-gfx/ico_map_lhc.png', new google.maps.Size(84, 52), new google.maps.Point(0,0),new google.maps.Point(0, 52));
	new google.maps.Marker({position: LHC, map: map,icon: ico,title:'Lighthouse Cunsultants'});
}

function placeholder(){
	$('.contact-form .f-text, .contact-form textarea').each(function(i,v){
		var inp = $(v);
		var ph = inp.parent().find('span:first');

//		if(inp.get(0).nodeName == "INPUT"){	
//		console.log(inp, inp.val());
		
			if(!(inp.val())){
				v.value = ph.text();
				inp.addClass('placeholder');
				inp.css('font-weight', 'bold');
			}
			
	        inp.focus( function(e) {
	            if( inp.val()==ph.text() ) {
	                inp.attr('value', '');
	                inp.removeClass('placeholder');
	                inp.css('font-weight', 'normal');
	            }
	        });	
	        
	        inp.blur( function(e) {
	            if( $.trim(inp.val())=='' ) {
	                inp.attr('value', ph.text());
	                inp.addClass('placeholder');
	                inp.css('font-weight', 'bold');
	            }
//	            console.log(inp.get(0));
	            
	        });	        
			
//		}
		
		ph.hide();
		
	});
	
	$('.contact-form:first').submit(function(){
		$(this).find('.placeholder').val('');
		return true;
	});
	
}



function initialize(){
	headers();
	cufon();
	home_tabs();
	clients();
	print();
	hoptop();
	go_back();
	font_size();
	gallery();
	placeholder();
	$("input[type=file]").customFileInput();
	if($('#map').length > 0){contact_map() ;};
//	$('.news img').imageDescription();
}
$(document).ready(initialize);
