jQuery.noConflict();

function preLava()
{
	jQuery("#nav .current_page_item, #nav .current_page_parent, #nav .current_page_ancestor").addClass("current").removeClass("current_page_item").removeClass("current_page_parent").removeClass("current_page_ancestor");
}

function dropDownPages() { 
jQuery("#nav a").removeAttr('title'); 
jQuery("#nav ul").css({display: "none"}); // Opera Fix 
jQuery("#nav li").hover(function(){ 
        jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).show(500, 'easeInOutCirc'); 
        },function(){ 
        jQuery(this).find('ul:first').css({visibility: "hidden"}); 
        }); 
}  


function simulateFirstChild()
{
		jQuery('#bottombar > div:first-child').addClass('firstChild');
}
function buttonFade()
{
	if(!(jQuery.browser.msie == true )){
	jQuery("span.button").each(function(){
			jQuery(this).css({"opacity" : ".6"});								
	});
	jQuery("span.button").each(function(){
			jQuery(this).hover(
      		function () {
        		jQuery(this).fadeTo(600, 1);
      		}, 
      		function () {
        		jQuery(this).fadeTo(600, .6);
      		});
	});
	jQuery("input#searchsubmit, #submit").each(function(){
			jQuery(this).hover(
      		function () {
        		jQuery(this).fadeTo(600, .6);
      		}, 
      		function () {
        		jQuery(this).fadeTo(600, 1);
      		});
	});
	jQuery(".galleryButton").css( { "opacity" : "0" } );
	jQuery(".viewBtn").css( { "right" : "-108px" } );
	jQuery(".zoomBtn").css( { "left" : "-108px" } );
	jQuery("#gallery .imgWrapper, #main .singleImgWrapper").each(function(){
			jQuery(this).hover(
      		function () {
        		jQuery(this).children(".viewBtn").animate({ "right" : "11px" }, { queue: false, duration: 600}).animate({ "opacity" : "1" }, { queue: false, duration: 600});
      		}, 
      		function () {
        		jQuery(this).children(".viewBtn").animate({ "right" : "-108px" }, { queue: false, duration: 600}).animate({ "opacity" : "0" }, { queue: false, duration: 600}).parent(this).children(".zoomBtn").animate({ "left" : "11px" }, { queue: false, duration: 600}).animate({ "opacity" : "1" }, { queue: false, duration: 600});
      		});
			jQuery(this).hover(
      		function () {
        		jQuery(this).children(".zoomBtn").animate({ "left" : "11px" }, { queue: false, duration: 600}).animate({ "opacity" : "1" }, { queue: false, duration: 600});
      		}, 
      		function () {
        		jQuery(this).children(".zoomBtn").animate({ "left" : "-108px" }, { queue: false, duration: 600}).animate({ "opacity" : "0" }, { queue: false, duration: 600});
      		});
	});
	}
}

/**
 * LavaLamp - A menu plugin for jQuery with cool hover effects.
 * @requires jQuery v1.2.x or higher
 *
 * http://nixbox.com/lavalamp.php
 *
 * Copyright (c) 2008, 2009 Jolyon Terwilliger, jolyon@nixbox.com
 * Original code Copyright (c) 2007, 2008
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * credits to Guillermo Rauch and Ganeshji Marwaha (gmarwaha.com) for previous editions
 */
(function(jQuery) {
jQuery.fn.lavaLamp = function(o) {
	o = jQuery.extend({ fx: 'swing', 
					  	speed: 500, 
						click: function(){return true}, 
						startItem: 'no',
						autoReturn: true,
						returnDelay: 0,
						setOnClick: true,
						homeTop:0,
						homeLeft:0,
						homeWidth:0,
						homeHeight:0,
						returnHome:false
						}, 
					o || {});

	return this.each(function() {
		var path = location.pathname + location.search + location.hash;
		var $selected = new Object;
		var delayTimer;
		var $back;
		var $home;
		var ce;
		
		//
		// create homeLava element if origin and dimensions set and startItem == off
		if (o.homeTop || o.homeLeft) { 
			$home = jQuery('<li class="homeLava selectedLava"></li>').css({ left:o.homeLeft, top:o.homeTop, width:o.homeWidth, height:o.homeHeight, position:'absolute' });
			jQuery(this).prepend($home);
		}
		
		var $li = jQuery('li', this);
		// check for complete path match, if so flag element into $selected
		if ( o.startItem == 'no' )
			$selected = jQuery('li.current', this);
			
		// double check, this may be just an anchor match
		if ($selected.length == 0 && o.startItem == 'no' && location.hash)
			$selected = jQuery('li a[href$="' + location.hash + '"]', this).parent('li');

		// no default selected element matches worked, 
		// or the user specified an index via startItem
		if ($selected.length == 0 || o.startItem != 'no') {
			// always default to first item, if no startItem specified.
			if (o.startItem == 'no') o.startItem = 0;
			$selected = jQuery($li[o.startItem]);
		}
		// set up raw element - this allows user override by class .selectedLava on load
		ce = jQuery('li.selectedLava', this)[0] || jQuery($selected).addClass('selectedLava')[0];

		// add mouseover event for every sub element
		$li.mouseover(function() {
			if (jQuery(this).hasClass('homeLava')) {
				ce = jQuery(this)[0];
			}
			move(this);
		});

		$back = jQuery('<li class="backLava"><div class="leftLava"><div class="innerLava"></div></div><div class="rightLava"></div></li>').appendTo(this);
		
		// after we leave the container element, move back to default/last clicked element
		jQuery(this).mouseout( function() {
			if (o.autoReturn) {
				
				if (o.returnHome && $home) {
					move($home[0]);
				}
				else if (o.returnDelay) {
					if(delayTimer) clearTimeout(delayTimer);
					delayTimer = setTimeout(move,o.returnDelay + o.speed);
				}
				else {
					move();
				}
			}
		});

		$li.click(function(e) {
			if (o.setOnClick) {
				jQuery(ce).removeClass('selectedLava');
				jQuery(this).addClass('selectedLava');
				ce = this;
			}
			return o.click.apply(this, [e, this]);
		});

		// set the starting position for the lavalamp hover element: .back
		if (o.homeTop || o.homeLeft) 
			$back.css({ left:o.homeLeft, top:o.homeTop, width:o.homeWidth, height:o.homeHeight });
		else
			$back.css({ left: ce.offsetLeft, top: ce.offsetTop, width: ce.offsetWidth, height: ce.offsetHeight });


		function move(el) {
			if (!el) el = ce;
			// .backLava element border check and animation fix
			var bx=0, by=0;
			if (!jQuery.browser.msie) {
				bx = ($back.outerWidth() - $back.innerWidth())/2;
				by = ($back.outerHeight() - $back.innerHeight())/2;
			}
			$back.stop()
			.animate({
				left: el.offsetLeft-bx,
				top: el.offsetTop-by,
				width: el.offsetWidth,
				height: el.offsetHeight
			}, o.speed, o.fx);
		};
	});
};
})(jQuery);


//contact form

jQuery(function() {
	
	var $mailUrl = jQuery('#contactForm').attr("action");
    var paraTag = jQuery('#contact input#submit').parent('p');
    jQuery(paraTag).children('input').remove();
    jQuery(paraTag).append('<input type="button" name="submit" id="submit" value="Submit" tabindex="4" />');

    jQuery('#contact input#submit').click(function() {
        jQuery('#contact').append('<p class="loaderIcon">Loading...</p>');

        var name = jQuery('input#name').val();
        var email = jQuery('input#email').val();
        var comments = jQuery('textarea#message').val();

        jQuery.ajax({
            type: 'post',
            url: $mailUrl,
            data: 'name=' + name + '&email=' + email + '&comments=' + comments,

            success: function(results) {
                jQuery('#contact p.loaderIcon').fadeOut(1000);
                jQuery('div#response').html(results);
            }
        });
    });
});

jQuery(document).ready(function(){
	preLava();
	dropDownPages();
	simulateFirstChild();
	jQuery("ul#nav").lavaLamp({ fx: "easeOutCubic", speed: 700 });
	buttonFade();
	
});
