﻿
$(function()
{
    setHoverTips();
    emailMissingImages();
    loginFunction();
});
function emailMissingImages()
{
    var host = document.location.host;
    if(host=='www.nflplayers.com' || host=='nflplayers.com')
    {
        method = "alertBrokenImage";
            var image = "";
            var page = escape(window.location.href);
         $('img').error(function() {  
            image += $(this).attr('src') + "<br>";
             }); 
             if (image!="")
             {
                 $.ajax({
                    url: "../webparts/jData/jmethods.aspx?q=" + method + "&img="+ image + "&page=" + page + "",
                    cache: false,
                    dataType: "json",
                    success: function(json) {
                        $(this).hide();
                 }
                });  
             }
     }
} 
function setHoverTips()
{
    $('.hoverTarget').hover(function()
    {
        var el = $(this).next('.hovertip');
        var h = el.height()+28;        
        var top = $(this).offset().top-h;
        var left = $(this).offset().left-20;
        el.css({
        'top':top,
        'left':left
        });
        tipFadeIn(el);
        },function(){
            var el = $(this).next('.hovertip');
            tipFadeOut(el);
     });
}
function loginFunction()
{
    var uEmail = readCookie('uEmail');
    //console.log(uEmail);
    if(uEmail != null && uEmail != "")
    {
        $('input[id$=_txtUsername]').val('')
        $('input[id$=_txtUsername]').val(uEmail);
        $('input[id$=_txtPassword]').focus();
    }
}
function tipFadeIn(el)
{
el.fadeIn(100);
}
function tipFadeOut(el)
{
el.fadeOut(150);
}
//DISABLE AUTOLOGIN ON ENTER

$(document).keypress(function (evt) {
         if (evt.keyCode == 13) {
            return false;
         }
     }); 
$('input[id$=_txtSearch]').keypress(function(evt){
    return true;
});  
//Weigh pages through search
function weigh(menu,recno,pid,type,url)
{
   $.ajax({
      type: "POST",
      url: "../webparts/methods.aspx/weighSearch",
      data: "{\"menuID\":\""+menu+"\", \"recNo\":\""+recno+"\", \"PID\":\""+pid+"\", \"type\":\""+type+"\"}",
      /*
      beforeSend: function(xhr) {
        xhr.setRequestHeader("Content-type", 
                             "application/json; charset=utf-8");
      },*/ 
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(msg) {
        //console.log(msg);
        //window.location=url;
      }
    });
} 

