﻿//<![CDATA[
	// Demo NyroModal
$(function() {




    //Get browser's width and height----------
    var myWidth;
    var myHeight;

    if (typeof (window.innerWidth) == 'number') {

        //Non-IE 

        myWidth = window.innerWidth;
        myHeight = window.innerHeight;

    } else if (document.documentElement &&

    (document.documentElement.clientWidth || document.documentElement.clientHeight)) {

        //IE 6+ in 'standards compliant mode' 

        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;

    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {

        //IE 4 compatible 

        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;

    }
    //end of getting browser's width and height ------------------



    $.nyroModalSettings({
        debug: false,
        processHandler: function(settings) {
            var url = settings.url;
            //alert(myWidth);
            //alert(url);
            if (url == '../emailbtc.aspx?preview=1' || url == '../emailttp.aspx?preview=1') {
                myWidth = 620;
            }
            else if (url == './rules_btc.aspx?tid=0') {
                myWidth = 980;
            }

            $.nyroModalSettings({
                width: myWidth
            });


            if (url && url.indexOf('http://www.youtube.com/watch?v=') == 0) {
                $.nyroModalSettings({
                    type: 'swf',
                    height: 355,
                    width: 425,
                    url: url.replace(new RegExp("watch\\?v=", "i"), 'v/')
                });
            }

        },
        endShowContent: function(elts, settings) {
            $('.resizeLink', elts.contentWrapper).click(function(e) {
                e.preventDefault();
                $.nyroModalSettings({
                    width: Math.random() * 1000,
                    height: Math.random() * 1000
                });
                return false;
            });
            $('.bgLink', elts.contentWrapper).click(function(e) {

                e.preventDefault();
                $.nyroModalSettings({
                    bgColor: '#' + parseInt(255 * Math.random()).toString(16) + parseInt(255 * Math.random()).toString(16) + parseInt(255 * Math.random()).toString(16)
                });
                return false;
            });
        }
    });

    $('#manual').click(function(e) {

        e.preventDefault();
        var content = 'Content wrote in JavaScript<br />';
        jQuery.each(jQuery.browser, function(i, val) {
            content += i + " : " + val + '<br />';
        });
        $.fn.nyroModalManual({
            bgColor: '#3333cc',
            content: content
        });
        return false;
    });
    $('#manual2').click(function(e) {
    alert('here');
        e.preventDefault();
        $('#imgFiche').nyroModalManual({
            bgColor: '#cc3333'
        });
        return false;
    });
    $('#myValidForm').submit(function(e) {
        e.preventDefault();
        if ($("#myValidForm :text").val() != '') {
            $('#myValidForm').nyroModalManual();
        } else {
            alert("Enter a value before going to " + $('#myValidForm').attr("action"));
        }
        return false;
    });
    $('#block').nyroModal({
        'blocker': '#blocker'
    });

    function preloadImg(image) {
        var img = new Image();
        img.src = image;
    }

    preloadImg('img/ajaxLoader.gif');
    preloadImg('img/prev.gif');
    preloadImg('img/next.gif');

});
	
	// Page enhancement
$(function() {
    var allPre = $('pre');
    allPre.each(function() {

        var pre = $(this);
        var link = $('<a href="#" class="showCode"></a>');
        pre.hide().before(link).before('<br />');
        link.click(function(event) {
            
            event.preventDefault();
            pre.slideToggle('fast');
            return false;
        });
    });
    var shown = false;
    $('#showAllCodes').click(function(event) {

        event.preventDefault();
        if (shown)
            allPre.slideUp('fast');
        else
            allPre.slideDown('fast');
        shown = !shown;
        return false;
    });
});
	
	//]]>
