$(document).ready(function() {

	if ($('#navbar').length > 0) {
		$('#navbar ul li:not(ul li ul li)').each(function() {
			//alert($('#menu-item-25').find('a').text().toLowerCase().replace(/ /g,'-'));
			$(this).children('a').addClass($(this).text().toLowerCase().replace(/ /g,'-'));
			$(this).not(':last-child').after('<li class="separator"></li>');
		});

		/*$('#menu-item-27').children('a').attr({toptions: 'width = 1000,height = 500, type = dom, title = Photo Gallery, layout = dashboard, resizable = 0', href: '#photo-gallery'});
		$('#menu-item-164').children('a').attr({toptions: 'width = 1000,height = 500, type = dom, title = Photo Gallery, layout = dashboard, resizable = 0', href: '#photo-gallery'});

		$('#menu-item-29').children('a').attr({toptions: 'width = 1000,height = 500, type = dom, title = Video Gallery, layout = dashboard, resizable = 0', href: '#video-gallery'});
		$('#menu-item-165').children('a').attr({toptions: 'width = 1000,height = 500, type = dom, title = Video Gallery, layout = dashboard, resizable = 0', href: '#video-gallery'});*/

    }

	if ($('#footer-outer-wrapper').length > 0){
		$('#footer-outer-wrapper').find('li').not(':last-child').after('<li class="separator">|</li>');
	}

	if ($('.live-standup-dates').length > 0){
		$('.live-standup-dates').find('a.view-all-dates').attr('href',$('#navbar').find('a.live-standup').attr('href'));
	}

	if ($('.featured-video').length > 0){
		//$('.featured-video').find('a.view-more-vidoes-btn').attr('href',$('#navbar').find('a.videos').attr('href'));
	}

	if ($('.twitter-feed').length > 0){
		$('.twitter-feed').find('a.follow-me-btn').attr('href',$('.twitter-icon').attr('href'));
	}
	
	if ($('.widget_archive').length > 0){
		$('.widget_archive').find('h2.title').remove();
		$('.widget_archive').addClass('news-archives').prepend('<div class="title"><img src="http://'+location.hostname+'/wp-content/themes/lancepatrick/images/news-archive-title.png" alt="" /></div>');
		$('.widget_archive').find('li').append(",");
	}

	if ($('.widget_tag_cloud').length > 0){
		$('.widget_tag_cloud').find('h2.title').remove();
		$('.widget_tag_cloud').addClass('tags').prepend('<div class="title"><img src="http://'+location.hostname+'/wp-content/themes/lancepatrick/images/tags-title.png" alt="" /></div>');
		
		$('.widget_tag_cloud').find('a').each(function() {
			$(this).after('<span>,</span>');
		});
	}

	if ($('.widget_calendar').length > 0){
		$('.widget_calendar').find('h2.title').remove();
		$('.widget_calendar').addClass('news-calendar').prepend('<div class="title"><img src="http://'+location.hostname+'/wp-content/themes/lancepatrick/images/news-calendar-title.png" alt="" /></div>');
		$('.widget_calendar').find('#calendar_wrap').each(function() {
			$('#wp-calendar').before($(this).find('caption'));
			$('#wp-calendar').wrap('<div id="wp-calendar-div"></div>');
		});
	}

	if ($('.paging').length > 0){
		$('.paging span a').text('');
	}

	if ($('#nform').length > 0){
		$('#nform').append($('#nform').find('input'));
		$('#nform').find('input[type=radio]').hide();
		$('#nform').find('p.wpsb_form_label').remove();
		$('#nform').find('h6').remove();
		$('#nform form').append($('#nform').find('input'));
		$('#nform').find('input.wpsb_form_txt').addClass('txB');
		$('#nform').find('input#wpsb_fld_5').removeClass('wpsb_form_txt').addClass('textbox-short');
		$('#nform').find('input#wpsb_fld_2').after($('#nform').find('input#wpsb_email'));
		$('#nform form').children('input:eq(0)').attr("title","Name");
		$('#nform form').children('input:eq(1)').attr("title","Email");
		$('#nform form').children('input:eq(2)').attr("title","City");
		$('#nform form').children('input:eq(3)').attr("title","State");
		$('#nform form').children('input:eq(4)').attr("title","Zip");

		$(".txB").focus(function(srcc) {
			if ($(this).val() == $(this)[0].title) {

				$(this).val("");
			}
		});
		
		$(".txB").blur(function() {
			if ($(this).val() == "") {
				$(this).val($(this)[0].title);
			}
		});
		
		$(".txB").blur(); 

	}
	
	
	if ($('.cont_for').length > 0){
	var originalValues = new Array();

	$("input").focus(function() {
	
		if (!originalValues[this.name]) {
		  originalValues[this.name] = $(this).val()
		}
	
		if ( $(this).val()==originalValues[this.name]) {
			   $(this).val('');
		   }  
	   });
	
		$("input").blur(function() {
		   if ( $(this).attr("value")=="") {
			   $(this).val(originalValues[this.name]);
		   }  
	   });
	  $("textarea").focus(function() {
	
		if (!originalValues[this.name]) {
		  originalValues[this.name] = $(this).val()
		}
	
		if ( $(this).val()==originalValues[this.name]) {
			   $(this).val('');
		   }  
	   });
	
		$("textarea").blur(function() {
		   if ( $(this).attr("value")=="") {
			   $(this).val(originalValues[this.name]);
		   }  
	   });

	}

       /* $('#slides').hide(); // hide them first
		$('#slides').innerfade({ speed: 'slow', timeout: 3000, type: 'sequence', containerheight: '275px' });
        $('#slides').show();*/
		
		$('#slides').innerfade({
			speed: 1000,
			timeout: 5000,
			type: 'sequence',
			containerheight: 	'130px',
			slide_timer_on: 	'yes',
			slide_ui_parent: 	'slides',
			slide_ui_text:		'portfolio-desc',
			pause_button_id: 	'pause_button',
			slide_nav_id:		'slide_nav'
			});
			$.setOptionsButtonEvent();
		
			
			$("#pause_button").click(function() {
				$.pause();
			});
			$("#next_button").click(function() {
				$.next();
			});
			
			$("#prev_button").click(function() {
				$.prev();
			});
			
			$("#first_button").click(function() {
				$.first();
			});
			
			$("#last_button").click(function() {
				$.last();
		});
	
	window.splitdisplay = function(id){
		var tweet = 0;
		var optionTexts = [];
		var divid = "#"+id;
		var list = "#"+id+" ul li"; 
		$(list).each(function() { optionTexts.push($(this).html()) });
		$(divid).html(optionTexts[0]+optionTexts[1]);
		$('.nav .prev').click( function(e){
			e.preventDefault();
			tweet==0 ? tweet=4:tweet-=1; 
			$('#'+id).html(optionTexts[tweet]);
		});
		$('.nav .next').click( function(e){
			e.preventDefault();
			tweet==4 ? tweet=0:tweet+=1; 
			$('#'+id).html(optionTexts[tweet]);
		});
		
		//$('.next')
		//alert(id);
		
	}
	
	$("#scroller").simplyScroll({
				autoMode: 'loop',
				frameRate: '15'
			});

	/*$(".youTube").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 385,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'				: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

		return false;
	});*/
	
});
