
function removeEmptyZones()
{$("#left,#right").each(function(){if($(this).is("empty")||$.trim($(this).html())=="")
{$(this).remove();}});}
function setContentWidth()
{if($("#content .panel").length>0)
{if($("#content .wrap-panels").length<1)
{$("#content .panel").wrapAll('<div class="wrap-panels"></div>');}}
var width=$("#main").width();if($("#left:visible").length)
{width-=$("#left").width();$("#content .wrap,#content .wrap-panels").addClass("padding-left");}
else
{$("#content .wrap, #content .wrap-panels").removeClass("padding-left");}
if($("#right:visible").length>0)
{width-=$("#right").width();$("#content .wrap,#content .wrap-panels").addClass("padding-right");}
else
{$("#content .wrap,#content .wrap-panels").removeClass("padding-right");}
$("#content").width(width);}
function setCountriesStates(countrySelector,currentCountry,stateSelector,currentState,provinceSelector,currentProvince,countriesStates){var countriesHTML='';jQuery.each(countriesStates,function(countryId,countryData)
{countriesHTML+='<option value="'+countryId+'" '+(countryId==currentCountry?'selected="selected"':'')+'>'+countryData.country_name+'</option>';});$(countrySelector+" select").html(countriesHTML);currentCountry=$(countrySelector+" select option:selected").attr("value");if(countriesStates[currentCountry].states!=null&&countriesStates[currentCountry].states!='undefined'&&countriesStates[currentCountry].states)
{var statesHTML='';if(currentState==''||currentState=='0')
{statesHTML+='<option value="">'+msg.select_state_or_province+'</option>';}
jQuery.each(countriesStates[currentCountry].states,function(stateId,stateName){statesHTML+='<option value="'+stateId+'" '+(stateId==currentState?'selected="selected"':'')+'>'+stateName+'</option>';});$(stateSelector+" select").html(statesHTML);$(provinceSelector).hide();$(stateSelector).show();}
else
{$(provinceSelector+" input[type='text']").val(currentProvince);$(stateSelector).hide();$(provinceSelector).show();}
$(countrySelector+" select").change(function(){currentCountry=$(countrySelector+" select option:selected").attr("value");if(countriesStates[currentCountry].states)
{var statesHTML='';jQuery.each(countriesStates[currentCountry].states,function(stateId,stateName){statesHTML+='<option value="'+stateId+'" '+(stateId==currentState?'selected="selected"':'')+'>'+stateName+'</option>';});$(stateSelector+" select").html(statesHTML);$(provinceSelector).hide();$(stateSelector).show();}
else
{$(stateSelector).hide();$(provinceSelector).show();}});}
jQuery.fn.editableSelectSetValue=function(val)
{$(this).val(val);$(this).prevAll("input[type='text']:first").val(val);}
jQuery.fn.editableSelect=function()
{if($(this).data('editable-select-options')!=null&&$(this).data('editable-select-options')!='undefined')return this;var edit=$('<input type="text" class="editable-select-text"/>').val($(this).find('option:selected').html()).click(function(){if($(this).nextAll('div.editable-select-options:first').is(":visible"))
{$(this).nextAll('div.editable-select-options:first').slideUp("fast");}
else
{$('div.editable-select-options').slideUp("fast");var pos=$(this).position();var w=$(this).width()+parseInt($(this).css('padding-left'))+parseInt($(this).css('padding-right'));$(this).nextAll('div.editable-select-options:first').css({position:'absolute',top:pos.top+$(this).height()+2+parseInt($(this).css('padding-top'))+parseInt($(this).css('padding-bottom')),left:pos.left,width:w<180?180:w}).slideDown("fast");}}).change(function(){$(this).nextAll('input[type="hidden"]:first').val($(this).val()).trigger('change');$(this).nextAll('div.editable-select-options:first').slideUp("fast");});if($(this).attr("style")!="undefined"&&$(this).attr("style")!="")
{$(edit).attr('style',$(this).attr("style"));}
var hidden=$('<input type="hidden"/>').attr('name',$(this).attr("name")).attr('id',$(this).attr("id")).data('editable-select-options',true).val($(this).val());var options="";jQuery.each($(this).find("option"),function(optIndex,opt){t=$.trim($(opt).html());options=options+'<li><a href="#'+escape($(opt).attr('value'))+'"><div>'+(t==""?"&nbsp;":t)+'</div></a></li>'});var dropDown=$('<div class="editable-select-options" style="display:none;"><ul>'+options+'</ul></div>');$(edit).replaceAll(this);$(hidden).insertAfter(edit);$(dropDown).insertAfter(hidden);$(dropDown).find('ul li a').click(function(event){event.stopPropagation();var val=unescape($(this).attr('href').substring(1));var valCaption=unescape($(this).find('div').html());if(valCaption=="&nbsp;")valCaption="";$(hidden).val(valCaption).trigger('change');$(edit).val(valCaption);$(edit).nextAll('div.editable-select-options:first').slideUp("fast");return false;});$(this).data('editable-select-options',true);return this;}
