try{ document.execCommand("BackgroundImageCache", false, true) }catch(err){}

$(function ()
		{
			if ($('.fixed-select-css').length)
				$('.fixed-select-css').ieSelectStyle();
		});
		
$(document).ready(function() {
	
	if (document.images)
	{
		 pic1= new Image(203,54);
		 pic1.src=SiteUrl+"img/btn_1_over.gif";
	
		 pic2= new Image(202,54);
		 pic2.src=SiteUrl+"img/btn_2_over.gif";
	
		 pic3= new Image(202,54);
		 pic3.src=SiteUrl+"img/btn_3_over.gif";
	 
		 pic4= new Image(203,54);
		 pic4.src=SiteUrl+"img/btn_4_over.gif";
	}
	
	$('.custom_chbx').simpleImageCheck({
		image: SiteUrl+'img/checkbox_off.png',
		imageChecked: SiteUrl+'img/checkbox_on.png'
	});
	
	// advanced search
	$('#advanced_search_btn a').click(function() {
		$(this).toggleClass('active');
		$('.advanced_search').toggle();
		return false;
	});
	
	
	
	$('.btn_1, #downmenu_1').hover( function () { SwitchMenu('downmenu_1') }, function () { SwitchMenu('downmenu_1') } );
	$('.btn_2, #downmenu_2').hover( function () { SwitchMenu('downmenu_2') }, function () { SwitchMenu('downmenu_2') } );
	$('.btn_3, #downmenu_3').hover( function () { SwitchMenu('downmenu_3') }, function () { SwitchMenu('downmenu_3') } );
	$('.btn_4, #downmenu_4').hover( function () { SwitchMenu('downmenu_4') }, function () { SwitchMenu('downmenu_4') } );
	
	$('#tourism_types_list input[type=checkbox]').click(function() {
		
		var is_parent_checked = !$(this).attr('checked');
		var childs = $(this).parent().parent().parent().parent().next('table.child').find('td.l_cell');
		childs = $(this).parent().parent().parent().parent().parent().next('li[class^=level_]');
		
		childs.each(function() {
			//$(this).css('border', '1px solid red');
			var img = $(this).find('img');
			var checkbox = $(this).find('input');
			
			if( is_parent_checked ) {
				img.addClass('checked');
				img.attr('aria-checked', 'true');
				img.attr('src', SiteUrl+'img/checkbox_on.png');
			}
			else {
				img.removeClass('checked');
				img.attr('aria-checked', 'false');
				img.attr('src', SiteUrl+'img/checkbox_off.png');
			}
			
			checkbox.attr('checked', is_parent_checked);
			
		});
		
	});
		
	
	$('a[rel=list]').click(function() {
		$('#tab_map_active').attr('id', 'tab_map');
		$(this).parent().attr('id', 'tab_list_active');
		$('#map_container').hide();
		$('#list_container').show();
		return false;
	});
	
	$('a[rel=map]').click(function() {
		$('#tab_list_active').attr('id', 'tab_list');
		$(this).parent().attr('id', 'tab_map_active');
		$('#list_container').hide();
		return false;
	});
	
});

function getFileSize(id) {
	
    var fileInput = $("#"+id)[0];

    if (fileInput.files == undefined || fileInput.files[0] == undefined)
        return 0;
    
   return fileInput.files[0].fileSize; // Size returned in bytes.
}
