var is_opera =  navigator.userAgent.indexOf('Opera') > -1;
var is_safari = navigator.userAgent.indexOf('AppleWebKit/') > -1;
var ie6 = false;
var ie7 = false;
var ie8 = false;


var default_field_text = {
    form_elements: [{element_id:'search-term', element_value:'UpiÅ¡i pojam'}, {element_id:'newsletter-email',element_value:'UpiÅ¡ite e-mail za prijavu'}, {element_id:'media-contact-name', element_value:'UpiÅ¡ite VaÅ¡e ime'}, {element_id:'media-contact-email', element_value:'UpiÅ¡ite VaÅ¡ e-mail'}, {element_id:'media-contact-message', element_value:'UpiÅ¡ite poruku'}],
    setup: function() {
        var il = this.form_elements.length;
        for(var i = 0; i < il; i++) {
            var current_element = $(this.form_elements[i]['element_id']);
            if(current_element) {
                Event.observe(current_element, 'focus',this.focusListener.bind(this));
                Event.observe(current_element, 'blur',this.blurListener.bind(this));
            }
        }
    },
    
    focusListener: function(e){
        
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase()=='img') {
            event_target = event_target.parentNode;
        }
        if(event_target.value != '') {
            var target_id = event_target.getAttribute('id');
            var default_value = this.getFieldValue(target_id);
            if(event_target.value == default_value) {
                event_target.value = '';
            }
        }
    },
    
    blurListener: function(e){
        
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase()=='img') {
            event_target = event_target.parentNode;
        }
        if(event_target.value == '') {
            var target_id = event_target.getAttribute('id');
            var default_value = this.getFieldValue(target_id);
            event_target.value = default_value;
        }
    },
    
    getFieldValue: function(target_id) {
        var result = null;

        var il = this.form_elements.length;
        for(var i = 0; i < il; i++) {
            var current_element = this.form_elements[i]['element_id'];
            if(current_element == target_id) {
                result = this.form_elements[i]['element_value']
            }
        }
        return result;
        
    }
}

var color_code_range = {

    handle: function(rating_type) {
        
        if(rating_type == 'reviews-featured') {
             var current_items = $('main-content').select('.reviews-featured .rating');
        } else if(rating_type == 'review-rating') {
             var current_items = $('rating-container').select('.total');
        } else if(rating_type == 'readers-reviews') {
             var current_items = $('readers-reviews').select('.total');
        }
        

        var jl = current_items.length;
        for(var j = 0; j < jl; j++) {
            current_rating = current_items[j].cloneNode(true);
            $(current_rating).select('span')[0].remove();
            var current_value = parseInt(current_rating.firstChild.nodeValue);

            if(current_value < 20) {
                $(current_items[j]).addClassName('rating-0-20');
            } else if(current_value >= 20 && current_value < 40) {
                $(current_items[j]).addClassName('rating-20-40');
            } else if(current_value >= 40 && current_value < 60) {
                $(current_items[j]).addClassName('rating-40-60');
            } else if(current_value >= 60 && current_value < 80) {
                $(current_items[j]).addClassName('rating-60-80');
            } else if(current_value >= 80 && current_value <= 100) {
                $(current_items[j]).addClassName('rating-80-100');
            }
        }
            
    }
}

var navigation_handler = {
    container: null,
    last: null,
    items: [],
    last_depth: 0,
    show_smooth_expanding: true,
    
    handle: function() {
        this.container = $('navigation');
        if(!this.container) return;
        this.items = $(this.container).select('a');
        var il = this.items.length;
        for(var i = 0; i < il; i++) {
            var current_item = this.items[i];
                Event.observe(current_item,'mouseover',this.mouseoverListener.bind(this));
        }
        
        var bd = document.getElementsByTagName('body')[0];
        Event.observe(bd,'mouseover',this.bodyListener.bind(this));
        
    },
    
    bodyListener: function(e) {
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase()=='img') {
            event_target = event_target.parentNode;
        }
        
        var obj = event_target;
        while(obj != this.container){
            obj = obj.parentNode;
            if(obj.nodeName.toLowerCase()=='html'){
                this.hideAll();
                obj = null;
                break;
            }
        }
    },
    
    hideAll: function() {
        var all_expanded_lis = $(this.container).select('.expanded');
        var il = all_expanded_lis.length;
        for(var i = 0; i < il; i++) {
            $(all_expanded_lis[i]).removeClassName('expanded');
        }
        this.cleanFirstLevel();
    },
    
    cleanFirstLevel: function() {
        var first_level_li = $(this.container).select('.first-childhomepage-expanded','.homepage-expanded','.user-expanded','.encyclopedia-expanded', '.reviews-expanded', '.auctions-expanded', '.comics-expanded', '.forum-expanded');
        var il = first_level_li.length;
        for(var i = 0; i < il; i++) {
           
			//debugger;
			$(first_level_li[i]).removeClassName('first-childhomepage-expanded');
			$(first_level_li[i]).removeClassName('homepage-expanded');
			$(first_level_li[i]).removeClassName('encyclopedia-expanded');
            $(first_level_li[i]).removeClassName('reviews-expanded');
            $(first_level_li[i]).removeClassName('auctions-expanded');
            $(first_level_li[i]).removeClassName('comics-expanded');
            $(first_level_li[i]).removeClassName('forum-expanded');
			$(first_level_li[i]).removeClassName('user-expanded');
        }
		        
    },
    
    mouseoverListener: function(e){
        Event.stop(e);
 
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase()=='img') {
            event_target = event_target.parentNode;
        }
        
        if(event_target.nodeName.toLowerCase() == 'a' && event_target.parentNode.className.indexOf('-expanded') != -1) {
            return;
        }
        
        var all_expanded_lis = $(this.container).select('.expanded');

        var obj = event_target;
        var depth = 0;
        while(obj != this.container){
            obj = obj.parentNode;
            if(obj.nodeName.toLowerCase() == 'li') {
                
                depth++;
                
                if(!$(obj).hasClassName('expanded')) {
                    var related_subnav = $(obj).select('ul')[0];
                    
                    if(related_subnav) {
                        if(this.show_smooth_expanding) {
                            $(related_subnav).setStyle({'opacity': '0.01'})
                            Effect.Appear(related_subnav, {duration: 0.8, from: 0.5, to: 0.9999});
                        }
                        $(obj).addClassName('expanded');
                        
                        var obj_class = obj.className;
                        //var is_first_level = obj_class.indexOf('homepage') != -1 || obj_class.indexOf('encyclopedia') != -1 || obj_class.indexOf('reviews') != -1 || obj_class.indexOf('auctions') != -1 || obj_class.indexOf('comics') != -1 || obj_class.indexOf('forum') != -1;
						var is_first_level = obj_class.indexOf('homepage') != -1 || obj_class.indexOf('user') != -1|| obj_class.indexOf('encyclopedia') != -1 || obj_class.indexOf('reviews') != -1 || obj_class.indexOf('auctions') != -1 || obj_class.indexOf('comics') != -1 || obj_class.indexOf('forum') != -1;
			
                        if(is_first_level) {
                            this.cleanFirstLevel();
                            var node_type = obj_class.replace('first-child', '');
                                node_type = obj_class.replace('expanded', '');
                                node_type = node_type.replace('last-child', '');
                                node_type = node_type.replace('active', '');
                                node_type = node_type.replace('selected', '');
                                node_type = node_type.replace(/ /gi,'')
                            $(obj).addClassName(node_type + '-expanded');
                        }
                        
                    }
                }
            }
            
			/*if(obj.nodeName.toLowerCase()=='iframe'){
				aler(obj.length);
				if (ie6) {
					var parent_ul_height =  $(obj).up('ul');	
					if (obj.length > 0) {
						obj.style.height = parent_ul_height.getHeight() + 'px';
						obj.style.width = parent_ul_height.getHeight()+ 'px';
					//iframe.height(0).width(0);
					}
				}
			}*/
			
            if(obj.nodeName.toLowerCase()=='html'){
                obj = null;
                break;
            }
        }     
        
        if((ie6 || ie7) && depth == 2 && related_subnav) {
            var parent_ul_height = $(related_subnav).up('ul');
            parent_ul_height.style.height = 'auto';
            parent_ul_height.style.height = related_subnav.offsetHeight + parent_ul_height.offsetHeight + 'px';
        }
		
		/*if(ie6 && related_subnav) {
			var parent_ul_height = $(related_subnav).up('ul');
			var iframe = parent_ul_height.select('iframe');
			//alert (iframe.length);
			if (iframe.length > 0) {
				iframe.height = parent_ul_height.getHeight();
				iframe.width = parent_ul_height.getWidth();
				//alert(iframe.height + " " + iframe.width);
			//iframe.height(0).width(0);
			} 
		} */
		
        if(all_expanded_lis[depth-1]) {
            $(all_expanded_lis[depth-1]).removeClassName('expanded');
        }

        this.last_depth = depth;
        
    }
}


var search_filter =  {
    container: null,
    items: [],
    
    handle: function(url_param) {
        this.container = $('filter');
        if(!this.container) return;
        
        var ul = document.createElement('ul');
        this.items = $(this.container).select('option');
        var il = this.items.length;
        var default_selection = null;

        var form_action = $(this.container).select('form')[0].getAttribute('action');
        

        for(var i = 0; i < il; i++) {
            var current_item = this.items[i];
            var current_li = document.createElement('li')
            var current_a = document.createElement('a')
                current_a.setAttribute('href', form_action + (form_action == '/' ? '?' : '&amp;') + url_param + '=' + current_item.getAttribute('value'));        
            var current_a_txt = document.createTextNode(current_item.firstChild.nodeValue);

                if(current_item.selected) {
                    var default_selection = current_item.firstChild ? current_item.firstChild.nodeValue : '';
                    $(current_li).addClassName('active');
                }
            
                current_a.appendChild(current_a_txt);
                current_li.appendChild(current_a);
                ul.appendChild(current_li);
                
                Event.observe(current_a, 'click', this.changeListener.bind(this));
        }
        
        $(this.container).select('form')[0].remove();
        $(this.container).appendChild(ul);

        var selection_p = document.createElement('p');
            selection_p.className += 'selection';
        var selection_p_txt = document.createTextNode(default_selection || 'Odabir');
            selection_p.appendChild(selection_p_txt);
            
        var toggle_p = document.createElement('p');
            toggle_p.className += 'toggle';
        
        var toggle_a = document.createElement('a');
            toggle_a.setAttribute('href', '#');
        var toggle_img = document.createElement('img');
            toggle_img.setAttribute('src', '/images/layout/arrow-expand.png');
            toggle_img.setAttribute('alt', 'otvori / zatvori');
            toggle_a.appendChild(toggle_img);
            toggle_p.appendChild(toggle_a);
            Event.observe(toggle_a, 'click', this.clickListener.bind(this));
            
            $(this.container).addClassName('collapsed');
            $(ul).insert({before:selection_p});
            $(ul).insert({before:toggle_p});

            var bd = document.getElementsByTagName('body')[0];
            Event.observe(bd,'click',this.bodyListener.bind(this));
    },
    
    bodyListener: function(e) {
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase()=='img') {
            event_target = event_target.parentNode;
        }

        var obj = event_target;
        while(obj != this.container){
            obj = obj.parentNode;
            if(obj.nodeName.toLowerCase()=='html'){
                if(!$(this.container).hasClassName('collapsed')) {
                    this.toggle();
                }
                obj = null;
                break;
            }
        }
    },

    clickListener: function(e){
        Event.stop(e);
        this.toggle();
    },
    
    toggle: function() {
        $(this.container).toggleClassName('collapsed');
        var ul = $(this.container).select('ul')[0];
        
        $(ul).setStyle({'opacity': '0.01'})
        Effect.Appear(ul, {duration: 0.8, from: 0.5, to: 0.9999});
        
        var toggle_img = $(this.container).select('.toggle img')[0];
        var current_src = toggle_img.getAttribute('src');
        if(current_src.indexOf('expand') != -1) {
            var new_src = current_src.replace('expand', 'collapse');
        } else {
            var new_src = current_src.replace('collapse', 'expand');
        }
        toggle_img.setAttribute('src', new_src);
    },
    
    changeListener: function(e){
        Event.stop(e);
        var event_target = window.event ? window.event.srcElement : e.target;
        this.makeSelection(event_target);
    },
    
    makeSelection: function(event_target) {
        var current_label = event_target.firstChild.nodeValue;
        $(this.container).select('.selection')[0].firstChild.nodeValue = current_label;
        this.toggle();
        document.location = event_target.getAttribute('href').replace('&amp;', '&');
    }
    
}


var pagination =  {
    container: null,
    items: [],
    
    handle: function() {
        this.container = $('pagination');
        if(!this.container) return;
        
        var ul = document.createElement('ul');
        this.items = $(this.container).select('option');
        var il = this.items.length;
        var default_selection = null;
        
        var form_action = $(this.container).select('form')[0].getAttribute('action');
        
        for(var i = 0; i < il; i++) {
            var current_item = this.items[i];
            var current_li = document.createElement('li')
            var current_a = document.createElement('a')
                current_a.setAttribute('href', form_action + (form_action == '/' ? '?' : '&amp;') +'page-no=' + current_item.getAttribute('value'));
            var current_a_txt = document.createTextNode(current_item.firstChild.nodeValue);

            if(current_item.selected) {
                var default_selection = current_item.firstChild ? current_item.firstChild.nodeValue : '';
                $(current_li).addClassName('active');
            }
                            
            current_a.appendChild(current_a_txt);
            current_li.appendChild(current_a);
            ul.appendChild(current_li);
            
            Event.observe(current_a, 'click', this.changeListener.bind(this));
        }
        
       $(this.container).select('form')[0].remove();
        $(this.container).appendChild(ul);

        var selection_p = document.createElement('p');
            selection_p.className += 'selection';
        var selection_p_txt = document.createTextNode(default_selection || 'Odabir');
            selection_p.appendChild(selection_p_txt);
            
        var toggle_p = document.createElement('p');
            toggle_p.className += 'toggle';
        
        var toggle_a = document.createElement('a');
            toggle_a.setAttribute('href', '#');
        var toggle_img = document.createElement('img');
            toggle_img.setAttribute('src', '/images/layout/arrow-expand.png');
            toggle_img.setAttribute('alt', 'otvori / zatvori');
            toggle_a.appendChild(toggle_img);
            toggle_p.appendChild(toggle_a);
            Event.observe(toggle_a, 'click', this.clickListener.bind(this));
            
            $(this.container).addClassName('collapsed');
            $(ul).insert({before:selection_p});
            $(ul).insert({before:toggle_p});

       var prev_p = document.createElement('p');
            prev_p.className += 'prev';
        var prev_a_txt = document.createTextNode('< Prethodna');
        var prev_a = document.createElement('a');
            prev_a.setAttribute('href', '#');
            prev_a.appendChild(prev_a_txt);
            prev_p.appendChild(prev_a);

        var next_p = document.createElement('p');
            next_p.className += 'next';
        var next_a_txt = document.createTextNode('Sljedeæa >');
        var next_a = document.createElement('a');
            next_a.setAttribute('href', '#');
            next_a.appendChild(next_a_txt);
            next_p.appendChild(next_a);       
           
           //$(this.container).insert({top:next_p});
           //$(this.container).insert({top:prev_p});
                        
            var bd = document.getElementsByTagName('body')[0];
            Event.observe(bd,'click',this.bodyListener.bind(this));
    },
    
    bodyListener: function(e) {
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase()=='img') {
            event_target = event_target.parentNode;
        }

        var obj = event_target;
        while(obj != this.container){
            obj = obj.parentNode;
            if(obj.nodeName.toLowerCase()=='html'){
                if(!$(this.container).hasClassName('collapsed')) {
                    this.toggle();
                }
                obj = null;
                break;
            }
        }
    },
    
    clickListener: function(e){
        Event.stop(e);
        this.toggle();
    },
    
    toggle: function() {
        $(this.container).toggleClassName('collapsed');
        var ul = $(this.container).select('ul')[0];
        
        var offset_x = $(this.container).select('.selection')[0].offsetLeft;
        
        $(ul).setStyle({'opacity': '0.01'})
        ul.style.left = offset_x + 'px';
        Effect.Appear(ul, {duration: 0.8, from: 0.5, to: 0.9999});
        
        
        var toggle_img = $(this.container).select('.toggle img')[0];
        var current_src = toggle_img.getAttribute('src');
        if(current_src.indexOf('expand') != -1) {
            var new_src = current_src.replace('expand', 'collapse');
        } else {
            var new_src = current_src.replace('collapse', 'expand');
        }
        toggle_img.setAttribute('src', new_src);
    },

    changeListener: function(e){

        Event.stop(e);
        var event_target = window.event ? window.event.srcElement : e.target;
        this.makeSelection(event_target);
        
    },
    
    makeSelection: function(event_target) {
        var current_label = event_target.firstChild.nodeValue;
        $(this.container).select('.selection')[0].firstChild.nodeValue = current_label;
        this.toggle();
        document.location = event_target.getAttribute('href').replace('&amp;', '&');
    }
    
}

var poll_results = {
    container: null, 
    items: [],
    track_width: 600,
    
    handle: function() {
        this.container = $('poll-results');
        if(!this.container) return;
        
        this.items = $(this.container).select('strong');
        var il = this.items.length;
        for(var i = 0; i < il; i++) {
            var current_item = this.items[i];
            var current_value = parseInt(current_item.firstChild.nodeValue);
            var position = Math.round(((100-current_value)/100) * this.track_width);
            var track = $(current_item).up('span');
                track.style.backgroundPosition = -position + 'px 0';
                
            if(current_value < 7) {
                $(track).addClassName('value-' + current_value);
            }
        }
        
    }
}

var poll_results2 = {
    container: null, 
    items: [],
    track_width: 180,

    handle: function() {
        this.container = $('poll-results2');
        if(!this.container) return;
        
        this.items = $(this.container).select('strong');
        var il = this.items.length;
        for(var i = 0; i < il; i++) {
            var current_item = this.items[i];
            var current_value = parseInt(current_item.firstChild.nodeValue);
            var position = Math.round(((100-current_value)/100) * this.track_width)+420;
            var track = $(current_item).up('span');
                track.style.backgroundPosition = -position + 'px 0';
                
            if (current_value <= 5) {
                $(track).addClassName('value-5');
            } else if (current_value >5 && current_value<= 10) {
                $(track).addClassName('value-10');
            } else if (current_value >10 && current_value<= 15) {
                $(track).addClassName('value-15');
            } else if (current_value >15 && current_value<= 20) {
                $(track).addClassName('value-20');
            }
			
			if(current_value < 20) {
				width=5+ current_value;
				// $(current_item).setAttribute('style', 'margin-left:' + width +'px;');
            }
        }
        
    }
}


   
var row_link = {
    container: null,

    handle: function(container_id) {
        this.container = $(container_id);
        if(!this.container) return;
        
        var trs = $(this.container).select('tbody tr');
        var il = trs.length;
        for(var i = 0; i < il; i++) {
            var current_row = trs[i];
                Event.observe(current_row,'click',this.clickListener.bind(this));
        }

    },
    
    clickListener: function(e){
        var event_target = window.event ? window.event.srcElement : e.target;
        
        if(event_target.nodeName.toLowerCase() != 'a') {
            
            if(event_target.nodeName.toLowerCase()=='img') {
                event_target = event_target.parentNode;
            }
            
            this.toggle(event_target);
        }
        
    },
    
    toggle: function(event_target) {
        var parent_tr = $(event_target).up('tr');
        if(!parent_tr) return;
        
        var related_a = $(parent_tr).select('a')[0];
        if(related_a) {
            window.location = related_a.getAttribute('href');
        }
    }
    
}

var dl_link = {
    container: null,

    handle: function() {
        this.container = $('top-content-container');
        if(!this.container) return;
        
        $(this.container).addClassName('hit-area');
        
        var lis = $(this.container).select('li');

        var il = lis.length;
        for(var i = 0; i < il; i++) {
            var current_li = lis[i];
                Event.observe(current_li,'click',this.clickListener.bind(this));
        }

    },
    
    clickListener: function(e){
        var event_target = window.event ? window.event.srcElement : e.target;
        
        if(event_target.nodeName.toLowerCase() !='a') {
            
            if(event_target.nodeName.toLowerCase()=='img') {
                event_target = event_target.parentNode;
            }
            
            this.toggle(event_target);
        }
        
    },
    
    toggle: function(event_target) {
        var parent_li = $(event_target).up('li');
        if(!parent_li) return;
        
        var related_a = $(parent_li).select('a')[0];
        if(related_a) {
            window.location = related_a.getAttribute('href');
        }
    }
    
}







var toggler = Class.create();
toggler.prototype=  {
    container: null,
    items: [],
    last: null,
    
    initialize: function(container_id) {


        this.container = $(container_id);
        if(!this.container) return;
        
        $(this.container).addClassName('loaded')
        
        this.items = $(this.container).select('.section');
        var il = this.items.length;
        
        for(var i = 0; i <il; i++) {
            var current_section = this.items[i];
            var section_heading = $(current_section).select('h3')[0];
            var heading_text = section_heading.firstChild.nodeValue;
            
            var heading_a = document.createElement('a')
                heading_a.setAttribute('href', '#');
                heading_a.appendChild(document.createTextNode(heading_text));
                
                section_heading.firstChild.nodeValue = '';
                section_heading.appendChild(heading_a);
                Event.observe(heading_a, 'click', this.clickListener.bindAsEventListener(this), false);
            
            if($(current_section).hasClassName('active')) {
                this.last = current_section;
            }
            
         }
   },
   

   clickListener: function(e) {

        Event.stop(e);

        var event = window.event ? window.event : e;
        var eventTarget = event.srcElement ? event.srcElement :  event.target;
        if(eventTarget.nodeName.toLowerCase() == 'img') {
            eventTarget = eventTarget.parentNode;
        }
        
        this.toggle(eventTarget);
   },
   
   toggle:function(eventTarget) {
    
        var related_section = $(eventTarget).up('.section');
        var related_ul = $(related_section).select('ul')[0];
        
        if($(related_section).hasClassName('active')) {
            Effect.BlindUp(related_ul, { duration: 0.5 });
            setTimeout(function(){ $(related_section).removeClassName('active')}, 500);
        } else {
            $(related_section).addClassName('active');
            related_ul.style.display = 'none';
            Effect.BlindDown(related_ul, { duration: 0.5 });
        }
        
        if(this.last != null && this.last != related_section) {
            var o = this;
            var last_ul = $(this.last).select('ul')[0];
            Effect.BlindUp(last_ul, { duration: 0.5 });
            setTimeout(function(){ $(last_ul).up('.section').removeClassName('active')}, 500);            
        }
        
        this.last = related_section;
   }
}


var default_field_text = {
    form_elements: [{element_id:'Title', element_value:'Pretražite aukcije'},{element_id:'UserTitle', element_value:'Pretražite korisnike'},{element_id:'search-term', element_value:'Pretražite www.stripovi.com'}, {element_id:'login-username',element_value:'Korisnièko ime'}, {element_id:'login-password', element_value:'Lozinka'}],
    setup: function() {
        var il = this.form_elements.length;
        for(var i = 0; i < il; i++) {
            var current_element = $(this.form_elements[i]['element_id']);
            if(current_element) {
                Event.observe(current_element, 'focus',this.focusListener.bind(this));
                Event.observe(current_element, 'blur',this.blurListener.bind(this));
            }
        }
    },
    
    focusListener: function(e){
        
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase()=='img') {
            event_target = event_target.parentNode;
        }
        if(event_target.value != '') {
            var target_id = event_target.getAttribute('id');
            var default_value = this.getFieldValue(target_id);
            if(event_target.value == default_value) {
                event_target.value = '';
            }
        }
    },
    
    blurListener: function(e){
        
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase()=='img') {
            event_target = event_target.parentNode;
        }
        if(event_target.value == '') {
            var target_id = event_target.getAttribute('id');
            var default_value = this.getFieldValue(target_id);
            event_target.value = default_value;
        }
    },
    
    getFieldValue: function(target_id) {
        var result = null;

        var il = this.form_elements.length;
        for(var i = 0; i < il; i++) {
            var current_element = this.form_elements[i]['element_id'];
            if(current_element == target_id) {
                result = this.form_elements[i]['element_value']
            }
        }
        return result;
        
    }
    
}


var dhtml_select = Class.create();
dhtml_select.prototype=  {

    container: null,
    items: [],
    original_select: null,
    
    initialize: function(original_select, select_index) {
        
        if(!original_select) return;
        this.original_select = original_select;
        
        this.container = document.createElement('div');
        $(this.container).addClassName('select-container');
        $(this.container).setAttribute('id', 'select-' + original_select.getAttribute('id'));
        $(this.container).style.zIndex = select_index;
        
        var ul = document.createElement('ul');
        this.items = $(this.original_select).select('option');
        var il = this.items.length;
        var default_selection = null;
        
        for(var i = 0; i < il; i++) {
            var current_item = this.items[i];
            var current_li = document.createElement('li')
            var current_a = document.createElement('a')
                current_a.setAttribute('href', '#');
            var current_a_txt = document.createTextNode(current_item.firstChild ? current_item.firstChild.nodeValue : '');

            if(!current_item.firstChild) {
                $(current_a).addClassName('empty');
            }

            if(current_item.selected) {
                var default_selection = current_item.firstChild ? current_item.firstChild.nodeValue : '';
                $(current_li).addClassName('active');
            }
                            
            current_a.appendChild(current_a_txt);
            current_li.appendChild(current_a);
            ul.appendChild(current_li);
            
            Event.observe(current_a, 'click', this.changeListener.bind(this));
        }
        
        //$(this.container).select('form')[0].remove();
        $(this.container).appendChild(ul);

        var selection_p = document.createElement('p');
            selection_p.className += 'selection';
        var selection_p_txt = document.createTextNode(default_selection || 'Odabir');
            selection_p.appendChild(selection_p_txt);
            
        var toggle_p = document.createElement('p');
            toggle_p.className += 'toggle';
        
        var toggle_a = document.createElement('a');
            toggle_a.setAttribute('href', '#');
        var toggle_img = document.createElement('img');
            toggle_img.setAttribute('src', '/images/layout/arrow-expand.png');
            toggle_img.setAttribute('alt', 'otvori / zatvori');
            toggle_a.appendChild(toggle_img);
            toggle_p.appendChild(toggle_a);
            Event.observe(toggle_a, 'click', this.clickListener.bind(this));
            
            $(this.container).addClassName('collapsed');
            $(ul).insert({before:selection_p});
            $(ul).insert({before:toggle_p});
            
            $(this.original_select).insert({after:this.container});

            var bd = document.getElementsByTagName('body')[0];
            Event.observe(bd,'click',this.bodyListener.bind(this));
    },
    
    bodyListener: function(e) {
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase()=='img') {
            event_target = event_target.parentNode;
        }

        var obj = event_target;
        while(obj != this.container){
            obj = obj.parentNode;
            if(obj.nodeName.toLowerCase()=='html'){
                if(!$(this.container).hasClassName('collapsed')) {
                    this.toggle();
                }
                obj = null;
                break;
            }
        }
    },
    
    clickListener: function(e){

        Event.stop(e);
        this.toggle();
    },
    
    toggle: function() {
        $(this.container).toggleClassName('collapsed');
        var ul = $(this.container).select('ul')[0];
        
        $(ul).setStyle({'opacity': '0.01'})

        Effect.Appear(ul, {duration: 0.8, from: 0.5, to: 0.9999});
        
        var toggle_img = $(this.container).select('.toggle img')[0];
        var current_src = toggle_img.getAttribute('src');
        if(current_src.indexOf('expand') != -1) {
            var new_src = current_src.replace('expand', 'collapse');
        } else {
            var new_src = current_src.replace('collapse', 'expand');
        }
        toggle_img.setAttribute('src', new_src);
    },

    changeListener: function(e){
        Event.stop(e);

        var event_target = window.event ? window.event.srcElement : e.target;

        this.makeSelection(event_target);
    },
    
    makeSelection: function(event_target) {
        var current_label = event_target.firstChild.nodeValue;
        //$(this.container).select('.selection')[0].firstChild.nodeValue = current_label;
        $(this.container).select('.selection')[0].innerHTML = current_label;
        
        var active_li = $(this.container).select('.active')[0];

        if(active_li) {
            $(this.container).select('.active')[0].removeClassName('active');
        }
        
        var parent_li = $(event_target).up('li');
        $(parent_li).addClassName('active');

        var element_index = this.getIndex(parent_li);
        if(element_index != null) {
            $(this.items)[element_index].selected = 'selected';
        }
        
        this.toggle();
    },
    
    getIndex: function(parent_li) {
        
        var index_no = null;
        var all_lis = $(this.container).select('li');
        
        var il = all_lis.length;
        for(var i = 0; i < il; i++) {
            if(all_lis[i] == parent_li) {
                index_no = i;
                break;
            }
        }
        return index_no;
    }
    
}


var dhtml_select_init = {
    container: null,
    items: null,
    
    setup: function(container_id) {
        this.container = $(container_id);
        if(!this.container) return;
        
        if(typeof dhtml_select != 'function') return;
        
        this.items = $(this.container).select('select');
        var il = this.items.length;
        
        for(var i = 0; i < il; i++) {
            var current_item = this.items[i];
            new dhtml_select(current_item, il-i+1);
        }
        
        $(this.container).addClassName('select-loaded');
    }
}


var tooltip = {
    container: null,
    items: [],
    last: null,
    delay: 1500,
    si: null,
    
    setup: function(container_id) {
        this.container = $(container_id);
        if(!this.container) return;
        
        if(container_id == 'serp-list') {
            this.items = $(this.container).select('.type-reviews', '.type-news');
        }
        
        var il = this.items.length;
        for(var i = 0; i < il; i++) {
            var current_a = this.items[i];
            Event.observe(current_a, 'mouseover', this.mouseoverListener.bind(this));
        }
        
    },
    
    mouseoverListener: function(e) {
        Event.stop(e);
        
        var event_target = window.event ? window.event.srcElement : e.target;
        if(event_target.nodeName.toLowerCase() != 'a') {
            event_target = $(event_target).up('a');
        }

        if(event_target.nodeName.toLowerCase() == 'a') {
            clearTimeout(this.si);
            this.show(event_target);
        }
               
    },
    
    show: function(event_target) {
            
        var tooltip = document.createElement('span');
        $(tooltip).addClassName('tooltip');
        var tooltip_text = '';
        
        if($(event_target).hasClassName('type-reviews')) {
            tooltip_text =  'Recenzija';
        } else if($(event_target).hasClassName('type-news')) {
            tooltip_text = 'Novost';
        }
        
        tooltip.appendChild(document.createTextNode(tooltip_text));
        event_target.appendChild(tooltip);
        var o = this;
        this.si = setTimeout(function() { o.cleanUp(); }, this.delay);
        
        this.cleanUp(tooltip);
        this.last = tooltip;
    },
    
    cleanUp: function(current_tooltip) {
        if(this.last && this.last != current_tooltip) {
            $(this.last).remove();
            this.last = null;
        }        
    }
    
    
}



var handle_min_height = Class.create();
handle_min_height.prototype=  {

    container: null,
    items: null,
    original_select: null,
    
    initialize: function(element_type, container) {
        this.items = [];
        
        if(element_type == 'reviews-featured') {
            this.items = $(container).select('.reviews-featured');
        }

        if(element_type == 'encyclopedia') {
            this.items = $(container).select('.related-content > div');
        }

        if(element_type == 'user-data') {
            var desc = $(container).immediateDescendants();
            var jl = desc.length;
            for(var j = 0; j < jl; j++) {
                var current_element = desc[j];
                if(current_element.nodeName.toLowerCase() == 'div') {
                    this.items.push(current_element);
                }
                
            }
        }
          
        var il = Math.floor(this.items.length / 2);
        
        if(il == 0) return;
        for(var i = 0; i < il * 2; i+=2) {
            var left_item = this.items[i];
            var lh = $(left_item).getHeight();
            
            var right_item = this.items[i+1];
            var rh = $(right_item).getHeight();
            
            var max_height = lh > rh ? lh : rh;
            var element_padding = parseInt($(this.items[0]).getStyle('paddingTop')) + parseInt($(this.items[0]).getStyle('paddingBottom'));
                max_height -= element_padding
           
            left_item.style.height = max_height + 'px';
            left_item.style.minHeight = max_height + 'px';
            
            right_item.style.height = max_height + 'px';
            right_item.style.minHeight = max_height + 'px';
            
            if(element_type == 'encyclopedia') {
                
                var inner_diff = 29;
                var left_inner = $(left_item).select('div')[0];
                var right_inner = $(right_item).select('div')[0]; 
                
                left_inner.style.height = max_height - inner_diff + 'px';
                left_inner.style.minHeight = max_height - inner_diff + 'px';
                    
                right_inner.style.height = max_height - inner_diff + 'px';
                right_inner.style.minHeight = max_height - inner_diff + 'px';
            }
        }
        

        
        
    }
}

var flash_handler  = {

    render: function(file_name, element_id, w, h, v, c){
        $(document.getElementsByTagName('body')[0]).addClassName('js-available');
        
        if($(element_id)) {
            var fm = $(element_id).select('.flash-js-message')[0];
            $(fm).select('noscript')[0].remove();
            $(fm).innerHTML = '<h2>Multimedijalni sadrÅ¾aj trenutno nije dostupan</h2><p>Za pregled multimedijalnog sadrÅ¾aja:</p><ul><li>omogucite JavaScript u web pregledniku</li><li>instalirajte <a href="http://www.adobe.com/products/flashplayer/">najnovniju verziju Flash playera</a></li></ul>';
        }

    		var so = new SWFObject(file_name, 'flash_' + element_id, w, h, v, c);
        so.addParam("scale","noscale");
        so.addParam("salign","tl");
        so.addParam("menu","false");

    		so.write(element_id);
     }
}


var date_range = {
    container: null,
    
    setup: function(container_id) {
        this.container = $(container_id);
        if(!this.container) return;
        
        if(container_id == 'edit-comic-form') {
            var day_select = $(this.container).select('label[for="comic-publish-day"]')[0];
            var month_select = $(this.container).select('label[for="comic-publish-month"]')[0];
            var year_select = $(this.container).select('label[for="comic-publish-year"]')[0];
            
            $(day_select).addClassName('date-related');
            $(month_select).addClassName('date-related');
            $(year_select).addClassName('date-related');
            
            var publish_date = document.createElement('label');
                publish_date.setAttribute('for', 'comic-publish-day');
                
                publish_date.appendChild(document.createTextNode('Datum izlaska'));
            
            $(day_select).insert({before:publish_date});
        }
        
    }
    
}


var first_letter = {
    items: [],
    setup: function() {
        
        if(!ie6 && !ie7 && !ie8) return;
        this.items = $('main-content').select('.hero-related-info p', '.author-related-info p');
        
        var il = this.items.length; 
        for(var i = 0; i < il; i++) {
            var current_p = this.items[i];
            var p_value = current_p.firstChild.nodeValue;
            var first_letter = p_value.substr(0,1);
            var p_diff = p_value.substr(1);
            
            var span = document.createElement('span');
                span.className = 'first-letter';
                span.appendChild(document.createTextNode(first_letter));
                
            current_p.firstChild.nodeValue = '';
            current_p.appendChild(span);
            current_p.appendChild(document.createTextNode(p_diff));
            
        }
    }
}


var styleSheet = document.styleSheets[0];
if(is_safari) {
    if (styleSheet.insertRule) {
      styleSheet.insertRule('#poll-container p a { padding-right: 5px; padding-left: 7px; }',styleSheet.cssRules.length);
      styleSheet.insertRule('.hero-related-info p:first-letter { margin: -6px 5px -15px 0; }',styleSheet.cssRules.length);
      styleSheet.insertRule('.author-related-info p:first-letter { margin: -6px 5px -15px 0; }',styleSheet.cssRules.length);
      styleSheet.insertRule('#add-publisher a { padding-left: 4px; padding-right: 4px; margin-left: 2px; }',styleSheet.cssRules.length);
      styleSheet.insertRule('#page-reviews-latest #pagination { margin-top: -28px; }',styleSheet.cssRules.length);
      styleSheet.insertRule('#page-poll-archive #pagination { margin-top: -28px; }',styleSheet.cssRules.length);
      styleSheet.insertRule('#page-news-latest #pagination { margin-top: -28px; }',styleSheet.cssRules.length);
      styleSheet.insertRule('#page-home #pagination { margin-top: -28px; }',styleSheet.cssRules.length);
      
    }
}
if(is_opera) {
    if (styleSheet.insertRule) {
      styleSheet.insertRule('#poll-container .input-submit { margin-bottom: -26px; }',styleSheet.cssRules.length);
      styleSheet.insertRule('#poll-container p a { padding-right: 7px; padding-left: 9px; }',styleSheet.cssRules.length);
      styleSheet.insertRule('.hero-related-info p:first-letter { margin: -6px 5px -10px 0; }',styleSheet.cssRules.length);
      styleSheet.insertRule('.author-related-info p:first-letter { margin: -6px 5px -10px 0; }',styleSheet.cssRules.length);
      styleSheet.insertRule('.related-content li { position: relative; }',styleSheet.cssRules.length);
    }
}


function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


function DisplayNewEditions(page){
    //debugger;
	var hg = $('new-editions').offsetHeight;
	//hg='318px';
	
	nextpage=page<20?page+1:20;
	prevpage=page>1 ? page-1:1;
	
	$('new-editions-box').innerHTML = '<div style="float:left; background: url(/images/layout/loading.gif) 50% 50% no-repeat;border: 0px solid black;width:910px; height:' + hg + 'px"></div>';
	$('forward-arrow').href='javascript:DisplayNewEditions('+ nextpage +')';
	$('back-arrow').href='javascript:DisplayNewEditions('+ prevpage +')';
  	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support XMLHTTP!");
	  return;
	  }
	var url="/include/new-editions.asp";
	url=url+"?page="+page;
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);

}

function DisplayNewAuctions(aucOwner, page){
    //debugger;
	var hg = $('new-editions').offsetHeight;
	//hg='318px';
	
	nextpage=page<1000?page+1:1000;
	prevpage=page>1 ? page-1:1;
	
	if ($('PageCounter').options.length>page) {
		$('PageCounter').selectedIndex=page-1;
	} else {
		nextpage=$('PageCounter').options.length;
	}
	
	$('new-editions-box').innerHTML = '<div style="float:left; background: url(/images/layout/loading.gif) 50% 50% no-repeat;border: 0px solid black;width:600px; height:' + hg + 'px"></div>';
	$('forward-arrow').href='javascript:DisplayNewAuctions('+ aucOwner +',' + nextpage +')';
	$('back-arrow').href='javascript:DisplayNewAuctions('+ aucOwner +',' + prevpage +')';
	
  	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support XMLHTTP!");
	  return;
	  }
	var url="/include/new-auctions.asp";
	url=url+"?page="+page + "&aucItemOwner="+aucOwner;
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);

}

function ComicVote(ComicID, ComicType, Vote){
 	$('ratingblock').innerHTML = '<div style="float:left; background: url(/images/layout/loading.gif) 50% 50% no-repeat;border: 0px solid black;"></div>';
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support XMLHTTP!");
	  return;
	  }
	var url="/include/ComicVote.asp";
	url=url+"?ComicID="+ComicID + "&ComicType=" + ComicType + "&Vote=" + Vote;
	xmlhttp.onreadystatechange=showVoteResult;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function showVoteResult()
{
if (xmlhttp.readyState==4)
  {
	$('ratingblock').innerHTML=xmlhttp.responseText;
  }
}


function stateChanged()
{
if (xmlhttp.readyState==4)
  {
	$('new-editions-box').innerHTML=xmlhttp.responseText;
  }
}


function htmlData(url, qStr,sourceName, destinationName)  
{  
   if (url.length==0)  
   {  
       document.getElementById(destinationName).innerHTML="";  
       return;  
   }  
   xmlHttp=GetXmlHttpObject()  
   if (xmlHttp==null)  
   {  
       alert ("Browser does not support HTTP Request");  
       return;  
   }  
  
   url=url+"?"+qStr + "&Name=" + sourceName;  
   //xmlHttp.onreadystatechange=stateChanged1(destinationName);  
   xmlHttp.onreadystatechange=function() { stateChanged1(destinationName); };
   xmlHttp.open("GET",url,true) ;  
   xmlHttp.send(null);  
}  

function stateChanged1(destinationName)  
{  

   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")  
   {  
        document.getElementById(destinationName).innerHTML= xmlHttp.responseText;  
   }  
   else {  
           //alert(xmlHttp.status);  
   }  
}  

function scaleImage(objImage) {

imgwidth=objImage.width;
imgheight=objImage.height;

if(imgheight>imgwidth) {
	percent=80/imgheight;
	imgwidth=Math.round(percent*imgwidth);
	objImage.height = 80;
	objImage.width = imgwidth;
	} else {
		percent=80/imgwidth;
		imgheight=Math.round(percent*imgheight);
		objImage.width = 80;
		objImage.height = imgheight;
	
	}
}

function checkall (str,itm) {
	if (isNaN(document.forms[str].checkbox1.length)) {
		if (!document.getElementById(itm).checked){
			document.forms[str].checkbox1.checked=false;
		} else {
			document.forms[str].checkbox1.checked=true;
		}
	} else {		
		for (var i=0;i<document.forms[str].checkbox1.length;i++) {
			if (!document.getElementById(itm).checked){
				document.forms[str].checkbox1[i].checked=false;
			} else {
				document.forms[str].checkbox1[i].checked=true;
			}
		}	
	}
}

function getvalues (str) {

	var retString="";
	var tmpInt=0;

	if (document.forms[str].checkbox1.length>1) {
		for (var i=0;i<document.forms[str].checkbox1.length;i++) {
			if (document.forms[str].checkbox1[i].checked){
				retString+=document.forms[str].checkbox1[i].value+";";
			}	
		}
	} else {
		retString+=document.forms[str].checkbox1.value;
	}	
	document.forms[str].ToDo.value=retString;
	//alert(retString);
	//alert(document.forms[str].ToDo.value);
	
}	

function sel() {
	document.form1.Action.value=0;
	document.form1.submit();
}

function ShowLoading() {
	var iFrameBody = document.getElementById("iframe").contentWindow.document.body;
	iFrameBody.innerHTML = '<div style="float:left; background: url(/images/layout/loading.gif) 50% 50% no-repeat;border: 0px solid black;display:block;width:600px; height:200px"></div>';	
}

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

//***********************************************************************************************************************************/
//	LyteBox v3.22
//
//	 Author: Markus F. Hay
//  Website: http://www.dolem.com/lytebox
//	   Date: October 2, 2007
//	License: Creative Commons Attribution 3.0 License (http://creativecommons.org/licenses/by/3.0/)
// Browsers: Tested successfully on WinXP with the following browsers (using no DOCTYPE and Strict/Transitional/Loose DOCTYPES):
//				* Firefox: 2.0.0.7, 1.5.0.12
//				* Internet Explorer: 7.0, 6.0 SP2, 5.5 SP2
//				* Opera: 9.23
//
// Releases: For up-to-date and complete release information, visit http://www.dolem.com/forum/showthread.php?tid=62
//				* v3.22 (10/02/07)
//				* v3.21 (09/30/07)
//				* v3.20 (07/12/07)
//				* v3.10 (05/28/07)
//				* v3.00 (05/15/07)
//				* v2.02 (11/13/06)
//
//   Credit: LyteBox was originally derived from the Lightbox class (v2.02) that was written by Lokesh Dhakar. For more
//			 information please visit http://huddletogether.com/projects/lightbox2/
//***********************************************************************************************************************************/
Array.prototype.removeDuplicates = function () { for (var i = 1; i < this.length; i++) { if (this[i][0] == this[i-1][0]) { this.splice(i,1); } } }
Array.prototype.empty = function () { for (var i = 0; i <= this.length; i++) { this.shift(); } }
String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ''); }

function LyteBox() {
	/*** Start Global Configuration ***/
		this.theme				= 'grey';	// themes: grey (default), red, green, blue, gold
		this.hideFlash			= true;		// controls whether or not Flash objects should be hidden
		this.outerBorder		= true;		// controls whether to show the outer grey (or theme) border
		this.resizeSpeed		= 8;		// controls the speed of the image resizing (1=slowest and 10=fastest)
		this.maxOpacity			= 80;		// higher opacity = darker overlay, lower opacity = lighter overlay
		this.navType			= 1;		// 1 = "Prev/Next" buttons on top left and left (default), 2 = "<< prev | next >>" links next to image number
		this.autoResize			= true;		// controls whether or not images should be resized if larger than the browser window dimensions
		this.doAnimations		= true;		// controls whether or not "animate" Lytebox, i.e. resize transition between images, fade in/out effects, etc.
		
		this.borderSize			= 12;		// if you adjust the padding in the CSS, you will need to update this variable -- otherwise, leave this alone...
	/*** End Global Configuration ***/
	
	/*** Configure Slideshow Options ***/
		this.slideInterval		= 4000;		// Change value (milliseconds) to increase/decrease the time between "slides" (10000 = 10 seconds)
		this.showNavigation		= true;		// true to display Next/Prev buttons/text during slideshow, false to hide
		this.showClose			= true;		// true to display the Close button, false to hide
		this.showDetails		= true;		// true to display image details (caption, count), false to hide
		this.showPlayPause		= true;		// true to display pause/play buttons next to close button, false to hide
		this.autoEnd			= true;		// true to automatically close Lytebox after the last image is reached, false to keep open
		this.pauseOnNextClick	= false;	// true to pause the slideshow when the "Next" button is clicked
        this.pauseOnPrevClick 	= true;		// true to pause the slideshow when the "Prev" button is clicked
	/*** End Slideshow Configuration ***/
	
	if(this.resizeSpeed > 10) { this.resizeSpeed = 10; }
	if(this.resizeSpeed < 1) { resizeSpeed = 1; }
	this.resizeDuration = (11 - this.resizeSpeed) * 0.15;
	this.resizeWTimerArray		= new Array();
	this.resizeWTimerCount		= 0;
	this.resizeHTimerArray		= new Array();
	this.resizeHTimerCount		= 0;
	this.showContentTimerArray	= new Array();
	this.showContentTimerCount	= 0;
	this.overlayTimerArray		= new Array();
	this.overlayTimerCount		= 0;
	this.imageTimerArray		= new Array();
	this.imageTimerCount		= 0;
	this.timerIDArray			= new Array();
	this.timerIDCount			= 0;
	this.slideshowIDArray		= new Array();
	this.slideshowIDCount		= 0;
	this.imageArray	 = new Array();
	this.activeImage = null;
	this.slideArray	 = new Array();
	this.activeSlide = null;
	this.frameArray	 = new Array();
	this.activeFrame = null;
	this.checkFrame();
	this.isSlideshow = false;
	this.isLyteframe = false;
	/*@cc_on
		/*@if (@_jscript)
			this.ie = (document.all && !window.opera) ? true : false;
		/*@else @*/
			this.ie = false;
		/*@end
	@*/
	this.ie7 = (this.ie && window.XMLHttpRequest);	
	this.initialize();
}
LyteBox.prototype.initialize = function() {
	this.updateLyteboxItems();
	var objBody = this.doc.getElementsByTagName("body").item(0);	
	if (this.doc.getElementById('lbOverlay')) {
		objBody.removeChild(this.doc.getElementById("lbOverlay"));
		objBody.removeChild(this.doc.getElementById("lbMain"));
	}
	var objOverlay = this.doc.createElement("div");
		objOverlay.setAttribute('id','lbOverlay');
		objOverlay.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		if ((this.ie && !this.ie7) || (this.ie7 && this.doc.compatMode == 'BackCompat')) {
			objOverlay.style.position = 'absolute';
		}
		objOverlay.style.display = 'none';
		objBody.appendChild(objOverlay);
	var objLytebox = this.doc.createElement("div");
		objLytebox.setAttribute('id','lbMain');
		objLytebox.style.display = 'none';
		objBody.appendChild(objLytebox);
	var objOuterContainer = this.doc.createElement("div");
		objOuterContainer.setAttribute('id','lbOuterContainer');
		objOuterContainer.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objLytebox.appendChild(objOuterContainer);
	var objIframeContainer = this.doc.createElement("div");
		objIframeContainer.setAttribute('id','lbIframeContainer');
		objIframeContainer.style.display = 'none';
		objOuterContainer.appendChild(objIframeContainer);
	var objIframe = this.doc.createElement("iframe");
		objIframe.setAttribute('id','lbIframe');
		objIframe.setAttribute('name','lbIframe');
		objIframe.style.display = 'none';
		objIframeContainer.appendChild(objIframe);
	var objImageContainer = this.doc.createElement("div");
		objImageContainer.setAttribute('id','lbImageContainer');
		objOuterContainer.appendChild(objImageContainer);
	var objLyteboxImage = this.doc.createElement("img");
		objLyteboxImage.setAttribute('id','lbImage');
		objImageContainer.appendChild(objLyteboxImage);
	var objLoading = this.doc.createElement("div");
		objLoading.setAttribute('id','lbLoading');
		objOuterContainer.appendChild(objLoading);
	var objDetailsContainer = this.doc.createElement("div");
		objDetailsContainer.setAttribute('id','lbDetailsContainer');
		objDetailsContainer.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objLytebox.appendChild(objDetailsContainer);
	var objDetailsData =this.doc.createElement("div");
		objDetailsData.setAttribute('id','lbDetailsData');
		objDetailsData.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objDetailsContainer.appendChild(objDetailsData);
	var objDetails = this.doc.createElement("div");
		objDetails.setAttribute('id','lbDetails');
		objDetailsData.appendChild(objDetails);
	var objCaption = this.doc.createElement("span");
		objCaption.setAttribute('id','lbCaption');
		objDetails.appendChild(objCaption);
	var objHoverNav = this.doc.createElement("div");
		objHoverNav.setAttribute('id','lbHoverNav');
		objImageContainer.appendChild(objHoverNav);
	var objBottomNav = this.doc.createElement("div");
		objBottomNav.setAttribute('id','lbBottomNav');
		objDetailsData.appendChild(objBottomNav);
	var objPrev = this.doc.createElement("a");
		objPrev.setAttribute('id','lbPrev');
		objPrev.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objPrev.setAttribute('href','#');
		objHoverNav.appendChild(objPrev);
	var objNext = this.doc.createElement("a");
		objNext.setAttribute('id','lbNext');
		objNext.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objNext.setAttribute('href','#');
		objHoverNav.appendChild(objNext);
	var objNumberDisplay = this.doc.createElement("span");
		objNumberDisplay.setAttribute('id','lbNumberDisplay');
		objDetails.appendChild(objNumberDisplay);
	var objNavDisplay = this.doc.createElement("span");
		objNavDisplay.setAttribute('id','lbNavDisplay');
		objNavDisplay.style.display = 'none';
		objDetails.appendChild(objNavDisplay);
	var objClose = this.doc.createElement("a");
		objClose.setAttribute('id','lbClose');
		objClose.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objClose.setAttribute('href','#');
		objBottomNav.appendChild(objClose);
	var objPause = this.doc.createElement("a");
		objPause.setAttribute('id','lbPause');
		objPause.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objPause.setAttribute('href','#');
		objPause.style.display = 'none';
		objBottomNav.appendChild(objPause);
	var objPlay = this.doc.createElement("a");
		objPlay.setAttribute('id','lbPlay');
		objPlay.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objPlay.setAttribute('href','#');
		objPlay.style.display = 'none';
		objBottomNav.appendChild(objPlay);
};
LyteBox.prototype.updateLyteboxItems = function() {	
	var anchors = (this.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		var relAttribute = String(anchor.getAttribute('rel'));
		if (anchor.getAttribute('href')) {
			if (relAttribute.toLowerCase().match('lytebox')) {
				anchor.onclick = function () { myLytebox.start(this, false, false); return false; }
			} else if (relAttribute.toLowerCase().match('lyteshow')) {
				anchor.onclick = function () { myLytebox.start(this, true, false); return false; }
			} else if (relAttribute.toLowerCase().match('lyteframe')) {
				anchor.onclick = function () { myLytebox.start(this, false, true); return false; }
			}
		}
	}
};
LyteBox.prototype.start = function(imageLink, doSlide, doFrame) {
	if (this.ie && !this.ie7) {	this.toggleSelects('hide');	}
	if (this.hideFlash) { this.toggleFlash('hide'); }
	this.isLyteframe = (doFrame ? true : false);
	var pageSize	= this.getPageSize();
	var objOverlay	= this.doc.getElementById('lbOverlay');
	var objBody		= this.doc.getElementsByTagName("body").item(0);
	objOverlay.style.height = pageSize[1] + "px";
	objOverlay.style.display = '';
	this.appear('lbOverlay', (this.doAnimations ? 0 : this.maxOpacity));
	var anchors = (this.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');
	if (this.isLyteframe) {
		this.frameArray = [];
		this.frameNum = 0;
		if ((imageLink.getAttribute('rel') == 'lyteframe')) {
			var rev = imageLink.getAttribute('rev');
			this.frameArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title'), (rev == null || rev == '' ? 'width: 400px; height: 400px; scrolling: auto;' : rev)));
		} else {
			if (imageLink.getAttribute('rel').indexOf('lyteframe') != -1) {
				for (var i = 0; i < anchors.length; i++) {
					var anchor = anchors[i];
					if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) {
						var rev = anchor.getAttribute('rev');
						this.frameArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title'), (rev == null || rev == '' ? 'width: 400px; height: 400px; scrolling: auto;' : rev)));
					}
				}
				this.frameArray.removeDuplicates();
				while(this.frameArray[this.frameNum][0] != imageLink.getAttribute('href')) { this.frameNum++; }
			}
		}
	} else {
		this.imageArray = [];
		this.imageNum = 0;
		this.slideArray = [];
		this.slideNum = 0;
		if ((imageLink.getAttribute('rel') == 'lytebox')) {
			this.imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));
		} else {
			if (imageLink.getAttribute('rel').indexOf('lytebox') != -1) {
				for (var i = 0; i < anchors.length; i++) {
					var anchor = anchors[i];
					if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) {
						this.imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
					}
				}
				this.imageArray.removeDuplicates();
				while(this.imageArray[this.imageNum][0] != imageLink.getAttribute('href')) { this.imageNum++; }
			}
			if (imageLink.getAttribute('rel').indexOf('lyteshow') != -1) {
				for (var i = 0; i < anchors.length; i++) {
					var anchor = anchors[i];
					if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) {
						this.slideArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
					}
				}
				this.slideArray.removeDuplicates();
				while(this.slideArray[this.slideNum][0] != imageLink.getAttribute('href')) { this.slideNum++; }
			}
		}
	}
	var object = this.doc.getElementById('lbMain');
		object.style.top = (this.getPageScroll() + (pageSize[3] / 15)) + "px";
		object.style.display = '';
	if (!this.outerBorder) {
		this.doc.getElementById('lbOuterContainer').style.border = 'none';
		this.doc.getElementById('lbDetailsContainer').style.border = 'none';
	} else {
		this.doc.getElementById('lbOuterContainer').style.borderBottom = '';
		this.doc.getElementById('lbOuterContainer').setAttribute((this.ie ? 'className' : 'class'), this.theme);
	}
	this.doc.getElementById('lbOverlay').onclick = function() { myLytebox.end(); return false; }
	this.doc.getElementById('lbMain').onclick = function(e) {
		var e = e;
		if (!e) {
			if (window.parent.frames[window.name] && (parent.document.getElementsByTagName('frameset').length <= 0)) {
				e = window.parent.window.event;
			} else {
				e = window.event;
			}
		}
		var id = (e.target ? e.target.id : e.srcElement.id);
		if (id == 'lbMain') { myLytebox.end(); return false; }
	}
	this.doc.getElementById('lbClose').onclick = function() { myLytebox.end(); return false; }
	this.doc.getElementById('lbPause').onclick = function() { myLytebox.togglePlayPause("lbPause", "lbPlay"); return false; }
	this.doc.getElementById('lbPlay').onclick = function() { myLytebox.togglePlayPause("lbPlay", "lbPause"); return false; }	
	this.isSlideshow = doSlide;
	this.isPaused = (this.slideNum != 0 ? true : false);
	if (this.isSlideshow && this.showPlayPause && this.isPaused) {
		this.doc.getElementById('lbPlay').style.display = '';
		this.doc.getElementById('lbPause').style.display = 'none';
	}
	if (this.isLyteframe) {
		this.changeContent(this.frameNum);
	} else {
		if (this.isSlideshow) {
			this.changeContent(this.slideNum);
		} else {
			this.changeContent(this.imageNum);
		}
	}
};
LyteBox.prototype.changeContent = function(imageNum) {
	if (this.isSlideshow) {
		for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }
	}
	this.activeImage = this.activeSlide = this.activeFrame = imageNum;
	if (!this.outerBorder) {
		this.doc.getElementById('lbOuterContainer').style.border = 'none';
		this.doc.getElementById('lbDetailsContainer').style.border = 'none';
	} else {
		this.doc.getElementById('lbOuterContainer').style.borderBottom = '';
		this.doc.getElementById('lbOuterContainer').setAttribute((this.ie ? 'className' : 'class'), this.theme);
	}
	this.doc.getElementById('lbLoading').style.display = '';
	this.doc.getElementById('lbImage').style.display = 'none';
	this.doc.getElementById('lbIframe').style.display = 'none';
	this.doc.getElementById('lbPrev').style.display = 'none';
	this.doc.getElementById('lbNext').style.display = 'none';
	this.doc.getElementById('lbIframeContainer').style.display = 'none';
	this.doc.getElementById('lbDetailsContainer').style.display = 'none';
	this.doc.getElementById('lbNumberDisplay').style.display = 'none';
	if (this.navType == 2 || this.isLyteframe) {
		object = this.doc.getElementById('lbNavDisplay');
		object.innerHTML = '&nbsp;&nbsp;&nbsp;<span id="lbPrev2_Off" style="display: none;" class="' + this.theme + '">&laquo; prev</span><a href="#" id="lbPrev2" class="' + this.theme + '" style="display: none;">&laquo; prev</a> <b id="lbSpacer" class="' + this.theme + '">||</b> <span id="lbNext2_Off" style="display: none;" class="' + this.theme + '">next &raquo;</span><a href="#" id="lbNext2" class="' + this.theme + '" style="display: none;">next &raquo;</a>';
		object.style.display = 'none';
	}
	if (this.isLyteframe) {
		var iframe = myLytebox.doc.getElementById('lbIframe');
		var styles = this.frameArray[this.activeFrame][2];
		var aStyles = styles.split(';');
		for (var i = 0; i < aStyles.length; i++) {
			if (aStyles[i].indexOf('width:') >= 0) {
				var w = aStyles[i].replace('width:', '');
				iframe.width = w.trim();
			} else if (aStyles[i].indexOf('height:') >= 0) {
				var h = aStyles[i].replace('height:', '');
				iframe.height = h.trim();
			} else if (aStyles[i].indexOf('scrolling:') >= 0) {
				var s = aStyles[i].replace('scrolling:', '');
				iframe.scrolling = s.trim();
			} else if (aStyles[i].indexOf('border:') >= 0) {
				// Not implemented yet, as there are cross-platform issues with setting the border (from a GUI standpoint)
				//var b = aStyles[i].replace('border:', '');
				//iframe.style.border = b.trim();
			}
		}
		this.resizeContainer(parseInt(iframe.width), parseInt(iframe.height));
	} else {
		imgPreloader = new Image();
		imgPreloader.onload = function() {
			var imageWidth = imgPreloader.width;
			var imageHeight = imgPreloader.height;
			if (myLytebox.autoResize) {
				var pagesize = myLytebox.getPageSize();
				var x = pagesize[2] - 150;
				var y = pagesize[3] - 150;
				if (imageWidth > x) {
					imageHeight = Math.round(imageHeight * (x / imageWidth));
					imageWidth = x; 
					if (imageHeight > y) { 
						imageWidth = Math.round(imageWidth * (y / imageHeight));
						imageHeight = y; 
					}
				} else if (imageHeight > y) { 
					imageWidth = Math.round(imageWidth * (y / imageHeight));
					imageHeight = y; 
					if (imageWidth > x) {
						imageHeight = Math.round(imageHeight * (x / imageWidth));
						imageWidth = x;
					}
				}
			}
			var lbImage = myLytebox.doc.getElementById('lbImage')
			lbImage.src = (myLytebox.isSlideshow ? myLytebox.slideArray[myLytebox.activeSlide][0] : myLytebox.imageArray[myLytebox.activeImage][0]);
			lbImage.width = imageWidth;
			lbImage.height = imageHeight;
			myLytebox.resizeContainer(imageWidth, imageHeight);
			imgPreloader.onload = function() {};
		}
		imgPreloader.src = (this.isSlideshow ? this.slideArray[this.activeSlide][0] : this.imageArray[this.activeImage][0]);
	}
};
LyteBox.prototype.resizeContainer = function(imgWidth, imgHeight) {
	this.wCur = this.doc.getElementById('lbOuterContainer').offsetWidth;
	this.hCur = this.doc.getElementById('lbOuterContainer').offsetHeight;
	this.xScale = ((imgWidth  + (this.borderSize * 2)) / this.wCur) * 100;
	this.yScale = ((imgHeight  + (this.borderSize * 2)) / this.hCur) * 100;
	var wDiff = (this.wCur - this.borderSize * 2) - imgWidth;
	var hDiff = (this.hCur - this.borderSize * 2) - imgHeight;
	if (!(hDiff == 0)) {
		this.hDone = false;
		this.resizeH('lbOuterContainer', this.hCur, imgHeight + this.borderSize*2, this.getPixelRate(this.hCur, imgHeight));
	} else {
		this.hDone = true;
	}
	if (!(wDiff == 0)) {
		this.wDone = false;
		this.resizeW('lbOuterContainer', this.wCur, imgWidth + this.borderSize*2, this.getPixelRate(this.wCur, imgWidth));
	} else {
		this.wDone = true;
	}
	if ((hDiff == 0) && (wDiff == 0)) {
		if (this.ie){ this.pause(250); } else { this.pause(100); } 
	}
	this.doc.getElementById('lbPrev').style.height = imgHeight + "px";
	this.doc.getElementById('lbNext').style.height = imgHeight + "px";
	this.doc.getElementById('lbDetailsContainer').style.width = (imgWidth + (this.borderSize * 2) + (this.ie && this.doc.compatMode == "BackCompat" && this.outerBorder ? 2 : 0)) + "px";
	this.showContent();
};
LyteBox.prototype.showContent = function() {
	if (this.wDone && this.hDone) {
		for (var i = 0; i < this.showContentTimerCount; i++) { window.clearTimeout(this.showContentTimerArray[i]); }
		if (this.outerBorder) {
			this.doc.getElementById('lbOuterContainer').style.borderBottom = 'none';
		}
		this.doc.getElementById('lbLoading').style.display = 'none';
		if (this.isLyteframe) {
			this.doc.getElementById('lbIframe').style.display = '';
			this.appear('lbIframe', (this.doAnimations ? 0 : 100));
		} else {
			this.doc.getElementById('lbImage').style.display = '';
			this.appear('lbImage', (this.doAnimations ? 0 : 100));
			this.preloadNeighborImages();
		}
		if (this.isSlideshow) {
			if(this.activeSlide == (this.slideArray.length - 1)) {
				if (this.autoEnd) {
					this.slideshowIDArray[this.slideshowIDCount++] = setTimeout("myLytebox.end('slideshow')", this.slideInterval);
				}
			} else {
				if (!this.isPaused) {
					this.slideshowIDArray[this.slideshowIDCount++] = setTimeout("myLytebox.changeContent("+(this.activeSlide+1)+")", this.slideInterval);
				}
			}
			this.doc.getElementById('lbHoverNav').style.display = (this.showNavigation && this.navType == 1 ? '' : 'none');
			this.doc.getElementById('lbClose').style.display = (this.showClose ? '' : 'none');
			this.doc.getElementById('lbDetails').style.display = (this.showDetails ? '' : 'none');
			this.doc.getElementById('lbPause').style.display = (this.showPlayPause && !this.isPaused ? '' : 'none');
			this.doc.getElementById('lbPlay').style.display = (this.showPlayPause && !this.isPaused ? 'none' : '');
			this.doc.getElementById('lbNavDisplay').style.display = (this.showNavigation && this.navType == 2 ? '' : 'none');
		} else {
			this.doc.getElementById('lbHoverNav').style.display = (this.navType == 1 && !this.isLyteframe ? '' : 'none');
			if ((this.navType == 2 && !this.isLyteframe && this.imageArray.length > 1) || (this.frameArray.length > 1 && this.isLyteframe)) {
				this.doc.getElementById('lbNavDisplay').style.display = '';
			} else {
				this.doc.getElementById('lbNavDisplay').style.display = 'none';
			}
			this.doc.getElementById('lbClose').style.display = '';
			this.doc.getElementById('lbDetails').style.display = '';
			this.doc.getElementById('lbPause').style.display = 'none';
			this.doc.getElementById('lbPlay').style.display = 'none';
		}
		this.doc.getElementById('lbImageContainer').style.display = (this.isLyteframe ? 'none' : '');
		this.doc.getElementById('lbIframeContainer').style.display = (this.isLyteframe ? '' : 'none');
		try {
			this.doc.getElementById('lbIframe').src = this.frameArray[this.activeFrame][0];
		} catch(e) { }
	} else {
		this.showContentTimerArray[this.showContentTimerCount++] = setTimeout("myLytebox.showContent()", 200);
	}
};
LyteBox.prototype.updateDetails = function() {
	var object = this.doc.getElementById('lbCaption');
	var sTitle = (this.isSlideshow ? this.slideArray[this.activeSlide][1] : (this.isLyteframe ? this.frameArray[this.activeFrame][1] : this.imageArray[this.activeImage][1]));
	object.style.display = '';
	object.innerHTML = (sTitle == null ? '' : sTitle);
	this.updateNav();
	this.doc.getElementById('lbDetailsContainer').style.display = '';
	object = this.doc.getElementById('lbNumberDisplay');
	if (this.isSlideshow && this.slideArray.length > 1) {
		object.style.display = '';
		object.innerHTML = "Image " + eval(this.activeSlide + 1) + " of " + this.slideArray.length;
		this.doc.getElementById('lbNavDisplay').style.display = (this.navType == 2 && this.showNavigation ? '' : 'none');
	} else if (this.imageArray.length > 1 && !this.isLyteframe) {
		object.style.display = '';
		object.innerHTML = "Image " + eval(this.activeImage + 1) + " of " + this.imageArray.length;
		this.doc.getElementById('lbNavDisplay').style.display = (this.navType == 2 ? '' : 'none');
	} else if (this.frameArray.length > 1 && this.isLyteframe) {
		object.style.display = '';
		object.innerHTML = "Page " + eval(this.activeFrame + 1) + " of " + this.frameArray.length;
		this.doc.getElementById('lbNavDisplay').style.display = '';
	} else {
		this.doc.getElementById('lbNavDisplay').style.display = 'none';
	}
	this.appear('lbDetailsContainer', (this.doAnimations ? 0 : 100));
};
LyteBox.prototype.updateNav = function() {
	if (this.isSlideshow) {
		if (this.activeSlide != 0) {
			var object = (this.navType == 2 ? this.doc.getElementById('lbPrev2') : this.doc.getElementById('lbPrev'));
				object.style.display = '';
				object.onclick = function() {
					if (myLytebox.pauseOnPrevClick) { myLytebox.togglePlayPause("lbPause", "lbPlay"); }
					myLytebox.changeContent(myLytebox.activeSlide - 1); return false;
				}
		} else {
			if (this.navType == 2) { this.doc.getElementById('lbPrev2_Off').style.display = ''; }
		}
		if (this.activeSlide != (this.slideArray.length - 1)) {
			var object = (this.navType == 2 ? this.doc.getElementById('lbNext2') : this.doc.getElementById('lbNext'));
				object.style.display = '';
				object.onclick = function() {
					if (myLytebox.pauseOnNextClick) { myLytebox.togglePlayPause("lbPause", "lbPlay"); }
					myLytebox.changeContent(myLytebox.activeSlide + 1); return false;
				}
		} else {
			if (this.navType == 2) { this.doc.getElementById('lbNext2_Off').style.display = ''; }
		}
	} else if (this.isLyteframe) {
		if(this.activeFrame != 0) {
			var object = this.doc.getElementById('lbPrev2');
				object.style.display = '';
				object.onclick = function() {
					myLytebox.changeContent(myLytebox.activeFrame - 1); return false;
				}
		} else {
			this.doc.getElementById('lbPrev2_Off').style.display = '';
		}
		if(this.activeFrame != (this.frameArray.length - 1)) {
			var object = this.doc.getElementById('lbNext2');
				object.style.display = '';
				object.onclick = function() {
					myLytebox.changeContent(myLytebox.activeFrame + 1); return false;
				}
		} else {
			this.doc.getElementById('lbNext2_Off').style.display = '';
		}		
	} else {
		if(this.activeImage != 0) {
			var object = (this.navType == 2 ? this.doc.getElementById('lbPrev2') : this.doc.getElementById('lbPrev'));
				object.style.display = '';
				object.onclick = function() {
					myLytebox.changeContent(myLytebox.activeImage - 1); return false;
				}
		} else {
			if (this.navType == 2) { this.doc.getElementById('lbPrev2_Off').style.display = ''; }
		}
		if(this.activeImage != (this.imageArray.length - 1)) {
			var object = (this.navType == 2 ? this.doc.getElementById('lbNext2') : this.doc.getElementById('lbNext'));
				object.style.display = '';
				object.onclick = function() {
					myLytebox.changeContent(myLytebox.activeImage + 1); return false;
				}
		} else {
			if (this.navType == 2) { this.doc.getElementById('lbNext2_Off').style.display = ''; }
		}
	}
	this.enableKeyboardNav();
};
LyteBox.prototype.enableKeyboardNav = function() { document.onkeydown = this.keyboardAction; };
LyteBox.prototype.disableKeyboardNav = function() { document.onkeydown = ''; };
LyteBox.prototype.keyboardAction = function(e) {
	var keycode = key = escape = null;
	keycode	= (e == null) ? event.keyCode : e.which;
	key		= String.fromCharCode(keycode).toLowerCase();
	escape  = (e == null) ? 27 : e.DOM_VK_ESCAPE;
	if ((key == 'x') || (key == 'c') || (keycode == escape)) {
		myLytebox.end();
	} else if ((key == 'p') || (keycode == 37)) {
		if (myLytebox.isSlideshow) {
			if(myLytebox.activeSlide != 0) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeSlide - 1);
			}
		} else if (myLytebox.isLyteframe) {
			if(myLytebox.activeFrame != 0) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeFrame - 1);
			}
		} else {
			if(myLytebox.activeImage != 0) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeImage - 1);
			}
		}
	} else if ((key == 'n') || (keycode == 39)) {
		if (myLytebox.isSlideshow) {
			if(myLytebox.activeSlide != (myLytebox.slideArray.length - 1)) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeSlide + 1);
			}
		} else if (myLytebox.isLyteframe) {
			if(myLytebox.activeFrame != (myLytebox.frameArray.length - 1)) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeFrame + 1);
			}
		} else {
			if(myLytebox.activeImage != (myLytebox.imageArray.length - 1)) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeImage + 1);
			}
		}
	}
};
LyteBox.prototype.preloadNeighborImages = function() {
	if (this.isSlideshow) {
		if ((this.slideArray.length - 1) > this.activeSlide) {
			preloadNextImage = new Image();
			preloadNextImage.src = this.slideArray[this.activeSlide + 1][0];
		}
		if(this.activeSlide > 0) {
			preloadPrevImage = new Image();
			preloadPrevImage.src = this.slideArray[this.activeSlide - 1][0];
		}
	} else {
		if ((this.imageArray.length - 1) > this.activeImage) {
			preloadNextImage = new Image();
			preloadNextImage.src = this.imageArray[this.activeImage + 1][0];
		}
		if(this.activeImage > 0) {
			preloadPrevImage = new Image();
			preloadPrevImage.src = this.imageArray[this.activeImage - 1][0];
		}
	}
};
LyteBox.prototype.togglePlayPause = function(hideID, showID) {
	if (this.isSlideshow && hideID == "lbPause") {
		for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }
	}
	this.doc.getElementById(hideID).style.display = 'none';
	this.doc.getElementById(showID).style.display = '';
	if (hideID == "lbPlay") {
		this.isPaused = false;
		if (this.activeSlide == (this.slideArray.length - 1)) {
			this.end();
		} else {
			this.changeContent(this.activeSlide + 1);
		}
	} else {
		this.isPaused = true;
	}
};
LyteBox.prototype.end = function(caller) {
	var closeClick = (caller == 'slideshow' ? false : true);
	if (this.isSlideshow && this.isPaused && !closeClick) { return; }
	this.disableKeyboardNav();
	this.doc.getElementById('lbMain').style.display = 'none';
	this.fade('lbOverlay', (this.doAnimations ? this.maxOpacity : 0));
	this.toggleSelects('visible');
	if (this.hideFlash) { this.toggleFlash('visible'); }
	if (this.isSlideshow) {
		for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }
	}
	if (this.isLyteframe) {
		 this.initialize();
	}
};
LyteBox.prototype.checkFrame = function() {
	if (window.parent.frames[window.name] && (parent.document.getElementsByTagName('frameset').length <= 0)) {
		this.isFrame = true;
		this.lytebox = "window.parent." + window.name + ".myLytebox";
		this.doc = parent.document;
	} else {
		this.isFrame = false;
		this.lytebox = "myLytebox";
		this.doc = document;
	}
};
LyteBox.prototype.getPixelRate = function(cur, img) {
	var diff = (img > cur) ? img - cur : cur - img;
	if (diff >= 0 && diff <= 100) { return 10; }
	if (diff > 100 && diff <= 200) { return 15; }
	if (diff > 200 && diff <= 300) { return 20; }
	if (diff > 300 && diff <= 400) { return 25; }
	if (diff > 400 && diff <= 500) { return 30; }
	if (diff > 500 && diff <= 600) { return 35; }
	if (diff > 600 && diff <= 700) { return 40; }
	if (diff > 700) { return 45; }
};
LyteBox.prototype.appear = function(id, opacity) {
	var object = this.doc.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + (opacity + 10) + ")";
	if (opacity == 100 && (id == 'lbImage' || id == 'lbIframe')) {
		try { object.removeAttribute("filter"); } catch(e) {}	/* Fix added for IE Alpha Opacity Filter bug. */
		this.updateDetails();
	} else if (opacity >= this.maxOpacity && id == 'lbOverlay') {
		for (var i = 0; i < this.overlayTimerCount; i++) { window.clearTimeout(this.overlayTimerArray[i]); }
		return;
	} else if (opacity >= 100 && id == 'lbDetailsContainer') {
		try { object.removeAttribute("filter"); } catch(e) {}	/* Fix added for IE Alpha Opacity Filter bug. */
		for (var i = 0; i < this.imageTimerCount; i++) { window.clearTimeout(this.imageTimerArray[i]); }
		this.doc.getElementById('lbOverlay').style.height = this.getPageSize()[1] + "px";
	} else {
		if (id == 'lbOverlay') {
			this.overlayTimerArray[this.overlayTimerCount++] = setTimeout("myLytebox.appear('" + id + "', " + (opacity+20) + ")", 1);
		} else {
			this.imageTimerArray[this.imageTimerCount++] = setTimeout("myLytebox.appear('" + id + "', " + (opacity+10) + ")", 1);
		}
	}
};
LyteBox.prototype.fade = function(id, opacity) {
	var object = this.doc.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	if (opacity <= 0) {
		try {
			object.display = 'none';
		} catch(err) { }
	} else if (id == 'lbOverlay') {
		this.overlayTimerArray[this.overlayTimerCount++] = setTimeout("myLytebox.fade('" + id + "', " + (opacity-20) + ")", 1);
	} else {
		this.timerIDArray[this.timerIDCount++] = setTimeout("myLytebox.fade('" + id + "', " + (opacity-10) + ")", 1);
	}
};
LyteBox.prototype.resizeW = function(id, curW, maxW, pixelrate, speed) {
	if (!this.hDone) {
		this.resizeWTimerArray[this.resizeWTimerCount++] = setTimeout("myLytebox.resizeW('" + id + "', " + curW + ", " + maxW + ", " + pixelrate + ")", 100);
		return;
	}
	var object = this.doc.getElementById(id);
	var timer = speed ? speed : (this.resizeDuration/2);
	var newW = (this.doAnimations ? curW : maxW);
	object.style.width = (newW) + "px";
	if (newW < maxW) {
		newW += (newW + pixelrate >= maxW) ? (maxW - newW) : pixelrate;
	} else if (newW > maxW) {
		newW -= (newW - pixelrate <= maxW) ? (newW - maxW) : pixelrate;
	}
	this.resizeWTimerArray[this.resizeWTimerCount++] = setTimeout("myLytebox.resizeW('" + id + "', " + newW + ", " + maxW + ", " + pixelrate + ", " + (timer+0.02) + ")", timer+0.02);
	if (parseInt(object.style.width) == maxW) {
		this.wDone = true;
		for (var i = 0; i < this.resizeWTimerCount; i++) { window.clearTimeout(this.resizeWTimerArray[i]); }
	}
};
LyteBox.prototype.resizeH = function(id, curH, maxH, pixelrate, speed) {
	var timer = speed ? speed : (this.resizeDuration/2);
	var object = this.doc.getElementById(id);
	var newH = (this.doAnimations ? curH : maxH);
	object.style.height = (newH) + "px";
	if (newH < maxH) {
		newH += (newH + pixelrate >= maxH) ? (maxH - newH) : pixelrate;
	} else if (newH > maxH) {
		newH -= (newH - pixelrate <= maxH) ? (newH - maxH) : pixelrate;
	}
	this.resizeHTimerArray[this.resizeHTimerCount++] = setTimeout("myLytebox.resizeH('" + id + "', " + newH + ", " + maxH + ", " + pixelrate + ", " + (timer+.02) + ")", timer+.02);
	if (parseInt(object.style.height) == maxH) {
		this.hDone = true;
		for (var i = 0; i < this.resizeHTimerCount; i++) { window.clearTimeout(this.resizeHTimerArray[i]); }
	}
};
LyteBox.prototype.getPageScroll = function() {
	if (self.pageYOffset) {
		return this.isFrame ? parent.pageYOffset : self.pageYOffset;
	} else if (this.doc.documentElement && this.doc.documentElement.scrollTop){
		return this.doc.documentElement.scrollTop;
	} else if (document.body) {
		return this.doc.body.scrollTop;
	}
};
LyteBox.prototype.getPageSize = function() {	
	var xScroll, yScroll, windowWidth, windowHeight;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = this.doc.scrollWidth;
		yScroll = (this.isFrame ? parent.innerHeight : self.innerHeight) + (this.isFrame ? parent.scrollMaxY : self.scrollMaxY);
	} else if (this.doc.body.scrollHeight > this.doc.body.offsetHeight){
		xScroll = this.doc.body.scrollWidth;
		yScroll = this.doc.body.scrollHeight;
	} else {
		xScroll = this.doc.getElementsByTagName("html").item(0).offsetWidth;
		yScroll = this.doc.getElementsByTagName("html").item(0).offsetHeight;
		xScroll = (xScroll < this.doc.body.offsetWidth) ? this.doc.body.offsetWidth : xScroll;
		yScroll = (yScroll < this.doc.body.offsetHeight) ? this.doc.body.offsetHeight : yScroll;
	}
	if (self.innerHeight) {
		windowWidth = (this.isFrame) ? parent.innerWidth : self.innerWidth;
		windowHeight = (this.isFrame) ? parent.innerHeight : self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = this.doc.documentElement.clientWidth;
		windowHeight = this.doc.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = this.doc.getElementsByTagName("html").item(0).clientWidth;
		windowHeight = this.doc.getElementsByTagName("html").item(0).clientHeight;
		windowWidth = (windowWidth == 0) ? this.doc.body.clientWidth : windowWidth;
		windowHeight = (windowHeight == 0) ? this.doc.body.clientHeight : windowHeight;
	}
	var pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
	var pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;
	return new Array(pageWidth, pageHeight, windowWidth, windowHeight);
};
LyteBox.prototype.toggleFlash = function(state) {
	var objects = this.doc.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++) {
		objects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
	var embeds = this.doc.getElementsByTagName("embed");
	for (var i = 0; i < embeds.length; i++) {
		embeds[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
	if (this.isFrame) {
		for (var i = 0; i < parent.frames.length; i++) {
			try {
				objects = parent.frames[i].window.document.getElementsByTagName("object");
				for (var j = 0; j < objects.length; j++) {
					objects[j].style.visibility = (state == "hide") ? 'hidden' : 'visible';
				}
			} catch(e) { }
			try {
				embeds = parent.frames[i].window.document.getElementsByTagName("embed");
				for (var j = 0; j < embeds.length; j++) {
					embeds[j].style.visibility = (state == "hide") ? 'hidden' : 'visible';
				}
			} catch(e) { }
		}
	}
};
LyteBox.prototype.toggleSelects = function(state) {
	var selects = this.doc.getElementsByTagName("select");
	for (var i = 0; i < selects.length; i++ ) {
		selects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
	if (this.isFrame) {
		for (var i = 0; i < parent.frames.length; i++) {
			try {
				selects = parent.frames[i].window.document.getElementsByTagName("select");
				for (var j = 0; j < selects.length; j++) {
					selects[j].style.visibility = (state == "hide") ? 'hidden' : 'visible';
				}
			} catch(e) { }
		}
	}
};
LyteBox.prototype.pause = function(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime) { return; }
	}
};
if (window.addEventListener) {
	window.addEventListener("load",initLytebox,false);
} else if (window.attachEvent) {
	window.attachEvent("onload",initLytebox);
} else {
	window.onload = function() {initLytebox();}
}
function initLytebox() { myLytebox = new LyteBox(); }

//** Featured Content Slider script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** May 2nd, 08'- Script rewritten and updated to 2.0.
//** June 12th, 08'- Script updated to v 2.3, which adds the following features:
			//1) Changed behavior of script to actually collapse the previous content when the active one is shown, instead of just tucking it underneath the later.
			//2) Added setting to reveal a content either via "click" or "mouseover" of pagination links (default is former).
			//3) Added public function for jumping to a particular slide within a Featured Content instance using an arbitrary link, for example.

//** July 11th, 08'- Script updated to v 2.4:
			//1) Added ability to select a particular slide when the page first loads using a URL parameter (ie: mypage.htm?myslider=4 to select 4th slide in "myslider")
			//2) Fixed bug where the first slide disappears when the mouse clicks or mouses over it when page first loads.

var featuredcontentslider={

//3 variables below you can customize if desired:
ajaxloadingmsg: '<div style="margin: 20px 0 0 20px"><img src="loading.gif" /> 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)
}

}
