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 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 nextSlide( ){
  var options = {};
	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");
	
	$("#slidecontainer img").unbind("click");
	if(popup == "1"){
		
		$("#slidecontainer img").bind("click", function( ){
			$.colorbox({href:nextLink,iframe:true, innerWidth:600, innerHeight:360});
		});
	}else{
		$("#slidecontainer img").bind("click", function( ){
			location.href = nextLink;   
		});	
	}
	$("#slidecontainer img:first").stop( ).effect("puff", options,500, function( ){
	
		$("#slidecontainer img:first").clone(true).appendTo("#slidecontainer").css("display","none");
		$("#slidecontainer img:first").remove( );
		$("#slidecontainer img:first").attr("style","");
		$("#slidecontainer img:first").css("display","block");
	});
	//$("#thumbs ul li:first").stop( ).animate({opacity: 0}, 200, function( ){
	$("#thumbs ul li:first").next("li").animate({left : '-150'},500,function( ){
	$("#thumbs ul li:first").clone(true).appendTo("#thumbs ul") ;
	$("#thumbs ul li:first").remove( );
	$("#thumbs ul li:last").css("opacity","1");
	$("#fpContent").html(nextContent);
	    
       });
	//}); 
}

function prevSlide( ){
	var options = {};
	var prevImage   = $("#thumbs ul li:last").children("img").attr("name");
	var prevContent = $("#thumbs ul li:last").children("img").attr("alt");
	var prevLink    = $("#thumbs ul li:last").children("img").attr("link");
	var popup       = $("#thumbs ul li:last").next("li").children("img").attr("popup");
	
	$("#slidecontainer img").unbind("click");
	if(popup == "1"){
		
		$("#slidecontainer img").bind("click", function( ){
			$.colorbox({href:prevLink,iframe:true, innerWidth:425, innerHeight:344});
		});
	}else{
		$("#slidecontainer img").bind("click", function( ){
			location.href = prevLink;   
		});	
	}
	
	$("#slidecontainer img:first").stop( ).effect("puff", options,500, function( ){
		
		$("#slidecontainer img:last").clone(true).prependTo("#slidecontainer");
		$("#slidecontainer img:last").remove( );
		$("#slidecontainer img:first").next("img").css("display","none");    		
		$("#slidecontainer img:first").css("display","block");
						
	     });
	//$("#thumbs ul li:first").stop( ).animate({opacity: 0}, 200, function( ){
	   $("#thumbs ul li:first").animate({left : '150'},500,function( ){
	   $("#thumbs ul li:last").clone(true).prependTo("#thumbs ul");
			     $("#thumbs ul li:last").remove( );
			     $("#thumbs ul li:first").css("opacity","1");
	   $("#fpContent").html(prevContent);
	    
       });

}

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 rmOpen( ){
	
	$("#leftcontent").animate({marginTop: '+=295'},500);
	$("#rightcontent").animate({marginTop: '+=295'},500);
	$("#main_background").animate({height: '+=295'},500);
	
	$("#footer").animate({top: '+=295px'},500);
	$("#expandVideo").css({visibility: 'visible', display: 'block'});
	$("#expandableAd").animate({height: '+=295'},500);
	$("#expandControl a img").attr("src", "images/template/close.png");
}

function rmClose( ){
	$("#leftcontent").animate({marginTop: '-=295'},500);
	$("#rightcontent").animate({marginTop: '-=295'},500);
	$("#main_background").animate({height: '-=295'},500);
	
	$("#footer").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 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 getArtist( ){
	
	$.ajax({
		type: "GET",
		url: "/includes/getCurrent.php",
		datatype: "text",
		success:function(data){
			
			if(data != ""){
				var songinfo = data.split("|");
				var out = "";
				size = songinfo[3].split("x");
				sizeAdjust = false;
				
				if(size[1] < 200){
					sizeAdjust = true;
					sizeAdjust_Amt = 200 - size[1];  
				}else if(size[1] > 200){
					songinfo[2] = "";
				}
				if(!firstload){ //Conditional for all subsequent loads after first
					if($("#topimage").css("display") == "hidden"){  //Check to see if the top image is hidden -- if it is then there is no artist artwork currently being shown
						$(".marquee").marquee("pause"); //pause marquee
						$(".marquee-showing").css("left","0"); //Sometimes, if the marquee is out of frame it will not show.  This will reset the left position of the song/artist display
						//Write out what will be displayed in regards to song/artist
						out = "<span style='color: #fff; font-weight: bold; height: 24px;'>" + songinfo[0] + " by " + songinfo[1] + "</span>";
						$("#nowplaying li, #nowplayingTop li").html(out); //put the song/artist on display
						$("#nowplaying").css("margin-top","2px");
						$(".marquee").marquee("resume"); //resume marquee
						if(songdisplay == 0){ //Check if song display equals zero.  If it does then no song was showing before and 'On Air' was being displayed 
							$("#status").html("Now Playing:").removeClass("onairDisplayAdjust");; //change 'On Air' -> 'Now Playing'
						}
					}else if((songinfo[0] != currentsong) && (songinfo[1] != currentartist)) { //The top image is not hidden BUT the song and artist being sent in DO NOT equal the current song and artist 
						$("#topimage").fadeOut(1000, function( ){ //Fade Out current image
							$(".marquee").marquee("pause"); //Pause Marquee
							$(".marquee-showing").css("left","0"); //Sometimes, if the marquee is out of frame it will not show.  This will reset the left position of the song/artist display
							//Write out what will be displayed in regards to song/artist
							out = "<span style='color: #fff; font-weight: bold; height: 24px;'>" + songinfo[0] + " by " + songinfo[1] + "</span>";
							$("#nowplaying li, #nowplayingTop li").html(out); //put the song/artist on display
							$("#nowplaying").css("margin-top","2px");
							$("#topimage").css("background","url(" + songinfo[2] + ") no-repeat top left").fadeIn(1000); // change out New artwork and fade IN
							if(sizeAdjust){
								$("#topimage").css("margin-top",sizeAdjust_Amt + "px");
							}else{
								$("#topimage").css("margin-top","0");
							}
							$(".marquee").marquee("resume"); //Resume Marquee
							if(songdisplay == 0){ //Check if song display equals zero.  If it does, then no song was shoing before and 'On Air' was being displayed
								$("#status").html("Now Playing:").removeClass("onairDisplayAdjust");; //change 'On Air' -> 'Now Playing'
							}		
						});
					}
					//If neither of the above two conditions are met, it means that the same sone is playing and nothing should be done.
					songdisplay = 1; //Set marker to true(1) to make say a song is on display
					currentsong = songinfo[0]; //Set currentsong variable to most recent song passed through
					currentartist = songinfo[1]; //Set currentartist variable to most recent artist passed through
				}else{
					if(songinfo[0] != "" && songinfo[1] != ""){
					  
						$("#topimage").fadeOut(1000, function( ){ //Fade Out current image
						out = "<span style='color: #fff; font-weight: bold;'>" + songinfo[0] + " by " + songinfo[1] + "</span>";
						$("#topimage").css("background","url(" + songinfo[2] + ") no-repeat top left").fadeIn(1000);
						if(sizeAdjust){
							$("#topimage").css("margin-top",sizeAdjust_Amt + "px");
						}else{
							$("#topimage").css("margin-top","0");
						}
						$("#nowplaying li, #nowplayingTop li").html(out);
						$("#nowplaying").css("margin-top","2px");
						$(".marquee").marquee("resume");
						songdisplay = 1;
						currentsong = songinfo[0];
						currentartist = songinfo[1];
						firstload = false;
						});
					}else{
					  $(".marquee").marquee("pause");
					  $(".marquee-showing").css("left","0");
						//$("#topimage").css("background","url(" + songinfo[2] + ") no-repeat top center");
						$("#nowplaying").css("margin-top","2px");
						$("#nowplaying li,#nowplayingTop li").html("");
						$(".marquee").marquee("resume");
						$("#topimage").fadeIn(1000,function( ){});
						if(sizeAdjust){
	      $("#topimage").css("margin-top",sizeAdjust_Amt + "px");
	    }else{
	      $("#topimage").css("margin-top","0");
	    }
						firstload = false;
					}
				}
			}else{
				if(songdisplay){
					if(!firstload){
					
						$("#topimage").fadeOut(1000,function( ){
							$(".marquee-showing").css("left","0");
	      //$("#status").html("On Air: ");
							//$(".scrollingtext").removeAttr("style");
							$("#nowplaying li, #nowplayingTop li").html(onair);
	      $("#nowplaying").css("margin-top","2px");
							$("#topimage").css("background","url(" + onairImg + ") no-repeat top left").fadeIn(1000);
						});
					}else{
					 
						$(".marquee-showing").css("left","0");;
						//$("#status").html("On Air: ");
						//$(".scrollingtext").removeAttr("style");
						$("#nowplaying li, $nowplayingTop li").html(onair);
	    $("#nowplaying").css("margin-top","2px");
	    $("#topimage").css("background","url(" + onairImg + ") no-repeat top left").fadeIn(1000);
					}
				}else{
				  
			    $(".marquee-showing").css("left","0");
					//$("#status").html("On Air: ");
					
					$("#nowplaying li, #nowplayingTop li").html(onair);
	  $("#nowplaying").css("margin-top","2px");
	  $("#topimage").css("background","url(" + onairImg + ") no-repeat top left").fadeIn(1000);
				}
				songdisplay = 0;
				if(firstload){firstload = false;}
			}
		},
		error: function( ){

		}
	});
}

function KW( ){
	var kw = $("#query").val( );
	location.href = 'getKeywordLink.php?q=' + kw;
}
	
function toggleMenuTop(menu){
	var count = 0;
	var dontOpen = false;
	$("#navmenu_top li ul").each(function( ){
		if($(this).css("display") == "block"){
			$(this).slideUp("5000");
			if($(this).attr("id") == (menu)){
				dontOpen = true;
			}
		}
	});
	if(!dontOpen){
		$("#" + menu).slideDown("5000");
	}
}

function wavePeel( ){
  peelOpen = true;
	if(firstPeel){
		//Tease Peel Ad, if Viewable
		
		$("#pageflip, #pageflip img").animate({width: '500px', height: '540px'}, 1000);
		$(".msg_block").animate({width: '500px', height: '520px'},1000, function( ){
			$("#videoContainer").fadeIn("slow", function( ){
				
			});
		});
		setTimeout(closePeel, 3000);
		
		firstPeel = false;
	}
}
function closePeel( ){
	$("#closepeel").hide("fast");
	$("#videoContainer").hide("fast",function( ){
		if(cellphone){
			$("#closepeel").fadeOut( );
		}
		$("#pageflip, #pageflip img").animate({width: '80px',height: '85px'}, 520);

		$(".msg_block").animate({width: '80px',	height: '80px'}, 500);
	});
	peelOpen = false;
	
}
	
function toggleMenu(menu){
	var count = 0;
	var dontOpen = false;
	$("#navmenu li ul").each(function( ){
		if($(this).css("display") == "block"){
			$(this).slideUp("5000");
			if($(this).attr("id") == (menu)){
				dontOpen = true;
			}
		}
	});
	if(!dontOpen){
		$("#" + menu).slideDown("5000");
	}
}

function showMenu( ){
  
  if(parseInt($("#topbar").css("top")) == -75){
       $("#topbar").animate({top: '+=75px'}, 500);
       menuWASHidden = true;
  }
  
}

function closeMenu( ){
  
  if(menuWASHidden){
    if(parseInt($("#topbar").css("top")) == 0){
      $("#topbar").animate({top: '-=75px'}, 100);
    }
    menuWASHidden = false;
  }
}

function switchTile( ){
		  
		  if($("#facebook").css("display") == "none"){
			 $("#twitter").slideUp("slow");
			 $("#facebook").slideDown("slow");
		  }else{
			 
			 $("#facebook").slideUp("slow");
			 $("#twitter").slideDown("slow");
		  }
		  
		  
		  
		  
}
function viewFullFBPost( ){
       clearInterval("tile");
       $.colorbox({href:"http://www.wilv.com/includes/viewFullFBPost.php",iframe:true, innerWidth:700, innerHeight:600});
}

function toggleRadar( ){
	
	
}

function rotate_offer( ){
	offer_left = offer_left + (150);
	var current_left;
	$("#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);
		}
	});
}


