/* EMBEDHELPER */
/**
 * Copyright (c) 2009 James Padolsey
 * -------------------------------------------------------
 * Dual licensed under the MIT and GPL licenses.
 *    - http://www.opensource.org/licenses/mit-license.php
 *    - http://www.gnu.org/copyleft/gpl.html
 */
var embedHelper=(function(){var a=(function(){var b=document.getElementsByTagName("script");return b[b.length-1]})();return{getConfig:function(g){var b=a.innerHTML,d={},c=Array.prototype.slice.call(arguments);try{d=(new Function("return "+b.replace(/\n|\r/g,"")))()}catch(f){}c.push(d);return this.merge.apply(this,c)},merge:function(g,f){if(typeof g!=="object"){g={}}for(var e in f){if(!f.hasOwnProperty||f.hasOwnProperty(e)){var b=f[e];if(typeof b==="object"){g[e]=this.merge(g[e],b);continue}g[e]=b}}for(var d=2,c=arguments.length;d<c;d++){this.merge(g,arguments[d])}return g},getQueryParams:function(){var g=a.src,c,d,f,e={},b=Array.prototype.slice.call(arguments);if(g.indexOf("?")>-1){c=g.split("?")[1].split("&");d=c.length;while(d--){f=c[d].split("=");e[f[0]]=f[1]}}b.push(e);return this.merge.apply(this,b)},insert:function(e){if(e.nodeName&&!e.length){return a.parentNode.insertBefore(e,a)}if(typeof e==="string"){var c=document.createElement("div");c.innerHTML=e;e=c.childNodes}for(var d=0,b=e.length||0;d<b;++d){this.insert(e[d])}return this},scriptRef:a}})();
/* ----------- */

/* Widget code */

document.checkSize=function(idx,height) {
  document.getElementById(idx).style.height= height + "px";
 
};



(function(){
    
    var userOptions = embedHelper.getConfig({
        /* Defaults */
        border:'1',   
        width: 300,
        height: 500,
        id: 'widget_123'
    });    
              
   var urlBase=embedHelper.scriptRef.getAttribute("src").replace("/widget-embed.js","");
                
    
  

    //deploy 
    //var url_json="http://verdi/staging_speciali/rugby/6_nazioni/2010/sky/include/shared/six_nations/2010/json/tempo_reale.json"
    
    //staging 
    //var url_json="include/shared/six_nations/2010/json/tempo_reale.json"
    

    //production
    var url_json="http://sport.sky.it/sport/rugby/sixnations/include/shared/six_nations/2010/json/tempo_reale.json";

    render_widget=function() {
      var div = document.createElement('iframe');
      	div.id = userOptions.id;

      	div.setAttribute("scrolling","no");
      	div.setAttribute("frameBorder","0");
      	div.setAttribute("marginHeight","0");
      	div.setAttribute("marginWidth","0");
      	div.setAttribute("border","0");


      	div.style.width = userOptions.width + 'px';
      	div.style.height = userOptions.height + 'px';
      	div.src= userOptions.url+ "?"+  userOptions.client;
      	//div.style.border="none";
      	//div.style.padding="none";
      	//div.style.margin="none";
      	embedHelper.insert(div);
    };
    

    $.ajax({
    	url: url_json,
    	type: 'POST',
    	dataType: 'json',
    	success: function(json) {
    		if (json.length>0) render_widget();
    	}
    });

    
    
    
 
  
})();


