var CurrentSubscriptionItem = 1;
var SubscriptionItems = 0;
var navmenuIsActive = false;


$(document).ready(
function() {
var PageQuery = $.parseQuery();


/**
* Update basket status
*/
UpdateBasketStatus(false);


/**
* Initialize Language Selector
*/
var WindowLocation = window.location.href;
//if ( WindowLocation.indexOf('lang=') > 0 ){
    if ( WindowLocation.indexOf('lang=norwegian') > 0 || WindowLocation.indexOf('http://www.aime.no') > 0  ) setCookie('Q3Language', 'norwegian');
    if ( WindowLocation.indexOf('lang=danish') > 0 || WindowLocation.indexOf('http://www.aime.no/_DK') > 0 ) setCookie('Q3Language', 'danish');
    if ( WindowLocation.indexOf('lang=finish') > 0 || WindowLocation.indexOf('http://www.aime.fi') > 0 ) setCookie('Q3Language', 'finish');
    if ( WindowLocation.indexOf('lang=czech') > 0 || WindowLocation.indexOf('http://www.aime.cz') > 0 ) setCookie('Q3Language', 'czech');
    if ( WindowLocation.indexOf('lang=slovak') > 0 || WindowLocation.indexOf('http://www.aime.sk') > 0 ) setCookie('Q3Language', 'slovak');
//}


/**
* Check GeoLocation
* http://www.nirsoft.net/countryip/
*/
$('#languageDialog').jqm({overlay:'97'});   
if ( $.cookie('Q3Language') === null && ClientIp != '' && ClientIp != '193.179.195.227' && ClientIp != '81.166.218.210' ){
    $.ajax({
         url: 'http://freegeoip.net/json/' + ClientIp,
         type: 'get',
         dataType: 'jsonp',
         success: function(data, textStatus, XMLHttpRequest) { 
            if ( data.country_code != 'NO' && data.country_code != 'DK' && data.country_code != 'FI' && data.country_code != 'SK' && data.country_code != 'CZ' ){
                $('#languageDialog').jqmShow();     
            }else{
                if ( data.country_code == 'NO' ) document.location.href = "http://www.aime.no?lang=norwegian";       
                if ( data.country_code == 'DK' ) document.location.href = "http://www.aime.no/_DK?lang=danish";
                if ( data.country_code == 'FI' ) document.location.href = "http://www.aime.fi?lang=finish";
                if ( data.country_code == 'CZ' ) document.location.href = "http://www.aime.cz?lang=czech";
                if ( data.country_code == 'SK' ) document.location.href = "http://www.aime.sk?lang=slovak";   
            } 
        },
        error: function(a,b,c){
            $('#languageDialog').jqmShow();
        }
     });
}
 
$('#languageDialog').find("a").live("mousedown keydown", function(){
    if ( $(this).attr("rel") == "norwegian") document.location.href = "http://www.aime.no?lang=norwegian";       
    if ( $(this).attr("rel") == "danish") document.location.href = "http://www.aime.no/_DK?lang=danish";
    if ( $(this).attr("rel") == "finish") document.location.href = "http://www.aime.fi?lang=finish";
    if ( $(this).attr("rel") == "czech") document.location.href = "http://www.aime.cz?lang=czech";
    if ( $(this).attr("rel") == "slovak") document.location.href = "http://www.aime.sk?lang=slovak";
})
 

 

/**
* Initialize default Ajax settings
*/
$.ajaxSetup({
    url: ServerUrl + '/index.php',
    type: 'get',
    contentType: "application/x-www-form-urlencoded; charset=utf-8",
    beforeSend:function(xhr) {}
})  



/**
* Handle "dummy" links
*/
$("a[href='#']").live("click", function(){ return false; } );



/**
* Initialize Terms and Condition  
*/
$('#conditionsDialog').jqm();
$(".showConditions").bind("mousedown", function(){
     $.ajax({
         url: ServerUrl + '/index.php',
         type: 'get',
         contentType: "application/x-www-form-urlencoded; charset=utf-8",
         data: { page: 'wsDocuments', file: 'betingelser.html', getType: 'partial' },
         success: function(data, textStatus, XMLHttpRequest) {
            $('#conditionsDialog').html(html_entity_decode( data ) );
            $('#conditionsDialog').jqmShow();  
        }
     });
});

                 
   

$('#wizardDialog').jqm();     
$(".CancelSubscription").live("mousedown", function(){
    $.ajax({
         url: ServerUrl + '/index.php',
         type: 'get',
         contentType: "application/x-www-form-urlencoded; charset=utf-8",
         data: { page: 'wsSubscription', tpl: 'Wizard', action: 'wizard', id: $(this).attr('name'), getType: 'partial' },
         success: function(data, textStatus, XMLHttpRequest) {
            $('#wizardDialog').html(html_entity_decode( data ) );
            $("#theForm").formwizard({ 
                     formPluginEnabled: true,
                     validationEnabled: false,
                     focusFirstInput : false,
                     textNext : Texts.Wizard.next,
                     textBack : Texts.Wizard.back,
                     textSubmit: Texts.Wizard.submit,
                     formOptions :{
                        contentType: "application/x-www-form-urlencoded; charset=utf-8",
                        data: { getType: 'json', action: 'cancel' },
                        success: function(data){
                            $.ajax({
                                url: '/index.php',
                                type: 'get',
                                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                                data: { page: 'wsAccount', tpl: 'Account(Subscriptions)',  getType: 'partial' },
                                success: function(data){
                                    $("div[name='SubscriptionsContainer']").html(data);  
                                    $('#wizardDialog').jqmHide(); 
                                }
                            })    
                        },
                        resetForm: true
                     }    
                 });
            $('#wizardDialog').jqmShow();  
        }
     });
    
});


/**
* Product slider
* Page: Main
*/
if ( $("#slider").length > 0 ){
    $("#slider").easySlider({
        continuous: true, 
        controlsShow: false,
        speed: 500,
        auto: true,
        pause: 4000
        });
}


/**
* Sets focus to username 
*/
$("input[name='Login[Username]']:last").focus().select();


/**
* Navigation Menu handlers
*/
if ( $("#navmenu").length > 0 ){

    //
    $("input[type='button'][class*='checkout']").live("click", function(){ document.location.href= ServerUrl + "/Checkout"; });
    $("input[type='button'][class*='checkoutconfirmed']").live("click", function(){ document.location.href= ServerUrl + "/Checkout/Confirmed"; });
        
    // Handler for items in Navmenu 
    $("#navmenu>ul>li").bind("click", function(){
        if ( $('#'+$(this).attr("name")+'Form').length > 0 ) {
         
            if ( $(this).is(".active") ){
                $(this).removeClass("active");   
                $('#'+$(this).attr("name")+'Form').hide();
            }else{ 
                $("#navmenu>ul>li").removeClass("active");
                $("#navmenu>.container").css({'display':'none'});
                $(this).addClass("active");   
                $('#'+$(this).attr("name")+'Form').css({'left' : $(this).find('a:first').position().left + 'px' }).show();
                $('#'+$(this).attr("name")+"Form input:visible:first").focus().select();
            }
        }
    } );
    
    // Checks if mousepointer is hoovering the navigation menu or not.
    $("#navmenu").mouseenter(function(){ navmenuIsActive = true; }).mouseleave(function(){ navmenuIsActive = false;});
    
    // Hide navboxes when click outside
    $("body").click( function(event) {
       if ( !navmenuIsActive ){
             $(".menu-nav > li").removeClass('active');
             $("#navmenu > .container").css({display : 'none'});
        }
    });
}

/**
* Searchbox handlers
*/
if ( $("#search_form").length > 0 ){
    $("#search_form > input")
        .focus(function() { if ($(this).val() == Texts.Search ) $(this).val(""); })
        .blur(function() { if ($(this).val() == "") $(this).val(Texts.Search);  })
        //.keypress( function(event) { $.console.log("TODO") } );
}




/**
*   Add Product To Basket 
*/
$(".AddToBasket,.ItemRemove").live('click', function(){
    var Quantity = $(this).prev().val();
    var obj = $(this);
    if( $(this).hasClass('ItemRemove') ){
        Quantity = 0; 
    }else{
        $(obj).addClass('cartadd');
    }
    $.ajax({
        data: {page: 'wsOrder', getType: 'partial', action: 'add', Aid: $(this).attr('name'), Quantity: Quantity },
        success: function(data, textStatus, XMLHttpRequest) {
            $("div[name='ShoppingCartContainer']").html(data);
            UpdateBasketStatus(true);
        },
        complete: function(){
            $(obj).removeClass('cartadd');
        }
    });
});

/**
* Empty basket
*/
$(".emptyBasket").live("click", function(){
    var objName = $(this).attr('name');
     $.ajax({
        data: {page: 'wsOrder', getType: 'partial', action: 'empty' },
        success: function(data, textStatus, XMLHttpRequest) {
            $("div[name='ShoppingCartContainer']").html(data);
            UpdateBasketStatus(true);
            if ( objName == 'CancelOrder' ){
                document.location.href = '/';
            }
        }
    });
});


/**
* Change Subscription Interval
*/
$(".ChangeSubscriptionInterval").live("change", function(){
    var objName = 'Partial' + $(this).attr('name');
    var objId = $(this).attr('title'); 
     $.ajax({
        data: {page: 'wsOrder', getType: 'partial', tpl: 'Checkout(OrderDetails)', SubId : objId, action: 'Interval', Interval : $(this).val()  },
        success: function(data, textStatus, XMLHttpRequest) {
            $("div[name='"+objName+"']").html('').html(data);
            UpdateBasketStatus(false);
        }
    });
});


/**
* Change existing subscription details
*/

// Update Interval
$(".ChangeAccountSubscriptionInterval").live("change", function(){
    var objName = 'Partial' + $(this).attr('name');
    var objId = $(this).attr('title'); 
     $.ajax({
        data: {page: 'wsSubscription', getType: 'partial', tpl: 'Account(Subscriptions)', id : objId, action: 'update', 'param[interval]' : $(this).val()  },
        success: function(data, textStatus, XMLHttpRequest) {
        }
    });
});

// Reactivate
$(".ActivateCustomerSubscription").live("mousedown", function(){
    var objId = $(this).attr('name'); 
     $.ajax({
        data: {page: 'wsSubscription', getType: 'partial', tpl: 'Account(Subscriptions)', id : objId, action: 'update', 'param[activate]' : true  },
        success: function(data, textStatus, XMLHttpRequest) {
            $("div[name='SubscriptionsContainer']").html(data);  
        }
    });
});




/**
* Mailinglist
*/
$("#MailinglistForm > input[type='button']").bind("click", function(){
    if ( $("#MailinglistForm").find("input[name='Email']").val().length < 5 || $("#MailinglistForm").find("input[name='Name']").val().length < 2 ){
        $("#MailinglistForm").find("div[class='status']").html('').html( Texts.Mailinglist.missing );
        return;   
    }
    
    req = $.ajax({
            dataType: 'json',
            data: {'method' : 'MailingList', 'getType' : 'json', 
                    'param[email]' : $("#MailinglistForm").find("input[name='Email']").val(),
                    'param[name]' : $("#MailinglistForm").find("input[name='Name']").val() },
            timeout: 2000,
            url: ServerUrl + '/RPC',
            success: function (Response) {
                if ( Response.status == 1 ){
                    $("#MailinglistForm").find("div[class='status']").html('').html( Texts.Mailinglist.added );
                    $("#MailinglistForm").find("input[name='Email']").val('');
                     $("#MailinglistForm").find("input[name='Name']").val('');
                }
                if ( Response.status == -1 ) $("#MailinglistForm").find("div[class='status']").html('').html( Texts.Mailinglist.invalid  );
                
            },
            error: function(){
                req.abort();
            }
        });    
})

/**
* New Customer
*/
$("#NewCustomerLink > a").bind('click', function(){ 
    $("#NewCustomer").show(); 
    $("#NewCustomer").find("input:first[type!='hidden']").delay(400).focus(); 
} );

/**
* Forgotten username/password
*/
$("#ResendEmailLink > a").bind('click', function(){
    $("#ResendEmail").show();
    $(this).html('<br />');
    $("#ResendEmail").find("input:first").focus();
})


/**
* Add Logout handler
*/
$("#LogoutDialog").jqm();
$("#LogoutDialog").find("input[type='button']:first").unbind("click mousedown").bind("click", function(){
    document.location.href = ServerUrl + "/Logout";    
})

$("#LogoutDialog").find("input[type='button']:last").bind("click", function(){
    document.location.href = ServerUrl + "/Checkout";    
})      

$(".menu-nav").find("li[name='AccountButton'] > a").bind("click", function(){
    if ( $("#navmenu").find("li[name='ShoppingCart']>a").html() == Texts.Basket.empty){
        document.location.href = ServerUrl + "/Logout";
    }else{
        $("#LogoutDialog").jqmShow();
    }  
});

$("#ResendEmail").find("input[type='button']").click(function(){
    if ( $("#ResendEmail").find("input:first").val().length > 3 ){

        req = $.ajax({
            dataType: 'json',
            data: {'method' : 'ResendPassword', 'getType' : 'json', 'param[email]' :$("#ResendEmail").find("input:first").val() },
            contentType: 'application/json; charset=utf-8',
            timeout: 2000,
            url: ServerUrl + '/RPC',
            success: function (Response) {
                if ( Response !== null ){
                    $("#ResendEmailMessage").html('').html(Texts.ResendPassword.invalidEmailAddress).show();
                    $("#ResendEmail").find('input:first').focus().select();
                }else{
                    var text = $.template(Texts.ResendPassword.success);
                    $("#ResendEmailMessage").html(text.apply({email: $("#ResendEmail").find("input:first").val()})).show();
                }
            },
            error: function(){
                $("#ResendPasswordContainer").find('input:first').focus().select(); 
                req.abort();
            }
        });

    }else{  
        $("#ResendPasswordErrorMessage").html('').html(Texts.ResendPassword.invalidEmailAddress);
        $("#ResendPasswordContainer").find('input:first').focus();
    }
});


if ( $("div[id='NewCustomer']").length > 0 ){
    var showuser = (typeof(PageQuery.showuser)=="undefined" ? 0 : 1);
    if ( showuser == 1 ) $("div[id='NewCustomer']").show(); 
    $("#NewCustomer").find("input:first[type!='hidden']").delay(400).focus(); 
}


/**
* Productinfo menu
* Page: Product
*/
$("#ReadMore").bind('click', function(){
    $("#productmenu .menu-product > li[name='ProductDescription']").mousedown().mouseup();  
    location.href="#ProductDescription";     
});

if ( $("#productmenu .menu-product > li").length > 0 ){
    $("#productmenu .menu-product > li").bind('mousedown', function(){
        $("#productmenu .menu-product > li").removeClass('active');
        //$(".ProductMenuTab").css({display: 'none'});
        $(".ProductMenuTab").hide();
        
        $(this).addClass('active');
        //$(".ProductMenuTab[name='"+$(this).attr('name')+"Container']").css({display: 'table'});
        $(".ProductMenuTab[name='"+$(this).attr('name')+"Container']").show();
    })
}



// Assign Subscibe handler
$(".AddSubscription").live("click", function(){
    var obj = $(this); 
    $.ajax({
        data: {page: 'wsOrder', getType: 'partial', action: 'subscription', Aid: $(this).attr('name') },
        success: function(data, textStatus, XMLHttpRequest) {
           $("div[name='ShoppingCartContainer']").html(data);
           UpdateBasketStatus(true);
        },
        complete: function(){
            $(obj).removeClass('cartadd');          
        }
});    
})

$(".Subscribe").live("click", function(){
    var obj = $(this);
    if ( $("table.subscriptiondetails > tbody > tr").length > 0 ){
        $("#productmenu > ul > li[name='ProductSubcriptions']").mousedown().mouseup();  
        var target_offset = $("#navigation").offset();
        var target_top = target_offset.top-350;
        $('html, body').animate({scrollTop:target_top}, 500);  
    }else{
        $(obj).addClass('cartadd');  
        $.ajax({
            data: {page: 'wsOrder', getType: 'partial', action: 'subscribe', Aid: $(this).attr('name') },
            success: function(data, textStatus, XMLHttpRequest) {
                $("div[name='ShoppingCartContainer']").html(data);
                UpdateBasketStatus(true);
            },
            complete: function(){
                $(obj).removeClass('cartadd');          
            }
        });
    }    
})


/**
* Myaccount menu
* Page: Account
*/
if ( $("#accountmenu .menu-product > li").length > 0 ){
    $("#accountmenu .menu-product > li").bind('mousedown', function(){
        $("#accountmenu .menu-product > li").removeClass('active');
        $(".accounttab").css({display: 'none'});
        
        $(this).addClass('active');
        $(".accounttab[name='"+$(this).attr('name')+"Container']").css({display: 'table'});
    })
}


$("#OrderDetailsDialog").jqm();
$("td[class='AccountOrderDetails'] > a").bind("click", function(){
    $.ajax({
        data: {page: 'wsOrderDetails', getType: 'partial', tpl: 'Account(OrderDetails)', Id: $(this).attr('name') },
        success: function(data, textStatus, XMLHttpRequest) {
            $("#OrderDetailsDialog").html('').html(data).jqmShow(); 
        }
    });
    
})

 
 

// Initiates the Subscription slider 

// Cycle hack for the slider
if ( $("#ma_liste > li").length > 0 ){
    $("#ma_liste").wslide({
                width: 180,
                height: 245,
                fade: true,
                duration: 2000
        });
        
    var SubscriptionItems = $("#ma_liste > li").length;
    var CurrentSubscriptionItem = 1;
    if ( SubscriptionItems > 0 ){
        
        window.setInterval(
            function(){
                
                CurrentSubscriptionItem = CurrentSubscriptionItem + 1;
                if ( CurrentSubscriptionItem > SubscriptionItems ){
                    CurrentSubscriptionItem = 1;    
                }
                
                $("#ma_liste-menu > A[href*='#ma_liste-"+CurrentSubscriptionItem+"']").click();
            }, 5000);
    }
}





/**
* Slideshow
*/
// Handler for Slideshow
if ( $("a[rel='ProductSlide']").length > 0 ){
    $("#imagecontainer").find('.large').bind( 'click', function(){
        $("a[rel='ProductSlide']:last").click();
    });
    $("a[rel='ProductSlide']").colorbox();
} 
 
 
 
      
} );





function getOffset( el ) {
    var _x = 0;
    var _y = 0;
    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
        _x += el.offsetLeft - el.scrollLeft;
        _y += el.offsetTop - el.scrollTop;
        el = el.parentNode;
    }
    return { top: _y, left: _x };
}




function setCookie(name, value){
    $.cookie( name, value, { path: '/', expires: 90 } );
}



function UpdateBasketStatus(blink){
    var NumOfProducts = $("#ShoppingCartForm").find("tr[class='BasketProduct']").length;
    var NumOfSubs = $("#ShoppingCartForm").find("tr[class='BasketSubscription']").length;
    var Text = Texts.Basket.empty;
    if ( NumOfProducts > 0 && NumOfSubs <= 0 ){
        if ( NumOfProducts >= 2){ 
            Text = Texts.Basket.Products.plural + Texts.Basket.joinIn + Texts.Basket.content;  
        }else{ 
            Text = Texts.Basket.Products.singular + Texts.Basket.joinIn + Texts.Basket.content; 
        }
    }else if( NumOfProducts <= 0 && NumOfSubs > 0 ){
        if ( NumOfSubs >= 2){ 
            Text = Texts.Basket.Subscriptions.plural + Texts.Basket.joinIn + Texts.Basket.content;  
        }else{ 
            Text = Texts.Basket.Subscriptions.singular + Texts.Basket.joinIn + Texts.Basket.content; 
        }
    }else if ( NumOfProducts == 1 && NumOfSubs == 1 ){
        Text = Texts.Basket.Products.singular + Texts.Basket.joinAnd + Texts.Basket.Subscriptions.singular + Texts.Basket.joinIn + Texts.Basket.content; 
    }else if ( NumOfProducts > 1 && NumOfSubs == 1 ){
        Text = Texts.Basket.Products.plural + Texts.Basket.joinAnd + Texts.Basket.Subscriptions.singular + Texts.Basket.joinIn + Texts.Basket.content;                 
    }else if ( NumOfProducts == 1 && NumOfSubs > 1 ){
        Text = Texts.Basket.Products.singular + Texts.Basket.joinAnd + Texts.Basket.Subscriptions.plural + Texts.Basket.joinIn + Texts.Basket.content;                 
    }else if ( NumOfProducts > 1 && NumOfSubs > 1 ){
        Text = Texts.Basket.Products.plural + Texts.Basket.joinAnd + Texts.Basket.Subscriptions.plural + Texts.Basket.joinIn + Texts.Basket.content;                 
    }

    if ( blink ){
        $("#navmenu").find("li[name='ShoppingCart']>a").html($.template(Text).apply({ProductQuantity: NumOfProducts, SubscriptionQuantity: NumOfSubs}))
            .fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400);
    }else{
        $("#navmenu").find("li[name='ShoppingCart']>a").html($.template(Text).apply({ProductQuantity: NumOfProducts, SubscriptionQuantity: NumOfSubs}));
    }
    if ( NumOfProducts > 0 || NumOfSubs > 0 ){
        $(".BasketText").html('<br>' + $.template(Text).apply({ProductQuantity: NumOfProducts, SubscriptionQuantity: NumOfSubs}))
    }
}



/**
* jQuery Logger
* v 0.1
* Author: QuickOla
*/
(function($) {
    $.console =
    {
        log: function(message) {
            //if('console' in window && 'log' in window.console)
            if (typeof window.console != 'undefined' && typeof window.console.log != 'undefined') {
                console.log(message);
            }
            else {
                //alert('console is not supported: ' + message);
            }
        },
        info : function(message) {
            // todo
        }
    }
})(jQuery);


/**
* HTML Entity Decode
*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('v r(b,6){e 4={},5={},g=0,7=\'\';e h={},9={};e 8={},d={};h[0]=\'j\';h[1]=\'f\';9[0]=\'p\';9[2]=\'u\';9[3]=\'o\';8=!q(b)?h[b]:b?b.m():\'j\';d=!q(6)?9[6]:6?6.m():\'u\';a(8!==\'j\'&&8!==\'f\'){1B 1A("1z: "+8+\' n 1y\')}4[\'38\']=\'&s;\';a(d!==\'p\'){4[\'34\']=\'&1C;\'}a(d===\'o\'){4[\'39\']=\'&#1D;\'}4[\'1H\']=\'&1G;\';4[\'1F\']=\'&1E;\';a(8===\'f\'){4[\'1x\']=\'&1w;\';4[\'1p\']=\'&1o;\';4[\'1n\']=\'&1l;\';4[\'1m\']=\'&1q;\';4[\'1r\']=\'&1v;\';4[\'1u\']=\'&1t;\';4[\'1s\']=\'&1I;\';4[\'1J\']=\'&20;\';4[\'1Z\']=\'&1Y;\';4[\'1X\']=\'&21;\';4[\'22\']=\'&26;\';4[\'25\']=\'&24;\';4[\'1k\']=\'&n;\';4[\'1W\']=\'&1V;\';4[\'1O\']=\'&1N;\';4[\'1M\']=\'&1K;\';4[\'1L\']=\'&1P;\';4[\'1Q\']=\'&1U;\';4[\'1T\']=\'&1S;\';4[\'1R\']=\'&27;\';4[\'Z\']=\'&N;\';4[\'M\']=\'&L;\';4[\'I\']=\'&K;\';4[\'O\']=\'&P;\';4[\'T\']=\'&S;\';4[\'R\']=\'&Q;\';4[\'U\']=\'&y;\';4[\'A\']=\'&B;\';4[\'z\']=\'&H;\';4[\'G\']=\'&F;\';4[\'E\']=\'&C;\';4[\'D\']=\'&J;\';4[\'1j\']=\'&1c;\';4[\'1b\']=\'&1a;\';4[\'19\']=\'&1d;\';4[\'1e\']=\'&1i;\';4[\'1h\']=\'&1g;\';4[\'1f\']=\'&18;\';4[\'V\']=\'&17;\';4[\'10\']=\'&Y;\';4[\'W\']=\'&X;\';4[\'11\']=\'&12;\';4[\'16\']=\'&15;\';4[\'14\']=\'&13;\';4[\'23\']=\'&2p;\';4[\'3o\']=\'&3n;\';4[\'3m\']=\'&3k;\';4[\'3l\']=\'&28;\';4[\'3p\']=\'&3q;\';4[\'3v\']=\'&3u;\';4[\'3t\']=\'&3r;\';4[\'3s\']=\'&3j;\';4[\'3i\']=\'&3a;\';4[\'37\']=\'&36;\';4[\'33\']=\'&35;\';4[\'3b\']=\'&3c;\';4[\'3h\']=\'&3g;\';4[\'3x\']=\'&3d;\';4[\'3e\']=\'&3w;\';4[\'3C\']=\'&3Q;\';4[\'3R\']=\'&3P;\';4[\'3O\']=\'&3M;\';4[\'3T\']=\'&3S;\';4[\'3U\']=\'&3X;\';4[\'3V\']=\'&3W;\';4[\'3N\']=\'&3K;\';4[\'3L\']=\'&3B;\';4[\'3A\']=\'&3y;\';4[\'3z\']=\'&3D;\';4[\'3E\']=\'&3J;\';4[\'3I\']=\'&3H;\';4[\'3F\']=\'&3G;\';4[\'3f\']=\'&31;\';4[\'2r\']=\'&2q;\';4[\'32\']=\'&2n;\';4[\'2o\']=\'&2s;\';4[\'2t\']=\'&2y;\';4[\'2x\']=\'&2w;\';4[\'2u\']=\'&2v;\';4[\'2m\']=\'&2l;\';4[\'2d\']=\'&2c;\';4[\'2b\']=\'&29;\';4[\'2a\']=\'&2e;\';4[\'2f\']=\'&2k;\';4[\'2j\']=\'&2i;\';4[\'2g\']=\'&2h;\';4[\'2z\']=\'&2A;\';4[\'2T\']=\'&2S;\';4[\'2R\']=\'&2P;\';4[\'2Q\']=\'&2U;\';4[\'2V\']=\'&30;\';4[\'2Z\']=\'&2Y;\';4[\'2W\']=\'&2X;\';4[\'2O\']=\'&2N;\';4[\'2F\']=\'&2E;\';4[\'2D\']=\'&2B;\'}w(g x 4){7=2C.2G(g);5[7]=4[g]}k 5}v 2H(t,6){e 5={},7=\'\',c=\'\',i=\'\';c=t.2M();a(l===(5=2L.r(\'f\',6))){k l}2K(5[\'&\']);5[\'&\']=\'&s;\';w(7 x 5){i=5[7];c=c.2I(i).2J(7)}k c}',62,246,'||||entities|histogram|quote_style|symbol|useTable|constMappingQuoteStyle|if|table|tmp_str|useQuoteStyle|var|HTML_ENTITIES|decimal|constMappingTable|entity|HTML_SPECIALCHARS|return|false|toUpperCase|not|ENT_QUOTES|ENT_NOQUOTES|isNaN|get_html_translation_table|amp|string|ENT_COMPAT|function|for|in|ordm|188|187|raquo|frac34|191|190|frac12|189|frac14|182|iquest|para|micro|181|acute|183|middot|sup1|185|cedil|184|186|198|200|Egrave|Ccedil|180|199|201|Eacute|Euml|203|Ecirc|202|AElig|Aring|194|Aacute|193|Agrave|Acirc|195|197|Auml|196|Atilde|192|172|cent|163|162|iexcl|161|pound|164|166|yen|165|curren|nbsp|160|supported|Table|Error|throw|quot|039|gt|62|lt|60|brvbar|167|macr|176|175|reg|174|deg|177|179|sup2|178|plusmn|shy|173|169|uml|168|sect|copy|170|204|laquo|171|ordf|sup3|Iuml|ntilde|242|241|eth|240|ograve|243|245|otilde|ocirc|244|oacute|iuml|239|ecirc|235|Igrave|eacute|233|euml|236|238|icirc|iacute|237|igrave|246|ouml|yuml|String|255|thorn|254|fromCharCode|html_entity_decode|split|join|delete|this|toString|yacute|253|oslash|249|248|divide|247|ugrave|250|252|uuml|ucirc|251|uacute|egrave|234|214||Ouml|Otilde|213|||Ocirc|215|times|Ugrave|218|232|Oslash|216|212|Oacute|Icirc|207|206|Iacute|205|208|ETH|Ograve|211|210|Ntilde|209|Uacute|217|atilde|228|227|acirc|219|auml|229|231|ccedil|aelig|230|aring|aacute|226|Yacute|225|221|Uuml|Ucirc|220|THORN|222|223|224|agrave|szlig'.split('|'),0,{}));

/**
 * wSlide 0.1 - http://www.webinventif.fr/wslide-plugin/
 * 
 * Rendez vos sites glissant !
 *
 * Copyright (c) 2008 Julien Chauvin (webinventif.fr)
 * Licensed under the Creative Commons License:
 * http://creativecommons.org/licenses/by/3.0/
 *
 * Date: 2008-01-27
 */
(function($){$.fn.wslide=function(h){h=jQuery.extend({width:150,height:150,pos:1,col:1,effect:'swing',fade:false,horiz:false,autolink:true,duration:1500},h);function gogogo(g){g.each(function(i){var a=$(this);var e=a.attr('id');if(e==undefined){e='wslide'+i}$(this).wrap('<div class="wslide-wrap" id="'+e+'-wrap"></div>');a=$('#'+e+'-wrap');var b=a.find('ul li');var f=h.effect;if(jQuery.easing.easeInQuad==undefined&&(f!='swing'||f!='normal')){f='swing'}var g=h.width;var j=h.height;function resultante(a){var b=a;b=b.split('px');b=b[0];return Number(b)}var k=g-(resultante(b.css('padding-left'))+resultante(b.css('padding-right')));var l=j-(resultante(b.css('padding-top'))+resultante(b.css('padding-bottom')));var m=h.col;if(h.horiz){m=Number(b.length+1)}var n='';var o=Math.ceil(Number(b.length)/m);a.css('overflow','hidden').css('position','relative').css('text-align','left').css('height',j+'px').css('width',g+'px').css('margin','0').css('padding','0');a.find('ul').css('position','absolute').css('margin','0').css('padding','0').css('width',Number((m+0)*g)+'px').css('height',Number(o*j)+'px');b.css('display','block').css('overflow','hidden').css('float','left').css('height',l+'px').css('width',k+'px');b.each(function(i){var b=a.offset();var c=$(this).offset();$(this).attr('id',e+'-'+Number(i+1)).attr('rel',Number(c.left-b.left)+':'+Number(c.top-b.top));n+=' <a href="#'+e+'-'+Number(i+1)+'">'+Number(i+1)+'</a>'});if(typeof h.autolink=='boolean'){if(h.autolink){a.after('<div class="wslide-menu" id="'+e+'-menu">'+n+'</div>')}}else if(typeof h.autolink=='string'){if($('#'+h.autolink).length){$('#'+h.autolink).html(n)}else{a.after('<div id="#'+h.autolink+'">'+n+'</div>')}}var p='#'+e+'-';var q="";$('a[href*="'+p+'"]').click(function(){$('a[href*="'+q+'"]').removeClass("wactive");$(this).addClass("wactive");var b=$(this).attr('href');b=b.split('#');b='#'+b[1];q=b;var c=$(b).attr('rel');c=c.split(':');var d=c[1];d=-d;c=c[0];c=-c;if(h.fade){a.find('ul').animate({opacity:0},h.duration/2,f,function(){$(this).css('top',d+'px').css('left',c+'px');$(this).animate({opacity:1},h.duration/2,f)})}else{a.find('ul').animate({top:d+'px',left:c+'px'},h.duration,f)}return false});if(h.pos<=0){h.pos=1}$('a[href$="'+p+h.pos+'"]').addClass("wactive");var r=$('a[href*="'+p+'"]:eq('+Number(h.pos-1)+')').attr('href');r=r.split('#');r='#'+r[1];q=r;var s=$(r).attr('rel');s=s.split(':');var t=s[1];t=-t;s=s[0];s=-s;a.find('ul').css('top',t+'px').css('left',s+'px')})}gogogo(this);return this}})(jQuery);


//(c) 2008 Michael Manning 
jQuery.parseQuery=function(A,B){var C=(typeof A==="string"?A:window.location.search),E={f:function(F){return unescape(F).replace(/\+/g," ")}},B=(typeof A==="object"&&typeof B==="undefined")?A:B,E=jQuery.extend({},E,B),D={};jQuery.each(C.match(/^\??(.*)$/)[1].split("&"),function(F,G){G=G.split("=");G[1]=E.f(G[1]);D[G[0]]=D[G[0]]?((D[G[0]] instanceof Array)?(D[G[0]].push(G[1]),D[G[0]]):[D[G[0]],G[1]]):G[1]});return D};

