/**
 * @author kchevalier@suntouchdesign.com
 */

$(document).ready(function(){
	
	// array of jQuery objects with transparent PNG backgrounds
	var transparentPNGs = [ $('#funnyGuys h2'), $('#mug'), $('#personalityTitle'), $('.twitter .page h3'), $('#twitterConvTop') ];
	browserHacks.pngList = transparentPNGs;
	browserHacks.stylesheetIE6 = '/wp-content/themes/bigbizshow/styleIE6.css';
	
	// initialize objects
	browserHacks.init();
	listenLocal.init();
	cssHacks.init();
	watchLive.init();
});

var listenLocal = {
	
	init: function() {
		
		// prep listen local app
		$('#localLink .submit').val('');
		$('#closeDrop').bind( 'click', function(e) {
			$('#localDrop').animate({ left: '4px' }, 1000 );
		} );
		
		// IE hack
		$('#closeDrop').animate({ opacity: 0 });
		
		// AJAX submit
		$('#localLink form').bind( 'submit', function(e) {
			e.preventDefault();
			$.ajax({
				type: 'POST',
				dataType: 'xml',
				url: 'http://bigbizshow.com/wp-content/themes/bigbizshow/listenLocalAJAX.php',
				data: { Zip_Code: $('#Zip_Code').val() },
				success: function(result) {
					if ( $(result).find("station").text() != '' ) {
						$('#localDrop p').text( $(result).find("station").text() + ' ' + $(result).find("frequency").text() );
					}
					else {
						$('#localDrop p').text( 'No Results' );
					}
					$('#localDrop').animate({ left: '-160px' }, 1000 );
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					window.location = 'http://www.businesstalkradio.net/zipsearch.shtml';
				}
			});
		} );
	}
}

var watchLive = {
		
		init: function() {
			$('#watchLiveLink a').bind( 'click', function(evt) {
				window.open( evt.target, 'watchus', 'left=200,top=100,width=400,height=350,toolbar=0,resizable=0' );
				return false;
			});
			$('#watchLiveLink2 a').bind( 'click', function(evt) {
				window.open( evt.target, 'watchus', 'left=200,top=100,width=400,height=350,toolbar=0,resizable=0' );
				return false;
			});
		}
	}

var cssHacks = {
	init: function() {
		$('#wp-submit').val('');
		$('.page #submit input').val('');
	}
}
