$(document).ready(function(){
    //IE background flickering
    if(jQuery.browser.msie && jQuery.browser.version==6.0) 
     document.execCommand("BackgroundImageCache",false,true);
    
    $("a[rel=external]").bind("click",function(){$(this).attr("target","_blank")});

    Hover(".Nav0 li > a");
    Hover(".HomeFeatured ul li > a");
    Hover(".RightNav li > a");
   
    // FirstChild and LastChild class
    var FirstAndLastChild = function() {
     if($.browser.msie || $.browser.opera){
      $("li:first-child").addClass("FirstChild");
      $("li:last-child").addClass("LastChild");
     }
     if($.browser.safari){
	     $("li:last-child").addClass("LastChild");
     }
    }
    FirstAndLastChild();
    
    HomeFeatured();
    
});

function HomeFeatured()
{
 $(".HomeFeatured ul.Stories li:eq(0) .Toogle").css("display","block");
 $(".HomeFeatured ul.Stories li > a").bind("click", function(e){
   $(".Toogle").hide();
   $(this).parent("li").children("div").show();
   return false;
  });
}

//Assign Hover effects on images
function Hover(className)
{
  $(className)
  .bind("mouseover", function(e)
  {
  Active=$(this).find('img').attr("src");
  if(Active.indexOf("Active")<=-1)
  {
  Active=Active.replace(".gif","Active.gif");
  $(this).find('img').attr("src",Active);
  IsActive=1;
  }
  }
  );
  
  $(className)
  .bind("mouseout", function(e)
  {
  Active=$(this).find('img').attr("src");
  if(IsActive==1)
  {
  Active=Active.replace("Active.gif",".gif");
  $(this).find('img').attr("src",Active);
  IsActive=0;
  }
  }
  );
}



//function to check valid email address
function isValidEmail(strEmail){
 
 validRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
 
 var Email = strEmail;

  // search email text for regular exp matches
  if (Email.search(validRegExp) == -1 || Email.length == 0) 
  {
     return false;
  } 
   return true; 
}