// Expand Panel
$(document).ready(function() {

    // Expand Panel
   $("#open").click(function(e){
       e.preventDefault();
	   var animate_height = '200px';
	   if ($(window).width() <=767) {
			animate_height = '180px';  
			
			// resize images here?
			//$("div#panel li img").width(338); 
	   }

        $("div#panel").animate({height: animate_height},"medium");
    });   

    // Collapse Panel
    $("#close").click(function(e){
        e.preventDefault();
        $("div#panel").animate({height: "0px"},"medium");
    });  

	// Set menu portfolio link to expand panel
	$('ul.menu a.portfolio').bind('click', function (e) {
		e.preventDefault();
		if ($('#close').is(':visible')){
			$("#close").trigger('click');
		}
		else {
			$("#open").trigger('click');
		}
	});

    // Switch buttons from "Log In | Register" to "Close Panel" on click
    $("#toggle a").click(function () {
        $("#toggle a").toggle();
    });  

    
});
// Expand Panel END



	var flashvars = {};
		flashvars.xml = "config.xml";
		var attributes = {};
		attributes.wmode = "transparent";
		attributes.id = "slider";
		swfobject.embedSWF("flash/cu3er.swf", "feature", "904", "240", "9", "expressInstall.swf", flashvars, attributes);



// Start of signup

function validate_signup(frm) {
	var emailAddress = frm.Email.value;
	var errorString = '';
	if (emailAddress == '' || emailAddress.indexOf('@') == -1) {
		errorString = 'Please enter your email address';
	}

    

	var isError = false;
    if (errorString.length > 0)
        isError = true;

    if (isError)
        alert(errorString);
	return !isError;
}



//homepage tweets
    jQuery(function($){
      $("#fi-tweets").tweet({
        avatar_size: 32,
        count: 2,
        username: ["dmc_runs", "helenduncan", "Cal_FI", "F1rst1mpression", "RobJenkins3", "martinjduncan"],
        loading_text: "searching twitter...",
        refresh_interval: 60
      });
    });



// homepage flickr

// Our very special jQuery JSON fucntion call to Flickr, gets details
// of the most recent 20 images
$(document).ready(function(){	
$.getJSON("http://api.flickr.com/services/feeds/photoset.gne?set=72157627727454208&nsid=67574415@N07&lang=en-us&format=json&jsoncallback=?", displayImages);
function displayImages(data) {

    // Start putting together the HTML string
    var htmlString = "";
   
    // Now start cycling through our array of Flickr photo details
    $.each(data.items, function(i,item){
   
        // I only want the ickle square thumbnails
        var sourceSquare = (item.media.m).replace("_m.jpg", "_s.jpg");
       
        // Here's where we piece together the HTML
        htmlString += '<li><a href="' + item.link + '" target="_blank">';
        htmlString += '<img title="' + item.title + '" src="' + sourceSquare;
        htmlString += '" alt="'; htmlString += item.title + '" />';
        htmlString += '</a></li>';
   
    });
   
    // Pop our HTML in the #flickr-stream ul
    $('#flickr-stream ul').html(htmlString);
   
    // Close down the JSON function call
}
    });
	

