//Script By Muhammad Furqan Abid
$(function(){
	
	var currentObjSlider = $("#sliderObj li.current");
	function activeSlider(){
		$("#galleryPreview").css ({"background":"#B1B1AE url(" + $("#sliderObj li.current").children("img").attr("src") + ")", "background-repeat":"no-repeat", "background-position":"top center"});
		$("#sliderObj li.current").fadeTo("slow", 1);
		$("#galleryPreview").children ("a.previewLink").attr("href", $("#sliderObj li.current").children("h2").children("a").attr("href"));
	}
	function animateSlider(){
		intervalID = setInterval(
			function (){
				var currentObjSlider = $("#sliderObj li.current");
				if (currentObjSlider.hasClass("slideLast")){
					var nextObjSlider = $("#sliderObj li:first");
				}else{
					var nextObjSlider = currentObjSlider.next("li");
				}
				$("#sliderObj li").removeClass ("current");
				$("#sliderObj li").fadeTo ("slow", 0.80);
				nextObjSlider.addClass ("current");
				$(nextObjSlider).fadeTo("fast", 1);
				$("#galleryPreview").css ({"background":"#B1B1AE url(" + nextObjSlider.children("img").attr("src") + ")", "background-repeat":"no-repeat", "background-position":"top center"});
				$("#galleryPreview").children ("a.previewLink").attr("href", nextObjSlider.children("h2").children("a").attr("href"));
				
				/*$("#galleryPreview").css ("background-repeat", "no-repeat");
				$("#galleryPreview").css ("background-position", "top center");*/
			}
			, 10000
		);
	}

	$("#sliderObj li:first").addClass ("slideFirst");
	$("#sliderObj li:last").addClass ("slideLast");
	$("#sliderObj li").fadeTo ("slow", 0.80);
	activeSlider();
	animateSlider();
	
	
	
	$("#sliderObj li").click (function (){
		clearInterval (intervalID);
		$("#sliderObj li").removeClass ("current");
		$("#sliderObj li").fadeTo ("slow", 0.80);
		$(this).addClass ("current");
		$(this).fadeTo("fast", 1);
		$("#galleryPreview").css ({"background":"#B1B1AE url(" + $(this).children("img").attr("src") + ")", "background-repeat":"no-repeat", "background-position":"top center"});
		$("#galleryPreview").children ("a.previewLink").attr("href", $(this).children("h2").children("a").attr("href"));
		animateSlider();
	})
	
	
	
	
	
	
	
	/*Starting Positioning*/
	var SP = $("#searchbox img").offset();
	$("#searcharea").css({'top':SP.top, 'left':SP.left-281});
	$("#searcharea").fadeOut("fast");
	var SP2 = $("#contactbox img").offset();
	$("#contactarea").css({'top':SP2.top, 'left':SP2.left-281});
	$("#contactarea").fadeOut("fast");
	$("#searchbox").hover(
		function () {
			$("#searcharea").fadeIn("fast");
		}, 
		function () {
			$("#searcharea").fadeOut("fast");
		}
    );
	$("#contactbox").hover(
		function () {
			$("#contactarea").fadeIn("fast");
		}, 
		function () {
			$("#contactarea").fadeOut("fast");
		}
    );

})
