jQuery.noConflict();

window.onresize = function () {
  resizeFlash();
}

function gotoTop() {
  new Effect.ScrollTo('header', {duration:3.0});
}

function gotoEnd() {
  //updateEntrylist();
  showEntries();
  new Effect.ScrollTo('last', {duration:3.0});
  jQuery(document).ready(function(){
    var height = document.getElementById("entries").offsetHeight;
	var groundElement = document.getElementById('inner-entries');
	newheight = height - 60;
	groundElement.style.height = newheight + 'px'; 

	resizeFlash(); 
  });
}

function resizeFlash() {
  // Get window height
  var viewportwidth;
  var viewportheight;
	 
  // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
  if (typeof window.innerWidth != 'undefined') {
    viewportwidth = window.innerWidth,
    viewportheight = window.innerHeight }
  // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
  else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
	  viewportwidth = document.documentElement.clientWidth,
	  viewportheight = document.documentElement.clientHeight
  } 
  // older versions of IE
  else {
    viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
    viewportheight = document.getElementsByTagName('body')[0].clientHeight
  }
  //document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
  var flashElement = document.getElementById('flash');
  flashElement.style.height = viewportheight + 'px';
}

function showEntries() {
  jQuery(document).ready(function(){
    jQuery('#inner').show();
  });
}

function getXMLHttp() {
  var xmlHttp

  try {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e) {
    //Internet Explorer
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e) {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}

function updateEntrylist() {
  var xmlHttp = getXMLHttp();
 
  xmlHttp.onreadystatechange = function() {
    if(xmlHttp.readyState == 4) {
      HandleResponse(xmlHttp.responseText, 'ResponseDiv');
    }
  }

  xmlHttp.open("GET", "ajax-entry.php", true);
  xmlHttp.send(null);
}

function HandleResponse(response, div) {
  document.getElementById(div).innerHTML = response;
}

function fillRight(div) {
  var xmlHttp = getXMLHttp();

  xmlHttp.onreadystatechange = function() {
    if(xmlHttp.readyState == 4) {
	  HandleResponse(xmlHttp.responseText, 'right');
	}
  }

  xmlHttp.open("GET", "ajax-"+div+".php", true);
  xmlHttp.send(null);
}

function sendEmails() {
  jQuery.post( 
    'ajax-sendmails.php', 
    jQuery('#ajax-form').serialize(), 
    function(data){ 
      document.getElementById('friends').innerHTML = data;
    } 
  );  
}

function addInput() {
  jQuery(document).ready(function(){
    jQuery("#names").append('<label for="name">Le nom de votre ami *</label><br /> <input type="text" id="" name="name[]" tabindex="8" /><br />');
    jQuery("#emails").append('<label for="email">Son adresse email *</label><br /> <input type="text" id="" name="email[]" tabindex="9" /><br />');
  });
}