//var base= 'http://www.vmtest.com.ar/druidics/';
var base= 'http://desarrollo/druidics/';

function initialize() {
    var latlng = new google.maps.LatLng(-32.95759931907371, -60.6394162774086);
    var settings = {
        zoom: 15,
        center: latlng,
        mapTypeControl: false,
        mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
        navigationControl: true,
        navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("gmap"), settings);
    var companyPos = new google.maps.LatLng(-32.95759931907371, -60.6394162774086);
    var companyMarker = new google.maps.Marker({
	  position: companyPos,
	  map: map,
	  title:"Druidics Rosario"
  });
  
    var latlng2 = new google.maps.LatLng(-34.612783, -58.380468);
    var settings2 = {
        zoom: 15,
        center: latlng2,
        mapTypeControl: false,
        mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
        navigationControl: true,
        navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map2 = new google.maps.Map(document.getElementById("gmap2"), settings2);
    var companyPos2 = new google.maps.LatLng(-34.612783, -58.380468);
    var companyMarker2 = new google.maps.Marker({
	  position: companyPos2,
	  map: map2,
	  title:"Druidics Buenos Aires"
  });

}

function cambia_idioma(lang){
    if(lang=='EN'){
        $.get("sitio/secciones/idioma.php", {lang: lang}, function(data){
            var pos= window.location.toString();
            window.location.replace(pos);
        })
    }else{
        $.get("sitio/secciones/idioma.php", {lang: lang}, function(data){
            var pos= window.location.toString();
            window.location.replace(pos);
        })
    }
}

$(document).ready(function(){
//MENU DESPLEGABLE
    $("#nav ul").css({display: "none"}); // Opera Fix
//    $("#nav ul").parent().append("<span></span>");
    $("#nav li").hover(function(){
        $(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
        if($(this).attr('class')=='hijo'){
            $(this).append('<span name="flechita"></span>');
        }
    },function(){
        $(this).find('ul:first').css({visibility: "hidden"});
        if($(this).attr('class')=='hijo'){
            $(this).find('span').remove();
        }
    });


//HOVER PARA NAVEGACION
	$('#nav li a.bgpos')
	.css( {backgroundPosition: "0px -42px"} )
	.mouseover(function(){
		$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:500})
	})
	.mouseout(function(){
		$(this).stop().animate({backgroundPosition:"(0px -42px)"}, {duration:500, complete:function(){
			$(this).css({backgroundPosition: "0px -42px"})
		}})
	})



//SLIDER

    $('#slider').cycle({ 
        fx:     'fade', 
        speed:  1000, 
        timeout: 5000,
        slideExpr: 'img', 
        pager:  '.controlNav',
        pagerAnchorBuilder: function(idx, slide) {
            // return selector string for existing anchor 
            return '.controlNav a:eq(' + idx + ')'; 
        },
        before: function(a,b,c,d){
            if(a.alt != ''){
                $(".cont_slider h1").html('').fadeOut(500);                
            }
        },
        after: function(a,b,c,d){
            if(b.alt != ''){
                $(".cont_slider h1").html(b.alt).fadeIn(200);
            }
        }
    });
        
////CAROUSEL
    function mycarousel_itemLastInCallback(carousel,a,i) {
        var i = i-1;
        var href = $("#carousel-destacadas li:eq("+i+") a").attr("href");
        $('#top_cont_img').attr("href",href);
    }
    $('#carousel-destacadas').jcarousel({scroll: 1, animation: 500, wrap: 'last', itemLastInCallback: mycarousel_itemLastInCallback});

//CURRENT MENU
    $('#nav li a[class!="bgpos"]').each( function(idx, el) {
        if (el.href === window.location.toString()) {
            $(el).css("color", "#E87A01");
            $(el).parent().parent().prev("a.bgpos").css({backgroundPosition: "0px 0px","backgroundImage":"url(sitio/img/current.gif)",color: "#fff"});
        }
    });

     $('#nav li a.bgpos').each( function(idx, el) {
        if (el.href === window.location.toString() || el.href+'/' === window.location.toString() ) {
            $(el).css({backgroundPosition: "0px 0px","backgroundImage":"url(sitio/img/current.gif)",color: "#fff"})
        }
    });



//CURRENT DE HOME
    var home= /(home)/;
    if ( window.location.toString() === base || home.test(window.location.toString())) {
        $('a#inicio').css("color", "#E87A01");
    }



////FANCYBOX
    $("a.zoom").fancybox({
        'onComplete' : function() {$("#fancybox-wrap").unbind('mousewheel.fb');} ,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'zoomSpeedIn'   : 500,
        'zoomSpeedOut'  : 500,
        'overlayShow'   : false,
        'autoScale'     : false,
        'width'         : 1000,
        'height'        : 600
    });

    $('a.mapa').fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'speedIn'		: 500,
		'speedOut'		: 500,
		'overlayShow'	: false,
        'type'          : 'iframe',
        'width'         : 800,
        'height'        : 600
	});

    $("a[title='video']").click(function() {
    	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		    : 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
                'wmode'             : 'transparent',
				'allowfullscreen'   : 'true'
			}
		});
    	return false;
    });

    initialize();
});// Cierro document ready
