/**
 * @author Nick Lockhart ;)
 */
var panelImage = '';
var panelImageName = '';
var galleryItemName ='';
var path = window.location.href.toLowerCase();
var IE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false;



	$2('.selection_2').live('click', function(event) {
		event.preventDefault();
		quote_open();
	});
	
	$2('.quote_request').live('click', function(event) {
		event.preventDefault();
		quote_open();
	});

	$2('a').live('click', function(event) {
		if($2(this).attr('a')=="/quote"){
		event.preventDefault();
		quote_open();
		}
	});

$2('.dropdowner a').unbind();

$2('.dropdowner a').click(function(event){
		event.preventDefault();
});

$2('.dropdowner a').hover(function(event){
		event.preventDefault();
},function(event){
		event.preventDefault();
});



$2(document).ready(function(){

if(IE6){
$2('.photogalleryItem a').each(function(){
		if (!$2(this).attr("title") == ""){
				galleryItemName = $2(this).attr('title');
		
				$2(this).parent().append('<div class="image_desc">'+galleryItemName+'</div>');
		}else{
				$2(this).parent().append('<div class="image_desc"> </div>');
		}
	$2(this).replaceWith($2(this).children('img')); 
	});
}

	$2('#topMenu a').hover(
	        function () {
	            $2(this).addClass('selected_page');
	 
	        },
	        function () {
	            //hide its submenu
	            $2(this).removeClass('selected_page');
	
	        }
	    );
    
    
    $2('.dropdown_list').hover(
        function () {
            $2(this).prev('a').addClass('selected_page');
 
        },
        function () {
            //hide its submenu
            $2(this).prev('a').removeClass('selected_page');

        }
    );





$2('.dropdowner').hover(
        function () {
            $2(this).children('.dropdown_list').css('display','block');
 
        },
        function () {
            //hide its submenu
            $2(this).children('.dropdown_list').hide();

        }
    );


	//Check if the URL has a service name in it
	if (path.indexOf('quote')!=-1) {
		//show about page
		$2('.selection_2').click();
	}




$2(".view_map").click(function(){
	if(IE6){
		window.open($2('.larger_map').children('a').attr('href'));
	}else{
$2("#location_modal").modal({
overlayClose:true,
onOpen: function (dialog) {
	dialog.overlay.fadeIn('slow', function () {
		dialog.container.slideDown('slow', function () {
			dialog.data.fadeIn('slow');
		});
	});
},
	onClose: function (dialog) {
	dialog.data.fadeOut('slow', function () {
		dialog.container.hide('slow', function () {
			dialog.overlay.slideUp('slow', function () {
				$2.modal.close();
			});
		});
	});
}

});
}
});
	
	$2('.panel_holder').hover(
		function(){
			panelImage = $2(this).children('a').children('img');
			panelImageName = $2(this).children('a').children('img').attr('alt');		
			
			panelImage.attr('src', 'images/active_'+panelImageName+'.jpg');
			
			$2(this).children('a').children('.panel_text').children('span').first().removeClass('panel_header');
			$2(this).children('a').children('.panel_text').children('span').first().next().removeClass('panel_desc');
			
			
			$2(this).children('a').children('.panel_text').children('span').first().addClass('active_panel_header');
			$2(this).children('a').children('.panel_text').children('span').first().next().addClass('active_panel_desc');
		},
		function(){
			panelImage.attr('src', 'images/'+panelImageName+'.jpg');
			$2(this).children('a').children('.panel_text').children('span').first().removeClass('active_panel_header');
			$2(this).children('a').children('.panel_text').children('span').first().next().removeClass('active_panel_desc');
			$2(this).children('a').children('.panel_text').children('span').first().addClass('panel_header');
			$2(this).children('a').children('.panel_text').children('span').first().next().addClass('panel_desc');
		}
		);
	$2('#CAT_Search').focus( function() {
		if ($2(this).val()=='Search here') {
			$2(this).val('');
		}
	});
	$2('#CAT_Search').focusout( function() {
		if ($2(this).val()=='') {
			$2(this).val('Search here');
		}
	});




	//faq accordian
	$2('.faq-question').click( function() {
		if (!$2(this).next('div').is(':visible')) {
			$2('.faq-answer').slideUp(400);

			$2('.faq-question').removeClass('faq_over');

			$2(this).next('div').slideDown(400);

			$2(this).addClass('faq_over');
		}

	});
	
	$2('.photogalleryItem').each(function(){
		if (!$2(this).children('a').attr("title") == ""){
				galleryItemName = $2(this).children('a').attr('title');
		
				$2(this).append('<div class="image_desc">'+galleryItemName+'</div>')
		}else{
				$2(this).append('<div class="image_desc"> </div>')
		}		 
	});
	
	

	
});// END DOCUMENT READY!

$2(window).load( function() {
	
	
	//CHANGE HEADER
	if(document.URL.indexOf("balustrades") >= 0){ 
		$2('#banner_image2').html('<img src="images/inner-panel-balustrades.jpg" />');
	}else if(document.URL.indexOf("pool-fences") >= 0){ 
		$2('#banner_image2').html('<img src="images/inner-panel-pool-fences.jpg" />');
	}else if(document.URL.indexOf("glass-showers") >= 0){ 
		$2('#banner_image2').html('<img src="images/inner-panel-glass-showers.jpg" />');
	} else if(document.URL.indexOf("mirrors") >= 0){ 
		$2('#banner_image2').html('<img src="images/inner-panel-mirrors.jpg" />');
	}else{
		$2('#banner_image2').html('<img src="images/inner-panel-general.jpg" />');
	}	
					
});//end window.load

function quote_open(){
		
		$2("#quote_modal").modal({
		overlayClose:true,
		onOpen: function (dialog) {
			dialog.overlay.fadeIn('slow', function () {
				dialog.container.slideDown('slow', function () {
					dialog.data.fadeIn('slow');
				});
			});
		},
			onClose: function (dialog) {
			dialog.data.fadeOut('slow', function () {
				dialog.container.hide('slow', function () {
					dialog.overlay.slideUp('slow', function () {
						$2.modal.close();
					});
				});
			});
		}
		
		});

}

