
// Browser sniff with object function
    function hideShowlayer(hidelayer,hideanother,showlayer){
    if(document.getElementById){
   	document.getElementById(hidelayer).style.visibility="hidden";
  	document.getElementById(hideanother).style.visibility="hidden";
  	document.getElementById(showlayer).style.visibility="visible";
   	}
    else if(document.all){
     document.all[hidelayer].style.visibility="hidden";
      document.all[hideanother].style.visibility="hidden";
     document.all[showlayer].style.visibility="visible";
	}   
	else return false;
	}

   function hideShowBorder(hideborder,showborder,showanother){
    if(document.getElementById){
    document.getElementById(hideborder).style.borderBottomWidth="0px";
    document.getElementById(showborder).style.borderBottomWidth="1px";
  	document.getElementById(showanother).style.borderBottomWidth="1px";
   	}
  
  
   	else if(document.all){
     document.all[noborderlayer].style.borderBottomWidth="0px";
     document.all[borderlayer].style.borderBottomWidth="1px";
	}   
 else return false;
	}

var preloadFlag= false;
function preloadImages(){
if (document.images)
	{	
	homeOn= new Image(100,28)
	homeOn.src="images/templates/nav_home_on.gif";
	homeOff= new Image(100,28)
	homeOff.src="images/templates/nav_home_off.gif";

	aboutOn= new Image(125,28)
	aboutOn.src="images/templates/nav_aboutus_on.gif";
	aboutOff= new Image(125,28)
	aboutOff.src="images/templates/nav_aboutus_off.gif";
	
	contactOn= new Image(130,28)
	contactOn.src="images/templates/nav_contactus_on.gif";
	contactOff= new Image(130,28)
	contactOff.src="images/templates/nav_contactus_off.gif";
	t_Off= new Image(105,22)
	t_Off.src="images/templates/t_off.gif";
	t1805_On= new Image(105,22)	
	t1805_On.src="images/templates/t1805.gif";
	t1850_On= new Image(105,22)	
	t1850_On.src="images/templates/t1850.gif";	
	t1900_On= new Image(105,22)	
	t1900_On.src="images/templates/t1900.gif";
	t1950_On= new Image(105,22)	
	t1950_On.src="images/templates/t1950.gif";
	preloadFlag= true;
	}
}
function ImgSwap(where, ImgObj){
if (document.images && (preloadFlag == true)){
document.images[where].src=eval(ImgObj + ".src");
}
}



function openWin(url) {
window.open(url,'','scrollbars,resizable,width=600,height=540,left=0,top=0');

}


function setAddr(link, fname, lname) 
{ 
  link.href = 'mai' + 'lto:' + fname +'.'+ lname + '@georgetown-umc.org'; 
} 
 
function setOutAddr(link, fname, lname, at) 
{ 
  link.href = 'mai' + 'lto:' + fname +'.'+ lname + '@' + at ; 
} 

 function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block'){
          e.style.display = 'none';}
       else{
          e.style.display = 'block';
    }
    return false;
  }


  $(document).ready(function(){
	
	//set class for links to external sites and other document types
	$('#content a[href^="http://"]').addClass('external').attr('target', '_blank');
	$('#content a[href^="http://www.micourthistory.org"]').removeClass('external').attr('target', '_self');
	$('#content a[href^="http://micourthistory.org"]').removeClass('external').attr('target', '_self');

	$('#content a[href$=".pdf"]').addClass('pdf').attr('target','_blank');
	$('#content a[href$=".ppt"]').addClass('powerpoint').attr('target','_blank');
	$('#content a[href$=".doc"]').addClass('word').attr('target','_blank');
	$('#content a[href$=".xls"]').addClass('excel').attr('target','_blank');
	$('#content a[href$=".csv"]').addClass('excel').attr('target','_blank');

	
	$('input[name="total"]').attr('readonly', 'readonly');
	$('input[name="number_individual_tickets"]').change(function(){
		var amount = $(this).val();
		var total = 0;
		amount = $.trim(amount);
		$(this).css({color : '#000'});
		if(amount!=''){
			if (isNaN(amount)) {
				alert("the number of tickets must be an integer");
				$('input[name="number_individual_tickets"]').css({color : '#c00'}).val('0');
				$('input[name="number_individual_tickets"]').focus();  
				
				return false;
			}		
		amount = Math.floor(amount);
		$(this).val(amount);
		
		updateTotal();
		
		return true;
		}
	});	
	
	$('input[name="number_tables"]').change(function(){
		var amount = $(this).val();
		var total = 0;
		amount = $.trim(amount);
		$(this).css({color : '#000'});
		if(amount!=''){
			if (isNaN(amount)) {
				alert("the number of tickets must be an integer");
				$('input[name="number_tables"]').css({color : '#c00'}).val('0');
				$('input[name="number_tables"]').focus();  
				
				return false;
			}		
		amount = Math.floor(amount);
		$(this).val(amount);
		
		updateTotal();
		
		return true;
		}
	});	

	
	
	
	$('#annual_luncheon').submit(function(){
		
		var total = $('input[name="total"]').val();
		total = $.trim(total);
		var num_individual = $('input[name="number_individual_tickets"]').val();
		num_individual = $.trim(num_individual);
		var num_table = $('input[name="number_tables"]').val();
		num_table = $.trim(num_table);
		
		if(isNaN(total)){
			alert('you must enter how many tickets you would like to purchase');
			return false;			
		}

		if(num_individual !=''  ){
			
			if(isNaN(num_individual)){
				alert('the number of tables must be an integer');
				return  false;
			}
		}	
		
		if(num_table!=''){
			
			if(isNaN(num_table)){
				alert('the number of tables must be an integer');
				return false;
			}
		}	

		return true;
	
	});


});

function updateTotal(){
	var num_individual = 0;
	var num_table = 0;
	var total = 0;
	
	num_individual = $('input[name="number_individual_tickets"]').val();
	num_table = $('input[name="number_tables"]').val();
	total = (num_individual * 35) + (num_table * 280);
	
	$('input[name="total"]').val(total);	
	
	return total;
}
