$(document).ready(function() {

	//Preload Images
	$.preloadImages("http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left-black.png", "http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right-black.png","http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left.png", "http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right.png");
	
	//Footer Opacity
	//$('#footer p.copyright').css('opacity', 0.50); 
	
	nd.rollover.init();
	
	function signupSuccess() {
		$('#signup-form').hide();
		$('#thanks-for-signing-up').show();
	}
	
	function enquirySuccess() {
		$('#contact-form').hide();
		$('#thanks-for-your-enquiry').show();
	}
	
	if ($('#twitter_update_list').length > 0) {
		$('#twitter_update_list li:not(span) a').prepend('<span class="tilde">~ </span>');
		$('#twitter_update_list li:not(span) a').after("<div style='clear:both;'></div>");
	}
	
	//Signup
	$("#signup-form").validationEngine({
		success :  function() { signupSuccess() },
		ajaxSubmit : true,
		failure : function() {}
	});
	
	//Enquiry 
	if ($('#contact-form').length > 0) {	
			$("#contact-form").validationEngine({
				success :  function() { enquirySuccess() },
				ajaxSubmit: true,
				failure : function() {}
			});
	}
	
	$('#signup').click(function() { 
		$('#signup-form').submit();
	});
	
	if ($('#slideshow').length > 0) {
		//Slideshow
		$('#slideshow').css('display', 'block');
		$('#slideshow').cycle({ 
			fx: 		 'fade',
	    	speed:       300, 
	    	timeout:     3000, 
	    	pager:      '#slideshow-nav', 
	   		pagerEvent: 'mouseover', 
	    	pauseOnPagerHover: true  
		});
		$('#slideshow-nav').css('z-index', '1000');
		Cufon('#slideshow-nav a');
		
		$('#slideshow-wrap').hover(
			function() { 
				$('#slideshow').cycle('pause');
				slideId = $('#slideshow img:visible').attr('id').substr(6);
				$('#tip-' + slideId).css('z-index', '10000');
				$('#tip-' + slideId).fadeIn("slow");
			}, 
			function() {
				$('#slideshow').cycle('resume');
				slideId = $('#slideshow img:visible').attr('id').substr(6);
			    $('.tip').fadeOut("slow");
			    $('.tip').css('z-index', '0');
			    
			}
		);
		
	}
	
	if ($('#contact-map').length > 0 ) {
			$('#contact-map').jmap('init', {'mapType':G_NORMAL_MAP,'mapCenter':[-27.45468398000284, 153.03067803382874], 'mapZoom':16, 'mapEnableDragging': false});
			
			// Create our "tiny" marker icon
			var blueIcon = new GIcon(G_DEFAULT_ICON);
			blueIcon.image = "http://www.newlight.com.au/wp-content/themes/newlight/images/gmap.png";
			blueIcon.iconSize = new GSize(50, 50);
			blueIcon.shadowSize = new GSize(0, 0);
			blueIcon.iconAnchor = new GPoint(6, 40);
			
			$('#contact-map').jmap('AddMarker', {
				'pointLatLng': [-27.454560213315858, 153.03045272827148],
				'pointHTML': '<strong>Newlight</strong><br/>100 Brunswick Street, Fortitude Valley 4006',
				'pointIcon': blueIcon
			});
	}
	
	if ($('#contact-form').length > 0 ) {
		$('#contact-form #bubble').click(function() { 
			$('#contact-form').submit();
		});
	}
	
	
	if ($('#secondary').length > 0) {
		$('#team-wrap').equalHeights();
	}
	
	if ($('.stream').length > 0) {
		$('.stream').equalHeights();
	}
		
	if ($('.rule').length > 0 ) {
		$('.rule, .h-divide').css('opacity', 0.20);
	}
	
	if ($('.post-rule').length > 0 ) {
		$('.post-rule').css('opacity', 0.20);
	}
	
	//About Menu
	if ($('#about-nav').length > 0) {
		$('#about-nav li.current_page_item a').prepend('<span class="arrows">&raquo;&nbsp;</a>');
	}
	
	//What we do Menu
	if ($('#wwd-nav').length > 0) {
		$('#wwd-nav li.current_page_item a').prepend('<span class="arrows">&raquo;&nbsp;</a>');
	}
	
	
	function doTheMenu(element) {
			$("#portfolio-nav").find(".current_page_item").removeClass();
			$("#portfolio-nav").find(".arrows").remove();
			$(element).addClass('current_page_item');
			$('#portfolio-nav li.current_page_item a').prepend('<span class="arrows">&raquo;&nbsp;</span>');
	}
	
	
	//Portfolio Menu
	if ($('#portfolio-nav').length > 0) {
		$('#portfolio-nav li.current_page_item a').prepend('<span class="arrows">&raquo;&nbsp;</span>');				
	}
	
	
	
	
	//Input fields
	$('#email-signup').click(function() {
		$(this).attr('value', '');
	});
	$('#s').click(function() {
		$(this).attr('value', '');
	});
	
	
	//Portfolio Page
	if ($('.portfolio-thumb').length > 0 ) {					
		$('.thumb-contain').hover(
			function() {
				oldImg = $('.portfolio-thumb',this).attr('src');
				$('.portfolio-thumb',this).attr('src', 'http://www.newlight.com.au/wp-content/themes/newlight/images/portfolio/client_rollover.jpg');
				$('.client-name', this).vAlign();
				//Damn IE6 eats balls
				if($.browser.msie && $.browser.version.substr(0,3)=="6.0"){
					currentMargin = $('.client-name',this).css('margin-top');
					newMargin = parseInt(currentMargin.substr(0,2));
					
					$('.client-name', this).css('margin-top', newMargin - 6);
				}
				$('.client-name', this).css('display', 'block');
			},
			function() {
				$('.portfolio-thumb', this).attr('src', oldImg);
				$('.client-name', this).css('display', 'none');
			}
		)
	}
	
	//Top Button
	if ($('.top-btn').length > 0) {
		$('.top-btn').click(function(){
			$('html, body').animate({scrollTop:0}, 'slow');
		});
	}
	
	//Frontpage Headline
	$("#home-bubble").hover(
      function () {
        $('.home-bubble-l').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left-black.png') no-repeat");
        $('.home-bubble-c').css('background', '#000');
        $('.home-bubble-r').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right-black.png') no-repeat");
      }, 
      function () {
        $('.home-bubble-l').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left.png') no-repeat");
        $('.home-bubble-c').css('background', '#c20037');
        $('.home-bubble-r').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right.png') no-repeat");
      }
    );
    
    
    //Frontpage Headline
	$("#home-bubble").hover(
      function () {
        $('.home-bubble-l').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left-black.png') no-repeat");
        $('.home-bubble-c').css('background', '#000');
        $('.home-bubble-r').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right-black.png') no-repeat");
      }, 
      function () {
        $('.home-bubble-l').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left.png') no-repeat");
        $('.home-bubble-c').css('background', '#c20037');
        $('.home-bubble-r').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right.png') no-repeat");
      }
    );
    
    
    //Error Headline
	$("#error-bubble").hover(
      function () {
        $('.error-bubble-l').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left-black.png') no-repeat");
        $('.error-bubble-c').css('background', '#000');
        $('.error-bubble-r').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right-black.png') no-repeat");
      }, 
      function () {
        $('.error-bubble-l').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left.png') no-repeat");
        $('.error-bubble-c').css('background', '#c20037');
        $('.error-bubble-r').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right.png') no-repeat");
      }
    );
    
    //Portfolio Headline
	$("#port-bubble").hover(
      function () {
        $('.port-bubble-l').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left-black.png') no-repeat");
        $('.port-bubble-c').css('background', '#000');
        $('.port-bubble-r').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right-black.png') no-repeat");
      }, 
      function () {
        $('.port-bubble-l').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-left.png') no-repeat");
        $('.port-bubble-c').css('background', '#c20037');
        $('.port-bubble-r').css("background", "url('http://www.newlight.com.au/wp-content/themes/newlight/images/home-speech-right.png') no-repeat");
      }
    );
    
    
    $("a[href^='http:']").not("[href*='newlight.com.au']").attr('target','_blank');
    $("a[href^='http:']").not("[href*='newlight.com.au']").attr('rel','nofollow');
	
		
	
});


$(document).load(function() { 
});




