// JavaScript Document

var opened = '';

function rollUp(DivId4,DivId1,button, openBut){
	
		$('#'+DivId1).slideUp('fast');
		opened = "";
		setTimeout('rollDown("'+DivId4+'","'+openBut+'")',300);
}
function rollDown(DivId2, butId){
	
		$('#'+DivId2).slideDown("fast");
		opened = DivId2;
		document.getElementById(DivId2).innerHTML = wow;
}
function dropDown(DivId3, ButtonId){
	
		if(opened != "" && opened != DivId3){rollUp(DivId3, opened, ButtonId);}				
		else{rollDown(DivId3, ButtonId);}
}

function LilBox(Pic){
	$('#shadow').fadeIn('fast');
	$('#LilBox').fadeIn('slow');
	$('#closeIt').fadeIn('slow');
	
	var i = '<img src="'+Pic+'"/>';
	document.getElementById('LilContent').innerHTML = i;
	
}
function closeIt(){
	$('#LilBox').fadeOut('fast');
	$('#closeIt').fadeOut('fast');
	var i = '';
	document.getElementById('LilContent').innerHTML = i;
	$('#shadow').fadeOut('slow');
	
}
//this is a generic ajax function i found online. I provided comments and  moddified the script to write content into a div layer chosen by its id.
function getMenu(Url,DivId,Method,Bid)
{
	//create our requst object. We have to try 3 objects, for the different browsers.
 var AJAX;
 try
 {  
  AJAX = new XMLHttpRequest(); 
 }
 catch(e)
 {  
  try
  {    
   AJAX = new ActiveXObject("Msxml2.XMLHTTP");    
  }
  catch(e)
  {    
   try
   {
    AJAX = new ActiveXObject("Microsoft.XMLHTTP");      
   }
   catch(e)
   {      
    alert("Your browser does not support AJAX.");      
    return false;      
   }    
  }  
 }//once the request is sent, check with the server on the requests status. 
 AJAX.onreadystatechange = function()
 {//4 == complete
  if(AJAX.readyState == 4)
  {
   //200 = complete and ready!
   if(AJAX.status == 200)
   {//print the resulting data into the div layer
  //	document.getElementById(DivId).innerHTML = AJAX.responseText;
	wow = AJAX.responseText;	
	dropDown(DivId, Bid); 
   }
   else
   {//shit the bed
    alert("Error: "+ AJAX.statusText +" "+ AJAX.status);
   }
  }  
 };
 //send the request object
 AJAX.open(Method, Url, true);
 AJAX.send(null);
}

function ajax(Url,DivId,Method)
{
	//create our requst object. We have to try 3 objects, for the different browsers.
 var AJAX;
 try
 {  
  AJAX = new XMLHttpRequest(); 
 }
 catch(e)
 {  
  try
  {    
   AJAX = new ActiveXObject("Msxml2.XMLHTTP");    
  }
  catch(e)
  {    
   try
   {
    AJAX = new ActiveXObject("Microsoft.XMLHTTP");      
   }
   catch(e)
   {      
    alert("Your browser does not support AJAX.");      
    return false;      
   }    
  }  
 }//once the request is sent, check with the server on the requests status. 
 AJAX.onreadystatechange = function()
 {//4 == complete
  if(AJAX.readyState == 4)
  {
   //200 = complete and ready!
   if(AJAX.status == 200)
   {//print the resulting data into the div layer
 		document.getElementById(DivId).innerHTML = AJAX.responseText;
		$('#'+ DivId).fadeIn('slow');
		setTimeout("closeMsg('"+DivId+"')",3000);
   }
   else
   {//shit the bed
    alert("Error: "+ AJAX.statusText +" "+ AJAX.status);
   }
  }  
 };
 //send the request object
 AJAX.open(Method, Url, true);
 AJAX.send(null);
}

function get(obj,email,place) {
      var poststr = "&email=" + encodeURI( document.getElementById(email).value ) +
					"&place=" + encodeURI( document.getElementById(place).value );
      ajax('newsletter.php?' + poststr,'confirm','POST');
   }
   
function closeMsg(DivId)
{
	$('#'+DivId).fadeOut('slow');
}