$(document).ready(function(){

    // Inistialising shadow box
    Shadowbox.init({
	handleOversize: "resize",
	overlayOpacity: 0.9
    });

//    $(window).click(function(){
//        window.onbeforeunload = null;
//    });
//
//    $('a').click(function(){
//        window.onbeforeunload = null;
//    });
//
//    $('button').click(function(){
//        window.onbeforeunload = null;
//    });
//
//    $('input').click(function(){
//        window.onbeforeunload = null;
//    });
//
//    window.onbeforeunload = function(){
//
//	// Language slector ...
//	// _icl_current_language (cookie)
//
//	var currentlang = readCookie('_icl_current_language');
//	var note = "Wait!! Looking for a poker room?\n €1 000+ Free from rooms like PartyPoker, Titan, 888poker...\n Check out our amazing offers!";
//
//	if(currentlang == 'fr'){
//	    note = "Attendez! Vous cherchez une salle de poker?\n€ 1 000 + Libre à partir de pièces comme PartyPoker.FR, Winamax.FR, PokerStars.FR...\nConsultez nos offres incroyables!";
//	    currentlang = '/' + currentlang;
//	} else if(currentlang == 'de'){
//	    note = "Warten Sie! Sie suchen einen Pokerraum?\n1 000 € + Frei von Räumen wie PartyPoker, Titan, 888poker...\nSchauen Sie sich unsere tolle Angebote!";
//	    currentlang = '/' + currentlang;
//	} else if(currentlang == 'es'){
//	    note = "Espere! ¿Busca una sala de póquer?\n€ 000 + Libre de salas como Party Poker, Titan, 888poker 1...\nEcha un vistazo a nuestras ofertas increíbles!";
//	    currentlang = '/' + currentlang;
//	} else if(currentlang == 'sv'){
//	    note = "Vänta! Letar du efter ett pokerrum?\n€1 000+ gratis från pokerrum som PartyPoker, Titan, 888poker...\nKolla in våra fantastiska erbjudanden!";
//	    currentlang = '/' + currentlang;
//	} else {
//
//	    currentlang = '';
//	}
//
//
//
//        Shadowbox.open({
//            content:  currentlang + '/exit-pop-up.html',
//            player:     "iframe",
//            width:      540,
//            height:     380,
//            modal: true
//        });
//
//        return note;
//
//    }

    $('form').validate();

    // Fixing the height
    if( $('div.container').height()  <  $(window).height())
	$('div.container').css({
	    height: $(window).height() + 'px'
	});

    $('.media-package-info',this).animate({
	right:250
    });

    $('#get-for-free').hover(function(){
	$('.media-package-info').first().stop(true, true).animate({
	    right:0
	});
    },function(){
	$('.media-package-info').first().stop(true, true).animate({
	    right:250
	});
    });

    $('#media-package-sidebar li').hover(function() {
	$('.media-package-info',this).stop(true, true).animate({
	    right:0
	});
    }, function(){
	$('.media-package-info',this).stop(true, true).animate({
	    right:250
	});
    }).click(function(){
	//
	//	var url = $(this).find('a').first().attr('href');
	//
	//	if(url != undefined)
	//	    window.open(url);
	//
	});

});

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
