/* Ionut Ticu - ionut@onecom.no */

$(function(){
	//top menu
	$('.menu ul').superfish();
	
	Cufon.replace('h1', { fontFamily: 'MuseoSans500' }); //Works without a selector engine
	Cufon.replace('h2', { fontFamily: 'MuseoSlab500' });
	Cufon.replace('h3', { fontFamily: 'MuseoSlab500' });

	
	$(".jcarousel-next-vertical").live("click", function(){
		Cufon.replace('h1', { fontFamily: 'MuseoSans500' });
	});
	$(".jcarousel-prev-vertical").live("click", function(){
		Cufon.replace('h1', { fontFamily: 'MuseoSans500' });
	});
	
	
	/* top banner */
    var bc = $('.buttonContainer');
    var $container = $('.banner .items').cycle({
        fx: 'fade',
        speed:1000,
        timeout:4000,
		pager: '.banner_nav',
		pagerAnchorBuilder: function(idx, slide) { //IT - custom navigation
			return '<a href="#">&nbsp;&nbsp;</a>'; 
		}
    });
    
    
    //portfolio page
    $('.portfolio_categ ul li').click(function() {
    	$('.portfolio_categ ul li').attr('class','');
    	$(this).attr('class','active');
    	
    	var divClass = $(this).attr('id');
    	$('.portfolio_items').hide();
    	$('html, body').animate({ scrollTop: 60000 },'slow');
    	$('.'+divClass).toggle('slow');
    	return false;
    });
    
    
	/* photo gallery */
	/*$(".gallery .image a").click(function() {
		var image = $(this).attr("href");		
		$('#gallery_big_img').hide();
		$('#gallery_big_img').fadeIn('slow');
		$('#gallery_big_img').html('<img src="' + image + '"/>');
		return false;
	});*/
	
	/* photo gallery tooltip */
	$(".gallery .image").mouseover(function() {
		$('.tooltip',this).css('display','block');
	});
	$(".gallery .image").mouseout(function() {
		$('.tooltip',this).css('display','none');
	});
	$(".gallery .tooltip").click(function() {
		var url = $('a',this).attr('href');
		window.location = url;
	});
	
	
	
	$(".contact_item .image").mouseover(function() {
		$('.qr_code',this).css('display','block');
	});
	$(".contact_item .image").mouseout(function() {
		$('.qr_code',this).css('display','none');
	});	


	//search input
	$(function() {
	    $('.footer .contact .search .search_input').focus(function() {	    	
	        $('.footer .contact .search').animate({ width:'131px' });
	        $('.footer .contact .search .search_input').animate({ width:'125px' });
	        $('.footer .contact .search').css("background","#7D7D7D");
	    }).blur(function() {
	        $('.footer .contact .search').animate({ width:'30px' });
	        $('.footer .contact .search .search_input').animate({ width:'20px' });
	        $('.footer .contact .search').css("background","url('http://www.onecom.no/resources/onecom/images/search_input_bg.png') no-repeat top left");
	    });
	});
	
});


function createMarker(point,html) {	
	var myIcon = new GIcon();
	myIcon.image = 'http://www.onecom.no/resources/onecom/images/projects_map_icon.png';
	myIcon.iconSize = new GSize(15,15);
	myIcon.shadow = null;
	myIcon.iconAnchor = new GPoint(11, 11);
	myIcon.infoWindowAnchor = new GPoint(12, 1);
	myIcon.infoShadowAnchor = new GPoint(12, 1);

    var marker = new GMarker(point, {icon:myIcon});
    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(html);
    });
    return marker;
  }
