
var adpos=0;

	$(document).ready(function() { 
							   
		$("a.lightview").fancybox({'overlayShow': true, overlayOpacity:0.9,frameWidth:600,frameHeight:400 });
		
		$("a").focus(function () {
        	$(this).blur();
		});
		
		$('.bookmarklinks').jFav();
		$('.team-content').equalHeights();
		$('.contact').equalHeights();
		$('#headerbar').equalHeights();
		$(".validateme").validate({meta: "validate"});
		$('#ourwork').equalHeights();
		$.each($("#list li:even"),function(){
			widtha=$('#'+this.id).height();
			widthb=$('#'+this.id+' + li').height();
			if(widtha>widthb){
				$('#'+this.id).height(widtha);
				$('#'+this.id+' + li').height(widtha);
			}else{
				$('#'+this.id).height(widthb);
				$('#'+this.id+' + li').height(widthb);
			}
		});
		currentpos=1;
		nextAd();
		checkTeamsNav();
		$("#md4e46email").Watermark("Email");
		$("#md4e46username").Watermark("Username");
	});
	
	function formatText(index, panel) {
		  return index + "";
	    }

    $(function () {
    
        $('.anythingSlider').anythingSlider({
            easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
            autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
            delay: 6000,                    // How long between slide transitions in AutoPlay mode
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            animationTime: 1200,             // How long the slide transition takes
            hashTags: true,                 // Should links change the hashtag in the URL?
            buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
    		pauseOnHover: false,             // If true, and autoPlay is enabled, the show will pause on hover
    		startText: "Go",             // Start text
		        stopText: "Stop",               // Stop text
		        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
        });
        
        $("#slide-jump").click(function(){
            $('.anythingSlider').anythingSlider(3);
        });
        
    });
	
	function nextAd(){
		$.each($('.largeimage'), function(){
			if(this.id == 'ad'+adpos){
				$('#'+this.id).css("display","block");
			}
			else
			{	
				$('#'+this.id).css("display","none");
			}
		});
		adpos++;
		if(adpos==$('.largeimage').size()){
			adpos=0;
		}
		setTimeout('nextAd()',5000);
	}
	
	function sendEmail() {
		$('#submitbutton').val('Sending...');
		$('#submitbutton').attr("disabled","true");
		$.post('form-contactus.htm?r='+Math.random(),{
			visitor_fullname: $('#visitor_fullname').val(),
			visitor_email: $('#visitor_email').val(),
			visitor_message: $('#visitor_message').val(),
			visitor_telephone: $('#visitor_telephone').val()
			},
			function (data) {
				$('#sendStatus').html("Your message has been sent, we will reply as soon as possible.<br /><br />Thank you,<br />Untangled Media");
				$('#submitbutton').val('Send Message');
				$('#submitbutton').attr("disabled",false);
				$('#contactForm').html("");
			}
		);
		return false;
	}
	
	function sendFriend() {
		$('#submitbutton').val('Sending...');
		$('#submitbutton').attr("disabled","true");
		$.post('form-friend.htm?r='+Math.random(),{
			visitor_fullname: $('#visitor_fullname').val(),
			visitor_email: $('#visitor_email').val(),
			visitor_friend: $('#visitor_friend').val()
			},
			function (data) {
				$('#sendStatus').html("Your message has been sent.<br /><br />Thank you,<br />Untangled Media");
				$('#submitbutton').val('Send Message');
				$('#submitbutton').attr("disabled",false);
				$('#contactForm').html("");
			}
		);
		return false;
	}
	
	function prevTeam(){
		if(currentpos>1){
			$("#summary-team-content").animate({left:"+=92px"}, 500 );
			currentpos--;
			checkTeamsNav();
		}
	}
	function nextTeam(){
		if(currentpos<=($(".summary-team-content-item").size()-7)){
			$("#summary-team-content").animate({left:"-=92px"}, 500 );
			currentpos++;
			checkTeamsNav();
		}
	}
	
	function checkTeamsNav(){
		if(currentpos>1){
			$("#summary-team-previous-img").attr('src','assets/img-design/team-previous.jpg');
		}else{
			$("#summary-team-previous-img").attr('src','assets/img-design/team-previous-faded.jpg');
		}
		
		if(currentpos<=($(".summary-team-content-item").size()-7)){
			$("#summary-team-next-img").attr('src','assets/img-design/team-next.jpg');
		}else{
			$("#summary-team-next-img").attr('src','assets/img-design/team-next-faded.jpg');
		}
	}
