﻿/*
    Replaces <select> elements on a page with styled controls designed to replicate a dropdown
    
    @example    $('select.fancy_drop_down').fancy_drop_downs({
                        'arrowImage' : 'images/select_arrow.png',
                        'listClass' : 'fancy_select_list'
                    }
                );
                
    @name fancy_drop_downs
    @type jQuery
    @param Object   hash with options, described below (all optional)
                    arrowImage      -   Path to image used as the down arrow for each dropdown control
                    arrowClass      -   Class to be applied to the image tag for each arrow
                    listClass       -   Class to be applied to each list
                    columnClass     -   Class to be applied to each column for multi-column dropdowns
                    hideValues      -   Array of values to hide from the select list
                                        any option whose value is in this array will not be shown in the dropdown
                                        allows setting of default values that cannot be re-selected
                     
    @return         the jQuery object the styling was applied to
    
    @methods        init        -   default initialization method
                    update      -   Replaces dropdown contents with a new list
                                    @param Object       array of objects with 2 fields each
                                                        value   -   The value for this option in the dropdown
                                                        text    -   The text to display for this option in the dropdown
                    val         -   Sets the dropdown to a value that is passed as a parameter, or returns
                                    the value of the dropdown if no parameter is passed
                                    
    @example    $('#ddlExample').fancy_drop_downs('update',
                                    [{'value' : 0, 'text' : 'zero'}, 
                                     {'value' : 1, 'text' : 'one'}]
                                 );
                                 
                $('#ddlExample').fancy_drop_downs('val', '1');
                
    @remarks        Any classes placed on the <select> element will be passed on to the <div> element that replaces it in the styled dropdown
                    Any onchange handler (via onchange="" or via jquery .change();) on the <select> will be called when the fancy dropdown's value changes
                    To specify a given dropdown as multi-column, add a class "cols_x" to the <select> where x is the number of columns desired
 */
(function($) {
    
    var DropDownControls;
    
    var methods = {
        update: function(newData) {
            return this.each(function(){
                var dropdown = $(this);
                var input = dropdown.data('input');
                var list = dropdown.data('list');
                var selectedVal = dropdown.val();
            
                dropdown.html('');
                list.html('');
            
                for(var i = 0; i < newData.length; i++)
                {
                    dropdown.append(
                        $('<option></option>').
                        attr('value', newData[i].value).
                        text(newData[i].text));      
                }
                
                dropdown.val(selectedVal);
                populateFancyDropDownList(dropdown);
            });
        },
        val: function(value) {
            if(value)
            {
                return this.each(function(){
                    var dropdown = $(this);
                    var input = dropdown.data('input');
                    var list = dropdown.data('list');
                    
                    dropdown.val(value);
                    input.text(dropdown.find('option:selected').text());
                });
            }
            else
            {
                return this.val();
            }
        }, 
        init: function(options) {
        
            //Avoid null/undefined reference
            if(!options)
            {
                options = {};
            }

            //Converts hideValues array to object to allow comparison later
            //[0,1,2] is converted to {'0':'', '1':'', '2':''}
            if(options.hideValues)
            {
                var hideValuesArray = options.hideValues;
                options.hideValues = {};
                
                for (var i = 0; i < hideValuesArray.length; i++)
                {
                    options.hideValues[hideValuesArray[i]] = '';
                }
            }
            
            var defaults = {
                'arrowImage' : 'images/blue_down_arrow.png',
                'arrowClass' : 'select_arrow',
                'listClass' : 'select_list',
                'columnClass' : 'inline',
                'hideValues': {}
            };
                
            //Set defaults for any values not specified
            options = $.extend(true, {}, defaults, options);
        
            this.each(function(){
                var dropdown = $(this);
                //dropdowns should ideally be hidden via CSS to prevent loading effects being visible, this is a backup
                dropdown.hide();
                
                dropdown.data('columnClass', options.columnClass);
                
                //Create input
                var input = $('<div></div>');
                input.attr('class', dropdown.attr('class'));
                input.attr('name', dropdown.attr('id') + '_select');
                input.attr('id', dropdown.attr('id') + '_select');
                input.insertAfter(dropdown);
                       
                //Create arrow
                var arrowLink = $('<a></a>');
                arrowLink.attr('id', dropdown.attr('id') + '_select_arrow');
                
                var arrowImage = $('<img />');
                arrowImage.attr('src', options.arrowImage);
                arrowImage.attr('class', options.arrowClass);
                arrowLink.append(arrowImage);
                arrowLink.insertAfter(input);
                
                //Create list
                var list = $('<div></div>')
                .attr('class', options.listClass)
                .attr('id', dropdown.attr('id') + '_select_list');
                        
                dropdown.data('input', input);
                dropdown.data('list', list);
                dropdown.data('hideValues', options.hideValues);
                
                populateFancyDropDownList($(this));
                
                $('body').append(list);
            
            });
    
            if(!DropDownControls)
            {
                DropDownControls = new fancyDropDowns();
            }
            else
            {
                DropDownControls.hide_drop_downs;
            }
        
            return this.each(function(){
                DropDownControls.newDropDown($(this).attr('id') + '_select');
            });
        }
    };
    
    $.fn.fancy_drop_downs = function(method) {
        // Method calling logic
        if ( methods[method] ) {
          return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
        } else if ( typeof method === 'object' || ! method ) {
          return methods.init.apply( this, arguments );
        } else {
          $.error( 'Method ' +  method + ' does not exist on jQuery.fancy_drop_downs' );
        }    
    };
})(jQuery);

function populateFancyDropDownList(dropdown)
{
    var input = dropdown.data('input');
    var list = dropdown.data('list');
    var hideValues = dropdown.data('hideValues');
    var columns = 1;
    var columnSize = 0;
    var columnIndex = 0;
    var currentColumn;
    
    //get class list and check if the dropdown has a "cols_#" attribute, if so set columns
    var classes = dropdown.attr('class').split(/\s+/);
    
    $.each(classes, function(index,item) {
        if(item.substring(0,5) == 'cols_')
        {
            columns = parseInt(item.substring(5));
        }
    });
    
    if(columns > 1)
    {
        columnSize = Math.ceil(dropdown.find('option').length / columns);
    }
    
    dropdown.find('option').each(function(){
        var option = $(this);
        if(!(option.attr('value') in hideValues))        
        {
            if(columns > 1)
            {
                if(columnIndex >= columnSize)
                {
                    columnIndex = 0;
                }
                if(columnIndex == 0)
                {
                    currentColumn = $('<div></div>');
                    currentColumn.attr('class', dropdown.data('columnClass'));
                    list.append(currentColumn);
                }
            }
            var newOption = $('<a></a>');
            newOption.attr('id', input.attr('id') + '_value_' + option.attr('value'));
            newOption.text(option.text());
            newOption.data('value', option.attr('value'));
            //Call the dropdown's onclick handler if the value has changed
            newOption.click(function(){
                if($(this).text() != input.text())
                {
                    //Change the value of the hidden select element
                    dropdown.find('[value="' + $(this).data('value') + '"]').attr('selected', 'selected');
                    if(document.createEvent)
                    {
                        //Code for dom-compliant browsers to generate the event
                        var evObj = document.createEvent('MouseEvents');
                        evObj.initEvent('change', true, true);
                        dropdown.get(0).dispatchEvent(evObj);
                    }
                    else
                    {
                        //Fall back to custom event handler for any browsers that do not support the DOM properly (IE)
                        dropdown.get(0).fireEvent('onchange');
                        dropdown.change();
                    }
                }
            });
            
            if(columns == 1)
            {
                list.append(newOption);
            }
            else
            {
                currentColumn.append(newOption);
                columnIndex++;
            }
        }
    });
    input.text(dropdown.find('option:selected').text());
}

//RedUrban code below this point
/**********
fancy_drop_downs.js

Dependencies: jQuery 1.4.2+



This manages the creating of non-standard dropdown boxes, or select lists 
as I like to call 'em.

Regardless, to function properly this script expects 3 elements to be present
in the HTML with the id's formatted as below

foo - a text input box
foo_arrow - an element which acts as the drop down arrow
foo_list - this list of elements to be displayed

When each drop down box is instantiated a hidden input is created in the 
document body to store the values (which may different from the Text displayed 
in the input fields). These have the name/id format of

foo_selected

As noted above, these are appended to the DOCUMENT BODY object, not a specific form.
It is currently not supported to add these hidden inputs to a specific document 
element. 

TRB 03/03/2011
tbaxter@redurban.ca
*******/

function fancyDropDowns(){
	
	this.hide_drop_downs;
	this.drop_down_list = new Array;
}
	
fancyDropDowns.prototype = {
	'newDropDown' :function(list_id){
		currentInstance = this;
		$('#'+list_id+', #'+list_id+'_arrow').live('click', function(){
			currentInstance.showDropDown(list_id);
		});

		$('#'+list_id+', #'+list_id+'_arrow').live('blur', function(evt){
		    //Note: DMT Change, allow for scrollbars
			currentInstance.clearDropdownInterval();
			if(evt.clientX > $('#'+list_id+'_list').width() + $('#'+list_id+'_list').offset().left)
		    {
		        currentInstance.setDropdownInterval();
		    }
		});

		$('#'+list_id+'_list, #'+list_id+', #'+list_id+'_arrow').mouseenter(function(){
			currentInstance.clearDropdownInterval();
		});

		$('#'+list_id+', #'+list_id+'_list, #'+list_id+'_arrow').mouseleave(function(evt){
		    //Note: DMT Change, allow for scrollbars, and add event to mouseout on arrow and select div
			currentInstance.clearDropdownInterval();
		    if( evt.clientX > $('#'+list_id+'_list').width() + $('#'+list_id+'_list').offset().left ||
		        evt.clientX < $('#'+list_id+'_list').offset().left ||
		        evt.clientY > $('#'+list_id+'_list').height() + $('#'+list_id+'_list').offset().top ||
		        evt.clientY < $('#'+list_id).offset().top)
		    {
			    currentInstance.setDropdownInterval()
			}
		});

        /*Note: DMT Change, was 
                             vv
        $('#'+list_id+'_list h3').live('click', function(){
                             ^^
        which did not seem to work.
        */        
		$('#'+list_id+'_list a').live('click', function(){
			currentInstance.selectDropDownOption(list_id,$(this).attr('id'),$(this).text());
		});
		
		/*
		Note: DMT Change
		Remove extra hidden input as it is no longer necessary if we are using a backing select input
		
		var valueStore = document.createElement('input');
		valueStore.setAttribute('type','hidden');
		valueStore.setAttribute('name',list_id+'_selected');
		valueStore.setAttribute('id',list_id+'_selected');
		valueStore.setAttribute('value','');
		document.body.appendChild(valueStore);
		*/
		
		currentInstance.drop_down_list.push(list_id)
	},
	'showDropDown' :function(list_id){
		//Note: DMT Change: Stop dropdowns from working when disabled
	    var dropdown = $('#' + list_id.replace('_select', ''));
	    if(dropdown.is(':disabled'))
	    {
	        return;
	    }
	    
		this.hideDropDowns();
		this.clearDropdownInterval();
		var currentLeft = parseInt($('#'+list_id).offset().left);
		var currentTop = parseInt($('#'+list_id).offset().top);
		//Note: DMT Change: Set width of list when dropdown is opened
		if($('#'+list_id).attr('class').toLowerCase().indexOf('cols') == -1)
        {
		    $('#'+list_id+'_list').width($('#'+list_id).outerWidth() - parseInt($('#'+list_id).css('border-left-width'),10) - parseInt($('#'+list_id).css('border-right-width'), 10));
		}
		$('#'+list_id+'_list').css({'top':(currentTop+parseInt($('#'+list_id).css('height'))-1),"left":(currentLeft), 'z-index' : 1000})
		$('#'+list_id+'_list').slideToggle("fast");
	},
	'selectDropDownOption' : function(list_id,short_value,text_value){
			this.clearDropdownInterval();
			/*Note: DMT Change
			Remove reference to hidden input that is no longer used, and change to text() instead of attr('value')
			To use divs instead of text inputs
			$('#'+list_id+'_selected').attr('value',short_value)
			$('#'+list_id).attr('value',text_value)*/
			$('#'+list_id).text(text_value)
			this.hideDropDowns();
	},
	'setDropdownInterval' : function(){
		currentInstance = this;
		this.hide_drop_downs = window.setInterval(function(){currentInstance.hideDropDowns()},1200);
	},
	'clearDropdownInterval' : function(){
		window.clearInterval(this.hide_drop_downs);
	},
	'hideDropDowns' : function(){
		for (var i in this.drop_down_list){
			$('#'+this.drop_down_list[i]+'_list').hide();					
		}
	}
}

/* --------------------------------------------------------------------------------------------- */

jQuery.fn.extend({
	selectbox: function(options) {
		return this.each(function() {
			new jQuery.SelectBox(this, options);
		});
	}
});

/* work around for ie logging */
if (!window.console) {
	var console = {
		log: function(msg) { 
	 }
	}
}

jQuery.SelectBox = function(selectobj, options) {
	
	var opt = options || {};
	opt.inputClass = opt.inputClass || "selectbox";
	opt.containerClass = opt.containerClass || "selectbox-wrapper";
	opt.hoverClass = opt.hoverClass || "current";
	opt.currentClass = opt.selectedClass || "selected"
	opt.debug = opt.debug || false;
	
	var elm_id = selectobj.id;
	var active = -1;
	var inFocus = false;
	var hasfocus = 0;
	//jquery object for select element
	var $select = $(selectobj);
	// jquery container object
	var $container = setupContainer(opt);
	//jquery input object 
	var $input = setupInput(opt);
	// hide select and append newly created elements
	$select.hide().before($input).before($container);

	init();
	
	$input
	.click(function(){
    if (!inFocus) {
		  $container.toggle();
		}
	})
	.focus(function(){
	   if ($container.not(':visible')) {
	       inFocus = true;
	       $container.show();
	   }
	})
	.keydown(function(event) {	   
		switch(event.keyCode) {
			case 38: // up
				event.preventDefault();
				moveSelect(-1);
				break;
			case 40: // down
				event.preventDefault();
				moveSelect(1);
				break;
			//case 9:  // tab 
			case 13: // return
				event.preventDefault(); // seems not working in mac !
				$('li.'+opt.hoverClass).trigger('click');
				break;
			case 27: //escape
			  hideMe();
			  break;
		}
	})
	.blur(function() {
		if ($container.is(':visible') && hasfocus > 0 ) {
			if(opt.debug) console.log('container visible and has focus')
		} else {
			hideMe();	
		}
	});

	function hideMe() { 
		hasfocus = 0;
		$container.hide(); 
	}
	
	function init() {
		$container.append(getSelectOptions($input.attr('id'))).hide();
		var width = $input.css('width');
		$container.width(width);
    }
	
	function setupContainer(options) {
		var container = document.createElement("div");
		$container = $(container);
		$container.attr('id', elm_id+'_container');
		$container.addClass(options.containerClass);
		
		return $container;
	}
	
	function setupInput(options) {
		var input = document.createElement("input");
		var $input = $(input);
		$input.attr("id", elm_id+"_input");
		$input.attr("type", "text");
		$input.addClass(options.inputClass);
		$input.attr("autocomplete", "off");
		$input.attr("readonly", "readonly");
		$input.attr("tabIndex", $select.attr("tabindex")); // "I" capital is important for ie
		
		return $input;	
	}
	
	function moveSelect(step) {
		var lis = $("li", $container);
		if (!lis) return;

		active += step;

		if (active < 0) {
			active = 0;
		} else if (active >= lis.size()) {
			active = lis.size() - 1;
		}

		lis.removeClass(opt.hoverClass);

		$(lis[active]).addClass(opt.hoverClass);
	}
	
	function setCurrent() {	
		var li = $("li."+opt.currentClass, $container).get(0);
		var ar = (''+li.id).split('_');
		var el = ar[ar.length-1];
		$select.val(el);
		$input.val($(li).text());
		setTimeout('__doPostBack(\'ctl00$cph$ddlSpecFilter\',\'\')', 0);
		return true;
	}
	
	// select value
	function getCurrentSelected() {
		return $select.val();
	}
	
	// input value
	function getCurrentValue() {
		return $input.val();
	}
	
	function getSelectOptions(parentid) {
		var select_options = new Array();
		var ul = document.createElement('ul');
		$select.children('option').each(function() {
			var li = document.createElement('li');
			li.setAttribute('id', parentid + '_' + $(this).val());
			li.innerHTML = $(this).text();
			if ($(this).is(':selected')) {
				$input.val($(this).text());
				$(li).addClass(opt.currentClass);
			}
			ul.appendChild(li);
			$(li)
			.mouseover(function(event) {
				hasfocus = 1;
				if (opt.debug) console.log('over on : '+this.id);
				jQuery(event.target, $container).addClass(opt.hoverClass);
			})
			.mouseout(function(event) {
				hasfocus = -1;
				if (opt.debug) console.log('out on : '+this.id);
				jQuery(event.target, $container).removeClass(opt.hoverClass);
			})
			.click(function(event) {
			  var fl = $('li.'+opt.hoverClass, $container).get(0);
				if (opt.debug) console.log('click on :'+this.id);
				$('li.'+opt.currentClass).removeClass(opt.currentClass); 
				$(this).addClass(opt.currentClass);
				setCurrent();
				hideMe();
			});
		});
		return ul;
	}
};

(function($) {
  $.fn.ezMark = function(options) {
	options = options || {}; 
	var defaultOpt = { 
		checkboxCls   	: options.checkboxCls || 'ez-checkbox' , radioCls : options.radioCls || 'ez-radio' ,	
		checkedCls 		: options.checkedCls  || 'ez-checked'  , selectedCls : options.selectedCls || 'ez-selected' , 
		hideCls  	 	: 'ez-hide'
	};
    return this.each(function() {
    	var $this = $(this);
    	var wrapTag = $this.attr('type') == 'checkbox' ? '<div class="'+defaultOpt.checkboxCls+'">' : '<div class="'+defaultOpt.radioCls+'">';
    	// for checkbox
    	if( $this.attr('type') == 'checkbox') {
    		$this.addClass(defaultOpt.hideCls).wrap(wrapTag).change(function() {
    			if( $(this).is(':checked') ) { 
    				$(this).parent().addClass(defaultOpt.checkedCls); 
    			} 
    			else {	$(this).parent().removeClass(defaultOpt.checkedCls); 	}
    		});
    		
    		if( $this.is(':checked') ) {
				$this.parent().addClass(defaultOpt.checkedCls);    		
    		}
    	} 
    	else if( $this.attr('type') == 'radio') {

    		$this.addClass(defaultOpt.hideCls).wrap(wrapTag).change(function() {
    			// radio button may contain groups! - so check for group
   				$('input[name="'+$(this).attr('name')+'"]').each(function() {
   	    			if( $(this).is(':checked') ) { 
   	    				$(this).parent().addClass(defaultOpt.selectedCls); 
   	    			} else {
   	    				$(this).parent().removeClass(defaultOpt.selectedCls);     	    			
   	    			}
   				});
    		});
    		
    		if( $this.is(':checked') ) {
				$this.parent().addClass(defaultOpt.selectedCls);    		
    		}    		
    	}
    });
  }
})(jQuery);

function unselectAllCheckBoxes() {
    $('input[type=checkbox]:checked').each( function() {
        this.checked = false;
    });
}

var lastSelectedCheckbox;

function checkBoxSelectionLimiter(checkbox) {
    var checkboxes_to_allow = 3;
    
    var selectedCheckboxes = $('input[type=checkbox]:checked');

    if (selectedCheckboxes.length == 0) {
        $('#ctl00_cph_btnContinue').hide();
    } else {
        $('#ctl00_cph_btnContinue').show();
    }
    
    if (selectedCheckboxes.length == (checkboxes_to_allow + 1)) {
        lastSelectedCheckbox.checked = false;
    }
    
    lastSelectedCheckbox = checkbox;
    
    $('input[type=checkbox]').ezMark();
}

function checkBoxSelectionLimiter2() {
    var checkboxes_to_allow = 3;
    
    var selectedCheckboxes = $('input[type=checkbox]:checked');

    if (selectedCheckboxes.length == 0) {
        $('#ctl00_cph_btnContinue').hide();
    } else {
        $('#ctl00_cph_btnContinue').show();
    }
    
    if (selectedCheckboxes.length >= (checkboxes_to_allow + 1)) {
        $('input[type=checkbox]:checked').each( function() {
            if (lastSelectedCheckbox.id == this.id) {
                this.checked = false;
            }
        });
        lastSelectedCheckbox = selectedCheckboxes[selectedCheckboxes.length - 1];
    }
    
    $('input[type=checkbox]').ezMark();
}

function setActiveView(activeViewIndex)
{
    if (activeViewIndex == 0) {
        document.getElementById('divCompetitorList').style.display = 'none';
        document.getElementById('divAdditionalCompetitorList').style.display = 'none';
        document.getElementById('divAddAnotherCompetitor').style.display = 'none';
        document.getElementById('divSelectAnotherCompetitor').style.display = 'none';
        document.getElementById('divNoCompetitorsAvailableMessage').style.display = 'none';
        
    } else if (activeViewIndex == 1){
        if (document.getElementById('divNoCompetitorsAvailableMessage').style.display != 'block') {
            document.getElementById('divCompetitorList').style.display = 'block';
        }
        document.getElementById('divAdditionalCompetitorList').style.display = 'none';
        document.getElementById('divAddAnotherCompetitor').style.display = 'block';
        document.getElementById('divSelectAnotherCompetitor').style.display = 'none';
        
    } else if (activeViewIndex == 2){
        if (document.getElementById('divNoCompetitorsAvailableMessage').style.display != 'block') {
            document.getElementById('divCompetitorList').style.display = 'block';
        }
        document.getElementById('divAdditionalCompetitorList').style.display = 'none';
        document.getElementById('divAddAnotherCompetitor').style.display = 'none';
        document.getElementById('divSelectAnotherCompetitor').style.display = 'block';
        
    } else if (activeViewIndex == 3){
        if (document.getElementById('divNoCompetitorsAvailableMessage').style.display != 'block') {
            document.getElementById('divCompetitorList').style.display = 'block';
        }
        document.getElementById('divAdditionalCompetitorList').style.display = 'block';
        document.getElementById('divAddAnotherCompetitor').style.display = 'block';
        document.getElementById('divSelectAnotherCompetitor').style.display = 'none';
        
    }
}

function showNoCompetitorsAvailableMessage(message)
{
    document.getElementById('divCompetitorList').style.display = 'none';
    document.getElementById('divAdditionalCompetitorList').style.display = 'none';
    document.getElementById('divAddAnotherCompetitor').style.display = 'block';
    document.getElementById('divSelectAnotherCompetitor').style.display = 'none';
    document.getElementById('divNoCompetitorsAvailableMessage').style.display = 'block';
    document.getElementById('divNoCompetitorsAvailableMessage').innerHTML = message;
}

function removeNoCompetitorsAvailableMessage()
{
    document.getElementById('divCompetitorList').style.display = 'block';
    document.getElementById('divAdditionalCompetitorList').style.display = 'none';
    document.getElementById('divAddAnotherCompetitor').style.display = 'block';
    document.getElementById('divSelectAnotherCompetitor').style.display = 'none';
    document.getElementById('divNoCompetitorsAvailableMessage').style.display = 'none';
    document.getElementById('divNoCompetitorsAvailableMessage').innerHTML = '';
}

function showComparison(display)
{
    if (display) {
        document.getElementById('divConfigure').style.display = 'none';
        document.getElementById('divComparison').style.display = 'block';
    	if($('img[src*="na.decdna.net"]').length == 0) {
    		$('#divComparison').append('<!--\n' +
            '/* Copyright 24/7 Real Media Inc. 2002-2009 */\n' +
            '/* This code is used to measure the efficiency of search engine listings*/\n' + 
            '/* Event Name: Comparator. Category: Conversion */\n' +
            '/* No private data is held. See our privacy policy:  http://www.247realmedia.com/privacy.html */\n' + 
            '/* Do not change the following line. */\n' +
            '-->\n' +
            '<img src="http://na.decdna.net/n/58675/62004/COMP/x/e?value=0&amp;trans=&amp;domain=na.decdna.net" width="1" height="1" alt="" />');
    	}
    } else {
        document.getElementById('divConfigure').style.display = 'block';
        document.getElementById('divComparison').style.display = 'none';
    }
    resizePage();
}

function updateCascadingDropdown(cddl)
{
    var dropdownID = cddl._element.id;
    
    var dropdown = $('#' + dropdownID);

    //Do not run update code if dropdowns have not been initialized    
    if(typeof(dropdown.data('input')) !== 'undefined')
    {
 
        //Build array of objects containing the new list of values in the dropdown   
        var data = new Array();
        
        dropdown.find('option').each(function(){
            var item = {};
            item.value = $(this).attr('value');
            item.text = $(this).text();
            
            data.push(item);
        });
        
        //Call plugin to update dropdown with list of data
        dropdown.fancy_drop_downs('update', data);
        
        //If the dropdown only has 1 element ('Select'), then style the dropdown as disabled
        if(dropdown.find('option').length > 1)
        {
            $('#'+dropdown.attr('id')+'_select').removeClass('disabled');
            $('#'+dropdown.attr('id')+'_select_arrow img').removeClass('disabled');
        }
        else
        {
            $('#'+dropdown.attr('id')+'_select').addClass('disabled');
            $('#'+dropdown.attr('id')+'_select_arrow img').addClass('disabled');
        }
    }
}

function resizePage()
{
    var helper_url = 'http://contents.vw.ca/vw4/helpers/resize_iframe.html';
    var pageHeight = $('body').height();
    
    $('#helper_iframe').attr('src', helper_url + '?height=' + pageHeight + '&cacheb=' + Math.random());
}
