/*
 * Name: Simple Video Box
 * Author: Michael Stowe
 * Version 1.0
 * ---------------------
 * Sends user input via "GET" to a dynamic page with a "q" query, and then takes the
 * pipe-delimited text and returns it as a clickable dropdown list.
 * ---------------------
 * Example: 
 * <input type="text" name="example" id="example" rel="use_this_page_for_results.php" />
 * <script language="javascript">$('#example').combosuggest();< /script>
 * ---------------------
 * Changelog: 
 * ---------------------
 * (c) 2010, http://www.mikestowe.com
 */ 

jQuery.fn.ajaxbox = function() {
	
	ajaxbox_loading_text = '<br /><br /><br /><br /><br /><br /><span style="color: #fff;">loading...</span>';
	
	if(navigator.userAgent.match(/firefox/gi)) {
		var marginleft = '-263px';
	} else if(navigator.userAgent.match(/safari/gi)) {
		var marginleft = '481px';
	} else if(navigator.userAgent.match(/msie 8/gi)) {
		// ie 8
		var marginleft = '283px';
	} else if(navigator.userAgent.match(/msie 7/gi)) {
		// ie 7
		var marginleft = '-263px';
	} else if(navigator.userAgent.match(/msie 6/gi)) {
		// ie 6
		var marginleft = '283px';
	} else {
		// hope this works
		var marginleft = '-263px';
	}

	document.write('<div id="ajaxbox" style="filter:alpha(opacity=80); -moz-opacity:0.8; -khtml-opacity: 0.8; opacity: 0.8; background: #000; position: absolute; left: 0px; top: 0px; height: '+($('html,body').height() + 2500)+'px; width: 100%; display: none; z-index: 200;"><div style="margin: 2100px auto; background: #000; border: 3px solid #fff; width: 520px; height: 330px;" id="ajaxbox_inner"></div><a href="javascript:void(0);" onclick="$(\'#ajaxbox_inner\').html(\'loading...\'); $(\'#ajaxbox\').fadeOut();" style="position: absolute; top: 2435px; width: 523px; margin-left: '+marginleft+'; font-size: 20px; font-weight: bold; color: #fff; background: #fff; text-align: right; padding: 0px 3px 2px 0px;"><img src="images/site/lightbox-btn-close.gif"></a></div>');
	
	
	$('#ajaxbox_inner').blur(
	        function() {
				$('#ajaxbox').fadeOut();
	            $('#ajaxbox_inner').html(ajaxbox_loading_text);
	        }
	);
	
  return this.each(function(){
    var url = $(this).attr('href');
	$(this).attr('href','javascript:void(0);');
	
    $(this).click(
        function() {
			$('#ajaxbox').css('top',($('html,body').scrollTop()-2000));
			$('#ajaxbox_inner').html(ajaxbox_loading_text);
			$('#ajaxbox').fadeIn();
			$.ajax({ 
				url: url,
				context: document.body,
				success: function(data){
       				 $('#ajaxbox_inner').html(data);
    		  }});
			  return true;
        }); 
  });
};
