﻿$(document).ready(function() {

	$('body').wrapInner('<div id="olive"></div>').append($('a.survey'));

	$('#header').append($('#tools'), $('#call'));

	$('#content, #aside').wrapAll('<div id="stars"><div id="space"></div></div>');

	$('#next').each(function() {
		$(this).find('li:even').addClass("odd");
		$(this).find('li').wrapInner('<div class="border"></div>').append('<div class="arrow"></div>');
	});

	$('#supplinks > a').click(function() {
		$("html:not(:animated), body:not(:animated)").animate({ scrollTop: 0 }, 500, "easeInOutCubic");
		return false;
	});
	
	$('#sitemaplink > a').click(function() {
		$("html:not(:animated), body:not(:animated)").animate({ scrollTop: $(document).height() }, 500, "easeInOutCubic");
		return false;
	});

	$('#email').each(function() { $(this).val($(this).prev().text()); this.defaultValue = this.value });

	$('#footer').prepend('<h4>Copyright &copy;</h4>').wrapInner('<div id="copy"></div>').prepend($('#subs, #sitemap')).wrapInner('<div id="verline"></div>');

	if($('#intro').length) {

		document.body.id = "home";

		$('#vid').before('<div class="sep"></div>').append($('#social'));

		// What is Powerstar
		var introList = $('#intro ul');
		introList.append('<ol id="slidenav" class="filmstrip"></ol>');
		var slideNav = $('#slidenav');
		introList.find('li').each(function(i) {
			$(this).children('a').wrapInner('<u></u>').append('<b>»</b>');
			slideNav.append('<li index="' + (i + 1) + '"></li>');
		});
		introList.galleryView({
			transition_speed: 500,
			transition_interval: 12000,
			pause_on_hover: true,
			easing: 'easeInOutQuad'
		});

		// Clients / Case Studies / Testimonials
		$('#clients ul').jcarousel({
			scroll: 1,
			wrap: "both",
			animation: 800,
			easing: "easeInOutQuart",
			initCallback: function() {
				$('#clients').append('<div class="r b"></div>');
				$('#clients p + a').each(function(i) {
					$(this).appendTo($(this).parent().parent()).css({ left: i * 255 }).before('<div></div>');
				});
			}
		});

	}

	$('#testimonials img').wrap('<div></div>');

	// CSS3 style sheet reference for IE
	if(document.createStyleSheet) {
		document.createStyleSheet("css/css3.css");
		$('#benefits, #next, #clients, #seminars').css({ behavior: "url(js/PIE.htc)" });
	}

	if(typeof ie6Fix == "function") ie6Fix();
	else document.documentElement.style.visibility = "visible";

	$('#email').focus(function() {
		if(this.value == this.defaultValue) this.value = "";
		if(!this.onblur) this.onblur = function() { if(this.value == "") this.value = this.defaultValue }
	});

});


if($.browser.msie) {
	$('html').addClass("ie");
	if     ($.browser.version.substring(0, 2) == "6.") document.write('<link rel="stylesheet" href="css/ie6.css" /><script src="js/ie6.js"></script>');
	else if($.browser.version.substring(0, 2) == "7.") $('html').addClass("ie7").addClass("ie6-7");
	else if($.browser.version.substring(0, 2) == "8.") $('html').addClass("ie8");
	else if($.browser.version.substring(0, 2) == "9.") $('html').addClass("ie9");
 	document.write('<style>.ie6-7 #sitenav ul li ul li a { zoom: 1 }</style>');
}
else if($.browser.mozilla) $('html').addClass("ff");


// CSS3 style sheet reference for modern browsers
$('head').append('<link rel="stylesheet" href="../css/css3.css" />')


document.documentElement.style.visibility = "hidden";
