function log(mssg){
    if(typeof console != undefined){
        console.log(mssg);
    }
    return null;
}

$(function(){
    $(".content ul.list li:first").addClass('first');
    $(".content table tr:last td").addClass('last');	
    $('img.withText').each(function(i,img){
        var new_width = parseFloat($(img).width()) + 10;
        if ($(img).attr('alt')) {
            $(img).wrap('<span class="image" style="width:'+new_width+'px"/>');
            $(img).after('<span class="caption">'+$(img).attr('alt')+'</span>');
        }
    });	
	
    $('#contTopMenu ul li').mouseover(function() {
        if(!$(this).is('.current')){
            $(this).addClass('active');
        }
    });
    $('#contTopMenu ul li').mouseout(function() {
        if(!$(this).is('.current')){
            $(this).removeClass('active');
        }
    });
	
	
    $('#contLanguages ul li').mouseover(function() {
        if(!$(this).is('.current')){		
            $(this).addClass('active');
        }
    });
    $('#contLanguages ul li').mouseout(function() {
        if(!$(this).is('.current')){
            $(this).removeClass('active');
        }
    });
	
    $('a[rel~="external"]').click(function(){
        $(this).attr({
            "target":"_blank"
        });
    });
	
});

//----------------------------------------------------------------------------------------------------------------------------------	

/* google maps - starts */

function showMap() {

    var myOptions = {
        zoom: 7,
        center: new google.maps.LatLng(55.21649,23.675537),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map"), myOptions);

    setMarkers(map, offices);
  
  
}


var offices = [
['Client 1', 55.81649,21.675537, 1],  ['Client 2', 55.02649,23.675537, 2],  ['Client 3', 55.13649,22.675537, 3],  ['Client 4', 55.64649,23.675537, 4],  ['Client 5', 55.25649,25.675537, 5]
]

function setMarkers(map, locations) {
    var image = new google.maps.MarkerImage('images/icon.png',
        // This marker is 20 pixels wide by 32 pixels tall.
        new google.maps.Size(25, 29),
        // The origin for this image is 0,0.
        new google.maps.Point(0,0),
        // The anchor for this image is the base of the flagpole at 0,32.
        new google.maps.Point(13, 29));

    for (var i = 0; i < locations.length; i++) {
        var office = locations[i];
        var myLatLng = new google.maps.LatLng(office[1], office[2]);
        var marker = new google.maps.Marker({
            position: myLatLng,
            map: map,
            icon: image,
            title: office[0],
            zIndex: office[3]
        });
    }
}

if($('#map').length > 0){
    showMap();
}


/* google maps - starts */


/* mindaugas */
$(function(){
    var contFlash = $('#contFlash');
    var lang = 'en';
    var body_class = $('body').attr('class').split(' ');
    var languages = ['en', 'lt', 'ru'];
    var languages_length = languages.length;
    
    if(languages_length > 0){
		for(var i = 0; i < languages_length; i++){
			if(body_class.indexOf(languages[i]) != -1){
				lang = languages[i];
			}
		}
	}
    
    if(contFlash.length > 0){
        swfobject.embedSWF('index_'+lang+'.swf', "contFlash", "956", "346", "9.0.0","expressInstall.swf", {}, {
            menu: "false", 
            base: ".",
            wmode: "transparent"
        }, {});
    }
    
    var gallery = $('.gallery');
    if(gallery.length > 0){
        $('a', gallery).fancybox();
    }
    
    
    var newsletter_input = $('.subscribeFormInput input[type="text"]');
    if(newsletter_input.length > 0){
        set_focus_blur(newsletter_input);
    }
    
});

function set_focus_blur(JQobjects){
    JQobjects.focus(function() {
        if (this.value == this.defaultValue){
            this.value = '';
        }
    });
    JQobjects.blur(function() {
        if ($.trim(this.value) == ''){
            this.value = (this.defaultValue) ? this.defaultValue : '';
        }
    });
}
