$('html').addClass('js');
	
		
// SCRIPTS TO RUN ASAP
$(document).ready(function(){

	// Make paragraphs containing image expand to width
	$("p:has(img)").css('width' , 'auto');


	// Hide Content & Nav Before Fade In
	if($.browser.msie){}
	else{ $("#content > div, #content > img, #content-grid, .catalog, .nav, #navSearchfield").animate({opacity: 0}, 0);}

	// Random Shuffle Items
	$("#content-grid:not(.archive)").shuffle();
	$("#content-grid").append("<div></div>");
	$(".catalog").shuffle();
	$(".catalog").append("<div></div>");
	
	
	// Build Column Grid
	var windowHeight = $(window).height();		
	if (windowHeight > "940") var gridHeight = 760;
	if (windowHeight < "940") var gridHeight = 580;
	if (windowHeight < "760") var gridHeight = 400;
	if (windowHeight < "760") $('html').addClass('smallwindow');
	
	$("#content-grid:not(.404)").columnize({width : 180,height: gridHeight,buildOnce: true});
	$(".404").columnize({width : 180,height: 580,buildOnce: true});
	$(".catalog ").columnize({width : 180,height: 580,buildOnce: true});


	// Build Blog Post Columns
	$("#post").addClass("hide-width");
	$('#post-content p, #post-content ul').addClass("dontsplit");
	$("#post-content").prepend("<div class=\"space dontsplit\"></div>");
	if (windowHeight > "760") {$("#post-content").columnize({width : 240,height: 420,buildOnce: false});} 
	if (windowHeight <= "760") {$("#post-content").columnize({width : 320,height: 330,buildOnce: false});} 

	// if (windowHeight <= "760") {$("#post-content").columnize({width : 300,height: 350,buildOnce: false});} 
    $("#post").removeClass("hide-width");
    $("#post-content").css({"display" : "inline-block", "*display" : "block", "zoom" : "1"});	
    
    
	
	// Blog Image Slideshow
	$('#post-images').cycle({ 
		width: $('#post-images img').widestSize(),
		timeout: 6000,
		delay: 3000
		});
	// $('.smallwindow .image-cycle img').css({"width" : "100% !important"})
	
	// Make Blog Item Clickable
	$('.blogItem').fitted();
	
	
	// Folio Navigation Filters
	$(".filterIdentity").click(function () {
		$(".projectItem:not(.Identity)").fadeTo("slow", 0.1); 
		$(".Identity").fadeTo("slow", 1);
		$(".sub-menu li:not(.filterIdentity)").removeClass("current-menu-item");
		$(this).addClass("current-menu-item");
		});
	$(".filterDigital").click(function () {
		$(".projectItem:not(.Digital)").fadeTo("slow", 0.1); 
		$(".Digital").fadeTo("slow", 1);
		$(".sub-menu li:not(.filterDigital)").removeClass("current-menu-item");
		$(this).addClass("current-menu-item");
		});
	$(".filterSignage").click(function () {
		$(".projectItem:not(.Signage)").fadeTo("slow", 0.1); 
		$(".Signage").fadeTo("slow", 1);
		$(".sub-menu li:not(.filterSignage)").removeClass("current-menu-item");
		$(this).addClass("current-menu-item");
		});
	$(".filterPrint").click(function () {
		$(".projectItem:not(.Print)").fadeTo("slow", 0.1); 
		$(".Print").fadeTo("slow", 1);
		$(".sub-menu li:not(.filterPrint)").removeClass("current-menu-item");
		$(this).addClass("current-menu-item");
		});
	$(".filterPackaging").click(function () {
		$(".projectItem:not(.Packaging)").fadeTo("slow", 0.1); 
		$(".Packaging").fadeTo("slow", 1);
		$(".sub-menu li:not(.filterPackaging)").removeClass("current-menu-item");
		$(this).addClass("current-menu-item");
		});
	jQuery(".filterPosters").click(function () {
		jQuery(".shopItem:not(.Posters)").fadeTo("slow", 0.1); 
		jQuery(".Posters").fadeTo("slow", 1);
		jQuery(".sub-menu li:not(.filterPosters)").removeClass("current-menu-item");
		jQuery(this).addClass("current-menu-item");
		});
	jQuery(".filterClothing").click(function () {
		jQuery(".shopItem:not(.Clothing)").fadeTo("slow", 0.1); 
		jQuery(".Clothing").fadeTo("slow", 1);
		jQuery(".sub-menu li:not(.filterClothing)").removeClass("current-menu-item");
		jQuery(this).addClass("current-menu-item");
		});
	jQuery(".filterGear").click(function () {
		jQuery(".shopItem:not(.Gear)").fadeTo("slow", 0.1); 
		jQuery(".Gear").fadeTo("slow", 1);
		jQuery(".sub-menu li:not(.filterGear)").removeClass("current-menu-item");
		jQuery(this).addClass("current-menu-item");
		});
	$(".navFolio > a").click(function () {
		$(".projectItem").fadeTo("slow", 1);
		$(".sectionFolio").attr("id", "pageFolio");
		$(".sub-menu li").removeClass("current-menu-item");
		});
	jQuery(".navOutlet > a").click(function () {
		jQuery(".shopItem").fadeTo("slow", 1);
		jQuery(".sectionStore").attr("id", "pageStore");
		jQuery(".sub-menu li").removeClass("current-menu-item");
		});
	
	var currentPage = (location.hash.substring(1));
	if (currentPage == "identity"){
		$(".projectItem:not(.Identity)").fadeTo("slow", 0.1); 
		$(".Identity").fadeTo("slow", 1);
		$(".sub-menu li").removeClass("current-menu-item");
		$(".filterIdentity").addClass("current-menu-item");}
	else if (currentPage == "digital"){
		$(".projectItem:not(.Digital)").fadeTo("slow", 0.1); 
		$(".Digital").fadeTo("slow", 1);
		$(".sub-menu li").removeClass("current-menu-item");
		$(".filterDigital").addClass("current-menu-item");}
	else if (currentPage == "signage"){
		$(".projectItem:not(.Signage)").fadeTo("slow", 0.1); 
		$(".Signage").fadeTo("slow", 1);
		$(".sub-menu li").removeClass("current-menu-item");
		$(".filterSignage").addClass("current-menu-item");}
	else if (currentPage == "print"){
		$(".projectItem:not(.Print)").fadeTo("slow", 0.1); 
		$(".Print").fadeTo("slow", 1);
		$(".sub-menu li").removeClass("current-menu-item");
		$(".filterPrint").addClass("current-menu-item");}
	else if (currentPage == "packaging"){
		$(".projectItem:not(.Packaging)").fadeTo("slow", 0.1); 
		$(".Packaging").fadeTo("slow", 1);
		$(".sub-menu li").removeClass("current-menu-item");
		$(".filterPackaging").addClass("current-menu-item");}
	else if (currentPage == "posters"){
		$(".shopItem:not(.Posters)").fadeTo("slow", 0.1); 
		$(".Environmental").fadeTo("slow", 1);
		$(".sub-menu li").removeClass("current-menu-item");
		$(".filterPosters").addClass("current-menu-item");}
	else if (currentPage == "clothing"){
		$(".shopItem:not(.Clothing)").fadeTo("slow", 0.1); 
		$(".Clothing").fadeTo("slow", 1);
		$(".sub-menu li").removeClass("current-menu-item");
		$(".filterClothing").addClass("current-menu-item");}
	else if (currentPage == "gear"){
		$(".shopItem:not(.Gear)").fadeTo("slow", 0.1); 
		$(".Gear").fadeTo("slow", 1);
		$(".sub-menu li").removeClass("current-menu-item");
		$(".filterGear").addClass("current-menu-item");}
	else $(".sectionFolio").attr("id", "pageFolio");
	
	
	// Log In & Sign Up Panels
	
		// Panel Slider
		jQuery("#contactLabel").click(function () {jQuery("#panelContact").animate({height: '235px'}, 1000);});
		jQuery("#contactClose").click(function () {jQuery("#panelContact").animate({height: '0px'}, 1000);});
		jQuery("#labsLabel").click(function () {jQuery("#panelLabs").animate({height: '235px'}, 1000);});
		jQuery("#labsClose").click(function () {jQuery("#panelLabs").animate({height: '0px'}, 1000);});
		jQuery("#enewsLabel").click(function () {jQuery("#panelEnews").animate({height: '235px'}, 1000);});
		jQuery("#enewsClose").click(function () {jQuery("#panelEnews").animate({height: '0px'}, 1000);});
		jQuery("#cartLabel").click(function () {jQuery("#panelCart").animate({height: '235px'}, 1000);});
		jQuery("#cartClose").click(function () {jQuery("#panelCart").animate({height: '0px'}, 1000);});
			
			// Switch between projectlab and newslab logins
			var tabContainers = jQuery('.loginLab');
		jQuery('#panelNav a').click(function () {tabContainers.hide().filter(this.hash).show();
		jQuery('#panelNav a').removeClass('active');jQuery(this).addClass('active');
		return false;}).filter(':first').click();
		
		var currentPage = (location.hash.substring(1));
		if (currentPage == "thankyou"){
			jQuery(".theForm").hide(); 
			jQuery(".confirmation").show();}
			
			
	// Input Labels
	// jQuery(":text:not(#blogSearch, .addcomment-input)").labelify({text: "label"});
	jQuery(".addcomment input, .panel input:text").labelify({text: "label"});
	jQuery(":password").labelify({text: "label"});
	jQuery(".addcomment textarea").labelify({text: "label"});
	
	
	
	
	// Google Docs Form
	
	jQuery('.ss-section-header').parent(".preerrorbox-good").addClass('survey-break');
	jQuery(".survey-break").each(function(i) {jQuery(this).nextUntil(".survey-break").andSelf().wrapAll('<div class="survey-section"></div>');});
	jQuery("#ss-form input:text").labelify({text: "label"});

	
	
	
});
	
	
	
// SCRIPTS TO RUN WHEN PAGE IS LOADED
jQuery(window).load(function () {

	// Fade In & Scroll Page
	jQuery("#load").animate({opacity: 0}, 1000 );
	if(jQuery.browser.msie){}
	else{ jQuery("#content > div, #content > img, #content-grid, .catalog, .nav, #navSearchfield").animate({opacity: 1}, 3500 );}
	jQuery.scrollTo('500px',0, {axis:'x'});
	jQuery.scrollTo('0px',3500, {axis:'x'}, 'easeOutQuad');
	
});



// NEWSLAB SIGNUP
jQuery(function() {
	jQuery(":submit").click(function() {	
		
		jQuery('form#subForm').submit(function() { return false; });
		
		formAction = $("form#subForm").attr("action");
		
		emailId = "jkftl";
		emailId = emailId.replace("/", "");
		emailId = emailId + "-" + emailId;
		
		var str = jQuery("form#subForm").serialize();
		
		final = str + "&action=" + formAction;
		
		jQuery.ajax({
			url: "http://www.sector7g.com.au/proxy_curl.php",
			type: "POST",
			data: final,
			success: function(html){
				jQuery(".theForm").hide(); // If successfully submitted hides the form
				jQuery(".confirmation").slideDown("slow");  // Shows "Thanks for subscribing" div
			}
		});
	});
});



// PROJECTLAB LOGIN
function checkEmail(email)
{	
	var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var emailVal = $("#" + email).val();
	return pattern.test(emailVal);
}


function Login(form) {
	var username = form.username.value;
	var password = form.password.value;
	var server = form.server.value;
	if (username && password && server) {
	var htsite = "http://" + username + ":" + password + "@" + server;
	window.location = htsite;
	}
	else {
	alert("Please enter your username and password.");
	   }
	}
