/* Author: 

*/

/* Cufon font replacement */
Cufon.replace('h1', { fontFamily: 'Arial', });
Cufon.replace('#landing p', { fontFamily: 'Arial', });
Cufon.replace('#top-nav', { fontFamily: 'Arial',  hover: true, letterSpacing: '2px' });
Cufon.replace('#tinker-title-wrap h2', { fontFamily: 'Arial',  hover: true, letterSpacing: '1px' });
Cufon.now();

<!--
		// Use a variable to reference the embedded SWF.
		var flashVideoPlayer;

		/* When the HTML page loads (via the onLoad event of the <body> tag) we have it call the initialize() function. */
		function initialize() {
			/* Check if the browser is IE. If so, flashVideoPlayer is window.videoPlayer. Otherwise, it's window.document.videoPlayer. The videoPlayer is the id assigned to <object> and <embed> tags. */
			var ie = navigator.appName.indexOf("Microsoft") != -1;
			flashVideoPlayer = (ie) ? window['videoPlayer'] : document['videoPlayer'];
		}

		
	// Call the pauseResume() function within the SWF.
		function callFlashPlayIncor() {
			initialize();
			flashVideoPlayer.playIncor();
		}
		// Call the pauseResume() function within the SWF.
		function callFlashPlayGrant() {
			initialize();
			flashVideoPlayer.playGrant();
		}

		
	// -->


$(document).ready(function() {
	// set background-position on main
	$('#main').css({backgroundPosition: '0px 0px'});
	// modal close
	$('#modal-close').live('click', function(e) { 
		// fade out the modal
		$(this).parents('#modal').fadeOut();
	});
	// research gallery
	$('#photo-archive-thumbnails a').live('click', function(event) {  
	      event.preventDefault();
	      $('#modal-white').hide();
	      // load the selected img
	      var sel_img = $(this).attr('href');
	      $('#photo-archive-img-load').prepend('<div id="modal-black"><p id="modal-close" class="gallery-close">Close</p><img class="png_bg" src="' + sel_img + '" alt="photo archive" /></div>');
	      // fade in full img
	      $('#modal-black').fadeIn();
	});
	// nav right hover states
	$("#nav-right a").hover(
		function () {
				$('.background-wrap').addClass($(this).attr("id"));
		},
		function () {
				$('.background-wrap').removeClass($(this).attr("id"));
		}
	);
	
	var x = 0;
	
	$('#enter').click(function() {
  
if ($('#code').val() == '081211') {
		
             $('#boxOverlayEnter').css('visibility','visible');
			 callFlashPlayGrant();
        
			} else {
				
				
if ( x == 0 ) {
				$('#code').val('NO');
				callFlashPlayIncor();
				setTimeout(function(){
				$('#code').val('');  
				},1000);
				x++
} else {
				$('#code').val('NO');
				callFlashPlayIncor()
				setTimeout(function(){
				$('#code').val('081211');  
				},1250);
}
			
			}

});
	



	
	// capture keybaord events and update the input box
	$(document).keypress(function(keypress) {
		keypress.preventDefault();
		// form submit?
		if (keypress.which == 13) {
			// check code is 08 12 11
			if ($('#code').val() == '081211') {
			  $('#boxOverlayEnter').css('visibility','visible');
			} else {
				$('#code').val('NO');
				setTimeout(function(){
				$('#code').val('081211');  
				},1250);
			}	
		} else {
			// get current value
			var currval = $('#code').val();
			// delete?
			if (keypress.which == 8) {
				// alert(e.which);
				var newval = currval.substring(0, currval.length-1);
			} else {
				if (keypress.which > 47 && keypress.which < 58) {
					var newval = currval + (keypress.which - 48);
					// keypress state 
					var key_id = keypress.which - 48;
					//$('#key-' + key_id).css('backgroundPosition', '0 0');
				}
			}
			// update input
			$('#code').val(newval);
		}
	})
	.keyup(function(keypress) {
		// alert('keyup');
		if (keypress.which > 47 && keypress.which < 58) {
			// keypress state 
			var key_id = keypress.which - 48;
			// alert(key_id);
			$('#key-' + key_id).css('backgroundPosition', '0 -19px');
			
			
		}
	});
	
	
});

 function insertNo(numbval)
    {
    
        var currentText = document.getElementById("code");
        
        var smileyWithPadding = "" + numbval + "";
        currentText.value += smileyWithPadding;
    currentText.focus();
    
    }
	
	 function deleteNo()
    {
    
        var currentText = document.getElementById("code");
        
        var smileyWithPadding = "";
        currentText.value = smileyWithPadding;
    currentText.focus();
    
    }

