$(document).ready(function(){ 
if($('#mailerform').length > 0) {
    data = $(":input[@name^='data']").map(function(){ return $(this).attr("name").replace(/data\[/, '').replace(/\]/, ''); });
    var d = new Array();
    jQuery.map(data, function(n) {if(jQuery.inArray(n, d) == -1) {d.push(n);}});
    h = document.createElement("input");
    h.name = 'ordered_input_names';
    h.type = 'hidden';
    h.value = d;
    $('#mailerform').append(h);

    $('#mailerform').submit(function() {
        $('#submit').val('submitting...');
        $('#submit').attr("disabled","disabled");
    })
}
});

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function rotatePhoto() {
	if(document.getElementById('bigpic')) {
		var rand = Math.floor(Math.random()*3)
		document.getElementById('bigpic').style.backgroundImage = "url(stylesheets/images/CoverShot" + rand + ".jpg)";
	}
}

addLoadEvent(rotatePhoto);


