// DD_roundies for rounded corners in IE
if ($.browser.msie && $.browser.version <= 8.0) {
	$('#logo').supersleight();
}

// jquery
$(document).ready(function() {
	// Set current menu selected
	var current = document.location.href;
	if (current)
	{
  	var m = current.toString().match(/.*\/(.+?)\./);
  	if (m && m.length > 1 && m[1] != "index" ) { 
  		var elem = "#gn-" + m[1]; 
  		$(elem).addClass('current');
  	}
 	}

	// slide show
	if ($('.coin-slider').length > 0) {
		var w, h, d;
		w = ($('#ss-index').length > 0) ? 400 : 600;
		h = ($('#ss-index').length > 0) ? 300 : 245;
		d = ($('#ss-index').length > 0) ? 8000 : 3000;
		$('.coin-slider').coinslider({
			width: w, // width of slider panel
			height: h, // height of slider panel
			spw: 10, // squares per width
			sph: 4, // squares per height
			delay: d, // delay between images in ms
			sDelay: 30, // delay beetwen squares in ms
			opacity: 0.7, // opacity of title and navigation
			titleSpeed: 500, // speed of title appereance in ms
			effect: 'rain', // random, swirl, rain, straight
			navigation: false, // prev next and buttons
			links : false, // show images as links 
			hoverPause: true // pause on hover
		});
	}
	
	//faq.php specific
	if($('#answers').length > 0){
		$('.answer').hide();
		$('.question').click(function() {
			//alert($(this).next('div').text());
			//$(this).next().slideDown();
			$(this).nextAll('.answer').slideToggle('slow');
		});
		$('.answer').click(function() {
			$(this).slideUp();
		});
	}
	
	//staff.php specific
	if ($('#start_date').length > 0) {	
		$('#start_date').datepicker({ showOn: 'button', buttonImage: 'images/calendar.png', buttonImageOnly: true }); 
	}
	if ($('#end_date').length > 0) { 
		$('#end_date').datepicker({ showOn: 'button', buttonImage: 'images/calendar.png', buttonImageOnly: true }); 
	}
	
	//staff.php and new-client.php specific
	if ($('form').length > 0) {
		$('form').validationEngine();
		$('form').submit(function() {
			/*var dialogButton;
			$('<div id="dialog" title="Alert"><p>Are you sure to submit this form?</p></div>').dialog({
				autoOpen: false,
				width: 600,
				buttons: {
					"Ok": function() { 
						$(this).dialog("close");
						dialogButton = true;
					}, 
					"Cancel": function() { 
						$(this).dialog("close");
						dialogButton = false;
					} 
				}
			});
			*/
			if($('form').validationEngine('validate')/* && dialogButton*/){
				return true;
			} else {
				return false;
			}
				
		});
	}
	
	// opportunities.php specific
	if ($('#specialties').length > 0) {
		$('img.specialty-picture').hide();
		
		$('#specialty1 div.specialty-list').mouseover(function(){
			$(this).hide();
			$('#specialty1 img.specialty-picture').show();
		});
		$('#specialty1 img.specialty-picture').mouseout(function(){
			$(this).hide();
			$('#specialty1 div.specialty-list').show();
		});
		
		$('#specialty2 div.specialty-list').mouseover(function(){
			$(this).hide();
			$('#specialty2 img.specialty-picture').show();
		});
		$('#specialty2 img.specialty-picture').mouseout(function(){
			$(this).hide();
			$('#specialty2 div.specialty-list').show();
		});
		
		$('#specialty3 div.specialty-list').mouseover(function(){
			$(this).hide();
			$('#specialty3 img.specialty-picture').show();
		});
		$('#specialty3 img.specialty-picture').mouseout(function(){
			$(this).hide();
			$('#specialty3 div.specialty-list').show();
		});
		
		$('#specialty4 div.specialty-list').mouseover(function(){
			$(this).hide();
			$('#specialty4 img.specialty-picture').show();
		});
		$('#specialty4 img.specialty-picture').mouseout(function(){
			$(this).hide();
			$('#specialty4 div.specialty-list').show();
		});
	}
});
