
function init(){
$('img').bind("ondragstart", function(e) { e.preventDefault(); });
$('img').bind("drag", function(e) { e.preventDefault(); });
}

function msgClickNormal(){
    var htmlMsg =  '<div id="ggd_text_exp">Haz clic<img id="ggd_text_exp_img" src="../../skins/S_GGD/img/cilc_icon.svg"/>para ver la información</div>';
    $("#ggd_text_exp").html( htmlMsg);
}

function msgClickAlterno(){
    var htmlMsg =  '<div id="ggd_text_exp">Haz clic<img id="ggd_text_exp_img" src="../../skins/S_GGD/img/cilc_icon.svg"/>  para ver el video</div>';
    $("#ggd_text_exp").html( htmlMsg);
}

function pause(idVideo){ 
    $('#'+idVideo).trigger('pause'); 
} 

function mostrarGrupo1(){

    $('#lineas3movil1').show().animate({ top: 73, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});
    $('#lineas1movil1').show().animate({ top: 116, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});
    $('#movil2').show().animate({ top: 110, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});
    $('#movil3').show().animate({ top: 110, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});
    $('#corrientesconveccion').show().animate({ top: 220, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});
    $('#conveccion').show().animate({ top: 10, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});
    $('#conveccionliquidos').show().animate({ top: 220, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});
}

function mostrarGrupo2(){

    $('#lineas4movil1').show().animate({ top: 350, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});

    $('#lineas5movil1').show().animate({ top: 302, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});

    $('#movil4').show().animate({ top: 350, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});

    $('#movil5').show().animate({ top: 350, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});

    $('#dia').show().animate({ top: 440, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});

    $('#noche').show().animate({ top: 440, opacity: 1 }, {duration: 1000, easing: 'easeOutBounce'});
}

// imgPopUp  Carlos
function imgPopUp(idImg){
    var imgTag= $('#'+idImg);
    var popUpImg =  $('#popUpImg');
    var imgContainer = $('#imgContainer');
    var width, height, aspectRatio;
    var stageWidth= $('#stage').width();
    var stageHeight= $('#stage').height();
    var PADDING_POPUP = 20;
    var PADDING_IMG = 40;

    sg.sound('success-low');
    imgContainer.attr("src",imgTag.attr('srcBig')).load(function(){
        width = this.width;
        height = this.height;
        aspectRatio = width/height;

        if(width >= height){ 
             console.log('escalado a width');

            if ((width + PADDING_POPUP + PADDING_IMG) > stageWidth){

                console.log('Wont Fit');
                var newImgWidth = stageWidth - (PADDING_POPUP+PADDING_IMG);
                var newImgHeight= (newImgWidth/aspectRatio);
                var newPopUpWidth= stageWidth - PADDING_POPUP;
                var newPopUpHeight= (newPopUpWidth/aspectRatio);

                var popPosLeft = (stageWidth - newPopUpWidth)/2;
                var popPosTop = (stageHeight - newPopUpHeight)/2;

                imgContainer.width(newImgWidth);
                imgContainer.height(newImgHeight);

                popUpImg.width(newPopUpWidth);
                popUpImg.height(newPopUpHeight);
                popUpImg.css({ "left": popPosLeft, "top": popPosTop});
            }
            else {
                console.log('Fit');
                var newPopUpWidth= width + PADDING_POPUP + PADDING_IMG ;
                var newPopUpHeight= newPopUpWidth/aspectRatio;
                // console.log('nw'+newPopUpWidth);
                // console.log('nh'+newPopUpHeight);

                var popPosLeft = (stageWidth - newPopUpWidth)/2;
                var popPosTop = (stageHeight - newPopUpHeight)/2;

                //console.log(stageWidth);
                //console.log("sp "+(stageWidth-newPopUpWidth));

                popUpImg.width(newPopUpWidth);
                popUpImg.height(newPopUpHeight);
                popUpImg.css({ "left": popPosLeft, "top": popPosTop});
            }
        }
        else{ 
             console.log('escalado a height');
            if ((height + PADDING_POPUP + PADDING_IMG) > stageHeight){

                console.log(' Wont Fit');
                var newImgHeight = stageHeight - (PADDING_POPUP+PADDING_IMG);
                var newImgWidth= (newImgHeight/aspectRatio);
                var newPopUpHeight= stageHeight - PADDING_POPUP;
                var newPopUpWidth= (newPopUpHeight/aspectRatio);

                var popPosTop = (stageHeight - newPopUpHeight)/2;
                var popPosLeft = (stageWidth - newPopUpWidth)/2;

                imgContainer.width(newImgWidth);
                imgContainer.height(newImgHeight);

                popUpImg.width(newPopUpWidth);
                popUpImg.height(newPopUpHeight);
                popUpImg.css({ "left": popPosLeft, "top": popPosTop});
            }
            else {
                console.log('Fit');
                var newPopUpHeight= height + PADDING_POPUP + PADDING_IMG ;
                var newPopUpWidth= newPopUpHeight*aspectRatio;

                var popPosTop = (stageHeight - newPopUpHeight)/2;
                var popPosLeft = (stageWidth - newPopUpWidth)/2;

                // console.log(stageWidth);
                // console.log("sp "+(stageWidth-newPopUpWidth));

                popUpImg.height(newPopUpHeight);
                popUpImg.width(newPopUpWidth);
                popUpImg.css({ "left": popPosLeft, "top": popPosTop});
                //imgContainer.attr({"width": newImgWidth , "height": (newImgWidth/aspectRatio)});
            }
        }
    });

    popUpImg.fadeIn();

} // Fin function imgPopUp Carlos U



