var bool_close_popup = false;

$(document).ready(function(){
	$(document).bind('keydown', 'esc', function(evt){
            closeAll();
            return false;
	});
})

jQuery.preloadImages = function() {
	var a = (typeof arguments[0] == 'object')? arguments[0] : arguments;
	for(var i = a.length -1; i >= 0; i--) {
		jQuery("<img>").attr("src", a[i]);
	}
}
// preloading images
var cardsImages = ['img/fivepopup.gif',
                   'img/fitpopup.gif',
                   'img/saimaxpopup.gif',
                   'img/ayspopup.gif',
                   'img/mayamipopup.gif',
                   'img/actionpopup.gif'
                   ];
$.preloadImages(cardsImages);

function closeAll() {
    popup = $('#photoPopup');
    if ( popup.length == 1 ) {
        return false;
    }
    $('.blind, .actionBut, .rollerBut, .mayamiBut, .aysBut, .labBut, .saimaxBut, .fitBut, .fiveBut, .contentSp').remove();

    if ( $('body .wrapper2').width() == 0 ) {
        $('body .wrapper2').show();
        $('body .blind2').show();
        return false;
    }

    $('body .wrapper2').remove();
    $('body .blind2').remove();

    return false;
}

function p(a){
    var li = $(a).parent();
    if ( li.hasClass('activ') ) {
        return false;
    }
    else {
        $('.rollermusic .activ').removeClass('activ');
        li.addClass('activ');
        $('.namesons').text( $(a).text() );
        uppodSend("ipod2", "play");

        var index = $('.rollermusic li').index(li);
        var files = ["1.mp3", "file2.mp3", "file3.mp3"];
        uppodSend("ipod2", "file:/player/files/" + files[index]);
        return false;
    }
}
