function callOverlay(input, mwidth, mheight, mtitle, is_ajax, mcontent) 
{
	if (mwidth == "" || mwidth == undefined)
	{
		mwidth = 750; 
	}
	if (mheight == "" || mheight == undefined)
	{
		mheight = 400; 
	}
	if (mtitle == "" || mtitle == undefined)
	{
		mtitle = "View detail"; 
	}
	if (is_ajax == "" || is_ajax == undefined)
	{
		is_ajax = 'yes'; 
	}

	$('#overlay').dialog('destroy'); 

	var dialogOpts = {
			title: mtitle,
			modal: true,
			autoOpen: false,
			width: parseInt(mwidth), 
			height: parseInt(mheight), 
			 open: function() {
				 $('body').find('select').css('display', 'none'); 
				 if (is_ajax == 'yes')
				 {
					 $("#overlay").load(input.attr('href')); 
				 }
				 else 
				 {
					 if (mcontent != "" && mcontent != undefined)
					 {
						$('.ui-dialog-content').html(mcontent); 
					 }
				 }
				 
			},
			close: function(){
				$('body').find('select').css('display', 'inline'); 			
				$('#overlay').dialog('destroy'); 
			}
		};
	$("#overlay").dialog(dialogOpts); 
	
	$('#overlay').dialog('open'); 
	
}


(function($) {
	$.fn.emptyTest = function(){
		return this.each(function(){
			this.options.length = 0; 
		}); 
	}
	$.fn.resetSelect = function(text) {
		return this.emptySelect().each(function(){
			if (this.tagName == "SELECT")
			{
				var selectElement = this; 
				var option = new Option(text, ''); 

				if ($.browser.msie)
				{
					selectElement.add(option);
				}
				else 
				{
					selectElement.add(option, null); 
				}
			}
		}); 
	}
	$.fn.showLoading = function(text) {
		return this.emptySelect().each(function(){
			if (this.tagName == "SELECT")
			{
				var selectElement = this; 
				var option = new Option(text, ''); 

				if ($.browser.msie)
				{
					selectElement.add(option);
				}
				else 
				{
					selectElement.add(option, null); 
				}
				
			}
		}); 
	}
	$.fn.disabled = function() {
		this.attr('disabled', true); 
		this.addClass('disabled_elem'); 
	}
	$.fn.enabled = function() {
		this.attr('disabled', false); 
		this.removeClass('disabled_elem'); 
	}

	$.fn.emptySelect = function() {
		return this.each(function(){
			if (this.tagName=='SELECT') this.options.length = 0;
		});
	}
	$.fn.loadSelect = function(optionsDataArray, lblFirst, currentValue) {
		return this.emptySelect().each(function(){
			if (this.tagName=='SELECT') {
				var selectElement = this;
				if (lblFirst != "")
				{
					//selectElement.add(new Option(lblFirst, ""));
					var option = new Option(lblFirst, ""); 
					if ($.browser.msie)
						selectElement.add(option); 
					else 
						selectElement.add(option, null); 
				}		
				if (optionsDataArray != null)
				{
					$.each(optionsDataArray,function(index,optionsData){		
						if (optionsData.opt_value == currentValue)
						{
							var option = new Option(optionsData.opt_text, optionsData.opt_value);
							option.selected = true; 
						}
						else
						{
							var option = new Option(optionsData.opt_text, optionsData.opt_value);
						}
						if ($.browser.msie) {
							selectElement.add(option);
						}
						else {
							selectElement.add(option,null);
						}
					});					
				}			
			}
		});
	}
	$.fn.loadSelectHotel = function(optionsDataArray, lblFirst) {
		return this.emptySelect().each(function(){
			if (this.tagName=='SELECT') {
				var selectElement = this;
				if (lblFirst != "")
				{
					//selectElement.add(new Option(lblFirst, ""));
					var option = new Option(lblFirst, ""); 
					if ($.browser.msie)
						selectElement.add(option); 
					else 
						selectElement.add(option, null); 
				}		
				if (optionsDataArray != null)
				{
					$.each(optionsDataArray,function(index,optionsData){		
						if (optionsData.opt_value == $.cookie('ck_hotel_search'))
						{
							var option = new Option(optionsData.opt_text, optionsData.opt_value);
							option.selected = true
						}
						else
						{
							var option = new Option(optionsData.opt_text, optionsData.opt_value);
						}
						if ($.browser.msie) {
							selectElement.add(option);
						}
						else {
							selectElement.add(option,null);
						}
					});
					
				}

				
			}
		});
	}
})(jQuery);
