function closeMenus(element){
	var up = 0;
	$('#stack_container div').each(function(index){
		if($('#' + this.id).css("display") == "block"){
			if(this.id == element){
				up = 1;
			}
			switch(this.id){
				case "onair_stack":
					$("#onair").css({backgroundColor: "", color: ""});
				break;
				case "musicconcerts_stack":
					$("#musicconcerts").css({backgroundColor: "", color: ""});
				break;
				case "local_stack":
					$("#local").css({backgroundColor: "", color: ""});
				break;
				case "extras_stack":
					$("#extras").css({backgroundColor: "", color: ""});
				break;
				case "connect_stack":
					$("#connect").css({backgroundColor: "", color: ""});
				break;
			}
			$('#' + this.id).hide( );
		}
	});
	return up;
}
	
function getArtist( ){
		
	$.ajax({
		type: "GET",
		url: "includes/getCurrent.php",
		datatype: "text",
		success:function(data){
			if(data != ""){
				var songinfo = data.split("|");
				var out = "";
				if(firstload || (currentsong != songinfo[0] && currentartist != songinfo[1])){
					if(!firstload){
						$("#topimage").fadeOut(1000, function( ){
							out = "Now Playing: <span id='nowplayingartistsong' ><span style='color: #fff; font-weight: bold;'>" + songinfo[0] + "</span> BY <span style='color: #fff; font-weight: bold '>" + songinfo[1] + "</span></span>";
							$("#topimage").css("background","url(" + songinfo[2] + ") no-repeat top center");
							$("#nowplayingdisplay").html(out);
							$("#topimage").fadeIn(1000);
							songdisplay = 1;
							currentsong = songinfo[0];
							currentartist = songinfo[1];
						});
					}else{
						if(songinfo[0] != "" && songinfo[1] != ""){
							out = "Now Playing: <span id='nowplayingartistsong' ><span style='color: #fff; font-weight: bold;'>" + songinfo[0] + "</span> BY <span style='color: #fff; font-weight: bold '>" + songinfo[1] + "</span></span>";
							$("#topimage").css("background","url(" + songinfo[2] + ") no-repeat top center");
							$("#nowplayingdisplay").html(out);
							$("#topimage").fadeIn(1000,function( ){});
							songdisplay = 1;
							currentsong = songinfo[0];
							currentartist = songinfo[1];
							firstload = false;
						}else{
							$("#topimage").css("background","url(" + songinfo[2] + ") no-repeat top center");
							$("#nowplayingdisplay").html("");
							$("#topimage").fadeIn(1000,function( ){});
							firstload = false;
						}
						
					}
				}
			}else{
				var imagepath = "";
				//imagepath = songinfo[2];
				if(onair == "Steve Downes/Kathy Voltmer"){
					//imagepath = "/images/Downes_bio.jpg";
				}else if(onair == "Bob Stroud"){
					//imagepath = "/images/Stroud_bio.jpg";
					//imagepath = "../images/artists/thewho.png"; WHO TEST
				}else if(onair == "Bobby Skafish"){
					//imagepath = "/images/Skafish_bio.jpg";
				}else if(onair == "Phil Manicki"){
					//imagepath = "/images/Manicki_bio.jpg";
				}
				if(firstload || songdisplay){
					if(!firstload){
						$("#topimage").fadeOut(1000,function( ){
							$("#nowplayingdisplay").html("");
							$("#topimage").css("background","url(" + imagepath + ") no-repeat top center");
							$("#topimage").fadeIn(1000);
						});
					}else{
						$("#nowplayingdisplay").html("");
						$("#topimage").css("background","url(" + imagepath + ") no-repeat top center");
						$("#topimage").fadeIn(1000,function( ){
						
						});
					}
				}
				songdisplay = 0;
				if(firstload){firstload = false;}
			}
		},
		error: function( ){

		}
	});
}

function nextSlide( ){
	var nextImage   = $("#thumbs ul li:first").next("li").children("img").attr("name");
	var nextContent = $("#thumbs ul li:first").next("li").children("img").attr("alt");
	var nextLink    = $("#thumbs ul li:first").next("li").children("img").attr("link");
	var popup       = $("#thumbs ul li:first").next("li").children("img").attr("popup");
	
	
	$(".block p").html("");
	$("#currentImage img").unbind("click");
	if(popup == "1"){
		
		nextLink += "?width=900&height=475&iframe=true";
								
		$("#currentImage img").bind("click", function( ){
			
			$.prettyPhoto.open(nextLink,"","");
		});
	}else{
	    $("#currentImage img").bind("click", function( ){
			location.href = nextLink;   
	    });	
	}
	
	
	$("#currentImage img").animate({opacity: 0},500,function( ){
	   
	    $("#currentImage img").attr("src",nextImage).animate({opacity: 1}, 500);
	    
	    $(".block p").html(nextContent);
	    
	   
	});
	
	 $("#thumbs ul li:first").animate({opacity: 0}, 500, function( ){
	 	
			$("#thumbs ul li:first").clone( ).appendTo("#thumbs ul");
			$("#thumbs ul li:first").remove( );
			$("#thumbs ul li:last").css("opacity","1");
			
		});
	
	$("#thumbs ul li:first").animate({left: '0'},500);
	
}

function prevSlide( ){
	var nextImage   = $("#thumbs ul li:last").children("img").attr("name");
	var nextContent = $("#thumbs ul li:last").children("img").attr("alt");
	var nextLink    = $("#thumbs ul li:last").children("img").attr("link");
	
	$("#currentImage a").attr("href",nextLink);
	$("#currentImage img").attr("src", nextImage).fadeIn("slow");
	$(".block p").html(nextContent).fadeIn("slow");
	
	$("#thumbs ul li:last").clone(true).prependTo("#thumbs ul");
	$("#thumbs ul li:last").remove( );

}

function updateClock( ){
	var currentTime = new Date ( );
	var currentHours = currentTime.getHours ( );
	var currentMinutes = currentTime.getMinutes ( );
	var currentSeconds = currentTime.getSeconds ( );
	// Pad the minutes and seconds with leading zeros, if required
	currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
	currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

	// Choose either "AM" or "PM" as appropriate
	var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

	// Convert the hours component to 12-hour format if needed
	currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

	// Convert an hours component of "0" to "12"
	currentHours = ( currentHours == 0 ) ? 12 : currentHours;

	// Compose the string for display
	var currentTimeString = currentHours + ":" + currentMinutes + " " + timeOfDay;

	// Update the time display
	$('#datetime #time').html(currentTimeString);	
}
	


function rotate_offer( ){
	offer_left = offer_left + (150);
	$("#offer_rotator ul li").each(function(index){
		if(index == 0){
			
			var content = $(this).html( );
			$(this).clone(true).appendTo("#offer_rotator ul");
			$(this).remove( );
			
			$("#offerlist").scrollLeft(current_left);
		}
	});
}
	
function stop( ){
	clearInterval(newsrotationID);
}

function start( ){
	   if(stopRotate == 0){
			 newsrotationID = setInterval(rotate,7000);
	   }
	
}
function filler( ){}
function error( ){

}
function showContent(a){
	
	$("#rotator_content a img").attr("src","");
	$("#rotator_content a img").attr("src",fpImages[a].src);
	if(fpLinkPopup[a] == "1"){
		
		$("#rotator_content a ").attr("href","javascript: $.prettyPhoto.open('" + fpLink[a] + "', '','');");
	}else{
		$("#rotator_content a").attr("href",fpLink[a]);
	}
	
	$("#fpContent").html("");
	$("#fpContent").bind("click",function( ){
		if(fpLinkPopup[a] == "1"){
			location.href = "javascript: $.prettyPhoto.open(" + fpLink[a] + "', '','');";
		}else{
			$("#rotator_content a").attr("href",fpLink[a]);
		}
	});
	//counter = a;
	$("#fpContent").html(rotationcontent[a]);
	
	//counter++;
	
}
function toggleWeather( ){
	if(!showFiveDay){
		if(showListen){
			$("#weatherfiveday").animate({opacity: 1, height: '-=250'},1000,function( ){$("#weatherfiveday").html(""); $("#weatherfiveday table").hide( );}); 
			$("#keyword_background").animate({opacity: 1, top: '-=250'},1000);
			showListen = 0;
		}
		$("#weatherfiveday").animate({opacity: 1, height: '+=200'},1000,function( ){$("#weatherfiveday").html(fivedayweather); $("#weatherfiveday table").show( );}); 
		$("#keyword_background").animate({opacity: 1, top: '+=200'},1000);
		showFiveDay = 1;
	}else{
		$("#weatherfiveday").animate({opacity: 1, height: '-=200'},1000,function( ){$("#weatherfiveday").html(""); $("#weatherfiveday table").hide( );}); 
		$("#keyword_background").animate({opacity: 1, top: '-=200'},1000);
		showFiveDay = 0;
	}
}

function toggleListen( ){
	if(!showListen){
		if(showFiveDay){
			$("#weatherfiveday").animate({opacity: 1, height: '-=200'},1000,function( ){$("#weatherfiveday").html(""); $("#weatherfiveday table").hide( );}); 
			$("#keyword_background").animate({opacity: 1, top: '-=200'},1000);
			showFiveDay = 0;
		}
		$("#weatherfiveday").animate({opacity: 1, height: '+=250'},1000,function( ){$("#weatherfiveday").html(listenlive); $("#weatherfiveday table").show( );}); 
		$("#keyword_background").animate({opacity: 1, top: '+=250'},1000);
		showListen = 1;
	}else{
		$("#weatherfiveday").animate({opacity: 1, height: '-=250'},1000,function( ){$("#weatherfiveday").html(""); $("#weatherfiveday table").hide( );}); 
		$("#keyword_background").animate({opacity: 1, top: '-=250'},1000);
		showListen = 0;
	}
}

function rmOpen( ){
	$("#header").animate({height: '+=295'},500);
	$("#nav_menu").animate({top: '+=295'},500);
	$("#navBG").animate({top: '+=295'},500);
	$("#weatherfiveday_container").animate({top: '+=295'},500);
	$("#keyword_background").animate({top: '+=295'},500);
	$("#main_background").animate({height: '+=295'},500);
	$("#content").animate({top: '+=295'},500);
	$("#main_bottom").animate({top: '+=295'},500);
	$("#expandVideo").css({visibility: 'visible', display: 'block'});
	$("#expandableAd").animate({height: '+=295'},500);
	$("#expandControl a img").attr("src", "images/template/close.png");
}

function rmClose( ){
	$("#header").animate({height: '-=295'},500);
	$("#nav_menu").animate({top: '-=295'},500);
	$("#navBG").animate({top: '-=295'},500);
	$("#weatherfiveday_container").animate({top: '-=295'},500);
	$("#keyword_background").animate({top: '-=295'},500);
	$("#main_background").animate({height: '-=295'},500);
	$("#content").animate({top: '-=295'},500);
	$("#main_bottom").animate({top: '-=295px'},500);
	$("#expandableAd").animate({height: '-=295'},500);
	$("#expandVideo").css({visibility: 'hidden', display: 'none'});
	$("#expandControl a img").attr("src","images/template/expand.png");
}

function closeMenu(stackname, elementid){
	
	$("#" + stackname).hide( );
	$("#" + elementid).css("background-color","");
	$("#" + elementid).css("color","#ddd");
}

function openStream(stream){
	if(stream == 1){
		window.open('http://den-a.plr.liquidcompass.net/player/flash/audio_player.php?id=WDRVFM&uid=447','WDRVFM','width=680,height=511,%20status=no,resizable=no,scrollbars=no');
		toggleListen( );
	}else if(stream == 1.5){
		window.open('tunekast885://open?station_id=885');
		toggleListen( );
	}else if(stream == 2.5){
		window.open('tunekast885://open?station_id=884');
		toggleListen( );
	}else if(stream == 2){
		window.open('http://den-a.plr.liquidcompass.net/player/flash/audio_player.php?id=WDRVHD2&uid=449','WDRVHD2','width=680,height=511,%20status=no,resizable=no,scrollbars=no');
		toggleListen( );
	}else if(stream == 3){
		location.href = 'http://www.wdrv.com/wdrv.php?pageid=mobileapps11';
		toggleListen( );
	}else if(stream == 4){
		location.href = 'http://www.wdrv.com/listen.php';
		toggleListen( );
	}
}

function loginPresslaff( ){
	var email = $('#advisoryEmailRightSide').val( );
	
	$.ajax({
		type: 'POST',
		url: 'loginPresslaff.php',
		data: "email=" + email,
		success: function(msg){
			var response = msg.split("|");
			var respCode = response[0];
			var respStr  = response[1];
			
			if(respCode == 0){
				$("#advisory_login").slideUp( );
				$("#chatlive_blog").slideDown( );
			}
		}
	});
}

function logout( ){
	
	logoutFacebookUser();
	$.ajax({
		type: 'POST',
		url: 'logout.php',
		success: function(msg){
					
			
		}
	});
	
}

function requestNewPW(email,action){
	
	$.ajax({
		type: 'POST',
		url: '/sharedcode/requestPW.php',
		data: 'email=' + email + "&action=" + action,
		dataType: "text",
		success: function(msg){
			$("#sentMsg").html(msg);
		},
		error: function(msg, b, c){
			$("#sentMsg").html(msg + "  " + b + "  " + c);
		}
	});
}

function postStatus( ){
	$.ajax({
		type: 'POST',
		url: '/sharedcode/postFBStatus.php',
		data: 'status=' + $("#status").val( ),
		dataType: "text",
		success: function(msg){
			
			var status_split = msg.split("|");
			$("#facebook_status").html(status_split[0]);
			$("#status_update_time").html(status_split[1]);
			$("#status").val("");
		},
		error: function(msg, b, c){
			
		}
	
	
	
	});

}

function openVideo(link){
	
		
			$.prettyPhoto.open(link, '','');	
		
		
		
	}

