$(function () {
	$("ul.dropdown li").hover(function () {
		$(this).addClass("hover");
		$('ul:first', this).css('visibility', 'visible');
	}, function () {
		$(this).removeClass("hover");
		$('ul:first', this).css('visibility', 'hidden');
	});
	$("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
	
//	$(".sub_menu li a").hover(function () {
//		$(this).css('color', '#fff');
//	}, function () {
//		$(this).css('color', '#5e5e5e');
//	});
//	
	$("ul.dropdown:parent > li a").hover(function () {
		$(this).css('color', '#fff');
	}, function () {
		$(this).css('color', '#000');
	});

	
});

function load_banner() {
   
}

$(document).ready(function () {
	Cufon.replace('#news h1,#featured-project h1,#feat-video h1,#connect h1,#our-sub h1,#stock-update h1,#projects h1,#inner-page h1,#inner-page h2,#projects h1,#projects h2,#projects h4,#projects p,#banner span,.subsd-info h3,.addr-title,ul#board-members li,ul#exec-management li', {
		fontFamily: 'Street - Plain',
		hover: true
	});
	
	load_banner();
	
	$('#top-links ul.left li.middle').click(function(event){
		event.preventDefault();
		alert("Coming soon...\nSorry for the inconvenience.");
	});
	
	
	
	if ($("#proj-img").length){
		$("#proj-img a span,#banner span").css({opacity: 0.9});
		$(".proj-info").css({opacity: 0.9});
	}
	
	if ($("ul#board-members").length){
		$("ul#board-members li:first").css("width","620px");
	}

	$(".toolTip").hover(function(){
		var z = $(this).attr('title');
		$(this).append('<p class="tip">' + z + '</p>');
	}, function () {
		$(".toolTip p").remove();
	});

	if ($('#contact-form').length) {
		$('input[title!=""]').hint();
		$('textarea[title!=""]').hint();
	}

	if($('.proj').length){
		$('.proj').hover(function () {
			var distance = $(this).outerWidth();
			$(this).find('.proj-info').animate({
				top: '-' + 90,
				height:'82px'
			}, {
				queue: false,
				duration: 150
			});
	
		}, function () {
			$(this).find('.proj-info').animate({
				top: '-45px',
				height:'38px'
			}, {
				queue: false,
				duration: 150
			});
		});
	}

	if ($("a[rel^='prettyPhoto']").length) {
		$("a[rel^='prettyPhoto']").prettyPhoto();
	}

	$('ul.dropdown li ul').hover(

	function () {
		$(this).parent().parent().css("color", "#000");
	}, function () {
		$(this).parent().parent().css("color", "#5e5e5e");
	});

	/*var n = $('#main-nav ul.dropdown').html();
	$('#footer ul.left').html(n);
	$('#footer ul.left ul.sub_menu').remove();
	$("#footer ul.left li:last").css('background','none');
	$("ul.dropdown:parent > li a").removeAttr("href");*/



	if ($('#foo1').length) {
		$("#foo1").carouFredSel({
			items: 2,
			auto: false,
			prev: "#foo1_prev",
			next: "#foo1_next"
		});
	}


	var currentURL = window.location.toString().split("/");
	var hash = currentURL[currentURL.length - 1];
	$("a[href $='" + hash + "']").parents("li").each(function () {
		$(this).addClass("current");
	});

	$(".dropdown dt a").click(function () {
		$(".dropdown dd ul").toggle();
	});

	$(".dropdown-two dt a").click(function () {
		$(".dropdown-two dd ul").toggle();
	});

	$(".dropdown img.flag,.dropdown-two img.flag").addClass("flagvisibility");

	$(".dropdown dd ul li a").click(function () {
		var text = $(this).html();
		$(".dropdown dt a span").html(text);
		$(".dropdown dd ul").hide();
	});

	$(".dropdown-two dd ul li a").click(function () {
		var text = $(this).html();
		$(".dropdown-two dt a span").html(text);
		$(".dropdown-two dd ul").hide();
	});

	$(document).bind('click', function (e) {
		var $clicked = $(e.target);
		if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide();
	});

	$(document).bind('click', function (e) {
		var $clicked = $(e.target);
		if (!$clicked.parents().hasClass("dropdown-two")) $(".dropdown-two dd ul").hide();
	});

});

$(window).load(function () {
	if ($('#slider').length) {
		$('#slider').nivoSlider({
			effect: 'sliceDown',
			boxCols: 8,
			// For box animations
			boxRows: 4,
			// For box animations
			controlNav: false
		});
	}

	if ($('#slider3').length) {
		$('#slider3').nivoSlider({
			effect: 'fade',
			pauseTime: 5000,
			pauseOnHover: false,
			controlNavThumbs: true,
			controlNavThumbsSearch: '.jpg',
			// Replace this with...
			controlNavThumbsReplace: '_thumb.jpg',
			// ...this in thumb Image src
			afterLoad: function () {
				$('#slider3').data('nivo:vars').stop = true;
			} // Triggers when slider has loaded
		});
	}

	if ($("#frmContact").length) {
		//$('textarea').keypress(function (event){ return event.keyCode == 13 ? false : true; });
		$("#frmContact").validationEngine({
			ajaxSubmit: true,
			ajaxSubmitFile: "assets/php/ajaxsubmit.php",
			ajaxSubmitMessage: "Thank you, your message has been received!",
			success: false,
			failure: function () {}
		})
	}
});
