$(document).ready(function(){
 
 	/* New England map image swap */
	$(".map map area").mouseover(function() {
		$(this).parent("map").siblings("img").attr("src","/chapter/csi/images/map_" + this.className + ".gif");
	});
	$(".map map area").mouseout(function() {
		$(this).parent("map").siblings("img").attr("src","/chapter/csi/images/map_ma.gif");
	});
	
	/* Who is AIGA Boston random selector */
	var rand_no = Math.floor((10)*Math.random()) + 1;
	$("#whois" + rand_no).css("display","block");
	
	var imagepath = "none";
	if (document.location.protocol == "http:") {
		imagepath = "/chapter/csi/images/"; 
	};
	if (document.location.protocol == "https:") {
		imagepath = "/bostonchapter/csi/images/"; 
	};

	/* Header + footer banners random selector */
	
	// $(".start-body").html("image by <a href=\"http://www.lemonland.net\">Kevin Grady</a>");
	// $(".start-body").html("image by <a href=\"http://www.stoltzedesign.com\">Stoltze Design</a>");
	// $(".start-body").html("image by <a href=\"http://www.melissadepasquale.com\">Melissa DePasquale</a>");
	
	var randtwo = Math.floor((12)*Math.random()) + 1;
	
	if (randtwo == 1) {
		$(".head").css("background-image","url(" + imagepath + "borsare_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "borsare_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Michael Borsare, MassArt, Grad &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 2) {
		$(".head").css("background-image","url(" + imagepath + "brien_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "brien_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Donovan Brien, BU, Senior &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 3) {
		$(".head").css("background-image","url(" + imagepath + "dahl_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "dahl_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Alex Dahl, Champlain, Junior &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 4) {
		$(".head").css("background-image","url(" + imagepath + "dejesus_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "dejesus_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Jessica De Jesus, MassArt, Senior &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 5) {
		$(".head").css("background-image","url(" + imagepath + "fitzpatrick_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "fitzpatrick_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Cory Fitzpatrick, UMD, Junior &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 6) {
		$(".head").css("background-image","url(" + imagepath + "geoghegan_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "geoghegan_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Barbara Geoghegan, AIB, Senior &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 7) {
		$(".head").css("background-image","url(" + imagepath + "graves_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "graves_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by George Graves, Endicott, Senior &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 8) {
		$(".head").css("background-image","url(" + imagepath + "huston_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "huston_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Amy Huston, Hartford, Junior &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 9) {
		$(".head").css("background-image","url(" + imagepath + "lam-cao_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "lam-cao_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Caspar Lam &amp; Ke Cao, Yale, Grad &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 10) {
		$(".head").css("background-image","url(" + imagepath + "lam_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "lam_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Caspar Lam, Yale, Grad &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 11) {
		$(".head").css("background-image","url(" + imagepath + "long_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "long_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Joshua Long, Hartford, Senior &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	else if (randtwo == 12) {
		$(".head").css("background-image","url(" + imagepath + "rodrigues_top.jpg)");
		$(".start-foot ").css("background-image","url(" + imagepath + "rodrigues_bot.jpg)");
		$(".start-body").html("image: New Voices, Unique Visions student exhibition entry by Jenna Lea Rodrigues, UMD, Senior &nbsp;<a href=\"/events/2010/03/34314254\">more</a>");
	}
	
	
	/* Advisory Board page */

	/* preload images */
	jQuery.preloadImages = function() {
  		for(var i = 0; i<arguments.length; i++)
  		{
    	jQuery("<img>").attr("src", arguments[i]);
  		}
	}
	$.preloadImages("/chapter/csi/images/advboard1.jpg","/chapter/csi/images/advboard3.jpg");
	
	/* photo and content switcher */
	
	$(".advisory #columnright div").hide();
	$(".col2 .advisory .inset div").hide();
	$(".advisory #columnright div.right0").show();
	
	var strip = "none";
	var position = "none";
	var my_class = "none";
	var my_id = "none";
	
	$(".advisory #columnleft map area").mouseover(function() {
		my_class = $(this).attr("class");
		my_id = $(this).attr("id");
		$(this).parent("map").siblings("img").attr("src","/chapter/csi/images/advboard" + my_class + ".jpg");
		$(".advisory #circle").attr("class",my_id);
	});
	$(".advisory #columnleft img.faces").mouseout(function() {
	});
	$(".advisory #circle").click(function() { 
		strip = my_class;
		position = $(this).attr("class");
		$(".advisory #columnright div").hide();
		$(".col2 .advisory .inset div").hide();
		$(".col2 .advisory .inset div." + position).show();
		$(".advisory #columnright div." + position).show();
		return false;
	});
	$(".advisory #columnleft map area").click(function() { 
		position = $(this).attr("id");
		$(".advisory #columnright div").hide();
		$(".col2 .advisory .inset div").hide();
		$(".col2 .advisory .inset div." + position).show();
		$(".advisory #columnright div." + position).show();
		return false;
	});
	
	/* Endicott competition submission form */
	
	$("#urlfield").css("position","absolute").css("left","-9999px"); 
	$("select#category").change(function () {
          var str = $("select#category option:selected").attr("id");
          if (str == "nocat") { $("#urlfield").css("position","absolute").css("left","-9999px"); }
		  if (str == "ID") { $("#urlfield").css("position","absolute").css("left","-9999px"); }
		  if (str == "PST") { $("#urlfield").css("position","absolute").css("left","-9999px"); }
		  if (str == "PUB") { $("#urlfield").css("position","absolute").css("left","-9999px"); }
		  if (str == "MOT") { $("#urlfield").css("position","static"); }
		  if (str == "WEB") { $("#urlfield").css("position","static"); }
		  if (str == "PKG") { $("#urlfield").css("position","absolute").css("left","-9999px"); }
		  if (str == "SER") { $("#urlfield").css("position","absolute").css("left","-9999px"); }
        })

	/* Main Twitter filter */
	
    $('#twitmain').jTweetsAnywhere({
        searchParams: ['q=from:aigaboston'],
        count: 3,
		tweetProfileImagePresent: false,
	  tweetDecorator: function(tweet, options) {
        var html = '';
        html = '<li class="jta-tweet-list-item">';
        html += options.tweetBodyDecorator(tweet, options);
        html += '</li>';
      	return html;
      },
	  tweetTimestampDecorator: function(tweet, options){
       var screenName =
           tweet.user ? tweet.user.screen_name : false || tweet.from_user;
       var date = new Date(formatDate(tweet.created_at));

       var dateString =
           (date.getHours() > 11 ? (date.getHours() - 12) == 0 ? '12' : date.getHours() - 12 : date.getHours()) + ':' +
           (date.getMinutes() < 10 ? '0' : '') +
           date.getMinutes() +
		   (date.getHours() > 11 ? " PM" : " AM") + ' on ' +
           (date.getMonth() + 1) + '.' +
           date.getDate() + '.' +
           date.getFullYear();

        var html =
            '<span class="jta-tweet-timestamp"> ' +
            '<a class="jta-tweet-timestamp-link" href="http://twitter.com/' +
            screenName + '/status/' + tweet.id + '">' + 'posted at ' +
            dateString + '</a></span>';

       return html;
      },
    });
	
	/* Design Link Twitter filter */
	
    $('#twitdesignlink').jTweetsAnywhere({
        username: 'aigaboston',
        count: 200,
		hideHashTags: ['BostonEvents','bostonevents','Bostonevents','bostonEvents'],
		tweetDecorator: function(tweet, options) {
        var html = '';
        var events = /#BostonEvents/i;
		if (events.test(tweet.text)) {
          html = '<li class="jta-tweet-list-item">';
          html += options.tweetBodyDecorator(tweet, options);
          html += '</li>';
        }
        return html;
      	},
	  tweetTimestampDecorator: function(tweet, options){
       var screenName =
           tweet.user ? tweet.user.screen_name : false || tweet.from_user;
       var date = new Date(formatDate(tweet.created_at));

       var dateString =
           (date.getHours() > 11 ? date.getHours() - 12 : date.getHours()) + ':' +
           (date.getMinutes() < 10 ? '0' : '') +
           date.getMinutes() +
		   (date.getHours() > 11 ? " PM" : " AM") + ' on ' +
           (date.getMonth() + 1) + '.' +
           date.getDate() + '.' +
           date.getFullYear();

        var html =
            '<span class="jta-tweet-timestamp"> ' +
            '<a class="jta-tweet-timestamp-link" href="http://twitter.com/' +
            screenName + '/status/' + tweet.id + '">' + 'posted at ' +
            dateString + '</a></span>';

       return html;
    },
	hashtagDecorator: function(text, options)
      {
        // Find hashtags, and then filter them according to the contents:
        return text.replace(/#([a-zA-Z0-9_]+)/gi, function (str, p1, offset, s)
        {
          // return nothing if it's in the list of hidden hash tags
          if (options.hideHashTags.indexOf(p1) + 1)
            return '';
          else
            // otherwise, return the string from defaultHashtagDecorator
            return '<a href="http://search.twitter.com/search?q=%23' +p1+ '" class="jta-tweet-a jta-tweet-hashtag" title="#' +p1+ '" target="_blank" rel="nofollow">#' +p1+ '<\/a>';
        })
      }
    });

});

/* sIFR */
	if (document.location.protocol == "http:") {
		var sifrpath = "/chapter/csi/";
	};
	if (document.location.protocol == "https:") {
		var sifrpath = "/bostonchapter/csi/";
	};
	
	var serifa = {
    src: '' + sifrpath + 'serifa.swf'
	};

	sIFR.activate(serifa);
	
	sIFR.replace(serifa, {
	wmode: 'transparent'
    ,selector: 'h1'
    ,css: [
      '.sIFR-root { color: #ffffff; background-color: #00b7ed; font-size: 30px; leading: -4; }'
    ]
  });
	

