function clearfield(sender, e){
    if(sender.value = 'Enter Search text'){
        sender.value = '';
    }
}

function overlay() {

	el = document.getElementById("overlay");

	el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";

}

function revertSearchfield(sender, e){
    if(sender.value == ''){
       sender.value = 'Enter Search Text';
  }
}

function doFilter(sender, e)
{

  if(e.keyCode == 13)
  {
     var btn = sender;
     if(btn != null)
    {
       e.cancelBubble = true;
       e.returnValue = false;

        if (e.preventDefault)
       {
           e.preventDefault();
       }
       btn.click();
   }
  }
}
 function doPositioning(){

 $("#scrollTop").text(ReadCookie("podcastScrollTop"));
 $("#scrollLeft").text(ReadCookie("podcastScrollLeft"));
 window.scrollTo( $("#scrollLeft").text(),  $("#scrollTop").text());

}

function   expandItem()     
{ 
var id = $(document).find("#currentlyExpandedId").text();

var KeepOpen = '#podcastBody_' + id;
var KeepClosed = '#podcastRating_' + id;
$(KeepOpen).show();
$(KeepClosed).hide();

	    }

/*  JQUERY 

$(window).scroll(function () { 
    SetCookie("podcastScrollTop", f_scrollTop());
    SetCookie("podcastScrollLeft", f_scrollLeft());
    $("#scrollTop").text(ReadCookie("podcastScrollTop"));
    $("#scrollLeft").text(ReadCookie("podcastScrollLeft"));    
});
*/
$(document).ready(function(){

$('.PodCastItemHeaderAlternative').hover(function() {
  $(this).css("cursor", "hand");
}, function() {
  $(this).css("cursor", "pointer");
}); 

$('.PodCastItemHeader').hover(function() {
  $(this).css("cursor", "hand");
}, function() {
  $(this).css("cursor", "pointer");
}); 

$('.PageLink').hover(function() {
 $(this).css("cursor", "hand");
}, function() {
  $(this).css("cursor", "pointer");
}); 

//doPositioning();

//hide the all of the element with class msg_body
$("div.DivPodCastItemBody").hide();
$(".podcastToolsDisplay").hide();
$("div.DivPodCastItemBodyAlternative").hide();
//using the cookie podid, keep the item open
var KeepOpen = '#podcastBody_' + ReadCookie("currentlyExpanded");
var KeepClosed = '#podcastRating_' + ReadCookie("currentlyExpanded");
$(KeepOpen).show();
$(KeepClosed).hide();


expandItem();
$(".RatingItem").click(function(){
doPositioning();
});

$(".PodCastItemHeader").click(function()
{  



if($("#currentlyExpandedId").text()!= $(this).find("#currentItemPodcastId").text())
  {

$(document).find(".podcastToolsDisplay").hide();

  if($("#IgnoreExpandAction").text()== 0 ){

        $(".schoolImage").hide();  
        $("#currentlyExpandedId").text($(this).find("#currentItemPodcastId").text()); 
        SetCookie("currentlyExpanded", $(this).find("#currentItemPodcastId").text());
        $(document).find("div.DivPodCastItemBody").hide();
        $(document).find("div.DivPodCastItemRating").show();
        $(document).find("div.DivPodCastItemBodyAlternative").hide();
        $(document).find("div.DivPodCastItemRatingAlternative").show();
	$(this).find(".podcastToolsDisplay").slideToggle(600);

    	$(this).next("#div DivPodCastItemBody").slideToggle(600);

    	$(document).find("#podcastRating_" + $("#currentlyExpandedId").text()).hide();
	$(".schoolImage").show();  
		

    }
  else
    {

        $("#IgnoreExpandAction").text('0'); 
  	}
 }
 else
 {
 
 //if its not a button that has been pressed
  if($("#IgnoreExpandAction").text()== 0 )
    {        
      //collapse it all, and set items to 0
        var podid = $("#currentlyExpandedId").text();
        $("#currentlyExpandedId").text('0'); 	
        
	$(this).find(".podcastToolsDisplay").slideToggle(600);
        SetCookie("currentlyExpanded", $("#currentlyExpandedId").text());
    	$(this).next("#div DivPodCastItemBody").slideToggle(600);
        $(document).find("#podcastRating_" + podid).show();
    }
     else //nothing happens, just set the collapsed to 0 again 
    {  $("#IgnoreExpandAction").text('0');   }
  }
});

 $(".PodCastItemHeaderAlternative").click(function()
  {  

    if($("#currentlyExpandedId").text()!= $(this).find("#currentItemPodcastId").text())
      {
        $("#currentlyExpandedId").text($(this).find("#currentItemPodcastId").text()); 

$(document).find(".podcastToolsDisplay").hide();
      if($("#IgnoreExpandAction").text()== 0 ){
 
        SetCookie("currentlyExpanded", $(this).find("#currentItemPodcastId").text());

        $(document).find("div.DivPodCastItemBodyAlternative").hide();
        $(document).find("div.DivPodCastItemRatingAlternative").show();
        $(document).find("div.DivPodCastItemBody").hide();
	$(document).find("div.DivPodCastItemRating").show();
	$(this).find(".podcastToolsDisplay").slideToggle(600);

        $(this).next("#div DivPodCastItemBodyAlternative").slideToggle(600);
      	$(document).find("#podcastRating_" + $("#currentlyExpandedId").text()).hide();
	  }else{
       $("#IgnoreExpandAction").text('0'); 
      } 
    }
    else
    {
     //if its not a button that has been pressed
      if($("#IgnoreExpandAction").text()== 0 )
        {        
            //collapse it all, and set items to 0
            var podid = $("#currentlyExpandedId").text();
            $("#currentlyExpandedId").text('0'); 
  	    $(this).find(".podcastToolsDisplay").slideToggle(600);
            SetCookie("currentlyExpanded", $("#currentlyExpandedId").text());
	        $(this).next("#div DivPodCastItemBodyAlternative").slideToggle(600);
	        $(document).find("#podcastRating_" + podid).show();
        }
        else //nothing happens, just set the collapsed to 0 again 
        {
            $("#IgnoreExpandAction").text('0'); 
        }
    }
 });

 
  $(".ImageButtonWithNoCollapse").click(function()
  {
  
    $("#IgnoreExpandAction").text('1'); 
        //this means that a button has been pressed, so no expanding can occur. 
      SetCookie("currentlyExpanded", $("#currentlyExpandedId").text());
      SetCookie("podcastScrollTop", $("#scrollTop").text());
      SetCookie("podcastScrollLeft", $("#scrollLfft").text());
 });
    
$(".DeleteCookieClass").click(function()
  {
    $("#IgnoreExpandAction").text('1'); 
    //this means that a button has been pressed, so no expanding can occur. 
 
     SetCookie("currentlyExpanded", "0");
     SetCookie("podcastScrollTop", "0");
     SetCookie("podcastScrollLeft", "0");
 
    $("#currentlyExpandedId").text(ReadCookie("currentlyExpanded"));
 });

$(".ratingStar").click(function()
{	
doPositioning();
});

 $(".myPodcastAlt").click(function()
  {
     
 var str =$(this).find("#myPodcastId").text();
    varURL = "my-podcasts.aspx?pid=" + str + "#" + str;
    self.setTimeout("self.location.href = varURL;",varHowLong); 
 });

$(".myPodcast").click(function()
  {
     
 var str =$(this).find("#myPodcastId").text();
    varURL = "my-podcasts.aspx?pid=" + str + "#" + str;
    self.setTimeout("self.location.href = varURL;",varHowLong); 
 });
 
 $('.myPodcastClickArea').hover(function() {
  $(this).css("cursor", "hand");
}, function() {
  $(this).css("cursor", "pointer");
});

});



//***********************************

$(document).ready(function() {
  $('div.podCastsNewBottom').hide();
  $('div.podCastsItemTopRightNew').hide();
$('div.podCastsListNew_no_expand').children('div.podCastsItemNew0').children('div.podCastsItemTopNew').children('div.podCastsItemTopRightNew').show();
$('div.podCastsListNew_no_expand').children('div.podCastsItemNew1').children('div.podCastsItemTopNew').children('div.podCastsItemTopRightNew').show();
  $('div.PodCastTeacherSectionStyle').hide();



$('h2.newHomePageH2').click(function() {
	
	if($(this).parent(".MYHome_Controller").attr("id")=="MYHOMEOpen"){
			$(this).children('.MYHOMEControlImg').attr("src",'/data/Assets/RIS/images/myHome_Collapsed.jpg');
			$(this).siblings('div.MYHOMEControlPanel').slideUp("slow",function(){
				
				$(this).parent(".MYHome_Controller").attr("id","");
			
			});
			
	}else{
		$(this).parent(".MYHome_Controller").siblings("#MYHOMEOpen").children("div.MYHOMEControlPanel").slideUp();
		$(this).parent(".MYHome_Controller").siblings("#MYHOMEOpen").children("h2").children('.MYHOMEControlImg').attr("src",'/data/Assets/RIS/images/myHome_Collapsed.jpg');
		$(this).children('.MYHOMEControlImg').attr("src",'/data/Assets/RIS/images/myHome_Expanded.jpg');
	$(this).siblings('div.MYHOMEControlPanel').slideDown("slow",function(){
		$(this).parent(".MYHome_Controller").attr("id","MYHOMEOpen");
	
	});
	
}
	



});

$('h2#orangeH2').parent(".MYHome_Controller").attr("id","MYHOMEOpen");






$('div.podCastsItemTopNew').click(function() {
	if($("#IgnoreExpandAction").text()== 0 ){

		$(this).children('div.podCastsItemTopRightNew:visible').fadeOut('slow');
		$(this).next('div.podCastsNewBottom:visible').toggle('slow');
		$(this).siblings('div.PodCastTeacherSectionStyle:visible').fadeOut("fast");
		$('div.podCastsItemTopRightNew:visible').fadeOut('slow');
		$('div.podCastsNewBottom:visible').hide('slow');
		$('div.PodCastTeacherSectionStyle:visible').hide('fast');
		$(this).children('div.podCastsItemTopRightNew:hidden').fadeIn('slow');
		$(this).next('div.podCastsNewBottom:hidden').toggle('slow');
		$(this).siblings('div.PodCastTeacherSectionStyle:hidden').fadeIn("slow");
                //$('object.podcastPlayControl:visible').hide();

    return false;
}
$("#IgnoreExpandAction").text('0') ;
  });

$('div.podCastsItemTopRightLinksNewShareF').click(function(e) {
  var height = $('#popuup_divF').height();
  var width = $('#popuup_divF').width();
  leftVal=e.pageX+100-(width/2)+"px";
  topVal=e.pageY+70-(height/2)+"px";
  $(this).next('#popuup_divF').css({right:leftVal,top:topVal}).toggle('slow');
});


$('div.podCastsItemTopRightLinksNewShare').click(function(e) {
  var height = $('#popuup_div').height();
  var width = $('#popuup_div').width();
  leftVal=e.pageX-212+"px";
  topVal=e.pageY+20+"px";
  $(this).next('#popuup_div').css({left:leftVal,top:topVal}).toggle('slow');
});

$('.popupcloseF').click(function(){
  $('.popup_msgF').toggle('slow');
});

$('.popupclose').click(function(){
  $('.popup_msg').hide('slow');
});
$(".ImageButtonWithNoExpand").click(function(){
    $("#IgnoreExpandAction").text('1'); 
 });


});




