var cookieDomain='.fifa.com';var baseUrl='http://es.fifa.com';var siteLang='es';var idSplitLen=3;var numWordsComment=100;var commentsPerPage=10;// Remove surrounding frames if any
if (parent.frames.length > 0 && self.location.href.indexOf("/ballondor/puskasaward/_ff_puskas_votation.html") == -1 ) {
    top.location.href = self.location.href;
}
// Mobile redirect
(function() {
  var pageUrl = document.URL;
  var userAgent = navigator.userAgent;
  function isTouchDevice(userAgent) {
    if (/(iPhone|iPod|Android|IEMobile\/|BlackBerry|webOS|Bada\/)/.test(userAgent)) {
      //if (/(iPhone|iPod|Android|Bada\/|IEMobile\/|BlackBerry|webOS)/.test(userAgent)) {
      //if (/testAgentTouch/.test(userAgent)) {
      return true;
    } return false;
  }
  function isKeyboardDevice(userAgent) {
    if (/(SymbianOS\/|Nokia|SAMSUNG-|Samsung-|SonyEricsson|Ericsson|MOT-|LG-|LGE-|LG\/|HTC-|Opera Mini\/|SGH-|SCH-|SEC-|Alcatel-|SIE-|DoCoMo\/|portalmmm\/|KDDI-|Sagem-|Windows CE|HTC_)/.test(userAgent)) {
      //if (/(SymbianOS\/|Nokia|SAMSUNG-|SonyEricsson|MOT-|LG-|HTC-|HTC_)/.test(userAgent)) {
      //if (/testAgentKeyboard/.test(userAgent)) {
      return true;
    } return false;
  }
  function isRedirectEnabled(pageUrl) {
    if (siteLang == 'ru' || siteLang == 'it') {
      return false;
    } else if (pageUrl.indexOf('mobile=true') > -1) { // Redirect querystring
      return false;
    } else if (document.referrer.indexOf('.fifa.com/') > -1) { // Referrer is already FIFA.com
      return false;
    } else if (pageUrl.indexOf('/aboutfifa/') > -1 || pageUrl.indexOf('/ballondor/') > -1 || pageUrl.indexOf('/classicfootball/') > -1) { // Redirect exceptions
      return false;
    } else if (!/http[s]{0,1}:\/\/[a-z]{2,3}\.fifa\.com/.test(pageUrl)) { // Not on main FIFA.com
      return false;
    } return true;
  }
  function getMobileUrl(pageUrl, mobileType) {
    if (siteLang == 'en') {
      mobileUrl = pageUrl.replace('www.fifa.com', mobileType + '.fifa.com');
    } else {
      mobileUrl = pageUrl.replace(/[a-z]{2}\.fifa\.com/, siteLang + '.' + mobileType + '.fifa.com');
    } return mobileUrl;
  }
  if (isTouchDevice(userAgent) && isRedirectEnabled(pageUrl)) {
    document.location = getMobileUrl(pageUrl, 'touch');
  } else if (isKeyboardDevice(userAgent) && isRedirectEnabled(pageUrl)) {
    document.location = getMobileUrl(pageUrl, 'm');
  }
})();
// AD: Test disable AccessFIFA
//function setCSS(title) {
//    $j("link[title='" + title + "']").each(function() {
//        this.disabled = false
//    });
//    $j("link[title!='" + title + "']").each(function() {
//        if ($j(this).attr("title")) this.disabled = true;
//    });
//    Cookie.set('accessFIFA', title, 365, '/');
//}
//function switchCSS() {
//    var t = Cookie.get('accessFIFA');
//    if (t === undefined || t == null || t == '')
//        t = 'standard';
//    if (t == 'standard')
//        t = 'accessible';
//    else
//        t = 'standard';
//    setCSS(t);
//}
//var openCSS = function() {
//    var t = Cookie.get('accessFIFA');
//    if (t === undefined || t == null || t == '')
//        t = 'standard';
//    if (this.ieOld)
//        t = 'accessible';
//    setCSS(t);
//} ();
function setCSS(title) {
    $j("link[title='" + title + "']").each(function() {
        this.disabled = false
    });
    $j("link[title!='" + title + "']").each(function() {
        if ($j(this).attr("title")) this.disabled = true;
    });
}
function switchCSS() {
    setCSS('standard');
}
var openCSS = function() {
    setCSS('standard');
} ();
/* HBX functions */
var hbxPageName = '', hbxContentCategory = '', bHbxFT = true;
function setHBXParameters(pn, cc) {
    hbxPageName = pn; hbxContentCategory = cc;
}
function invokeAjaxHBXPageView() {
    if (!bHbxFT)
        invokeHBXPageView(hbxPageName, hbxContentCategory);
    bHbxFT = false;
}
function invokeHBXPageView() {
    if (hbxPageName != '' && hbxContentCategory != '') _hbPageView(hbxPageName, hbxContentCategory);
}
/* Sponsor tracking dismissed in March 09 - Function edited for backward compatibility only */
function _hbPageViewSponsored(pn, cc, sp) {
    if (pn != '' && cc != '') _hbPageView(pn, cc);
}
function getHostName() { var s = document.location.href; s = s.replace(/(^[a-zA-z0-9]*:\/\/)/, ''); s = s.replace(/(\/.*)/, ''); return s; }
function getUrlParams() { var s = document.location.href; if (s.indexOf('?') != -1) return s.substring(s.indexOf('?') + 1); if (s.indexOf('#') != -1) return s.substring(s.indexOf('#') + 1); return ''; }
function fnClearInput(inp, ot) { if (inp.value.toLowerCase() == ot.toLowerCase()) inp.value = ''; }
/*OLD VIDEO PLAYER open in popup*/
function wpOpen(u) { window.location = u; return true; }
function wpopenlower(u) { return wpOpen(u); }
function openPopup(u, h, w) { window.open(u, 'popup', 'width=' + w + ',height=' + h + ',resizable=no,scrollbars=no,location=no,menubar=no,status=no,toolbar=no') }
function mcOpen(u) {
    var h = 'height=705';
    window.open(u, 'popup', 'width=770,' + h + ',resizable=no,scrollbars=no,location=no,menubar=no,status=no,toolbar=no');
}
function mcWCQOpen(u) {
    window.open(u, 'popup', 'width=885, height=705,resizable=no,scrollbars=no,location=no,menubar=no,status=no,toolbar=no');
}
function mcFriendOpen(u) {
    window.open(u, 'popup', 'width=885, height=758,resizable=no,scrollbars=no,location=no,menubar=no,status=no,toolbar=no');
}
function mcFCCOpen(u) {
    document.location.href = u;
}
function resizeFWCQFlashPopUp(divId, h, w, resizeType) {
    var ua = navigator.userAgent.toLowerCase();
    var hNew, wNew;
    if (resizeType == '1') {
        $j('#prelmatchcast').css('visibility', 'visible');
    }
    else {
        $j('#prelmatchcast').css('visibility', 'hidden');
    }
    if (ua.indexOf("chrome") > -1) {
        if (resizeType == '1') window.resizeTo(Number(w) + Number(10), 760); else window.resizeTo(Number(w) + Number(5), 135);
        return;
    }
    if (ua.indexOf("msie 6") > -1) {
        if (resizeType == '1') window.resizeTo(Number(w) + Number(10), 745); else window.resizeTo(Number(w), 120);
        return;
    }
    var o = $j('#resizeReference');
    window.resizeTo(w, h);
    var hDiff = mcFWCQstartH - o.clientHeight;
    var wDiff = mcFWCQstartW - o.clientWidth;
    var hDiffmin = mcFWCQstartHmin - o.clientHeight;
    var wDiffmin = mcFWCQstartWmin - o.clientWidth;
    if (resizeType == '1') {
        hNew = Number(h) + Number(hDiff);
        wNew = Number(w) + Number(wDiff);
        window.resizeTo(wNew, hNew);
    }
    else if (resizeType == '2') {
        hNew = Number(h) + Number(hDiffmin - 20);
        wNew = Number(w) + Number(wDiffmin);
        window.resizeTo(wNew, hNew);
    }
}
function dcOpen() { window.open('/live/competitions/worldcup/preliminarydraw/drawcast.html', 'popup', 'width=885,height=700,resizable=no,scrollbars=no,location=no,menubar=no,status=no,toolbar=no'); }
var Tab = {
    id: ""
    , tab: 0
    , Change: function(id, url, tab, callback) {
        Tab.id = id;
        Tab.tab = tab;
        $j.get(url, function(data) {
            $j("#" + id + "_content").html(data);
            $j("#" + id + " .current").removeClass("current");
            $j("#" + id + "_" + tab).addClass("current");
            if (typeof callback == 'function') {
                callback();
            }
        });
    }
}
function toggleImg(obj, img1, img2) {
    if (obj.src.indexOf(img1) > 0) {
        obj.src = img2;
    } else {
        obj.src = img1;
    }
}
//GG-2010: return selected item
//function currMenuItem(id) {
//  $j("id").currMenuItem();
//}
function currMenuItem(id) {
  $j(id).currMenuItem();
}
// old version
//function currMenuItem_OLD(id) {
//    //functions
//    var findItem = function(path) {
//        if (path.length == 0) {
//            //not found
//            return null;
//        }
//        var items = $j(_id + " [href^='" + path + "']");
//        if (items.length == 0) {
//            //search in parent path
//            path = getParent(path);
//            return findItem(path);
//        }
//        var item = getItem(path, items);
//        if (item.lenght == 0) {
//            //not found, search in parent path
//            path = getParent(path);
//            return findItem(path);
//        }
//                
//        //exclude FWC more menu
//        if (item.parents(".lev2MenuMore").length > 0) {
//            return null;
//        }
//        item.addClass("current");
//        item.parents("li").addClass("current");
//        return item;
//    };
//    //try to get the right item
//    var getItem = function(path, items) {
//        if (items.length == 1) {
//            return items;
//        }
//        var index;
//        //here some logic to find the right url, if more then one
//        //if there is exactly the path or a path ending in index.html, that's it
//        var sel1 = _id + " [href$='" + path + "/']";
//        var sel2 = _id + " [href$='" + path + "/index.html']";
//        return $j(sel1 + ", " + sel2);
//    };
//    var getParent = function(path) {
//        //check for VSets pages
//        var r = new RegExp(",[a-z]+=[0-9/]+.html");
//        if (r.test(path)) {
//            path = path.replace(r, '.html');
//        }
//        else {
//            path = path.substring(0, path.lastIndexOf("/"));
//        }
//        return path;
//    };
//    //Code
//    $j("id")
//    var _id = id;
//    var menu = $j(_id);
//    if (menu.length = 0) {
//        //menu doesn't exist
//        return;
//    }
//    // if selectedPath is set as a global value use it to select menu item (instead of pathname)
//    var path = (window["selectedPath"]) ? window["selectedPath"] : document.location.pathname;
//    return findItem(path);
//  };
// currMenuItem (optimised and implemented as a jQuery plugin)
// usage: $j('#fifacom2_lev00menu, #fifacom2_lev01menu').currMenuItem();
(function($) {
  $.fn.currMenuItem = function(options) {
    var me = $(this);
    var settings = jQuery.extend({
      lev0: false
    }, options);
    // link database
    var links = {};
    $("a", me).each(function() {
      var href = $(this).attr("href");
      if (href && !links[href]) {
        href = href.replace(/(http|https):\/\/[^\/]*/, "");
        links[href] = $(this);
      }
    });
    // path to search
    var path = (window["selectedPath"]) ? window["selectedPath"] : document.location.pathname;
    if (path.indexOf("/") < 0) path = "/" + path; // to avoid endless loop
    // search logic
    var getLink = function(path) {
      return links[path] || links[path + "/"] || links[path + "/index.html"] || links[path + "/index.htmx"];
    }
    var getParent = function(path) {
      //check for VSets pages
      var r = new RegExp(",[a-z]+=[0-9/]+.html");
      if (r.test(path)) {
        path = path.replace(r, '.html');
      }
      else {
        path = path.substring(0, path.lastIndexOf("/"));
      }
      return path;
    };
    // special cases for lev0 menu
    if (settings.lev0) {
      if (path.toLowerCase().indexOf("/associations/") == 0) {
        $j("#fifacom2_associations").addClass("current").parent("li").addClass("current");
        return;
      } else if (path.toLowerCase().indexOf("/theclub/") == 0) {
        $j("#fifacom2_lev01menu a[href*='/theclub/']").addClass("current").parent("li").addClass("current");
        return;
      }
    }
    // search loop
    while (path.length > 0) {
      var link = getLink(path);
      if (link) {
        link.addClass("current");
        link.parent("li").addClass("current");
        link.parents("li.lev3menu").addClass("current").find(">a").addClass("current");
        return link;
      } else {
        path = getParent(path);
      }
    }
  };
})(jQuery);
//function currMenuItem(id, path) {
//  if ($j(id).length > 0) {
//    if (path == '' || path == undefined) { 
//      path = document.location.pathname;
//    }
//    var menuItemElements = $j(id + " [href^='" + path + "']");
//    if (menuItemElements !== undefined && menuItemElements != null && menuItemElements.length == 1) {
//      //exclude FWC more menu
//      if (menuItemElements.parents(".lev2MenuMore").length > 0) return;
//      menuItemElements.addClass("current");
//      menuItemElements.parents("li").addClass("current");
//    }
//    else {
//      //check for VSets pages
//      var r = new RegExp(",[a-z]+=[0-9/]+.html");
//      if (r.test(path)) {
//        path = path.replace(r, '.html');
//      }
//      else {
//        path = path.substring(0, path.lastIndexOf("/"));
//      }
//      if (path.length == 0) {
//        return;
//      }
//      currMenuItem(id, path);
//    }
//  }
//};
function currMenuItemFullRanking(id) {
    if ($j(id + " li.current").length != 0) {
        return;
    }
    var path = path = document.location.pathname;
    path = path.substring(0, path.lastIndexOf("/"));
    if (path != "/worldcup/statistics/castrolindex")
    { return; }
    var menuItemElements = $j(id + " [href^='/worldcup/statistics/castrolindex/ranking.html']");
    if (menuItemElements !== undefined && menuItemElements != null && menuItemElements.length == 1) {
        //exclude FWC more menu
        if (menuItemElements.parents(".lev2MenuMore").length > 0) return;
        menuItemElements.addClass("current");
        menuItemElements.parents("li").addClass("current");
    }
};
function currMenuItemSelect(id, urltoselect) {
    var i, u;
    try {
        if ($j(id)) {
            for (i = 0; i < $j(id).childNodes.length; i++) {
                u = String($j(id).childNodes[i].innerHTML.match(/href="[^"]*"/));
                u = u.replace(/href=|"/ig, '');
                if (urltoselect.match(u) && u != '') {
                    Element.addClassName($j(id).childNodes[i], 'current');
                    return;
                }
            }
        }
    } catch (e) { }
}
function currMenuItemCC(id) {
    try {
        if ($(id)) {
            var p = document.location.pathname;
            for (i = 0; i < $(id).childNodes.length; i++) {
                var u = String($(id).childNodes[i].innerHTML.match(/href="[^"]*"/));
                u = u.replace(/href=|"/ig, '');
                if (p.match(u)) {
                    Element.addClassName($(id).childNodes[i], 'current');
                    Element.addClassName($(id).childNodes[$(id).childNodes.length - 1], 'last');
                    Element.addClassName($(id).childNodes[i - 1], 'precurrent');
                    return;
                }
            }
        }
    } catch (e) { }
}
function checkToS() {
    var accept_tos_ayq = $j('#c_agree').checked;
    if (accept_tos_ayq) {
        Comment.submitComments()
        $j('#d_errPanelComments').hide();
        return true;
    }
    else {
        $j('#d_errPanelComments').show();
        $j('#d_errPanelComments').focus();
        window.scrollTo(0, 0);
        return false;
    }
}
function WFTickerOnLeagueSelect(nat) {
    document.location.href = "/worldfootball/worldmatchcentre/index.html#" + nat;
}
function printAndGoBack() {
    window.print(); window.close();
}
/***** Widgets *****/
function openWidget(name) {
    closeWidget();
    $j("#" + name).animate({ opacity: "show", top: "100", left: "250" }, "fast");
}
function closeWidget() {
    $j(".widgetFlashBox").animate({ opacity: "hide", top: "0", left: "250" }, "fast");
}
function openWidgetWC(name) {
    closeWidget();
    $j("#" + name).animate({ opacity: "show", top: "0", left: "0" }, "fast");
}
function closeWidgetWC() {
    $j(".widgetFlashBox").animate({ opacity: "hide", top: "-100", left: "0" }, "fast");
}
/*****************/
/***** Popup Dubai2010 Microsite *****/
function openDubaiSite() { window.open("http://www.fifa.com/flash/beachsoccerworldcup/dubai2009/index.html", "dubai2009", "location=0, menubar=0, scrollbars=0, resizable=0, width=1050,height=670"); }
/*************************************/
function parseXML(xml) {
    if (typeof xml == "string") {
        if (window.ActiveXObject && window.GetObject) {
            var dom = new ActiveXObject('Microsoft.XMLDOM');
            dom.loadXML(xml);
            return dom;
        }
        if (window.DOMParser)
            return new DOMParser().parseFromString(xml, 'text/xml');
        //throw new Error('No XML parser available');
    }
  }
  /* box slider - usage: $j("#box_GUID").boxSlider({replaceTitle:true, isTitleClickable:true, hideItemTitle:true }); */
  (function($) {
    $.fn.boxSlider = function(options) {
      var me = $(this);
      var boxTitle = me.parent().find("div.bH h3");
      var settings = jQuery.extend({
        replaceTitle: false,
        isTitleClickable: false,
        hideItemTitle: false
      }, options);
      var timeout;
      var current = 0;
      var count = $("div.caItem", me).size();
      var selectedDotImg = "/imgml/worldcup/dot_03bluehover.png";
      var deSelectedDotImg = "/imgml/worldcup/dots_03.png";
      var item = $("div.caNavigator li:first a", me).attr("href").replace("#", "");
      var firstItemToShow = $("div.caItem." + item, me);
      $("div.caItem", me).hide();
      firstItemToShow.show();
      if (settings.hideItemTitle) {
        $("div.caItem h3", me).hide();
      }
      if (!settings.replaceTitle && settings.isTitleClickable) {
        me.parent().find("div.bH").addClass("bHHover");
        if($j("a", boxTitle).size() == 0) {
          boxTitle.html("<a class='clickable' href='#'>" + boxTitle.html() + "</a>");
        }
      }
      // callback
      var callback = function(obj) {
        if (settings.replaceTitle) {
          boxTitle.html($j("h3", obj).html());
          // class replacement
          var cl = $("div.teaser", obj).attr("class").replace(/teaser/, "");
          me.parent().attr("class", "box " + cl);
        } else if (settings.isTitleClickable) {
          //$("a", boxTitle).attr("href", $j("h3 a", obj).attr("href"));
          $("a", boxTitle).attr("href", $j("h3 a", obj).attr("href") || $j("ul.moreLink a", obj).attr("href"));
        }
      };
      callback(firstItemToShow);
      // timing functions
      var update = function() {
        var next = (current + 1) % count;
        $("div.caNavigator li:eq(" + next + ") a", me).click();
      };
      var startTimer = function() {
        timeout = setTimeout(update, 4000);
      };
      startTimer();
      // click
      $("div.caNavigator li a", me).click(function(e) {
        clearTimeout(timeout);
        e.preventDefault();
        var index = $j("div.caNavigator li", me).index($j(this).parent("li"));
        if (index != current) {
          current = index;
          $j("div.caNavigator li a img", me).attr("src", deSelectedDotImg);
          $j("img", this).attr("src", selectedDotImg);
          var item = $(this).attr("href").replace("#", "");
          $j("div.caItem:visible", me).fadeOut(600);
          var next = $j("div.caItem." + item, me);
          callback(next);
          next.fadeIn(600);
        }
        startTimer();
      });
    };
  })(jQuery);
  /**/
jQuery.fn.phGalSlideInArticle = function() {
    return this.each(function() {
        var container = $j(this).find("#slideContent");
        var navigation = $j(this).find(".caNavigator");
        var animationDuration = 600, timeoutDuration = 3000;
        var currentPos, timeout;
        function slideTo(pos) {
            if (timeout) clearTimeout(timeout);
            container.find(">div:visible").fadeOut(animationDuration);
            container.find(">div:eq(" + pos + ")").fadeIn(animationDuration);
            navigation.find("li.current").removeClass("current");
            navigation.find("li:eq(" + pos + ")").addClass("current");
            // TODO: use classes instead
            navigation.find("a img").attr("src", "/imgml/icons/dots_03.png");    // TODO: remove (use classes only)
            navigation.find("li:eq(" + pos + ") a img").attr("src", "/imgml/icons/dot_03hover.png"); // TODO: remove (use classes only)
            currentPos = pos;
            timeout = setTimeout(slideNext, timeoutDuration);
        }
        function slideNext() {
            var nextId = (currentPos + 1) % navigation.find("li").size();
            slideTo(nextId, true);
        }
        $j(this).find(".sliderNav li a").each(function(i) {
            $j(this).click(function(pos) {
                return function() {
                    slideTo(pos);
                    return false;
                };
            } (i));
        });
        //container.find('ul.phGalSlide li img').hoverpulse({ size: 15 });  // does not work
        // does not animate if there is only one gallery
        if (container.find(">div").size() > 1) {
            slideTo(0);
        }
    });
}
var dartPlayer = null;
function initAdvert()
{
  if (dartPlayer==null) 
    dartPlayer = new DartPlayer(myRPOjbect, DARTReady);
}
var myRPOjbect='dsrmotion';
var loggingEnabled=false;
var areCompanions=true;
var adTag = "http://ad.doubleclick.net/adi/instreamsite/windowsmedia;sz="
var dcSeed = ";dc_seed=";
var zoneTag = "videoplayer";		
var AdvSyncLB = false;
var adBase = "http://ad.doubleclick.net/adi/4597.fifa.com/"
// site detection to be improved
if (getHostName().match(/^[a-z]{2}\./)) {
  var dartSite = getHostName().match(/^[a-z]{2}/);
} else {
  var dartSite = 'www';
}
var asPostfix = ";site="+dartSite+";sz=728x90;ord="
// site detection to be improved
var enableCallbacks = true;		
var enableAuto3rdPartyTracking = true;		
   
function clearRoadBlock() {}
DARTReady=function(){
if(enableCallbacks){
dartPlayer.attachOnClick(logClick);
dartPlayer.attachOnAdStart(logStart);
dartPlayer.attachOnAdComplete(logComplete);
}
if(!enableAuto3rdPartyTracking){dartPlayer.setAutoLogThirdPartyImpression(false);dartPlayer.setAutoLogThirdPartyClick(false);}
}
function logClick() {
 if(loggingEnabled){
  logCallback("Video Ad was clicked.");
 }
  dartPlayer.setClickThroughWindowFeatures("width=800,height=600,menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes");
  dartPlayer.setClickThroughWindowBlocked(function(){logCallback("pub callback popup blocked");});
}
function changeLB(zt) 
{
  var tzt;
  if (zt==null)
  {zoneTag="videoplayer";tzt="videoplayer"}
  else if (zt=="") 
  {tzt=zoneTag}
  else
  {zoneTag=zt;tzt=zt;}
	var tmp = adBase+tzt+asPostfix+Math.random()+"?";
	var lB = $("leaderBoard");
	if (lB==null) return;
	lB.src = tmp ;
}
function logStart() {
  if (AdvSyncLB==false) return;
	var tmp = adBase+vpEventListner.chAdvertTag+asPostfix+dartPlayer.getAd().getDartId()
	var compTag = dartPlayer.getRoadblockURL(tmp);
	//alert(compTag);
	var lB = $("leaderBoard");
	if (lB==null) return;
	lB.src = tmp ;
}
 
 
function logComplete() {
vpEventListner.moveNextVideo();
}
 
 
function detach() {
	dartPlayer.unregister();
}
 

