function mainmenu(){
$("#navigation ul ul ").css({display: "none"}); // Opera Fix
$("#navigation li").hover(function(){
$(this).find('ul:first').parent('li').addClass("active");
$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(300);
},function(){
jQuery(this).find('ul:first').parent('li').removeClass("active");
jQuery(this).find('ul:first').css({visibility: "hidden"});
});
}

jQuery(function() {
 
	 mainmenu();
	
	jQuery('#banner ul#slides li').hide();
	jQuery('#banner ul#slides li:first').show();
	
	var numberofslides = jQuery('ul#slides li').size();
	var x = 1;
	var slideclass;
	var slidep;
	var y = 0;
	
	function slideleft() {
		x--;
		if(x == 0) { x = numberofslides; }
		slideclass = 'ul#slides li.slide'+x;
		jQuery('ul#slides li').fadeOut(500);
		slidep = slideclass+' p';
		jQuery(slideclass).fadeIn(1000);
		jQuery(slidep).animate({"bottom":"-200px"});
		jQuery(slidep).animate({"bottom":"0px"});
		jQuery('ul#circles li').css({"opacity":"0.4"});
		jQuery('ul#circles li').eq(x-1).animate({"opacity":"1"});
	}
	
	function slideright() {
		x++;
		if(x > numberofslides) { x = 1; }
		slideclass = 'ul#slides li.slide'+x;
		jQuery('ul#slides li').fadeOut(500);
		slidep = slideclass+' p';
		jQuery(slideclass).fadeIn(1000);
		jQuery(slidep).animate({"bottom":"-200px"});
		jQuery(slidep).animate({"bottom":"0px"});
		jQuery('ul#circles li').css({"opacity":"0.4"});
		jQuery('ul#circles li').eq(x-1).animate({"opacity":"1"});
	}
	
	if(jQuery('.autoslide').text() == "") { } else {
		setInterval(function() {
	if(y == 0) { 
		x++;
		if(x > numberofslides) { x = 1; }
		slideclass = 'ul#slides li.slide'+x;
		jQuery('ul#slides li').fadeOut(500);
		slidep = slideclass+' p';
		jQuery(slideclass).fadeIn(1000);
		jQuery(slidep).animate({"bottom":"-200px"});
		jQuery(slidep).animate({"bottom":"0px"});
		jQuery('ul#circles li').css({"opacity":"0.4"});
		jQuery('ul#circles li').eq(x-1).animate({"opacity":"1"});
	}
		}, jQuery('.autoslide').text());
	}
	
	jQuery('.arrowleft').click(function() {
		slideleft();
		y = 1;
		return false;
	});
	
	jQuery('.arrowright').click(function() {
		slideright();
		y = 1;
		return false;
	});
	
	jQuery('ul#circles li').click(function() {
		y = 1;
		x=jQuery('ul#circles li').index(jQuery(this))+ 1;
		slideclass = 'ul#slides li.slide'+x;
		jQuery('ul#slides li').fadeOut(500);
		slidep = slideclass+' p';
		jQuery(slideclass).fadeIn(1000);
		jQuery(slidep).animate({"bottom":"-200px"});
		jQuery(slidep).animate({"bottom":"0px"});
		jQuery('ul#circles li').css({"opacity":"0.4"});
		jQuery(this).animate({"opacity":"1"});
		return false;
	});
	
	
	jQuery('#banner ul#circles li').css({"opacity":"0.4"});
	jQuery('#banner ul#circles li:first').css({"opacity":"1"});
	
	var tabid = 0;
	jQuery('.tabs .tabbar li').click(function() {
		tabid = jQuery(this).parent('.tabbar').find('li').index(jQuery(this));
		jQuery(this).parent('.tabbar').find('li').removeClass('active');
		jQuery(this).addClass('active');
		jQuery(this).parent('.tabbar').parent('.tabs').find('.tabpanes').find('.tabpane').hide();
		jQuery(this).parent('.tabbar').parent('.tabs').find('.tabpanes').find('.tabpane').eq(tabid).show();
	});
	
	jQuery('.widget ul li:last-child').css({"border":"0"});
	
	jQuery('.gallery .post').hover(function() {
		jQuery(this).find('.gallerythumb').find('span').fadeIn();
		jQuery(this).find('.gallerythumbslider').find('span').fadeIn();
		jQuery(this).find('h3').addClass('hover');
	}, function() {
		jQuery(this).find('.gallerythumb').find('span').hide();
		jQuery(this).find('.gallerythumbslider').find('span').hide();
		jQuery(this).find('h3').removeClass('hover');
	});
	
	jQuery('.mainimage li:first').show();
	var galleryslidernumber;
	jQuery('.gallery_slider .post .gallerythumbslider').click(function() {
		galleryslidernumber = jQuery(this).parent('p').parent('.post').attr('id');
		jQuery('.mainimage li').hide();
		jQuery('.mainimage li').eq(galleryslidernumber).fadeIn();
		return false;
	});
	
	jQuery('.tabs .tabbar li').eq(0).addClass('active');
	jQuery('.tabs .tabpane').eq(0).addClass('active');
	
	jQuery('.toggle h5 a').click(function() {
		jQuery(this).parent('h5').parent('.toggle').find('.text').slideToggle();
		jQuery(this).parent('h5').parent('.toggle').toggleClass('toggleactive');
		if(jQuery(this).find('span.plus').text() == "+") { jQuery(this).find('span.plus').text('-'); } else { jQuery(this).find('span.plus').text('+'); }
		return false;
	});
	
	var sliderid = 0;
	jQuery('.slider ul.thumbs li').css({"opacity":"0.4"});
	jQuery('.slider ul.thumbs li').eq(0).css({"opacity":"1"});
	jQuery('.slider ul.thumbs li').click(function() {
		sliderid = jQuery(this).parent('ul').find('li').index(jQuery(this));
		jQuery(this).parent('ul').parent('.slider').find('ul.slides').find('li').fadeOut(1000);
		jQuery(this).parent('ul').parent('.slider').find('ul.slides').find('li').eq(sliderid).fadeIn(1000);
		jQuery(this).parent('ul').find('li').css({"opacity":"0.4"});
		jQuery(this).animate({"opacity":"1"});
	});
	
	var navigationhtml = "<div style='clear:both' class='navigation'>"+jQuery('.navigation').html()+"</div>";
	jQuery('.entry .thenavigation').html(navigationhtml);
	jQuery('.entry .navigation:first').remove();
	
	var navihtml = "<div style='clear:both' class='navigation'><div  class='wp-pagenavi'>"+jQuery('.wp-pagenavi').html()+"</div></div>";
	jQuery('.entry .thenavigation').html(navihtml);
	jQuery('.entry .wp-pagenavi:first').remove();
	
	jQuery('#s').focus(function() {
		if(jQuery(this).attr("value") == "Search...") { jQuery(this).attr("value",""); }
	});
	jQuery('#s').blur(function() {
		if(jQuery(this).attr("value") == "") { jQuery(this).attr("value","Search..."); }
	});
	
	
	jQuery('ul.circles li').css({"opacity":"0.4"});
	jQuery('ul.circles li.active').css({"opacity":"1"});
	var homelatestpostsnumber = 0;
	jQuery('.homelatestposts ul.circles li').click(function() {
		homelatestpostsnumber = jQuery('.homelatestposts ul.circles li').index(jQuery(this));
		jQuery('.homelatestposts .postslider .post').hide();
		if(homelatestpostsnumber == 1) {
			jQuery('.homelatestposts .postslider .post').eq(4).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(5).delay(100).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(6).delay(200).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(7).delay(300).fadeIn(200);
		} else if(homelatestpostsnumber == 2) {
			jQuery('.homelatestposts .postslider .post').eq(8).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(9).delay(100).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(10).delay(200).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(11).delay(300).fadeIn(200);
		} else if(homelatestpostsnumber == 3) {
			jQuery('.homelatestposts .postslider .post').eq(12).fadeIn();
			jQuery('.homelatestposts .postslider .post').eq(13).delay(100).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(14).delay(200).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(15).delay(300).fadeIn(200);
		} else if(homelatestpostsnumber == 4) {
			jQuery('.homelatestposts .postslider .post').eq(16).fadeIn();
			jQuery('.homelatestposts .postslider .post').eq(17).delay(100).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(18).delay(200).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(19).delay(300).fadeIn(200);	
		} else {
			jQuery('.homelatestposts .postslider .post').eq(0).fadeIn();
			jQuery('.homelatestposts .postslider .post').eq(1).delay(100).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(2).delay(200).fadeIn(200);
			jQuery('.homelatestposts .postslider .post').eq(3).delay(300).fadeIn(200);
		}
		jQuery('.homelatestposts ul.circles li').css({"opacity":"0.4"});
		jQuery(this).animate({"opacity":"1"});
	});
	
	jQuery('.feature').hover(function(){
		jQuery(this).css({"borderColor":"#CCC"});
	}, function() {
		jQuery(this).css({"borderColor":"#EEE"});
	});
	
	jQuery('.features p').hide();
	jQuery('.features .feature p').show();
	
	jQuery('.features_cols2 .feature').eq(1).css({"marginRight":"0px", "width":"49%"});
	jQuery('.features_cols2 .feature').eq(2).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols2 .feature').eq(3).css({"marginRight":"0px", "width":"49%"});
	jQuery('.features_cols2 .feature').eq(4).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols2 .feature').eq(5).css({"marginRight":"0px", "width":"49%"});
	jQuery('.features_cols2 .feature').eq(6).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols2 .feature').eq(7).css({"marginRight":"0px", "width":"49%"});
	jQuery('.features_cols2 .feature').eq(8).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols2 .feature').eq(9).css({"marginRight":"0px", "width":"49%"});
	jQuery('.features_cols2 .feature').eq(10).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols2 .feature').eq(11).css({"marginRight":"0px", "width":"49%"});
	jQuery('.features_cols2 .feature').eq(12).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols2 .feature').eq(13).css({"marginRight":"0px", "width":"49%"});
	jQuery('.features_cols2 .feature').eq(14).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols2 .feature').eq(15).css({"marginRight":"0px", "width":"49%"});
	jQuery('.features_cols2 .feature').eq(16).before("<div style='clear:both;display:block;height:10px;'></div>");
	
	jQuery('.features_cols3 .feature').eq(2).css({"marginRight":"0px", "width":"32%"});
	jQuery('.features_cols3 .feature').eq(3).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols3 .feature').eq(5).css({"marginRight":"0px", "width":"32%"});
	jQuery('.features_cols3 .feature').eq(6).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols3 .feature').eq(8).css({"marginRight":"0px", "width":"32%"});
	jQuery('.features_cols3 .feature').eq(9).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols3 .feature').eq(11).css({"marginRight":"0px", "width":"32%"});
	jQuery('.features_cols3 .feature').eq(12).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols3 .feature').eq(14).css({"marginRight":"0px", "width":"32%"});
	jQuery('.features_cols3 .feature').eq(15).before("<div style='clear:both;display:block;height:10px;'></div>");
	
	jQuery('.features_cols4 .feature').eq(3).css({"marginRight":"0px", "width":"24%"});
	jQuery('.features_cols4 .feature').eq(4).before("<div style='clear:both;display:block;height:10px;'></div>");
	jQuery('.features_cols4 .feature').eq(7).css({"marginRight":"0px", "width":"24%"});
	jQuery('.features_cols4 .feature').eq(8).before("<div style='clear:both;display:block;height:10px'></div>");
	jQuery('.features_cols4 .feature').eq(11).css({"marginRight":"0px", "width":"24%"});
	jQuery('.features_cols4 .feature').eq(12).before("<div style='clear:both;display:block;height:10px'></div>");
	jQuery('.features_cols4 .feature').eq(15).css({"marginRight":"0px", "width":"24%"});
	jQuery('.features_cols4 .feature').eq(16).before("<div style='clear:both;display:block;height:10px'></div>");
	
	var latestpostswidgettoshow = 0;
	var latestpostswidgetpostclass;
	jQuery('.latestpostswidget ul.circles li').click(function() {
		latestpostswidgettoshow = jQuery(this).parent('ul').find('li').index(jQuery(this));
		latestpostswidgetpostclass = latestpostswidgettoshow + 1;
		latestpostswidgetpostclass = "li.posts"+latestpostswidgetpostclass;
		jQuery(this).parent('ul').parent('.bottom').parent('.latestpostswidget').find('ul.posts').find('li').hide();
		jQuery(this).parent('ul').parent('.bottom').parent('.latestpostswidget').find('ul.posts').find(latestpostswidgetpostclass).fadeIn(200);
		jQuery(this).parent('ul').find('li').css({"opacity":"0.4"});
		jQuery(this).animate({"opacity":"1"});
	});
	
	var testimonialtoshow = 0;
	var testimonialpostclass;
	jQuery('.testimonialswidget ul.circles li').click(function() {
		testimonialtoshow = jQuery(this).parent('ul').find('li').index(jQuery(this));
		testimonialpostclass = testimonialtoshow + 1;
		testimonialpostclass = ".quote"+testimonialpostclass;
		jQuery(this).parent('ul').parent('.text').find('.thequote').hide();
		jQuery(this).parent('ul').parent('.text').find(testimonialpostclass).fadeIn();
		jQuery(this).parent('ul').find('li').css({"opacity":"0.4"});
		jQuery(this).animate({"opacity":"1"});
	});
	
	jQuery('.skills .bar p').css({"width":"0%"});
	jQuery('.skills .bar p').each(function() {
		jQuery(this).animate({"width":jQuery(this).find('span').find('span').text()+"%"});
	});
	
	if(jQuery.browser.msie){ } else {
	jQuery('.sociallist ul li a img').css({"opacity":"0.7"});
	}
	jQuery('.sociallist ul li a').hover(function() {
	if(jQuery.browser.msie){ } else {
		jQuery('.sociallist ul li a img').css({"opacity":"0.7"});
		jQuery(this).find('img').css({"opacity":"1"});
	}
	}, function() {
	if(jQuery.browser.msie){ } else {
		jQuery(this).find('img').css({"opacity":"0.7"});
	}
	});
	
	
	jQuery('.portfolioslider ul.circles').show();
	jQuery('.portfolioslider ul.slides li').hide();
	jQuery('.portfolioslider ul.slides li:first').show();
	var portfolioimagetoshow = 0;
	jQuery('.portfolioslider ul.circles li').click(function() {
		portfolioimagetoshow = jQuery('.portfolioslider ul.circles li').index(jQuery(this));
		jQuery(this).parent('ul').parent('.portfolioslider').find('ul.slides').find('li').hide();
		jQuery(this).parent('ul').parent('.portfolioslider').find('ul.slides').find('li').eq(portfolioimagetoshow).fadeIn();
		jQuery(this).parent('ul').find('li').css({"opacity":"0.4"});
		jQuery(this).animate({"opacity":"1"});
	});

	
	// IPHONE //
	jQuery('.shownav').click(function() {
		if(jQuery(this).text() == "Show Navigation") { jQuery(this).text('Hide Navigation'); } else { jQuery(this).text('Show Navigation'); }
		jQuery('#navigation ul').slideToggle();
		return false;
	});
	
});

jQuery(window).ready(function() {
	jQuery('.feature').each(function(index) {
		jQuery(this).find('.icon').height(jQuery(this).height()+20);
	});
});
