
    $(document).ready(function() {
        $("select.sector")
        .mouseover(function() {
            $(this)
                .data("origWidth", $(this).css("width"))
                .css("width", "auto")
                .focus();
        })
        .mouseout(function() {
            $(this)
                .blur(function() {
                    $(this).css("width", $(this).data("origWidth"));
                })
                .change(function() {
                    $(this).css("width", $(this).data("origWidth"));
                })
        });
    });
	
	
	$(document).ready(function(){
								 
								 

	
	
	
		
		$(function() {
			setInterval( "slideSwitch()", 5000 );
		});
				 
//		$(function() {
//			setInterval( "homeslideSwitch()", 5000 );
//		});
				
		$(function() {
			setInterval( "fiveslideSwitch()", 3000 );
		});
				
	
        
        $("#menu li").hover(
            function(){
                if($(this).find("ul").css('display')=='none')
                    $(this).find("ul").show();
            },
            function(){
                $(this).find("ul").hide();
            }
        );
		
		 $("#menu li ul li").hover(
            function(){
                if($(this).find("li a").css('background')=='transparent url(/img/hover.png) repeat-x center');
            },
			
            function(){
                if($(this).find("li a").css('background')=='none');
            }
        );

        
        
		

		jQuery('.cropbox').Jcrop({
			onChange: showPreview,
			onSelect: showPreview,
			setSelect: [ 0, 0, 1000, 1000 ],
			boxWidth: 500,
			boxHeight: 300,
			aspectRatio: 1
		});
		
		
			jQuery('.admincropbox').Jcrop({
			onChange: showPreview,
			onSelect: showPreview,
			setSelect: [ 0, 0, 1000, 1000 ],
			boxWidth: 500,
			boxHeight: 300,
			aspectRatio: 13/6
		});
			
			
			jQuery('.homecropbox').Jcrop({
			onChange: showPreview,
			onSelect: showPreview,
			setSelect: [ 0, 0, 1000, 1000 ],
			boxWidth: 500,
			boxHeight: 300,
			aspectRatio: 12/5
		});
			
			
			jQuery('.galcropbox').Jcrop({
			onChange: showPreview,
			onSelect: showPreview,
			setSelect: [ 0, 0, 1000, 1000 ],
			boxWidth: 500,
			boxHeight: 300,
			aspectRatio: 6/4
		});
			
			
			jQuery('.advertcropbox').Jcrop({
			onChange: showPreview,
			onSelect: showPreview,
			setSelect: [ 0, 0, 1000, 1000 ],
			boxWidth: 500,
			boxHeight: 300,
			aspectRatio: 5/7
		});
		

	});
	
	function gallery() {
		$('ul.gallery').galleria({
				history   : true, // activates the history object for bookmarking, back-button etc.
				clickNext : true, // helper for making the image clickable
				insert    : '#main_image', // the containing selector for our main image
				onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
					
					// fade in the image & caption
					if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
						image.css('display','none').fadeIn(1000);
					}
					caption.css('display','none').fadeIn(1000);
					
					// fetch the thumbnail container
					var _li = thumb.parents('li');
					
					// fade out inactive thumbnail
					_li.siblings().children('img.selected').fadeTo(500,0.3);
					
					// fade in active thumbnail
					thumb.fadeTo('fast',1).addClass('selected');
					
					// add a title for the clickable image
					image.attr('title','Next image >>');
				},
				onThumb : function(thumb) { // thumbnail effects goes here
					
					// fetch the thumbnail container
					var _li = thumb.parents('li');
					
					// if thumbnail is active, fade all the way.
					var _fadeTo = _li.is('.active') ? '1' : '0.3';
					
					// fade in the thumbnail when finnished loading
					thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
					
					// hover effects
					thumb.hover(
						function() { thumb.fadeTo('fast',1); },
						function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
					)
				}
			});	
		
		

		
		
	}
	
	
	
	function toggle_spouse(val) {
	document.getElementById('atype').style.display = (val) ? 'block' : 'none';
	document.getElementById('ni').style.display = (val) ? 'block' : 'none';

	}
	
	function toggle_tspouse(val) {
	document.getElementById('sta').style.display = (val) ? 'block' : 'none';

	}
	
		function slideSwitch() {
			var $active = $('#slideshow li.active');
		
			if ( $active.length == 0 ) $active = $('#slideshow li:last');
		
			var $next =  $active.next().length ? $active.next()
				: $('#slideshow li:first');
		
			$active.addClass('last-active');
		
			$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1000, function() {
					$active.removeClass('active last-active');
				});
		}
		
			function homeslideSwitch() {
			var $active = $('#homeshow div.active');
		
			if ( $active.length == 0 ) $active = $('#homeshow div:last');
		
			var $next =  $active.next().length ? $active.next()
				: $('#homeshow div:first');
		
			$active.addClass('last-active');
		
			$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1000, function() {
					$active.removeClass('active last-active');
			
			});
		}
		
			function fiveslideSwitch() {
			var $active = $('#fiveshow div.active');
		
			if ( $active.length == 0 ) $active = $('#fiveshow div:last');
		
			var $next =  $active.next().length ? $active.next()
				: $('#fiveshow div:first');
		
	/*		$active.addClass('last-active');
			$('last-active').animate({opacity: 0}, 1000); */
		
			$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1000)
			$active.removeClass('active last-active');

		}


	function showPreview(coords, id){
		jQuery('#x_' + id).val(coords.x);
		jQuery('#y_' + id).val(coords.y);
		jQuery('#x2_' + id).val(coords.x2);
		jQuery('#y2_' + id).val(coords.y2);
		jQuery('#w_' + id).val(coords.w);
		jQuery('#h_' + id).val(coords.h);
	}

	
	
	

