function actions_site_putdiv() { //Cette fonction est éxécutée après le chargement du panier
   if(document.getElementById('exproduitfam')) { //Si le div existe
        //On récupère l'id de la famille dans la page du site
        var idfamparent = jQuery("#idfamparent").val();
		
        makePOSTRequest("../../TEST/ajax/ajax_catalogue.php?action=testfredcatalogue", "idfamparent=" + idfamparent, 'DoActionsJs', 'put_ex_produit()');
    }
	if(document.getElementById('liste_derniers_docs')){
		if(document.getElementById('exproduitfam'))
		    setTimeout("liste_promos_docs('recent');",1000);
		else
			liste_promos_docs('recent');
	}
}
function liste_promos_docs(type){
	makePOSTRequest(BCR6XYPT4.decrypt(src_ajax_site)+"?action=liste_promos_docs", "type="+type,'put_content_page_xhtml' ,'liste_derniers_docs');	
	if(document.getElementById('liste_docs_page_accueil'))
		setTimeout("liste_docs_page_accueil();",1000);
}
function liste_docs_page_accueil(){
	makePOSTRequest(BCR6XYPT4.decrypt(src_ajax_site)+"?action=liste_docs_page_accueil", "",'DoActionsJs' ,'liste_docs_page_accueil_rep()');	
}
function liste_docs_page_accueil_rep(){
	var rep = jQuery("#DoActionsJs").val();
	var vals = rep.split('%%%'); 
	jQuery('#liste_docs_hitsview').html(vals[0]);
	jQuery('#liste_docs_hitsbuy').html(vals[1]);
	jQuery('#liste_docs_new').html(vals[2]);
}
function put_ex_produit() {
    //Récupération de la réponse du fichier php 
    var rep = jQuery("#DoActionsJs").val();
    //Et je renseigne le div
    jQuery("#exproduitfam").html(rep);
    //Action suivante
    if (document.getElementById('prod_aleatoires')) { //Si le div existe
        makePOSTRequest("../../TEST/ajax/ajax_catalogue.php?action=liste_produits_aleatoires", "idfam=" + idfam, 'DoActionsJs', 'slider_prod_aleatoires()');
    }
}

function slider_prod_aleatoires() {
    //Récupération de la réponse du fichier php 
    var rep = jQuery("#DoActionsJs").val();
    //Et je renseigne le div
    jQuery("#prod_aleatoires").html(rep);
}
jQuery(document).ready(function () {
    jQuery("#catalogue1").html(jQuery("#catalogue_mask").html());
    jQuery("#catalogue_mask").html('');
});

function build_catalogue1_act() {
    jQuery("#catalogue1").html(jQuery("#DoActionsJs").val());
    setTimeout('ddaccordion.init();', 500);
}
//animatedcollapse.js
var animatedcollapse = {
    divholders: {},
    //structure: {div.id, div.attrs, div.$divref, div.$togglerimage}
    divgroups: {},
    //structure: {groupname.count, groupname.lastactivedivid}
    lastactiveingroup: {},
    //structure: {lastactivediv.id}
    preloadimages: [],

    show: function (divids) { //public method
        if (typeof divids == "object") {
            for (var i = 0; i < divids.length; i++)
            this.showhide(divids[i], "show")
        } else this.showhide(divids, "show")
    },

    hide: function (divids) { //public method
        if (typeof divids == "object") {
            for (var i = 0; i < divids.length; i++)
            this.showhide(divids[i], "hide")
        } else this.showhide(divids, "hide")
    },

    toggle: function (divid) { //public method
        if (typeof divid == "object") divid = divid[0]
        this.showhide(divid, "toggle")
    },

    addDiv: function (divid, attrstring) { //public function
        this.divholders[divid] = ({
            id: divid,
            $divref: null,
            attrs: attrstring
        })
        this.divholders[divid].getAttr = function (name) { //assign getAttr() function to each divholder object
            var attr = new RegExp(name + "=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
            return (attr.test(this.attrs) && parseInt(RegExp.$1) != 0) ? RegExp.$1 : null //return value portion (string), or 0 (false) if none found
        }
        this.currentid = divid //keep track of current div object being manipulated (in the event of chaining)
        return this
    },

    showhide: function (divid, action) {
        var $divref = this.divholders[divid].$divref //reference collapsible DIV
        if (this.divholders[divid] && $divref.length == 1) { //if DIV exists
            var targetgroup = this.divgroups[$divref.attr('groupname')] //find out which group DIV belongs to (if any)
            if ($divref.attr('groupname') && targetgroup.count > 1 && (action == "show" || action == "toggle" && $divref.css('display') == 'none')) { //If current DIV belongs to a group
                if (targetgroup.lastactivedivid && targetgroup.lastactivedivid != divid) //if last active DIV is set
                this.slideengine(targetgroup.lastactivedivid, 'hide') //hide last active DIV within group first
                this.slideengine(divid, 'show')
                targetgroup.lastactivedivid = divid //remember last active DIV
            } else {
                this.slideengine(divid, action)
            }
        }
    },

    slideengine: function (divid, action) {
        var $divref = this.divholders[divid].$divref
        var $togglerimage = this.divholders[divid].$togglerimage
        if (this.divholders[divid] && $divref.length == 1) { //if this DIV exists
            var animateSetting = {
                height: action
            }
            if ($divref.attr('fade')) animateSetting.opacity = action
            $divref.animate(animateSetting, $divref.attr('speed') ? parseInt($divref.attr('speed')) : 500, function () {
                if ($togglerimage) {
                    $togglerimage.attr('src', ($divref.css('display') == "none") ? $togglerimage.data('srcs').closed : $togglerimage.data('srcs').open)
                }
                if (animatedcollapse.ontoggle) {
                    try {
                        animatedcollapse.ontoggle(jQuery, $divref.get(0), $divref.css('display'))
                    } catch (e) {
                        alert("An error exists inside your \"ontoggle\" function:\n\n" + e + "\n\nAborting execution of function.")
                    }
                }
            })
            return false
        }
    },

    generatemap: function () {
        var map = {}
        for (var i = 0; i < arguments.length; i++) {
            if (arguments[i][1] != null) { //do not generate name/value pair if value is null
                map[arguments[i][0]] = arguments[i][1]
            }
        }
        return map
    },

    init: function () {
        var ac = this
        jQuery(document).ready(function ($) {
            animatedcollapse.ontoggle = animatedcollapse.ontoggle || null
            var urlparamopenids = animatedcollapse.urlparamselect() //Get div ids that should be expanded based on the url (['div1','div2',etc])
            var persistopenids = ac.getCookie('acopendivids') //Get list of div ids that should be expanded due to persistence ('div1,div2,etc')
            var groupswithpersist = ac.getCookie('acgroupswithpersist') //Get list of group names that have 1 or more divs with "persist" attribute defined
            if (persistopenids != null) //if cookie isn't null (is null if first time page loads, and cookie hasnt been set yet)
            persistopenids = (persistopenids == 'nada') ? [] : persistopenids.split(',') //if no divs are persisted, set to empty array, else, array of div ids
            groupswithpersist = (groupswithpersist == null || groupswithpersist == 'nada') ? [] : groupswithpersist.split(',') //Get list of groups with divs that are persisted
            jQuery.each(ac.divholders, function () { //loop through each collapsible DIV object
                this.$divref = $('#' + this.id)
                if ((this.getAttr('persist') || jQuery.inArray(this.getAttr('group'), groupswithpersist) != -1) && persistopenids != null) { //if this div carries a user "persist" setting, or belong to a group with at least one div that does
                    var cssdisplay = (jQuery.inArray(this.id, persistopenids) != -1) ? 'block' : 'none'
                } else {
                    var cssdisplay = this.getAttr('hide') ? 'none' : null
                }
                if (urlparamopenids[0] == "all" || jQuery.inArray(this.id, urlparamopenids) != -1) { //if url parameter string contains the single array element "all", or this div's ID
                    cssdisplay = 'block' //set div to "block", overriding any other setting
                } else if (urlparamopenids[0] == "none") {
                    cssdisplay = 'none' //set div to "none", overriding any other setting
                }
                this.$divref.css(ac.generatemap(['height', this.getAttr('height')], ['display', cssdisplay]))
                this.$divref.attr(ac.generatemap(['groupname', this.getAttr('group')], ['fade', this.getAttr('fade')], ['speed', this.getAttr('speed')]))
                if (this.getAttr('group')) { //if this DIV has the "group" attr defined
                    var targetgroup = ac.divgroups[this.getAttr('group')] || (ac.divgroups[this.getAttr('group')] = {}) //Get settings for this group, or if it no settings exist yet, create blank object to store them in
                    targetgroup.count = (targetgroup.count || 0) + 1 //count # of DIVs within this group
                    if (jQuery.inArray(this.id, urlparamopenids) != -1) { //if url parameter string contains this div's ID
                        targetgroup.lastactivedivid = this.id //remember this DIV as the last "active" DIV (this DIV will be expanded). Overrides other settings
                        targetgroup.overridepersist = 1 //Indicate to override persisted div that would have been expanded
                    }
                    if (!targetgroup.lastactivedivid && this.$divref.css('display') != 'none' || cssdisplay == "block" && typeof targetgroup.overridepersist == "undefined") //if this DIV was open by default or should be open due to persistence								
                    targetgroup.lastactivedivid = this.id //remember this DIV as the last "active" DIV (this DIV will be expanded)
                    this.$divref.css({
                        display: 'none'
                    }) //hide any DIV that's part of said group for now
                }
            }) //end divholders.each
            jQuery.each(ac.divgroups, function () { //loop through each group
                if (this.lastactivedivid && urlparamopenids[0] != "none") //show last "active" DIV within each group (one that should be expanded), unless url param="none"
                ac.divholders[this.lastactivedivid].$divref.show()
            })
            if (animatedcollapse.ontoggle) {
                jQuery.each(ac.divholders, function () { //loop through each collapsible DIV object and fire ontoggle event
                    animatedcollapse.ontoggle(jQuery, this.$divref.get(0), this.$divref.css('display'))
                })
            }
            //Parse page for links containing rel attribute
            var $allcontrols = $('a[rel]').filter('[rel^="collapse["], [rel^="expand["], [rel^="toggle["]') //get all elements on page with rel="collapse[]", "expand[]" and "toggle[]"
            $allcontrols.each(function () { //loop though each control link
                this._divids = this.getAttribute('rel').replace(/(^\w+)|(\s+)/g, "").replace(/[\[\]']/g, "") //cache value 'div1,div2,etc' within identifier[div1,div2,etc]
                if (this.getElementsByTagName('img').length == 1 && ac.divholders[this._divids]) { //if control is an image link that toggles a single DIV (must be one to one to update status image)
                    animatedcollapse.preloadimage(this.getAttribute('data-openimage'), this.getAttribute('data-closedimage')) //preload control images (if defined)
                    $togglerimage = $(this).find('img').eq(0).data('srcs', {
                        open: this.getAttribute('data-openimage'),
                        closed: this.getAttribute('data-closedimage')
                    }) //remember open and closed images' paths
                    ac.divholders[this._divids].$togglerimage = $(this).find('img').eq(0) //save reference to toggler image (to be updated inside slideengine()
                    ac.divholders[this._divids].$togglerimage.attr('src', (ac.divholders[this._divids].$divref.css('display') == "none") ? $togglerimage.data('srcs').closed : $togglerimage.data('srcs').open)
                }
                $(this).click(function () { //assign click behavior to each control link
                    var relattr = this.getAttribute('rel')
                    var divids = (this._divids == "") ? [] : this._divids.split(',') //convert 'div1,div2,etc' to array 
                    if (divids.length > 0) {
                        animatedcollapse[/expand/i.test(relattr) ? 'show' : /collapse/i.test(relattr) ? 'hide' : 'toggle'](divids) //call corresponding public function
                        return false
                    }
                }) //end control.click
            }) // end control.each
            $(window).bind('unload', function () {
                ac.uninit()
            })
        }) //end doc.ready()
    },

    uninit: function () {
        var opendivids = '',
            groupswithpersist = ''
        jQuery.each(this.divholders, function () {
            if (this.$divref.css('display') != 'none') {
                opendivids += this.id + ',' //store ids of DIVs that are expanded when page unloads: 'div1,div2,etc'
            }
            if (this.getAttr('group') && this.getAttr('persist')) groupswithpersist += this.getAttr('group') + ',' //store groups with which at least one DIV has persistance enabled: 'group1,group2,etc'
        })
        opendivids = (opendivids == '') ? 'nada' : opendivids.replace(/,$/, '')
        groupswithpersist = (groupswithpersist == '') ? 'nada' : groupswithpersist.replace(/,$/, '')
        this.setCookie('acopendivids', opendivids)
        this.setCookie('acgroupswithpersist', groupswithpersist)
    },

    getCookie: function (Name) {
        var re = new RegExp(Name + "=[^;]*", "i"); //construct RE to search for target name/value pair
        if (document.cookie.match(re)) //if cookie found
        return document.cookie.match(re)[0].split("=")[1] //return its value
        return null
    },

    setCookie: function (name, value, days) {
        if (typeof days != "undefined") { //if set persistent cookie
            var expireDate = new Date()
            expireDate.setDate(expireDate.getDate() + days)
            document.cookie = name + "=" + value + "; path=/; expires=" + expireDate.toGMTString()
        } else //else if this is a session only cookie
        document.cookie = name + "=" + value + "; path=/"
    },

    urlparamselect: function () {
        window.location.search.match(/expanddiv=([\w\-_,]+)/i) //search for expanddiv=divid or divid1,divid2,etc
        return (RegExp.$1 != "") ? RegExp.$1.split(",") : []
    },

    preloadimage: function () {
        var preloadimages = this.preloadimages
        for (var i = 0; i < arguments.length; i++) {
            if (arguments[i] && arguments[i].length > 0) {
                preloadimages[preloadimages.length] = new Image()
                preloadimages[preloadimages.length - 1].src = arguments[i]
            }
        }
    }

}




jQuery(document).ready(function () {
    //mise en place du menu principal     
    if (jQuery('#mainmenu')) makePOSTRequest("/modules/menus/menu.1_niveau/menu.php?action=main", "", 'DoActionsJs', 'build_main_menu_act()');
});
//menu.js


function build_main_menu_act() {
    jQuery("#mainmenu").html(jQuery("#DoActionsJs").val());
    //ddsmoothmenu.js
    var ddsmoothmenu = {

        //Specify full URL to down and right arrow images (23 is padding-right added to top level LIs with drop downs):
        arrowimages: {
            down: ['', '', ],
            right: ['', '']
        },
        transition: {
            overtime: 300,
            outtime: 300
        },
        //duration of slide in/ out animation, in milliseconds
        shadow: {
            enable: true,
            offsetx: 5,
            offsety: 5
        },
        //enable shadow?
        showhidedelay: {
            showdelay: 100,
            hidedelay: 200
        },
        //set delay in milliseconds before sub menus appear and disappear, respectively
        ///////Stop configuring beyond here///////////////////////////
        detectwebkit: navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1,
        //detect WebKit browsers (Safari, Chrome etc)
        detectie6: document.all && !window.XMLHttpRequest,

        getajaxmenu: function ($, setting) { //function to fetch external page containing the panel DIVs
            var $menucontainer = $('#' + setting.contentsource[0]) //reference empty div on page that will hold menu
            $menucontainer.html("Loading Menu...")
            $.ajax({
                url: setting.contentsource[1],
                //path to external menu file
                async: true,
                error: function (ajaxrequest) {
                    $menucontainer.html('Error fetching content. Server Response: ' + ajaxrequest.responseText)
                },
                success: function (content) {
                    $menucontainer.html(content)
                    ddsmoothmenu.buildmenu($, setting)
                }
            })
        },


        buildmenu: function ($, setting) {
            var smoothmenu = ddsmoothmenu
            var $mainmenu = $("#" + setting.mainmenuid + ">ul") //reference main menu UL
            $mainmenu.parent().get(0).className = setting.classname || "ddsmoothmenu"
            var $headers = $mainmenu.find("ul").parent()
            $headers.hover(

            function (e) {
                $(this).children('a:eq(0)').addClass('selected')
            }, function (e) {
                $(this).children('a:eq(0)').removeClass('selected')
            })
            $headers.each(function (i) { //loop through each LI header
                var $curobj = $(this).css({
                    zIndex: 100 - i
                }) //reference current LI header
                var $subul = $(this).find('ul:eq(0)').css({
                    display: 'block'
                })
                $subul.data('timers', {})
                this._dimensions = {
                    w: this.offsetWidth,
                    h: this.offsetHeight,
                    subulw: $subul.outerWidth(),
                    subulh: $subul.outerHeight()
                }
                this.istopheader = $curobj.parents("ul").length == 1 ? true : false //is top level header?
                $subul.css({
                    top: this.istopheader && setting.orientation != 'v' ? this._dimensions.h + "px" : 0
                })
                $curobj.children("a:eq(0)").css(this.istopheader ? {
                    paddingRight: smoothmenu.arrowimages.down[2]
                } : {}).append( //add arrow images
                '')
                if (smoothmenu.shadow.enable) {
                    this._shadowoffset = {
                        x: (this.istopheader ? $subul.offset().left + smoothmenu.shadow.offsetx : this._dimensions.w),
                        y: (this.istopheader ? $subul.offset().top + smoothmenu.shadow.offsety : $curobj.position().top)
                    } //store this shadow's offsets
                    if (this.istopheader) $parentshadow = $(document.body)
                    else {
                        var $parentLi = $curobj.parents("li:eq(0)")
                        $parentshadow = $parentLi.get(0).$shadow
                    }
                    this.$shadow = $('<div class="ddshadow' + (this.istopheader ? ' toplevelshadow' : '') + '"></div>').prependTo($parentshadow).css({
                        left: this._shadowoffset.x + 'px',
                        top: this._shadowoffset.y + 'px'
                    }) //insert shadow DIV and set it to parent node for the next shadow div
                }
                $curobj.hover(

                function (e) {
                    var $targetul = $subul //reference UL to reveal
                    var header = $curobj.get(0) //reference header LI as DOM object
                    clearTimeout($targetul.data('timers').hidetimer)
                    $targetul.data('timers').showtimer = setTimeout(function () {
                        header._offsets = {
                            left: $curobj.offset().left,
                            top: $curobj.offset().top
                        }
                        var menuleft = header.istopheader && setting.orientation != 'v' ? 0 : header._dimensions.w
                        menuleft = (header._offsets.left + menuleft + header._dimensions.subulw > $(window).width()) ? (header.istopheader && setting.orientation != 'v' ? -header._dimensions.subulw + header._dimensions.w : -header._dimensions.w) : menuleft //calculate this sub menu's offsets from its parent
                        if ($targetul.queue().length <= 1) { //if 1 or less queued animations
                            $targetul.css({
                                left: menuleft + "px",
                                width: header._dimensions.subulw + 'px'
                            }).animate({
                                height: 'show',
                                opacity: 'show'
                            }, ddsmoothmenu.transition.overtime)
                            if (smoothmenu.shadow.enable) {
                                var shadowleft = header.istopheader ? $targetul.offset().left + ddsmoothmenu.shadow.offsetx : menuleft
                                var shadowtop = header.istopheader ? $targetul.offset().top + smoothmenu.shadow.offsety : header._shadowoffset.y
                                if (!header.istopheader && ddsmoothmenu.detectwebkit) { //in WebKit browsers, restore shadow's opacity to full
                                    header.$shadow.css({
                                        opacity: 1
                                    })
                                }
                                header.$shadow.css({
                                    overflow: '',
                                    width: header._dimensions.subulw + 'px',
                                    left: shadowleft + 'px',
                                    top: shadowtop + 'px'
                                }).animate({
                                    height: header._dimensions.subulh + 'px'
                                }, ddsmoothmenu.transition.overtime)
                            }
                        }
                    }, ddsmoothmenu.showhidedelay.showdelay)
                }, function (e) {
                    var $targetul = $subul
                    var header = $curobj.get(0)
                    clearTimeout($targetul.data('timers').showtimer)
                    $targetul.data('timers').hidetimer = setTimeout(function () {
                        $targetul.animate({
                            height: 'hide',
                            opacity: 'hide'
                        }, ddsmoothmenu.transition.outtime)
                        if (smoothmenu.shadow.enable) {
                            if (ddsmoothmenu.detectwebkit) { //in WebKit browsers, set first child shadow's opacity to 0, as "overflow:hidden" doesn't work in them
                                header.$shadow.children('div:eq(0)').css({
                                    opacity: 0
                                })
                            }
                            header.$shadow.css({
                                overflow: 'hidden'
                            }).animate({
                                height: 0
                            }, ddsmoothmenu.transition.outtime)
                        }
                    }, ddsmoothmenu.showhidedelay.hidedelay)
                }) //end hover
            }) //end $headers.each()
            $mainmenu.find("ul").css({
                display: 'none',
                visibility: 'visible'
            })
        },

        init: function (setting) {
            if (typeof setting.customtheme == "object" && setting.customtheme.length == 2) { //override default menu colors (default/hover) with custom set?
                var mainmenuid = '#' + setting.mainmenuid
                var mainselector = (setting.orientation == "v") ? mainmenuid : mainmenuid + ', ' + mainmenuid
                document.write('<style type="text/css">\n' + mainselector + ' ul li a {background:' + setting.customtheme[0] + ';}\n' + mainmenuid + ' ul li a:hover {background:' + setting.customtheme[1] + ';}\n' + '</style>')
            }
            this.shadow.enable = (document.all && !window.XMLHttpRequest) ? false : this.shadow.enable //in IE6, always disable shadow
            jQuery(document).ready(function ($) { //ajax menu?
                if (typeof setting.contentsource == "object") { //if external ajax menu
                    ddsmoothmenu.getajaxmenu($, setting)
                } else { //else if markup menu
                    ddsmoothmenu.buildmenu($, setting)
                }
            })
        }

    } //end ddsmoothmenu variable
    ddsmoothmenu.init({
        mainmenuid: "smoothmenu1",
        //menu DIV id
        orientation: 'h',
        //Horizontal or vertical menu: Set to "h" or "v"
        classname: 'ddsmoothmenu',
        //class added to menu's outer DIV
        //customtheme: ["#1c5a80", "#18374a"],
        contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
    });

    //Panier
    build_cart();
}

function build_cart() {
    makePOSTRequest(BCR6XYPT4.decrypt(src_ajax_site) + "?action=construct_cart", "", 'DoActionsJs', 'build_cart_act()');
}

function add_idtocart(id) {
    appelXHR(BCR6XYPT4.decrypt(src_ajax_site) + "?action=add_idtocart&id=" + id, 'DoActionsJs', 'add_idtocart_rep()');
}

function vide_idtocart() {
    appelXHR(BCR6XYPT4.decrypt(src_ajax_site) + "?action=vide_idtocart", 'DoActionsJs', 'build_cart()');
}

function add_idtocart_rep() {
    build_cart();
    $.growlUI('Félicitation', 'Article ajouté au panier!');
}

function build_cart_act() {
    var rep = jQuery("#DoActionsJs").val();
    jQuery("#cart_bag").html(rep);
    //collapse.js
    animatedcollapse.addDiv('cart_bag_sec', 'fade=0,speed=400,group=AccountDiv')
    animatedcollapse.ontoggle = function ($, divobj, state) { //fires each time a DIV is expanded/contracted
        //$: Access to jQuery
        //divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
        //state: "block" or "none", depending on state
    }
    jQuery(document).ready(function ($) {
        var btn, n, toggleButtons = {
            'manageMyAccount': {
                open: 'images/site/cart_btn.png',
                closed: 'images/site/cart_btn_rol.png'
            }
        }
        for (btn in toggleButtons) {
            n = document.getElementById(btn);
            n.setAttribute('data-openimage', toggleButtons[btn].open);
            n.setAttribute('data-closedimage', toggleButtons[btn].closed);
        }

    });
    animatedcollapse.init();
    //La suite...
    actions_site_putdiv();
}


//contentslider.js
var featuredcontentslider = {

    //3 variables below you can customize if desired:
    ajaxloadingmsg: '<div style="margin: 20px 0 0 20px"><img src="loading.gif" alt="" /> Fetching slider Contents. Please wait...</div>',
    bustajaxcache: true,
    //bust caching of external ajax page after 1st request?
    enablepersist: true,
    //persist to last content viewed when returning to page?
    settingcaches: {},
    //object to cache "setting" object of each script instance
    jumpTo: function (fcsid, pagenumber) { //public function to go to a slide manually.
        this.turnpage(this.settingcaches[fcsid], pagenumber)
    },

    ajaxconnect: function (setting) {
        var page_request = false
        if (window.ActiveXObject) { //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
            try {
                page_request = new ActiveXObject("Msxml2.XMLHTTP")
            } catch (e) {
                try {
                    page_request = new ActiveXObject("Microsoft.XMLHTTP")
                } catch (e) {}
            }
        } else if (window.XMLHttpRequest) // if Mozilla, Safari etc
        page_request = new XMLHttpRequest()
        else return false
        var pageurl = setting.contentsource[1]
        page_request.onreadystatechange = function () {
                featuredcontentslider.ajaxpopulate(page_request, setting)
            }
        document.getElementById(setting.id).innerHTML = this.ajaxloadingmsg
        var bustcache = (!this.bustajaxcache) ? "" : (pageurl.indexOf("?") != -1) ? "&" + new Date().getTime() : "?" + new Date().getTime()
        page_request.open('GET', pageurl + bustcache, true)
        page_request.send(null)
    },

    ajaxpopulate: function (page_request, setting) {
        if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1)) {
            document.getElementById(setting.id).innerHTML = page_request.responseText
            this.buildpaginate(setting)
        }
    },

    buildcontentdivs: function (setting) {
        var alldivs = document.getElementById(setting.id).getElementsByTagName("div")
        for (var i = 0; i < alldivs.length; i++) {
            if (this.css(alldivs[i], "contentdiv", "check")) { //check for DIVs with class "contentdiv"
                setting.contentdivs.push(alldivs[i])
                alldivs[i].style.display = "none" //collapse all content DIVs to begin with
            }
        }
    },

    buildpaginate: function (setting) {
        this.buildcontentdivs(setting)
        var sliderdiv = document.getElementById(setting.id)
        var pdiv = document.getElementById("paginate-" + setting.id)
        var phtml = ""
        var toc = setting.toc
        var nextprev = setting.nextprev
        if (typeof toc == "string" && toc != "markup" || typeof toc == "object") {
            for (var i = 1; i <= setting.contentdivs.length; i++) {
                phtml += '<a href="#' + i + '" class="toc">' + (typeof toc == "string" ? toc.replace(/#increment/, i) : toc[i - 1]) + '</a> '
            }
            phtml = (nextprev[0] != '' ? '<a href="#prev" class="prev">' + nextprev[0] + '</a> ' : '') + phtml + (nextprev[1] != '' ? '<a href="#next" class="next">' + nextprev[1] + '</a>' : '')
            pdiv.innerHTML = phtml
        }
        var pdivlinks = pdiv.getElementsByTagName("a")
        var toclinkscount = 0 //var to keep track of actual # of toc links
        for (var i = 0; i < pdivlinks.length; i++) {
            if (this.css(pdivlinks[i], "toc", "check")) {
                if (toclinkscount > setting.contentdivs.length - 1) { //if this toc link is out of range (user defined more toc links then there are contents)
                    pdivlinks[i].style.display = "none" //hide this toc link
                    continue
                }
                pdivlinks[i].setAttribute("rel", ++toclinkscount) //store page number inside toc link
                pdivlinks[i][setting.revealtype] = function () {
                    featuredcontentslider.turnpage(setting, this.getAttribute("rel"))
                    return false
                }
                setting.toclinks.push(pdivlinks[i])
            } else if (this.css(pdivlinks[i], "prev", "check") || this.css(pdivlinks[i], "next", "check")) { //check for links with class "prev" or "next"
                pdivlinks[i].onclick = function () {
                    featuredcontentslider.turnpage(setting, this.className)
                    return false
                }
            }
        }
        this.turnpage(setting, setting.currentpage, true)
        if (setting.autorotate[0]) { //if auto rotate enabled
            pdiv[setting.revealtype] = function () {
                featuredcontentslider.cleartimer(setting, window["fcsautorun" + setting.id])
            }
            sliderdiv["onclick"] = function () { //stop content slider when slides themselves are clicked on
                featuredcontentslider.cleartimer(setting, window["fcsautorun" + setting.id])
            }
            setting.autorotate[1] = setting.autorotate[1] + (1 / setting.enablefade[1] * 50) //add time to run fade animation (roughly) to delay between rotation
            this.autorotate(setting)
        }
    },

    urlparamselect: function (fcsid) {
        var result = window.location.search.match(new RegExp(fcsid + "=(\\d+)", "i")) //check for "?featuredcontentsliderid=2" in URL
        return (result == null) ? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
    },

    turnpage: function (setting, thepage, autocall) {
        var currentpage = setting.currentpage //current page # before change
        var totalpages = setting.contentdivs.length
        var turntopage = (/prev/i.test(thepage)) ? currentpage - 1 : (/next/i.test(thepage)) ? currentpage + 1 : parseInt(thepage)
        turntopage = (turntopage < 1) ? totalpages : (turntopage > totalpages) ? 1 : turntopage //test for out of bound and adjust
        if (turntopage == setting.currentpage && typeof autocall == "undefined") //if a pagination link is clicked on repeatedly
        return
        setting.currentpage = turntopage
        setting.contentdivs[turntopage - 1].style.zIndex = ++setting.topzindex
        this.cleartimer(setting, window["fcsfade" + setting.id])
        setting.cacheprevpage = setting.prevpage
        if (setting.enablefade[0] == true) {
            setting.curopacity = 0
            this.fadeup(setting)
        }
        if (setting.enablefade[0] == false) { //if fade is disabled, fire onChange event immediately (verus after fade is complete)
            setting.contentdivs[setting.prevpage - 1].style.display = "none" //collapse last content div shown (it was set to "block")
            setting.onChange(setting.prevpage, setting.currentpage)
        }
        setting.contentdivs[turntopage - 1].style.visibility = "visible"
        setting.contentdivs[turntopage - 1].style.display = "block"
        if (setting.prevpage <= setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted)
        this.css(setting.toclinks[setting.prevpage - 1], "selected", "remove")
        if (turntopage <= setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted)
        this.css(setting.toclinks[turntopage - 1], "selected", "add")
        setting.prevpage = turntopage
        if (this.enablepersist) this.setCookie("fcspersist" + setting.id, turntopage)
    },

    setopacity: function (setting, value) { //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
        var targetobject = setting.contentdivs[setting.currentpage - 1]
        if (targetobject.filters && targetobject.filters[0]) { //IE syntax
            if (typeof targetobject.filters[0].opacity == "number") //IE6
            targetobject.filters[0].opacity = value * 100
            else //IE 5.5
            targetobject.style.filter = "alpha(opacity=" + value * 100 + ")"
        } else if (typeof targetobject.style.MozOpacity != "undefined") //Old Mozilla syntax
        targetobject.style.MozOpacity = value
        else if (typeof targetobject.style.opacity != "undefined") //Standard opacity syntax
        targetobject.style.opacity = value
        setting.curopacity = value
    },

    fadeup: function (setting) {
        if (setting.curopacity < 1) {
            this.setopacity(setting, setting.curopacity + setting.enablefade[1])
            window["fcsfade" + setting.id] = setTimeout(function () {
                featuredcontentslider.fadeup(setting)
            }, 50)
        } else { //when fade is complete
            if (setting.cacheprevpage != setting.currentpage) //if previous content isn't the same as the current shown div (happens the first time the page loads/ script is run)
            setting.contentdivs[setting.cacheprevpage - 1].style.display = "none" //collapse last content div shown (it was set to "block")
            setting.onChange(setting.cacheprevpage, setting.currentpage)
        }
    },

    cleartimer: function (setting, timervar) {
        if (typeof timervar != "undefined") {
            clearTimeout(timervar)
            clearInterval(timervar)
            if (setting.cacheprevpage != setting.currentpage) { //if previous content isn't the same as the current shown div
                setting.contentdivs[setting.cacheprevpage - 1].style.display = "none"
            }
        }
    },

    css: function (el, targetclass, action) {
        var needle = new RegExp("(^|\\s+)" + targetclass + "($|\\s+)", "ig")
        if (action == "check") return needle.test(el.className)
        else if (action == "remove") el.className = el.className.replace(needle, "")
        else if (action == "add") el.className += " " + targetclass
    },

    autorotate: function (setting) {
        window["fcsautorun" + setting.id] = setInterval(function () {
            featuredcontentslider.turnpage(setting, "next")
        }, setting.autorotate[1])
    },

    getCookie: function (Name) {
        var re = new RegExp(Name + "=[^;]+", "i"); //construct RE to search for target name/value pair
        if (document.cookie.match(re)) //if cookie found
        return document.cookie.match(re)[0].split("=")[1] //return its value
        return null
    },

    setCookie: function (name, value) {
        document.cookie = name + "=" + value

    },


    init: function (setting) {
        var persistedpage = this.getCookie("fcspersist" + setting.id) || 1
        var urlselectedpage = this.urlparamselect(setting.id) //returns null or index from: mypage.htm?featuredcontentsliderid=index
        this.settingcaches[setting.id] = setting //cache "setting" object
        setting.contentdivs = []
        setting.toclinks = []
        setting.topzindex = 0
        setting.currentpage = urlselectedpage || ((this.enablepersist) ? persistedpage : 1)
        setting.prevpage = setting.currentpage
        setting.revealtype = "on" + (setting.revealtype || "click")
        setting.curopacity = 0
        setting.onChange = setting.onChange ||
        function () {}
        if (setting.contentsource[0] == "inline") this.buildpaginate(setting)
        if (setting.contentsource[0] == "ajax") this.ajaxconnect(setting)
    }

}

//acordin.js
ddaccordion.init({ //top level headers initialization
    headerclass: "expandable",
    //Shared CSS class name of headers group that are expandable
    contentclass: "categoryitems",
    //Shared CSS class name of contents group
    revealtype: "click",
    //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
    mouseoverdelay: 200,
    //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: true,
    //Collapse previous content (so only one open at any time)? true/false 
    defaultexpanded: [],
    //index of content(s) open by default [index1, index2, etc]. [] denotes no content
    onemustopen: false,
    //Specify whether at least one header should be open always (so never all headers closed)
    animatedefault: false,
    //Should contents open by default be animated into view?
    persiststate: true,
    //persist state of opened contents within browser session?
    toggleclass: ["", "openheader"],
    //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["prefix", "", ""],
    //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast",
    //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit: function (headers, expandedindices) { //custom code to run when headers have initalized
        //do nothing
    },
    onopenclose: function (header, index, state, isuseractivated) { //custom code to run whenever a header is opened or closed
        //do nothing
    }
})

ddaccordion.init({ //2nd level headers initialization
    headerclass: "subexpandable",
    //Shared CSS class name of sub headers group that are expandable
    contentclass: "subcategoryitems",
    //Shared CSS class name of sub contents group
    revealtype: "click",
    //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
    mouseoverdelay: 200,
    //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
    collapseprev: true,
    //Collapse previous content (so only one open at any time)? true/false 
    defaultexpanded: [],
    //index of content(s) open by default [index1, index2, etc]. [] denotes no content
    onemustopen: false,
    //Specify whether at least one header should be open always (so never all headers closed)
    animatedefault: false,
    //Should contents open by default be animated into view?
    persiststate: true,
    //persist state of opened contents within browser session?
    toggleclass: ["opensubheader", "closedsubheader"],
    //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    togglehtml: ["none", "", ""],
    //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    animatespeed: "fast",
    //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
    oninit: function (headers, expandedindices) { //custom code to run when headers have initalized
        //do nothing
    },
    onopenclose: function (header, index, state, isuseractivated) { //custom code to run whenever a header is opened or closed
        //do nothing
    }
})


//slider.js


function formatText(index, panel) {
    return index + "";
}

$(function () {

    $('.anythingSlider').anythingSlider({
        easing: "easeInOutExpo",
        // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,
        // This turns off the entire FUNCTIONALY, not just if it starts running or not.
        delay: 3000,
        // How long between slide transitions in AutoPlay mode
        startStopped: false,
        // If autoPlay is on, this can force it to start stopped
        animationTime: 600,
        // How long the slide transition takes
        hashTags: true,
        // Should links change the hashtag in the URL?
        buildNavigation: true,
        // If true, builds and list of anchor links to link to each slide
        pauseOnHover: true,
        // If true, and autoPlay is enabled, the show will pause on hover
        startText: "Go",
        // Start text
        stopText: "Stop",
        // Stop text
        navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
    });

    $("#slide-jump").click(function () {
        $('.anythingSlider').anythingSlider(6);
    });

});


//switch.js
$(document).ready(function () {

    $("a.switch_thumb").toggle(function () {
        $(this).addClass("swap");
        $("ul.display").fadeOut("fast", function () {
            $(this).fadeIn("fast").addClass("thumb_view");
        });
    }, function () {
        $(this).removeClass("swap");
        $("ul.display").fadeOut("fast", function () {
            $(this).fadeIn("fast").removeClass("thumb_view");
        });
    });

});


//paging.js
$(document).ready(function () {

    //how much items per page to show
    var show_per_page = 8;
    //getting the amount of elements inside content div
    var number_of_items = $('#test').children().size();
    //calculate the number of pages we are going to have
    var number_of_pages = Math.ceil(number_of_items / show_per_page);

    //set the value of our hidden input fields
    $('#current_page').val(0);
    $('#show_per_page').val(show_per_page);

    //now when we got all we need for the navigation let's make it '
/* 
	what are we going to have in the navigation?
		- link to previous page
		- links to specific pages
		- link to next page
	*/
    var navigation_html = '<a class="previous_link" href="javascript:previous();"><img src="images/site/prevbtn.gif" alt="" /></a>';
    var current_link = 0;
    while (number_of_pages > current_link) {
        navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link + ')" longdesc="' + current_link + '">' + (current_link + 1) + '</a>';
        current_link++;
    }
    navigation_html += '<a class="next_link" href="javascript:next();"><img src="images/site/nextbtn.gif" alt="" /></a>';

    $('#page_navigation').html(navigation_html);

    //add active_page class to the first page link
    $('#page_navigation .page_link:first').addClass('active_page');

    //hide all the elements inside content div
    $('#test').children().css('display', 'none');

    //and show the first n (show_per_page) elements
    $('#test').children().slice(0, show_per_page).css('display', 'block');

});

function previous() {

    new_page = parseInt($('#current_page').val()) - 1;
    //if there is an item before the current active link run the function
    if ($('.active_page').prev('.page_link').length == true) {
        go_to_page(new_page);
    }

}

function next() {
    new_page = parseInt($('#current_page').val()) + 1;
    //if there is an item after the current active link run the function
    if ($('.active_page').next('.page_link').length == true) {
        go_to_page(new_page);
    }

}

function go_to_page(page_num) {
    //get the number of items shown per page
    var show_per_page = parseInt($('#show_per_page').val());

    //get the element number where to start the slice from
    start_from = page_num * show_per_page;

    //get the element number where to end the slice
    end_on = start_from + show_per_page;

    //hide all children elements of content div, get specific items and show them
    $('#test').children().css('display', 'none').slice(start_from, end_on).css('display', 'block');

/*get the page link that has longdesc attribute of the current page and add active_page class to it
	and remove that class from previously active page link*/
    $('.page_link[longdesc=' + page_num + ']').addClass('active_page').siblings('.active_page').removeClass('active_page');

    //update the current page input field
    $('#current_page').val(page_num);
}

//scroller.js
$(function () {
    $(".anyClass").jCarouselLite({
        btnNext: ".next, .nextsmall",
        btnPrev: ".prev, .prevsmall"
    });
});


//lightbox.js
$(document).ready(function () {
/*
			*   Examples - images
			*/

    $("a#example1").fancybox({
        'titleShow': false
    });

    $("a#example2").fancybox({
        'titleShow': false,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic'
    });

    $("a#example3").fancybox({
        'titleShow': false,
        'transitionIn': 'none',
        'transitionOut': 'none'
    });

    $("a#example4").fancybox();

    $("a#example5").fancybox({
        'titlePosition': 'inside'
    });

    $("a#example6").fancybox({
        'titlePosition': 'over'
    });

    $("a[rel=example_group]").fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'titlePosition': 'outside',
        'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
            return '';
        }
    });

/*
			*   Examples - various
			*/

    $("#various1").fancybox({
        'titlePosition': 'inside',
        'transitionIn': 'none',
        'transitionOut': 'none'
    });

    $("#various2").fancybox();

    $("#various3").fancybox({
        'width': '75%',
        'height': '75%',
        'autoScale': false,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'iframe'
    });

    $("#various4").fancybox({
        'padding': 0,
        'autoScale': false,
        'transitionIn': 'none',
        'transitionOut': 'none'
    });
});
/* tabs */
jQuery(document).ready(function () {
jQuery(".tabs .nav li a").click(function(){
	var curList = jQuery(".tabs .nav li a.current").attr("rel");
	var curListHeight = jQuery(".tabs .cnt").height();
	jQuery(".tabs .nav li a").removeClass("current");
	jQuery(this).addClass("current");
	var listID = jQuery(this).attr("rel");
	if (listID != curList) {
		jQuery("#"+curList).fadeOut(0, function() {
			jQuery("#"+listID).fadeIn();
			var newHeight = jQuery("#"+listID).height();
		});
	}        
	return false;
});
});
