/* Scripts for Interactive Emmys Information Site
 *
 * Marc Johnson, March 2011
 */
 
 
/* Rollover image swap */
function SimpleSwap(el,which){
    el.src=el.getAttribute(which||"origsrc");
}


function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};

window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}

/*
 * Email functions - designed to hide email addys from spambots
 */
function inquireJG() { inquire("john", "codeandtheory", "com"); }
function inquireMJ() { inquire("marc.johnson.la", "gmail", "com"); }
function inquireMG() { inquire("mgregor", "velope", "tv"); }


function inquire(whom, where, ext)
{
	//Build email message and send
	var emailAddress = (whom); // username
	var emailDomain = (where); // domain
	var sendTo = buildEmailStr(emailAddress, emailDomain, ext); //build full send-to string

	var subject = ("2011 Interactive Emmy Awards inquiry");
	var cc = ("");
	var bcc = ("");
	var mailbody = ("");
	

	this.location.href = sendTo +
		'?subject=' +subject+
		'&cc=' +cc+
		'&bcc=' +bcc+
		'&body=' +mailbody;	

	return true;
}

function buildEmailStr (addressee, domain, ext)
{
	var emailAddy = ""
	var atSign = "%40" //"&#64;" //"@"
	var the_ext = ext

	emailAddy = addressee + atSign + domain + "." + the_ext;

	var fullMailStr = "mailto:" + emailAddy
	//alert (fullMailStr);
	
	return(fullMailStr);
}


/* This cycles thru the divs in the #footer container div */
// See http://jquery.malsup.com/cycle/begin.html

/* cycle() function:
 * Choose from any of the following named effects:
 * 
 * blindX
 * blindY
 * blindZ
 * cover
 * curtainX
 * curtainY
 * fade
 * fadeZoom
 * growX
 * growY
 * scrollUp
 * scrollDown
 * scrollLeft
 * scrollRight
 * scrollHorz
 * scrollVert
 * shuffle
 * slideX
 * slideY
 * toss
 * turnUp
 * turnDown
 * turnLeft
 * turnRight
 * uncover
 * wipe
 * zoom
 */
 //
$(document).ready(function(){
	$('body').css("display", "none");
	$('body').fadeIn(1000);
			   
	$('#footer').cycle({ 
	  fx:    'fade',
	  speed:  1500,
	  pause: 1,
	  delay: -1500
	});
});



//function fadeDiv(whichDiv) {
//	  $(whichDiv).hide();
//	  $(whichDiv).fadeIn(1000);
//}
//

/* Another method - couldn't make this work.
 */
//$(document).ready(function(){
//	$('#footer').animate({ opacity: 'toggle', height: 'toggle' }, "slow");
//});

//$(".fadeNext").click(function(){   
//  	$(this).next().fadeSliderToggle()
// 	return false;
// })


