<?xml version="1.0" encoding="UTF-8" ?>
<Module>

	<!-- 
	TV Gadget
	Design & Code: LabPixies
	All subsequent code and resources used are proprietary of LabPixies unless directly stated otherwise.
	Copyright (C) 2006 LabPixies.    
	www.labpixies.com

	This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 2.5 License.
	To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/2.5/ or
	send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
	-->
	
	<ModulePrefs
	height="300"
	author="Labpixies"
	author_email="info@labpixies.com"
	description="__MSG_description__"
	screenshot="http://www.labpixies.com/campaigns/tv/images/screenshot.jpg"
	title="__MSG_gTitle__"
	title_url="http://www.labpixies.com/"
	thumbnail="http://www.labpixies.com/campaigns/tv/images/thumbnail.jpg"
	render_inline="never"
	directory_title="">
		
		<Locale messages="http://www.labpixies.com/campaigns/tv/i19/all_all.xml"/>
	
		<Require feature="setprefs" />
		<Require feature="analytics" /> 
		<Require feature="dynamic-height" />
		<Require feature="views" />
	</ModulePrefs>
	
  <UserPref name="isFirstLoad"	datatype="hidden" default_value="1" />
  <UserPref name="defaultStation"	datatype="hidden" default_value="" /> 
	<UserPref name="n1"  datatype="hidden" default_value="" />
	<UserPref name="u1"  datatype="hidden" default_value="" />
	<UserPref name="i1"  datatype="hidden" default_value="" />
  
  <UserPref name="k1" datatype="hidden" default_value="" />
	<UserPref name="k2" datatype="hidden" default_value="" />
	<UserPref name="k3" datatype="hidden" default_value="" />
	
	<UserPref name="skin"			datatype="hidden" default_value="98" /> 
	<UserPref name="skinImg"	datatype="hidden" default_value="0.png" /> 
	<UserPref name="h1"	datatype="hidden" default_value="432" /> 
	<UserPref name="t1"  datatype="hidden" default_value="42" />
	<UserPref name="l1"  datatype="hidden" default_value="70" />
	
	<UserPref name="h2"	datatype="hidden" default_value="238" /> 
	<UserPref name="t2"  datatype="hidden" default_value="20" />
	<UserPref name="l2"  datatype="hidden" default_value="22" />
	
	<UserPref name="auto_play"   datatype="hidden" default_value="0" />

<Content type="url" href="http://www.labpixies.com/campaigns/tv/tv.html" />

<Content type="html" view="profile,home">  
<![CDATA[	
<title>LabPixies TV</title>
<style type="text/css">
<!--

body,html {

  margin:0px;
  padding:0px;
  background-color:#ffffff;
}


#full_screen, #more_stations {
	font-family:verdana;
  font-size:11px;
  color:#808080;
	cursor:pointer;
}
#main_tv {
  width:244px;
	height:238px;
	margin-top:6px;
}
.buttons_sprite{}

	-->
</style>
<script language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>		
<script language="JavaScript" src="http://www.google-analytics.com/ga.js"></script>	

<!-- PUT THIS TAG IN THE head SECTION -->
<script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js">
</script>
<script type="text/javascript">
GS_googleAddAdSenseService("ca-pub-8123415297019784");
GS_googleEnableAllServices();
</script>
<script type="text/javascript">
GA_googleAddSlot("ca-pub-8123415297019784", "tv_txt");
</script>
<script type="text/javascript">
GA_googleFetchAds();
</script>
<!-- END OF TAG FOR head SECTION -->
<script type="text/javascript">
    var _gadgetID=25;
    var $lp = jQuery.noConflict();

    var mPlayer = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_player.js");
    document.write('<scr'+'ipt type="text/javascript" src="'+mPlayer+'"></scr'+'ipt>');
    var mMENU = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_sidebar.js");
    document.write('<scr'+'ipt type="text/javascript" src="'+mMENU+'"></scr'+'ipt>');
</script>
<script language="JavaScript">
  	
	var IMAGES_BASE = "http://cdn.labpixies.com/campaigns/tv/images/v2/gadget/";
	
	var g_prefs;
	
	var ga = new _gat._getTracker("UA-345375-1");
	ga._initData();
	function trackEvent(event_name, event_value) {
	    try {
        ga._trackEvent("TV - V2 Min", event_name, event_value );
      }
      catch(ee) {}
	}
	
	var curStation = 0;
	var curStationName = "C Span";
	var curStationURL = "http://play.rbn.com/play.asx?url=cspan/cspan/wmlive/cspan1v.asf&proto=mms?mswmext=.asx";
	var curStationID = "6";
	var isPlaying=false;
	var player;
	var isPlugInInstalled=true;
	var plugInInfo;
	
	_IG_RegisterOnloadHandler(function(){
     player = new lp_player('player',200,150);
		 player.init();
		 plugInInfo=player.getPlugInInfo();
		 isPlugInInstalled=(plugInInfo.isInstalled);
		 init_module();
	});

		
	function init_module(){
		loadImages();
		g_prefs = new _IG_Prefs();
        setSkin();
		
    var addSidebarParams = {}; // contains the texts for notification areas
		var addMenuParams = {}; // contains menu parameters
		
    // deploy sidebar
		lpgadgets.lp.sidebar.deploy('container', addSidebarParams, addMenuParams);
		loadStation();
	}
	
	function loadStation() {
    var timeout = 0;
    var callback = function(data) {};
    curStation = g_prefs.getInt('defaultStation');
      
    //FIRST LOAD OF THE GADGET - LOADING FROM JSON
		if (g_prefs.getString("isFirstLoad")=="1") {
		
		  callback = function(data) {
        clearTimeout(timeout);
        try {
          curStationName=data[0].name;
          curStationURL=data[0].url;
          curStationID =data[0].id;
          g_prefs.set('n1',curStationName.substring(0,100),
                      'u1',curStationURL,
                      'i1',curStationID,
                      "isFirstLoad","2");
          finalInit();
        }
        catch(ee) {
          loadStationError();
        } 
      };
      timeout = setTimeout(function(){callback = function(data){};loadStationError(); },7000);
      $lp.getJSON("http://www.labpixies.com/campaigns/tv/get_default_tv_stations_json_v2.php?cb=?",function(data){callback(data);});
    } 
    else { //LOADING FROM PREFS
      curStationName = g_prefs.getString('n1');  //n1=name of last played station
	    curStationURL = g_prefs.getString('u1');   //u1=url of last played station
	    curStationID = g_prefs.getString('i1');   //i1=id of last played station
	    finalInit();
    }
  }
  
  //If we didn't manage to load the stations we use the default station embeded in the gadget 
  function loadStationError() {
    finalInit();
  }
	
	function finalInit(){
    _gel('station_name').innerHTML = curStationName;
    _gel('station_name').title = curStationName;
    _gel('playing_txt').title = curStationName;
    _gel('play_stop_icon').title = curStationName;
		
		//in min mode the gadget never loads in play mode (always stopped)
		setBackgroundPos('play_stop_icon','-32px -9px'); 
		_gel('playing_txt').innerHTML = "__MSG_play__"+":";

		handlePlayerMsg();
		_gel('container').style.display = "";
		_IG_AdjustIFrameHeight();
  }

  function handlePlayerMsg() {
    if (!(isPlugInInstalled)) setErrorMsg();
  }
  
  //when the plug-in is missing needs to display the div containing the error message on the player
	function setErrorMsg(){
	  addCssClass('error_msg', 'background:transparent url(' + getCachedImage(IMAGES_BASE + 'error_message_icon.png' ) + ');' );
	  _gel('center_player').style.cursor = 'default';
	  _gel('play_stop_icon').style.cursor = 'default';
	  _gel('playing_txt').style.cursor = 'default';
	  _gel('station_name').style.cursor = 'default';
	  _gel('center_player').onclick=null;
	  _gel('center_player').onmouseover = null;
	  _gel('center_player').onmouseout = null;
	  _gel('center_player').style.verticalAlign="middle";
	  var msg = '<table cellspacing="0" cellpadding="0" style="width:180px; height:130px; background-color:#FFFFFF; border-color:#FF0000; border-width: 2px; border-style: solid;">'+
                  '<tr><td style="padding-top:10px; padding-right:10px; padding-left:10px;" align="center"><div style="width:100px; height:58px; overflow:hidden;" class="error_msg"></div></td></tr>'+
                  '<tr><td style="font-family:arial; font-size:12px; text-align:center; padding-left:10px; padding-right:10px;" >__MSG_plugIn_missing__</td></tr>'+
                  '<tr><td style="padding-left:10px; padding-right:10px; padding-bottom:10px; text-align:center;"><a onclick="trackEvent(\'PlugInMissingMSG\',\'SupportLink\');" href="http://www.labpixies.com/support/?ans=3#anc_question_3" target="_blank" style="font-family:arial; font-weight:bold; font-size:10px; text-align:center; color:#FF0000; text-decoration:none;">__MSG_support_link__</a></td></tr>'+
                  '</table>';
    _gel('center_player').innerHTML = msg;
  }
  
  //setting the skin
	function setSkin(){
    var height=g_prefs.getString('h2');
    var top=g_prefs.getString('t2');
    var left=g_prefs.getString('l2');
    var file=g_prefs.getString('skinImg');
    //setting width, height and background according to the current skin
    _gel('main_tv').style.height = height;
    _gel('main_tv').style.background = 'transparent url('+getCachedImage(IMAGES_BASE+file)+') no-repeat';
    _gel('top_main_div').style.height=top;
    _gel('bottom_main_div').style.height = height-top-150;
    _gel('left_player').style.width=left;
    _gel('right_player').style.width=44-left;  //(244-200=44  total_width-player_width)  
  }
		
	
	function getCachedImage(src){
	   return(_IG_GetImageUrl(src));	
	}
	
	function loadImages() {
	  if (isPlugInInstalled)
		 _gel('center_player').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'play_screen.png')+') no-repeat'; 
		setBackgroundPos('center_player','0px 0px');
		$lp(".buttons_sprite").css('background','transparent url('+getCachedImage(IMAGES_BASE + 'buttons_sprites_gadget.png')+') no-repeat');
		setBackgroundPos('more_stations_icon','-16px 0px');		
		setBackgroundPos('full_screen_icon','0px 0px');
	}
	
	function setBackgroundPos (id, pos){
		_gel(id).style.backgroundPosition = pos;
	}
	
	//Full screen and More stations rollover behavior
	function buttonOver (button_id, pos) {
		setBackgroundPos(button_id+"_icon",pos); 
    _gel(button_id).style.textDecoration='underline'; 
	}
	
	//Full screen and More stations rollout behavior
	function buttonOut (button_id, pos) {
		setBackgroundPos(button_id+"_icon",pos); 
	  _gel(button_id).style.textDecoration='none'; 

	}
	
	//setting the apropraite style to the play/stop button on the player screen	
	function setScreenIcon(isRollOver) {
		if(isPlaying || (!(isPlugInInstalled))) return;
		if(isRollOver) setBackgroundPos('center_player','0px -150px');
		else setBackgroundPos('center_player','0px 0px');
	}

	function playStopClick(buttonType) {
	   if (!(isPlugInInstalled)) return;
		//stop
		if(isPlaying) {
		  trackEvent("Stop", buttonType);
			isPlaying=false;
			player.stop();
			setBackgroundPos('center_player','0px 0px');
			_gel('center_player').onclick = playStopClick;
			_gel('center_player').style.cursor="pointer";
			setBackgroundPos('play_stop_icon','-32px -9px'); 
			_gel('playing_txt').innerHTML = "__MSG_play__"+":";
		}
		//play
		else{
			isPlaying=true;
			_gel('center_player').onclick=null;
		  setBackgroundPos('center_player','0px -570px');
		  _gel('center_player').style.cursor="none";
			trackEvent("Play", buttonType);
			setBackgroundPos('play_stop_icon','-32px 0px'); 
			_gel('playing_txt').style.fontWeight="";  //in case it was "error loading" in bold red
      _gel('playing_txt').style.color="#808080";
			_gel('playing_txt').innerHTML = "__MSG_loading__"+":";
			player.play(curStationURL,function(data){
          if(data=="success" || data=="unknown") {
            $lp.getJSON("http://www.labpixies.com/campaigns/tv/report_station_event.php?id="+curStationID+"&evt=2&cb=?",function(data){});
            _gel('playing_txt').innerHTML = "__MSG_now_playing__"+":";
          }
          else {
            $lp.getJSON("http://www.labpixies.com/campaigns/tv/report_station_event.php?id="+curStationID+"&evt=3&cb=?",function(data){});
            playStopClick("playerError");
            _gel('playing_txt').style.fontWeight="bold";
            _gel('playing_txt').style.color="#FF0000";
            _gel('playing_txt').innerHTML = "__MSG_error_loading__:";
            alert("__MSG_error_loading__: "+curStationName);
          }
      }, 'visible');
		}
	}
	
	//on the past we had a "change skin" on min mode. we still can use it in the future in 
  //order to open the "skin box" automatically when max mode is being opened by passing "true" to this function.
	function switchToCanvas(changeSkin){
		var views = gadgets.views.getSupportedViews();
	  gadgets.views.requestNavigateTo( views['canvas'], changeSkin );	
  
	}
	
	// adds a new css class definition to the document, used for assigning classes for cached images
	function addCssClass(classname, rule) {
		var ssheet=(document.styleSheets.length==0)? document.createStyleSheet(): document.styleSheets[0];
		if(ssheet.insertRule){
		rulecount=ssheet.cssRules.length;
		fullrule='.'+classname+"{"+ rule +"}";	
		ssheet.insertRule(fullrule, rulecount++ );
		}else if(document.styleSheets[0].addRule){
		rulecount=ssheet.rules.length;
		ssheet.addRule('.'+classname, rule, rulecount++);	
		}
	}
	
</script>	
<center>
<div id="container" style="display:none;">
  <div id="top" style="width:244px; margin-top:8px; margin-bottom:0px;">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
  	   <tr>
         <td align="left">
            <div id="more_stations" align="left" style="text-align:left; display:block; vertical-align:middle; cursor:pointer; float:left;" onmouseover="buttonOver('more_stations','-16px -16px');" onmouseout="buttonOut('more_stations','-16px 0px');" onclick="trackEvent('SwitchToCanvas','Change stations'); switchToCanvas(false);"><div class="buttons_sprite" style="width:16px; height:16px; overflow:hidden; float:left; margin-right:2px;" id="more_stations_icon" onmouseover="buttonOver('more_stations','16px -16px');" onmouseout="buttonOut('more_stations','16px 0px');" onclick="trackEvent('SwitchToCanvas','Change stations'); switchToCanvas(false);" ></div>__MSG_change_stations__</div>
         </td>
         <td style="width:4px; font-size:1px;"></td>
         <td align="right">
            <div id="full_screen" style="text-align:right;display:block; vertical-align:middle; cursor:pointer;" onmouseover="buttonOver('full_screen','0px -16px');" onmouseout="buttonOut('full_screen','0px 0px');" onclick="trackEvent('SwitchToCanvas','Full Screen'); switchToCanvas(false);"><div class="buttons_sprite" style="width:16px; height:16px; overflow:hidden; float:right;" id="full_screen_icon" onmouseover="buttonOver('full_screen','0px -16px');" onmouseout="buttonOut('full_screen','0px 0px');" onclick="trackEvent('SwitchToCanvas','Full Screen'); switchToCanvas(false);" ></div>__MSG_full_screen__</div>
          </td>
      </tr>
    </table>
	</div>
	<div id="main_tv">
		<div id="top_main_div" style="width:244px; height:20px; font-size:1px;"></div>
		<div id="center_main_div" style="width:244px; height:150px;">
			<table cellspacing="0" cellpadding="0" border="0">
				<tr>
					<td id="left_player" style="width:22px; height:150px;"></td>
					<td id="center_player" style="width:200px; height:150px; vertical-align:top; cursor:pointer;" align="center" onmouseover="setScreenIcon(true);" onmouseout="setScreenIcon(false);" onclick="playStopClick('screen');">
						<div id="player" style="height:150px; width:200px; overflow:hidden;"></div>
					</td>
					<td id="right_player" style="width:22px; height:150px;font-size:1px;"></td>
				</tr>
			</table>
		</div>
		<div id="bottom_main_div" style="width:244px; height:68px;"></div>
	</div>
	<div id="bottom" style="width:244px; height:14px; font-size:11px; font-family:verdana; overflow:hidden; color:#808080;" align="left">
	 <div id="play_stop_icon" class="buttons_sprite" style="height:9px; width:9px; overflow:hidden; float:left; margin-top:3px; cursor:pointer;" onclick="playStopClick('bottomIcon');"></div>
   <span id="playing_txt" style="font-family:verdana; margin-left:3px; margin-right:2px; cursor:pointer;" onclick="playStopClick('botttomIcon');"></span>
	 <span id="station_name" onclick="playStopClick('bottomIcon');" style="font-family:verdana; font-weight:bold; cursor:pointer;" align="left"></span>
	</div>
	<div style="margin-top:5px;">
		<script type="text/javascript">
				GA_googleFillSlot("tv_txt");
		</script>
  </div>
</div>
</center>
<script type="text/javascript">
	_IG_Analytics("UA-345375-1", "/TV_V2_Profile");
</script>

]]>  
</Content>
	
<Content type="html" view="canvas">  
<![CDATA[	
<title>LabPixies TV</title>
<style type="text/css">
#container {
    width:520px;
    overflow:hidden;
    text-align:left;
}
#playing_txt, #change_skin {
	font-family:verdana;
  font-size:12px;
  color:#4C4C4C;
	height:20px;
	padding-left:4px;
	cursor:pointer;
}
#station_name {
	font-family:verdana;
  font-size:12px;
  color:#4C4C4C;
	font-weight: bold;
	overflow:hidden;
	float:left;
	line-height:20px;
	cursor:pointer;
	padding-left:2px;
}
#main_tv {
	width:520px;
	height:432px;
}
#my_stations_header {
	width:520px;
	height:64px;
}
#refresh_txt{ 
	font-family:verdana;
	font-size:10px;
	color:#4C4C4C;
	text-align:left;
	vertical-align:middle; 
}
#my_station_title {
	width:520px;
	height:32px; 
	font-family:verdana;
	font-size:14px;
	color:#FFFFFF;
	font-weight:bold;
	padding-left:12px;
	padding-right:12px;
	vertical-align:middle;
}
#my_stations_list, #more_td {
	width:520px;
	height:1px;
	background-color: #FFFFFF;
	border-top-width: 0px;
	border-bottom-width: 0px;
	border-right-width: 1px;
	border-left-width: 1px;
	border-right-style: solid;
	border-left-style: solid;
	border-right-color: #868d96;
	border-left-color: #868d96;
}
#submit_box {
	height:107px;
	width:520px;
	background-color: #FFFFFF;
	border-top-width: 0px;
	border-bottom-width: 1px;
	border-right-width: 1px;
	border-left-width: 1px;
	border-bottom-style: solid;
	border-right-style: solid;
	border-left-style: solid;
	border-right-color: #868d96;
	border-bottom-color: #868d96;
	border-left-color: #868d96;
}
#seperator_td{
  width:518px; 
  height:1px;
  font-size:1px;
  background-color:#FFFFFF; 
  border-top-width: 0px;
	border-bottom-width: 0px;
	border-right-width: 1px;
	border-left-width: 1px;
	border-right-style: solid;
	border-left-style: solid;
	border-right-color: #868d96;
	border-left-color: #868d96;
}
#more_stations_title, #submit_stations_title {
	font-family:verdana;
	color:#FFFFFF;
	font-size:14px;
	font-weight:bold;
	cursor:pointer;
	float:left;
}
#more_stations_container, #submit_stations_container {
	width:400px;
	height:30px; 
	padding-left:10px;
	vertical-align:middle;
}
#close_submit_td, #close_more_td {
	width:93px;
	height:30px; 
	font-size:10px;
	font-family:verdana;
	color:#FFFFFF;
	text-align:right;
	vertical-align:middle;
	padding-right:14px;
}

#submit_center { 
	height:30px;
	font-size:11px;
	font-family:verdana;
	color:#FFFFFF;
	text-align:center; 
	vertical-align:bottom;
	padding-bottom:7px;
	cursor:pointer;
}

.submit_expl {
	width:498px; 
	height:60px;
	font-family:verdana;
	color:#4C4C4C;
	font-size:11px;
	line-height:18px;
	text-align:left; 
	vertical-align:middle;
}

.dropdown {
	font-size:11px;
	font-family:verdana;
	color:#4C4C4C;
}

.search {
	width:173px;
	height:35px;
	text-align:right; 
	vertical-align:middle;

}

.sortTitles {
	font-size:11px;
	font-family:verdana;
	color:#005CAC;
	font-weight:bold;
	height:25px;
	text-align:left;
	vertical-align:middle;
	cursor:pointer;
}



.channels {
	font-size:11px;
	font-family:verdana;
	color:#4C4C4C;
	overflow:hidden;
	height:15px;
}

.myChannels {
	width:174px; 
	height:30px;
	font-size:11px;
	font-family:verdana;
	color:#4C4C4C;
	overflow:hidden;
	line-height:30px;
	padding-left:6px;
}

#top_anc_container a:link	{text-decoration:none;color:#ffffff;font-family: Verdana, Arial, sans-serif; font-size:1px;}
#top_anc_container a:hover {text-decoration:underline;color:#ffffff;font-family: Verdana, Arial, sans-serif; font-size:1px;}

</style>
<script language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>		
<script language="JavaScript" src="http://www.google-analytics.com/ga.js"></script>	

<script type="text/javascript">
  var _gadgetID=25;
	var $lp = jQuery.noConflict();

  var mData = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_data.js");
  document.write('<scr'+'ipt type="text/javascript" src="'+mData+'"></scr'+'ipt>');
  var mPlayer = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_player.js");
  document.write('<scr'+'ipt type="text/javascript" src="'+mPlayer+'"></scr'+'ipt>');
	var mSIDEBAR = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_sidebar.js");
	document.write('<scr'+'ipt type="text/javascript" src="'+mSIDEBAR+'"></scr'+'ipt>');
	var mJQTWO = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/jquery/jquery.mousewheel.js");
	document.write('<scr'+'ipt type="text/javascript" src="'+mJQTWO+'"></scr'+'ipt>');
	var mJQTHREE = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/jquery/jscrollpane.js");
	document.write('<scr'+'ipt type="text/javascript" src="'+mJQTHREE+'"></scr'+'ipt>');
	var mSKINS = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_skins.js");
	document.write('<scr'+'ipt type="text/javascript" src="'+mSKINS+'"></scr'+'ipt>');
	var mSKINCSS=_IG_GetCachedUrl("http://cdn.labpixies.com/infra/css/skins.css");
	document.write('<li'+'nk rel="stylesheet" type="text/css" media="all" href="'+mSKINCSS+'" />');
</script>
<script type="text/javascript">
	
	var ga = new _gat._getTracker("UA-345375-1");
	ga._initData();
	function trackEvent(event_name, event_value) {
	    try {
        ga._trackEvent("TV - V2 Max", event_name, event_value);
      } 
      catch (ee) {}
	}
	var STOPPED=0;
	var PLAYING=1;
	var LOADING=2;
	
	var IMAGES_BASE = "http://cdn.labpixies.com/campaigns/tv/images/v2/maxmode/";

	var g_prefs = new _IG_Prefs();
	
	var curStation = 0;
  var curStationName = "C Span";
	var curStationURL = "http://play.rbn.com/play.asx?url=cspan/cspan/wmlive/cspan1v.asf&proto=mms?mswmext=.asx";
	var curStationID = "6";

	var curr_skin;
	var isPlaying=STOPPED;
	var isSubmitOpen=false;
	var isStationsOpen=false;
	var g_data;
	var g_genres;
	var g_countries;
	var g_userCountry;
	var dbFirstLoad=true;
	var lastSort="name";
	var g_my_stations=[];
	var player; 
	var isPlugInInstalled=true;
	var plugInInfo;
	
	//Titles for skins box
	var user_params = {"mainTitle":"__MSG_choose_skin__",
  					"saveText":"__MSG_save_changes__",
  					"cancelText":"__MSG_cancel__"};	
	
	
	_IG_RegisterOnloadHandler(function() {
  		player = new lp_player('max_player',380,285);
  		player.init();
  		//getting the plugIn info
  		plugInInfo=player.getPlugInInfo();
  		isPlugInInstalled=(plugInInfo.isInstalled);
  		
  		loadImages();
		  //load the sidebar
        var addSidebarParams = {};
	    var addMenuParams = {};
  		lpgadgets.lp.sidebar.deploy('container', addSidebarParams, addMenuParams);
  		lpgadgets.lp.menu.addMenuItem('__MSG_submit_new_station__', function(){ 
          trackEvent('SideBar','SubmitButton');
  	   	  window.open("http://www.labpixies.com/campaigns/tv/check_tv_station_v2.php", "submitStation");
       });
		
       lpgadgets.lp.data.init(loadStations);
	});
	
	//final init, includes setting the current station name and url, deciding whether to play or not, displaying user's stations, initializing skin
	function final_init() {
      //setting the current station name and url
      if (g_my_stations.length>curStation) {
            curStationName = g_my_stations[curStation][0];
          	curStationURL = g_my_stations[curStation][1];
          	curStationID = g_my_stations[curStation][2];
      }
      _gel('station_name').innerHTML = curStationName;
      //displaying user's stations
      displayMyStations();
      //deciding whether to play or not
      setPlayMode();
      handlePlayerMsg(); //in case the plugIn is missing
      _gel('container').style.display="";  //displaying the gadget
	   initSkin();
  }
  
  //function to handle the special cases (missing plugIn or FF on MAC-special msg)
  function handlePlayerMsg() {
    if (!(isPlugInInstalled)) setErrorMsg();
  }
  
	function setErrorMsg(){
    addCssClass('error_msg', 'background:transparent url(' + getCachedImage(IMAGES_BASE + 'error_message_icon.png' ) + ');' );
	  _gel('station_name').style.cursor = 'default';
	  _gel('playing_txt').style.cursor = 'default';
	  _gel('top_play_status').onclick=null;
	  _gel('top_play_status').onmouseover = null;
	  _gel('top_play_status').onmouseout = null;
	  _gel('top_play_status').style.cursor = 'default';
	  _gel('station_name').onclick=null;
	  _gel('station_name').onmouseover = null;
	  _gel('station_name').onmouseout = null;
	  _gel('station_name').style.cursor = 'default';
	  _gel('max_player_container').onclick=null;
	  _gel('max_player_container').onmouseover = null;
	  _gel('max_player_container').onmouseout = null;
	  _gel('max_player_container').style.verticalAlign="middle";
	  _gel('max_player_container').style.cursor = 'default';
	  var msg = '<table cellspacing="0" cellpadding="0" style="width:220px; height:170px; background-color:#FFFFFF; border-color:#FF0000; border-width: 2px; border-style: solid;">'+
                  '<tr><td style="padding-top:10px; padding-right:10px; padding-left:10px;" align="center"><div style="width:100px; height:58px; overflow:hidden;" class="error_msg"></div></td></tr>'+
                  '<tr><td style="font-family:arial; font-size:12px; text-align:center; padding-left:10px; padding-right:10px;" >__MSG_plugIn_missing__</td></tr>'+
                  '<tr><td style="padding-left:10px; padding-right:10px; padding-bottom:10px; text-align:center;"><a onclick="trackEvent(\'PlugInMissingMSG\',\'SupportLink\');" href="http://www.labpixies.com/support/?ans=3#anc_question_3" target="_blank" style="font-family:arial; font-weight:bold; font-size:12px; text-align:center; color:#FF0000; text-decoration:none;">__MSG_support_link__</a></td></tr>'+
                  '</table>';
    _gel('max_player_container').innerHTML = msg;
  
  }
  
	function setPlayMode() {
	   
    //deciding whether to play or not on load
    //play 
		if (g_prefs.getString('auto_play')=="1") {
        _gel('refresh').checked=true;
        if (isPlugInInstalled) {
          _gel('play_stop_icon').style.backgroundPosition = "-19px 0px";
  			  _gel('playing_txt').innerHTML = "__MSG_loading__:";
  			  isPlaying=LOADING;
  			  play(g_my_stations[curStation][2]);
  			}
		}
		//not to play
		else {
      _gel('refresh').checked=false;
      _gel('play_stop_icon').style.backgroundPosition = "0px 0px";
			_gel('playing_txt').innerHTML = "__MSG_play__"+":";
			_gel('station_name').innerHTML = curStationName;
		}

  }
	
function loadStations(response){
      if(!response.success) {
    	    trackEvent("ErrorOnDataGet", "GadgetLoad");
    		  gadget_data_error();
    		  
    	}
    	else{
        var timeout = 0;
        var callback = function(data) {
          //this function is called when we got the default station list from the servers
          clearTimeout(timeout);
          try {
              for (var item in data) {
                g_my_stations.push([data[item].name, data[item].url, data[item].id]);
              }
              curStation = 0;
              final_init();
              saveStations();
              setTimeout("saveCurStationInPref()",2000);
          }
          catch(ee) {
              loadStationsError();
          }
        }
        //if user doesn't have stations, loading defaults, otherwise loading his
        var firstLoadState=g_prefs.getString('isFirstLoad');
        if ((firstLoadState=="1") || (firstLoadState=="2")) {
          timeout = setTimeout(function() {callback = function(data){}; loadStationsError();},7000);
          $lp.getJSON("http://www.labpixies.com/campaigns/tv/get_default_tv_stations_json_v2.php?cb=?",function(data){callback(data);});
          
        }
        else {//this is not the first load of the gadget. the user should already have his own settings
          lpgadgets.lp.data.get(["stations"], function(response) {
        	  if(!response.success) {
        	    trackEvent("ErrorOnDataGet", "GadgetLoad");
        		  gadget_data_error();
        	  }
        	  else {
        	    //setting user's list and current station
        	    try {
                  g_my_stations = lpgadgets.lp.utils.jsonParse(response.data.stations);
                  curStation = g_prefs.getInt('defaultStation');
                  final_init();
              } catch (ee) {
                gadget_data_error();
              }
          }});
       }
    }
}
	
	//if couldn't load stations from defaults - use the embeded station in the gadget
function loadStationsError() {
    try{
      g_my_stations=[];
      g_my_stations.push([curStationName, curStationURL, curStationID]);
      curStation = 0;
      final_init();
      saveStations();
      setTimeout("saveCurStationInPref()",2000);
    }
    catch (ee){}
}
	
	// display error message instead of the gadget, in case of lp data error
  function gadget_data_error(){	
    _gel('container').innerHTML='<center><div style="text-align:center;width:245px;height:274px;font-family: Arial, Helvetica, sans-serif;font-size:12px; line-height:17px; color:#363636"><img src="http://cdn.labpixies.com/images/oops_data_icon.png" width="150" height="74" style="margin-top:15px;margin-bottom:15px"/><br/>__MSG_data_err1__<br/>__MSG_data_err2__</div></center>';
    _gel('container').style.display="";	
  }
    
	function saveStations() {
    lpgadgets.lp.data.set("stations", lpgadgets.lp.utils.jsonStringify(g_my_stations), function(r) {
        if( !r.success ) {
            trackEvent("ErrorOnData", "saveStations");
            gadget_data_error();
        }
    });
	}
	
    function saveCurStationInPref() {
        g_prefs.set("defaultStation", curStation,
            "n1",curStationName.substring(0,100),
            "u1",curStationURL,
            "i1",curStationID,
            "isFirstLoad",""+Math.floor((Math.random()*10000+5))
        );
    }
	
	function loadImages() {
		_gel('play_stop_icon').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'play_pause_sprites.png')+') no-repeat';
		setBackgroundPos ('play_stop_icon','0px 0px');
		_gel('more_arrow').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'open_close_box.png')+') no-repeat';
		setBackgroundPos ('more_arrow','0px 0px');
		_gel('submit_arrow').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'open_close_box.png')+') no-repeat';
		setBackgroundPos ('submit_arrow','0px 0px');
		_gel('change_skin_icon').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'change_skin.png')+') no-repeat';
		setBackgroundPos('change_skin_icon','0px 0px');
		if ((isPlugInInstalled))
       _gel('max_player_container').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'play_screen.png')+') no-repeat'; 
		setBackgroundPos('max_player_container','0px 0px');
		_gel('my_stations_header').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'my_channels_background.png')+') no-repeat'; 
		_gel('search_button').src = getCachedImage(IMAGES_BASE + 'search_icon.png');
		_gel('submit_left').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'submit_icon.png')+') no-repeat'; 
		setBackgroundPos('submit_left','0px 0px');
		_gel('submit_right').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'submit_icon_right.png')+') no-repeat'; 	
		_gel('submit_center').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'submit_icon_background.png')+') repeat'; 	
	  _gel('refresh_question_mark').style.background = 'transparent url('+getCachedImage(IMAGES_BASE + 'whats_this_sprite.png')+') repeat'; 	
    addCssClass('image_plus', 'background:transparent url(' + getCachedImage( IMAGES_BASE + 'add_sprite_v.png' ) + ');' );
    addCssClass('image_v_added', 'background:transparent url(' + getCachedImage( IMAGES_BASE + 'add_sprite_v.png' ) + '); background-position: 0px -36px;' );
		addCssClass('image_try', 'background:transparent url(' + getCachedImage( IMAGES_BASE + 'preview_sprite.png' ) + ');' );
		addCssClass('image_delete', 'background:transparent url(' + getCachedImage( IMAGES_BASE + 'delete_sprite.png' ) + ');' );
		addCssClass('loading_stations', 'background:transparent url(' + getCachedImage( IMAGES_BASE + 'loading_animation.gif' ) + ') no-repeat; height:24px; width:26px;' );
		addCssClass('statNumBack', 'background:transparent url(' + getCachedImage( IMAGES_BASE + 'channel_number_sprite.png' ) + '); font-size:10px; font-family:verdana; color:#4C4C4C; vertical-align:middle; text-align:center; line-height:16px; width:17px;height:17px;overflow:hidden;' );
  }

	function setBackgroundPos (id, pos){
		_gel(id).style.backgroundPosition = pos;
	}

	function getCachedImage(src){
    return(_IG_GetImageUrl(src));	
	}
	
	
	function playStopClick(buttonType) {
	 if (!(isPlugInInstalled)) return;
		//stop
		if(isPlaying==PLAYING || isPlaying==LOADING) {
		  trackEvent("Stop",buttonType);
			_gel('max_player_container').onclick = screenClicked;
			isPlaying=STOPPED;
			player.stop();
			_gel('max_player_container').style.cursor="pointer";
			setBackgroundPos('max_player_container','0px 0px');
			_gel('playing_txt').innerHTML = "__MSG_play__:";
			_gel('station_name').innerHTML = curStationName;
			if(g_my_stations[curStation]!=null) _gel('name'+curStation).innerHTML=g_my_stations[curStation][0]; //if it was loading... needs to set back to station name (checking first that it wasn't deleted
		}
		//play
		else{
		  trackEvent("Play",buttonType);
			isPlaying=LOADING;
			play(g_my_stations[curStation][2]);
		}
	}
	
	function play(id) {
	  //disable screen clicks while playing
		_gel('max_player_container').onclick=null;
		setBackgroundPos('max_player_container','0px -570px');
		_gel('max_player_container').style.cursor="default";
		//setting titles to current mode and station
		_gel('playing_txt').style.fontWeight="";
    _gel('playing_txt').style.color="#4C4C4C";
		_gel('playing_txt').innerHTML = "__MSG_loading__:";
		_gel('station_name').innerHTML = curStationName;
		player.play(curStationURL,function(data){
          if(data=="success" || data=="unknown") {
            $lp.getJSON("http://www.labpixies.com/campaigns/tv/report_station_event.php?id="+id+"&evt=2&cb=?",function(data){});
            if (g_my_stations[curStation]!=null && g_my_stations[curStation][1]==curStationURL) {//if this is a station played from my list
		            _gel('name'+curStation).innerHTML=g_my_stations[curStation][0];
	          }
            isPlaying=PLAYING;
            _gel('playing_txt').innerHTML = "__MSG_now_playing__"+":";
          }
          //can't play the station
          else {
            playStopClick("playerError");  //doing this in order to stop the player
            $lp.getJSON("http://www.labpixies.com/campaigns/tv/report_station_event.php?id="+id+"&evt=3&cb=?",function(data){});
            setPlayIcon(false);
            _gel('playing_txt').style.fontWeight="bold";
            _gel('playing_txt').style.color="#FF0000";
            _gel('playing_txt').innerHTML = "__MSG_error_loading__:";
            alert("__MSG_error_loading__: "+curStationName);
          }

    }, 'visible');
	}
	
	
	function screenClicked () {
		playStopClick("screenButton"); 
		setPlayIcon(false); 
		setScreenIcon(false);
	}
	
	//setting the apropraite style to the play/stop button at the top of the gadget
	function setPlayIcon(isRollOver) {
		if(isPlaying==PLAYING  || isPlaying==LOADING) {
			if(isRollOver) setBackgroundPos('play_stop_icon','-19px -19px');
			else setBackgroundPos('play_stop_icon','-19px 0px');
		}
		else {
			if(isRollOver) setBackgroundPos('play_stop_icon','0px -19px');
			else setBackgroundPos('play_stop_icon','0px 0px');
		}
	}
	
	//setting the apropraite style to the play/stop button on the player screen	
	function setScreenIcon(isRollOver) {
		if(isPlaying==PLAYING  || isPlaying==LOADING) return;
		if(isRollOver) setBackgroundPos('max_player_container','0px -285px');
		else setBackgroundPos('max_player_container','0px 0px');
	}
	
	//setting the "remember play_mode on refresh" property
	function refreshChange() {
		if (_gel('refresh').checked) {
      g_prefs.set("auto_play", "1");
      trackEvent("AutoPlay", "checked");
    }
		else {
      g_prefs.set("auto_play", "0");
      trackEvent("AutoPlay", "unchecked");
    }
	}
	
	function openCloseSubmitBox(buttonType) {
		if (isSubmitOpen) {
		  trackEvent("CloseSubmitBox", buttonType);
			$lp('#submit_box').hide();
			_gel('submit_header').style.backgroundColor='#868d96';
			setBackgroundPos('submit_arrow','0px 0px');
			_gel('close_submit_td').innerHTML='';
			_gel('close_submit_td').onclick=null;
			_gel('close_submit_td').style.cursor='';
			
		}
		else {
		   trackEvent("OpenSubmitBox", buttonType);
			$lp('#submit_box').show();
			_gel('submit_header').style.backgroundColor='#005CAC';
			setBackgroundPos('submit_arrow','0px -13px');
			_gel('close_submit_td').innerHTML="__MSG_close__";
			_gel('close_submit_td').onclick=openCloseSubmitBox;
			_gel('close_submit_td').style.cursor='pointer';
			
			
		}
		isSubmitOpen = !isSubmitOpen;
		_IG_AdjustIFrameHeight();
	}
	
	
	function openCloseMoreBox(buttonType) {
		if (isStationsOpen){
		  trackEvent("CloseStationsBox", buttonType);
			$lp('#more_box').hide();
			_IG_AdjustIFrameHeight();
			_gel('seperator_tr').style.display="";
			_gel('more_header').style.backgroundColor='#868d96';
			setBackgroundPos('more_arrow','0px 0px');
			_gel('close_more_td').innerHTML='';
			_gel('close_more_td').onclick=null;
			_gel('close_more_td').style.cursor='';
		}
		else {
		  trackEvent("OpenStationsBox", buttonType);
			$lp('#more_box').show();
			_IG_AdjustIFrameHeight();
			if (dbFirstLoad) {
			   //display "loading..."     
			  _gel('more_container').innerHTML= "<div style='font-size:11px; font-family:verdana; color:#424242;' ><div style='width:26px; height:24px; overflow:hidden;' class='loading_stations'></div>__MSG_loading_stations__</div>";
        bringFromDB();
        }
			_gel('seperator_tr').style.display="none";
			_gel('more_header').style.backgroundColor='#005CAC';
			setBackgroundPos('more_arrow','0px -13px');
			_gel('close_more_td').innerHTML="__MSG_close__";
			_gel('close_more_td').onclick=openCloseMoreBox;
			_gel('close_more_td').style.cursor='pointer';
		}
		
		isStationsOpen = !isStationsOpen;
	}
	
	
	function getFromDB(userCountry ,genresData, countriesData, data) {
	   
  	 //needs to set the countries/genres drop down and user's country
  	 dbFirstLoad=false;
  	 g_userCountry = countriesData["_"+userCountry.id];
  	 g_genres=genresData;
  	 g_countries=countriesData;
  	 setGenresDropDown();
     setCountriesDropDown();
  	 _gel('search_bar_items').style.display="";
  	 g_data=data;
  	 sortAndDisplay();
	}
	
	
	function bringFromDB() {
	  var timeout = 0;
	  var callback = function(data) {
       try {
           getFromDB(data.userCountry,data.genres,data.countries,data.stations);
           clearTimeout(timeout);
          }
          catch(ee) {
            showLoadDBError();
          }
	  }
	  timeout = setTimeout(function() {showLoadDBError();callback = function(data){}},20000);
		$lp.getJSON("http://www.labpixies.com/campaigns/tv/stations_json.php?cb=?", function (data){ callback(data);});
	}
	
	function showLoadDBError(){
	   _gel('more_container').innerHTML= "<div style='font-size:11px; font-family:verdana; color:#424242;'>__MSG_timeout_loading_stations__<br />__MSG_please_try_again__</div>";     
	}
	
	function sortAndDisplay(sortBy){
	   //display "loading..."
			_gel('more_container').innerHTML= "<div style='font-size:11px; font-family:verdana; color:#424242;' ><div style='width:26px; height:24px; overflow:hidden;' class='loading_stations'></div>__MSG_loading_stations__</div>";
	
    //sorting according to the last sort category if no other category was chosen                          
		if (sortBy=="" || sortBy==null) sortBy=lastSort;
		else lastSort=sortBy;
		
		//setting titles style
		_gel('genre_title').style.textDecoration='none';
		_gel('country_title').style.textDecoration='none';
		_gel('name_title').style.textDecoration='none';
		_gel(sortBy+'_title').style.textDecoration='underline';	
		
		//getting filters
		var searchByCountry = _gel('search_sountry').value;
		var searchByGenre = _gel('search_genre').value;
		var searchByWords = _gel('search_input').value;
		if (searchByWords=="__MSG_search_input__") searchByWords="";
		var sorted = [];
		//filter the array according to the selected category
		for(var item in g_data) {
			if ((searchByCountry=="" || (searchByCountry!="" && searchByCountry==g_data[item].country)) && (searchByGenre=="" || (searchByGenre!="" && searchByGenre==g_data[item].genre)) && (searchByWords=="" || (searchByWords!="" && (g_data[item].name.toLowerCase().indexOf(searchByWords.toLowerCase(),0)>-1)))) {
				if (sortBy=="name") sorted.push([item, g_data[item].name]);
				if (sortBy=="country") sorted.push([item, g_data[item].country]);
				if (sortBy=="genre") sorted.push([item, g_data[item].genre]);
			}
		}
		//sort the array according to the selected sort
		sorted.sort(function(a,b) {
		    a[1] = a[1].toLowerCase();
		    b[1] = b[1].toLowerCase();
        if (a[1] > b[1]) return 1;
        if (a[1] < b[1]) return -1;
        return 0;
    });
		var out = [];
		var curItem;
		var sortedLength = sorted.length;
		//no stations were found
		if (sortedLength==0) {
		    //hiding titles and displaying msg "no stations found"
		  _gel('country_title').style.display="none";
      _gel('genre_title').style.display="none";
      _gel('name_title').style.display="none";
      out.push("<div id='more_div' style='height:372px; width:518px;'>");
      out.push("<table cellspacing='0' cellpadding='0' border='0'>");
      out.push("<tr><td style='width:504px; height:372px; font-size:14px; font-family:verdana; color:#4C4C4C; vertical-align:top; padding-top:20px; text-align:center;'>__MSG_no_stations_found__</td></tr></table></div>");
    }
    //there are stations to display
    else {    
      out.push("<div id='more_div' style='height:372px; width:518px; overflow-y: scroll;'>");
      out.push("<table cellspacing='0' cellpadding='0' border='0'>");
      //showing titles
      _gel('country_title').style.display="";
      _gel('genre_title').style.display="";
      _gel('name_title').style.display="";
      var name="";
      var url="";
      var isInMyList=false;
      
      //showing found stations
  		for(i=0; i< sortedLength; i++ ) {
  			curItem = sorted[i][0];
  			name=g_data[curItem].name;
  			url=g_data[curItem].url;
  			isInMyList=isStationInMyList(name,url);
  			out.push("<tr><td width='504' colspan='9' style='background-color:#C2C6CA; height:1px;'></td></tr>");
  			out.push("<tr id='"+curItem+"'><td class='"+curItem+"' style='width:15px;height:24px;font-size:0px;'>&nbsp;</td>");
  			out.push("<td id='"+curItem+"_country' style='vertical-align:middle; text-align:left;' onmouseover='stationRollOver(\""+curItem+"\","+isInMyList+");' onmouseout='stationOut(\""+curItem+"\");'><div class='channels' style='width:130px;'>"+g_data[curItem].country+"</div></td>");
  			out.push("<td id='"+curItem+"_genre' style='vertical-align:middle; text-align:left;' onmouseover='stationRollOver(\""+curItem+"\","+isInMyList+");' onmouseout='stationOut(\""+curItem+"\");'><div class='channels' style='width:100px;'>"+g_data[curItem].genre+"</div></td>");
  			out.push("<td id='"+curItem+"_name' style='vertical-align:middle; text-align:left;' onmouseover='stationRollOver(\""+curItem+"\","+isInMyList+");' onmouseout='stationOut(\""+curItem+"\");'><div class='channels' style='width:195px;' >"+g_data[curItem].name+"</div></td>");
  			out.push("<td id='"+curItem+"_space1' style='width:5px;height:24px;font-size:0px;' onmouseover='stationRollOver(\""+curItem+"\","+isInMyList+");' onmouseout='stationOut(\""+curItem+"\");'>&nbsp;</td>");
  			if (isInMyList) {
           out.push("<td id='"+curItem+"_plus' style='width:18px; height:24px;' title='__MSG_already_added__' onmouseout='stationOut(\""+curItem+"\");' onmouseover='plusRollover(\""+curItem+"\","+isInMyList+");'><div id='plus"+curItem+"' class='image_plus' style='background-position:0px -36px; width:18px;height:18px;overflow:hidden;display:none;'></div></td>");
  			}
  			else{
  			    out.push("<td id='"+curItem+"_plus' title='__MSG_add_station__' style='width:18px; height:24px;' onmouseover='plusRollover(\""+curItem+"\","+isInMyList+");' onmouseout='stationOut(\""+curItem+"\");'><div id='plus"+curItem+"' class='image_plus' style='width:18px;height:18px;overflow:hidden;display:none; cursor:pointer;' onclick='addStation(\""+curItem+"\");'></div></td>");
  			}
        out.push("<td id='"+curItem+"_space2' style='width:12px; height:24px;' onmouseover='stationRollOver(\""+curItem+"\","+isInMyList+");' onmouseout='stationOut(\""+curItem+"\");'></td>");
  			out.push("<td id='"+curItem+"_preview' title='__MSG_preview__' style='width:18px; height:24px;' onmouseover='tryRollover(\""+curItem+"\","+isInMyList+");' onmouseout='stationOut(\""+curItem+"\");' onclick='tryStation(\""+curItem+"\");'><div id='try"+curItem+"' class='image_try' style='width:18px;height:18px;overflow:hidden;display:none;cursor:pointer'></div></td>");
  			out.push("<td id='"+curItem+"_space3' style='width:7px;height:24px;font-size:0px;' onmouseover='stationRollOver(\""+curItem+"\","+isInMyList+");' onmouseout='stationOut(\""+curItem+"\");'>&nbsp;</td></tr>");						
  		}
  		out.push("<tr><td width='504' colspan='9' style='background-color:#C2C6CA; height:1px;'></td></tr></div>");
  	}
    out.push("</table>");
		_gel('more_container').innerHTML=out.join('');
	}
    
	function getMyStationsContent(fromStation,toStation) {
      var out=[];
    	for(var i=fromStation; i<(toStation); i++ ) {
				out.push("<tr><td style='width:17px; height:30px; cursor:pointer;' title='"+g_my_stations[i][0]+" - __MSG_click_to_play__' onclick='playFromList(\""+i+"\");' onmouseover='myRowRollover(\""+i+"\");' onmouseout='myRowOut(\""+i+"\");'><div id='icon"+i+"' class='statNumBack'>"+(i+1)+"</div></td>");
				out.push("<td style='text-align:left; height:30px; width:198px; cursor:pointer;' title='"+g_my_stations[i][0]+" - __MSG_click_to_play__' onclick='playFromList(\""+i+"\");' onmouseover='myRowRollover(\""+i+"\");' onmouseout='myRowOut(\""+i+"\");' ><div id='name"+i+"' class='myChannels'>"+g_my_stations[i][0]+"</div></td>");
				out.push("<td title='__MSG_remove__' style='height:30px; width:14px; cursor:pointer;' onmouseover='myDeleteRollover(\""+i+"\");' onmouseout='myDeleteOut(\""+i+"\");' onclick='removeStation(\""+i+"\");'><div class='image_delete' id='delete"+i+"' style='width:14px; height:13px; overflow:hidden; display:none;'></div></td>");
				out.push("<td style='width:4px;height:30px;font-size:0px;' onmouseover='myRowRollover(\""+i+"\");' onmouseout='myRowOut(\""+i+"\");'></td></tr>");
				//adding div line
				if (i<(toStation-1)) out.push("<tr><td colspan='4' style='width:233px; background-color:#C2C6CA; height:1px;font-size:1px;'></td></tr>");
			}
			return out.join('');
  }
  
  //checking if station is in my list by comparing name and url
  function isStationInMyList(name, url) {
    for (var item in g_my_stations){
      if (g_my_stations[item][0]==name && g_my_stations[item][1]==url){
        return true;
      }
    }
    return false;
  }
  
  
	function displayMyStations() {
		var out=[];
		var i;
		var station_length= g_my_stations.length;
		//My stations box is being built by 2 tables, one next to the other (left and right)
		if (station_length>1) {
			var numOfLines = Math.ceil(station_length/2);
			out.push("<table cellspacing='0' cellpadding='0' border='0'><tr><td style='width:12px;font-size:1px;'></td><td style='width:233px;'><table cellspacing='0' cellpadding='0' border='0'>");
      //filling left table
			out.push(getMyStationsContent(0,numOfLines));
			//filling right table
			out.push("</table></td><td style='width:25px;font-size:0px;'>&nbsp;</td><td style='width:233px;'><table cellspacing='0' cellpadding='0' border='0'>");
			out.push(getMyStationsContent(numOfLines,station_length));
      
			//adding empty cell if needed (odd number of stations)
			if (station_length<(2*numOfLines)) {
				out.push("<tr><td colspan='4' style='width:233px; background-color:#C2C6CA; height:1px; font-size:1px;'></td></tr>");
				out.push("<tr><td colspan='4' style='width:233px;height:30px;font-size:0px;'>&nbsp;</td></tr>");
			}
			out.push("</table></td><td style='width:15px;font-size:0px;'></td></tr></table>");
		}
		//handling the one station case
		else {
			out.push("<table cellspacing='0' cellpadding='0' border='0'><tr><td style='width:12px;height:30px;font-size:0px;'></td>");
			out.push("<td style='width:17px; height:30px; cursor:pointer;' title='"+g_my_stations[0][0]+" - __MSG_click_to_play__' onclick='playFromList(\"0\");'><div id='icon0' class='statNumBack'>1</div></td>");
			out.push("<td style='text-align:left; height:30px; width:198px; cursor:pointer;' title='"+g_my_stations[0][0]+" - __MSG_click_to_play__' onclick='playFromList(\"0\");'><div id='name0' class='myChannels'>"+g_my_stations[0][0]+"</div></td>");
			out.push("<td style='width:291px;height:30px;font-size:0px;'></td></tr>");
			out.push("</table>");
		}
		_gel('my_stations_list').innerHTML=out.join('');
	//	_gel('my_stations_list').innerHTML=str;
		

		//setting style for current played 
		_gel('name'+curStation).style.color='#005CAC';
  		_gel('icon'+curStation).style.color='#FFFFFF';
  		setBackgroundPos("icon"+curStation, "0px -17px");
  		if (isPlaying==LOADING && g_my_stations[curStation][1]==curStationURL) {
  		  _gel('name'+curStation).innerHTML='__MSG_loading__'+'...';
  		}
  		
		_IG_AdjustIFrameHeight();
	
	}
	
	
	function myRowRollover(id) {
		_gel("delete"+id).style.display="block";
		setBackgroundPos("delete"+id,"0px 0px");
	}
	
	function myDeleteRollover(id) {
		_gel("delete"+id).style.display="block";
		setBackgroundPos("delete"+id,"0px -13px");
	}
	
	function myDeleteOut(id) { _gel("delete"+id).style.display="none";	}
	
	function myRowOut(id){ _gel("delete"+id).style.display="none"; }
	
	
	
	function removeStation(num) {
	   trackEvent("RemoveStation");
	   //removing the station from the array and saving to lp data
		g_my_stations.splice(num,1);

	  //handling the case that the current played station has been removed
		if (parseInt(num)==curStation) {
		  curStation=0;
		  //if the current station was being played
  		if(isPlaying==PLAYING || isPlaying==LOADING) {
  			_gel('max_player_container').onclick = screenClicked;
  			isPlaying=STOPPED;
  			player.stop();
  			_gel('max_player_container').style.cursor="pointer";
  			setBackgroundPos('max_player_container','0px 0px');
  			setPlayIcon(false);
  		}
  		_gel('playing_txt').style.fontWeight="";
      _gel('playing_txt').style.color="#4C4C4C";
  		_gel('playing_txt').innerHTML = "__MSG_play__:";
  		_gel('station_name').innerHTML = g_my_stations[curStation][0];
    }
    //if the removed station number is lower than the current played one, need to handle style issues and to shift the default value
   	if (curStation>parseInt(num)) {
        curStation=curStation-1;
    }
    curStationName = g_my_stations[curStation][0];
    curStationURL = g_my_stations[curStation][1];
    curStationID = g_my_stations[curStation][2];
		saveStations();
		saveCurStationInPref();
    displayMyStations();
	}
	
	function addStation(stationID){
	  trackEvent("AddStation");
	  //updating the "add_count" field on the db 
	  $lp.getJSON("http://www.labpixies.com/campaigns/tv/report_station_event.php?id="+stationID.substring(1)+"&evt=1&cb=?",function(data){});
		if (g_my_stations.length<20) {
	    
    	    //we need to set the added station to have a style and behavior of an added station
          _gel(stationID+"_country").onmouseover=function(){ stationRollOver(stationID,true)};
          _gel(stationID+"_genre").onmouseover=function(){ stationRollOver(stationID,true)};
          _gel(stationID+"_name").onmouseover=function(){ stationRollOver(stationID,true)};
          _gel(stationID+"_preview").onmouseover=function(){ tryRollover(stationID,true)};
          _gel(stationID+"_plus").onmouseover=function(){ plusRollover(stationID,true)};
          _gel("plus"+stationID).onclick=null;
          _gel("plus"+stationID).style.cursor="default";
          _gel(stationID+"_plus").title='__MSG_already_added__';

          setBackgroundPos("plus"+stationID,"0px -36px");
          _gel(stationID+"_space1").onmouseover=function(){ stationRollOver(stationID,true)};
          _gel(stationID+"_space2").onmouseover=function(){ stationRollOver(stationID,true)};
          _gel(stationID+"_space3").onmouseover=function(){ stationRollOver(stationID,true)};

          var stationsNum = g_my_stations.push([g_data[stationID].name, g_data[stationID].url, stationID.substring(1)]);
          //in case this is the first time the gadget loads and the first prefs.set failed
          saveStations();
          displayMyStations();
		}
		else alert("__MSG_station_limit_alert__");

	}
	
	
	function tryRollover(id, added) {
		$lp('#'+id).css("background-color","#E6EBEE");
		_gel("plus"+id).style.display="block";
		if (!added) setBackgroundPos("plus"+id,"0px 0px");
		_gel("try"+id).style.display="block";
	  setBackgroundPos("try"+id,"0px -18px");
	}
	
	function plusRollover(id, added) {
		$lp('#'+id).css("background-color","#E6EBEE");
		_gel("plus"+id).style.display="block";
		if (!added) setBackgroundPos("plus"+id,"0px -18px");
		_gel("try"+id).style.display="block";
		setBackgroundPos("try"+id,"0px 0px");
	}
	
	//If the station is added or not need to acts differnetly with the "add/v" gif
	function stationRollOver(id, added) {
		//setting highlighted row
		$lp('#'+id).css("background-color","#E6EBEE");
		_gel("plus"+id).style.display="block";
		if (!added) setBackgroundPos("plus"+id,"0px 0px");
		_gel("try"+id).style.display="block";
		setBackgroundPos("try"+id,"0px 0px");
	}
	
	function stationOut (id){
		//setting regular row
		 $lp("#"+id).css("background-color","#FFFFFF");
		_gel("plus"+id).style.display="none";
		_gel("try"+id).style.display="none";
	}
	
	function tryStation(id) {
	  if (isPlugInInstalled) {
  	  trackEvent("PreviewStation");
  	  _gel('top_anc').focus();
  		curStationURL = g_data[id].url;	
  		curStationName = g_data[id].name;
  		curStationID = id.substring(1);
  		if(g_my_stations[curStation]!=null) _gel('name'+curStation).innerHTML=g_my_stations[curStation][0]; //if it was loading... needs to set back to station name (checking first that it wasn't deleted
  		isPlaying=LOADING;
  		setPlayIcon(false);
  		play(id.substring(1));
  	}
	}
	
	function playFromList(id) {
    trackEvent("Play", "fromUserList");
    
    if (isPlaying!=STOPPED && curStationURL==g_my_stations[id][1]) return; //if the selected station is already being loaded or played-->do nothing
		
		//setting style for previous played station
		_gel('name'+curStation).style.color='#4C4C4C';
  	_gel('name'+curStation).innerHTML=g_my_stations[curStation][0];  //in case it was while loading
  	_gel('icon'+curStation).style.color='#4C4C4C';
  	setBackgroundPos("icon"+curStation, "0px 0px");
  		
		curStation = id;
		curStationName=g_my_stations[curStation][0];
    curStationURL=g_my_stations[curStation][1];
    curStationID =g_my_stations[curStation][2];
    saveCurStationInPref();

		//setting style for default 
		_gel('name'+curStation).style.color='#005CAC';
		_gel('icon'+curStation).style.color='#FFFFFF';
		setBackgroundPos("icon"+curStation, "0px -17px");

    //playing only if the plugIn is installed
    if (isPlugInInstalled) {
      _gel('name'+curStation).innerHTML='__MSG_loading__'+'...';
      isPlaying=LOADING;
      setPlayIcon(false);
	    play(g_my_stations[curStation][2]);
    }
		//if the plugIn not installed we still want to change the top text. Setting titles to current mode and station
		else{
		  _gel('station_name').innerHTML = curStationName;
    }
	}
	
	//creating and displaying the Genres dropDown list
	function setGenresDropDown(){
		
		var str = '<select name="search_genre" id="search_genre" class="dropdown" style="width:110px;" onChange="genreChanged();">'+
				  '<option value="">__MSG_all_genres__</option>';
		
		for (var item in g_genres) {
			str=str+'<option value="'+g_genres[item]+'">'+g_genres[item]+'</option>';
		}
		str=str+'</select>';
		_gel('genre_filter').innerHTML=str;
		
	}
	
	function countryChanged() {
	  _gel('search_input').value='__MSG_search_input__';
    sortAndDisplay(); 
    trackEvent("Search","Country");
  }
  
  function genreChanged() {
    _gel('search_input').value='__MSG_search_input__';
    sortAndDisplay(); 
    trackEvent("Search","Genre");
  }
  	//creating and displaying the Countries dropDown list
	function setCountriesDropDown(){
		
		var str = '<select name="search_country" id="search_sountry" class="dropdown" style="width:152px;" onChange="countryChanged();">';

		var country_name="";
		
		for (var item in g_countries) {
			 country_name=g_countries[item];
			 if (country_name.indexOf("Proxy",0)<0) {
			     if (country_name==g_userCountry) {
              str=str+'<option value="'+country_name+'" selected>'+country_name+'</option>';
           }
			     else str=str+'<option value="'+country_name+'">'+country_name+'</option>';
			}
		}
		str=str+'</select>';
		_gel('country_filter').innerHTML=str;

	}
	
	function submit() {
		  trackEvent('Submit','submitButton');
	   	window.open("http://www.labpixies.com/campaigns/tv/check_tv_station_v2.php", "submitStation");
	}
	
	
	function goToAutoPlaySupport() {
		  trackEvent('AutoPlay','support_button');
	   	window.open("http://www.labpixies.com/support/?ans=9#anc_question_9", "AutoPlaySupport");
	}
	

	// adds a new css class definition to the document, used for assigning classes for cached images
	function addCssClass(classname, rule) {
		var ssheet=(document.styleSheets.length==0)? document.createStyleSheet(): document.styleSheets[0];
		if(ssheet.insertRule){
		rulecount=ssheet.cssRules.length;
		fullrule='.'+classname+"{"+ rule +"}";	
		ssheet.insertRule(fullrule, rulecount++ );
		}else if(document.styleSheets[0].addRule){
		rulecount=ssheet.rules.length;
		ssheet.addRule('.'+classname, rule, rulecount++);	
		}
	}

  //setting the TV skin on load
  function initSkin(skinId,skinNum,height,top,left){
  		curr_skin = {};
  		curr_skin.skin_id = g_prefs.getString('skin');
  		curr_skin.name = '';
  		curr_skin.src = g_prefs.getString('skinImg');
  		curr_skin.h1=g_prefs.getString('h1');
  		curr_skin.t1=g_prefs.getString('t1');
  		curr_skin.l1=g_prefs.getString('l1');
    	skinChanged(curr_skin);   
    	if (gadgets.views.getParams()) showSkins();
  }
  
  //setting skin
  function skinChanged(skin_json){
    trackEvent("SkinChanged", ""+skin_json.skin_id);
    _gel('main_tv').style.height = skin_json.h1;
    _gel('main_tv').style.background = 'transparent url('+getCachedImage(IMAGES_BASE+skin_json.src)+') no-repeat';
    _gel('top_main_div').style.height=skin_json.t1;
    _gel('bottom_main_div').style.height = skin_json.h1-skin_json.t1-285;
    _gel('left_player').style.width=skin_json.l1;
    _gel('right_player').style.width=140-skin_json.l1;  //(380-240=140  total_width-player_width)  
  }
  
  function skinCanceledClicked(){
    trackEvent("CancelSkinButton");
  }
  
  //saving the chosen current skin
  function saveSkin(skin_json){
    trackEvent("SaveSkin");
    curr_skin=skin_json;
    //Skin file name and skin id on the db
	  g_prefs.set("skin",skin_json.skin_id,  
	              "skinImg",skin_json.src);   
	  //saving height/top/left properties of the current skin for both max (h1/t1/l1) and min (h2/t2/l2) mode
	  g_prefs.set("h1",skin_json.h1,
	              "t1",skin_json.t1,
	              "l1",skin_json.l1,
	              "h2",skin_json.h2,
	              "t2",skin_json.t2,
	              "l2",skin_json.l2);
	  _IG_AdjustIFrameHeight();
  }
  
  function skinsLoaded(){
    _IG_AdjustIFrameHeight();
  };
  
  
  function showSkins(){
    trackEvent("OpenSkinsBox");
    _gel('skinContainer').style.paddingBottom="5px";
    //this was done becaue the previous size was 0 in order to disable the auto-height of the div in IE
    _gel('skin_out').style.fontSize="";
    lpgadgets.lp.skins.showSkins('skinContainer',
    						curr_skin,
    						skinChanged, 
    						saveSkin,
    						user_params,
    						skinsLoaded,
                skinCanceledClicked);					
  }	
	

</script>
<div style="margin-left:23px;width:760px; height:106px; background-image:url(http://cdn.labpixies.com/infra/images/ad_unit_bg_760.png)">
	<div style="text-align:left; margin-left:22px; padding-top:9px;">
    <script type="text/javascript"><!--
    google_ad_client = "pub-8123415297019784";
    /* TV - Leaderboard - Top */
    google_ad_slot = "8148914794";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
  </div>
</div>
<div id="container" style="display:none;">
  <div id="top_anc_container" style="height:1px; width:1px; font-size:1px;"><a id="top_anc" name="top_anc" href="javascript:void(0);"></a></div>
	<div id="top" style="width:520px; height:24px;">
		<div id="top_play_status" style="float:left; cursor:pointer; height:24px;" onclick="playStopClick('topIcon'); setPlayIcon(true);" onmouseover="setPlayIcon(true);" onmouseout="setPlayIcon(false);">
			<div id="play_stop_icon" style="width:19px;height:19px;float:left;"></div>
			<span id="playing_txt" style="line-height:20px;"></span>
		</div>
		<div id="station_name" onclick="playStopClick('topIcon'); setPlayIcon(true);" onmouseover="setPlayIcon(true);" onmouseout="setPlayIcon(false);"></div>
		<div style="float:right; cursor:pointer; height:24px; padding-top:3;">
			<div id="change_skin_icon" style="width:16px;height:16px;float:left;overflow:hidden;"  onmouseover="setBackgroundPos('change_skin_icon','0px -16px');" onmouseout="setBackgroundPos('change_skin_icon','0px 0px');" onclick="showSkins();"></div>
			<span id="change_skin" style="height:24px;"  onmouseover="setBackgroundPos('change_skin_icon','0px -16px');" onmouseout="setBackgroundPos('change_skin_icon','0px 0px');" onclick="showSkins();">__MSG_change_skin__</span>
		</div>
	</div>
	<div id="skin_out" style="padding-left:20px;font-size:1px;"><div id="skinContainer" style="width:485px;"></div></div>
	<div id="main_tv"> 
		<div id="top_main_div" style="width:520px; height:42px;"></div>
		<div id="center_main_div" style="width:520px; height:285px; overflow:hidden;">
			<table cellspacing="0" cellpadding="0" border="0">
				<tr>
					<td id="left_player" style="width:69px; height:285px;"></td>
					<td id="max_player_container" style="width:380px; height:285px; vertical-align:middle; cursor:pointer;" align="center" onmouseover="setScreenIcon(true);" onmouseout="setScreenIcon(false);" onclick="screenClicked();">
						<div id="max_player" style="width:380px;overflow:hidden;"></div>
					</td>
					<td id="right_player" style="width:71px; height:285px;">&nbsp;</td>
				</tr>
			</table>
		</div>
		<div id="bottom_main_div" style="width:520px; height:115px;">&nbsp;</div>
	</div>
	<table cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td id="my_stations_header">
				<table cellspacing="0" cellpadding="0" border="0" align="right">
					<tr>
					 <td>
					   <div style="float:right;">
					     <table height="32" valign="middle" cellspacing="0" cellpadding="0" border="0">
					       <tr>
						        <td style="text-align:right; vertical-align: middle;width:120px;"><input type="checkbox" id="refresh" name="refresh" value="refresh" onclick="refreshChange();" /></td>
					         	<td id="refresh_txt">__MSG_remember_play_mode__</td>
					         	<td style="width:15px; padding-top:8px;" align="right" valign="top" ><div style="width:11px; height:11px; overflow:hidden; cursor:pointer;" id="refresh_question_mark" onmouseover="setBackgroundPos('refresh_question_mark','0px -11px');"  onmouseout="setBackgroundPos('refresh_question_mark','0px 0px');" onclick="goToAutoPlaySupport();" title="__MSG_what_this__"></div></td>
					        </tr>
					      </table>
					    </div>
					  </td>
					</tr>
					<tr>
						<td id="my_station_title" colspan="2" >__MSG_my_stations__</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td id="my_stations_list"></td>
		</tr>
		<tr>
			<td id="more_header" style="width:520px; height:30px;background-color:#868d96;">
				<table cellspacing="0" cellpadding="0" border="0">
					<tr>
						<td style="width:12px; font-size:0px;">&nbsp;</td>
						<td style="width:13px; vertical-align:middle;"><div id="more_arrow" style="width:13px;height:12px;overflow:hidden;cursor:pointer;" onclick="openCloseMoreBox('arrowIcon', false);"></div></td>
						<td id="more_stations_container" onclick="openCloseMoreBox('moreHeaderText', false);" style="cursor:pointer;"><div id="more_stations_title">__MSG_get_more_stations__</div></td>
						<td id="close_more_td" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';"></td>
					<tr>
				</table>
			</td>
		</tr>
		<tr id="more_box" style="display:none;"><td id="more_td">
				<table cellspacing="0" cellpadding="0" border="0">
					<tr>
						<td colspan="5" style="width:518px; height:35px;background-color:#DCE3EB">
							<table id="search_bar_items" cellspacing="0" cellpadding="0" border="0" style="display:none;">
								<tr>
									<td style="width:15px;height:35px;font-size:0px;">&nbsp;</td>
									<td id="country_filter" style="width:165px; height:35px;"></td>
									<td id="genre_filter" style="width:135px;height:35px;"></td>
									<td id="search" class="search">
									   <form onsubmit="sortAndDisplay(); trackEvent('Search','Enter Input'); return false;" style="padding: 0px; margin: 0px;" >
										    <input name="search" type="text" id="search_input" style="width:166px; border: #888888 1px solid;font-size:11px;font-family:verdana;color:#4C4C4C;" value="__MSG_search_input__" onclick="this.select();"/>
									   </form>
									</td>
									<td style="width:32px;height:35px;text-align:left;vertical-align:middle;padding-left:4px;">
										<div><img id="search_button" src="" style="cursor:pointer;" width="17" height="17" onclick="sortAndDisplay(); trackEvent('Search','searchButton');"/></div>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td style="width:15px;height:25px;font-size:0px;">&nbsp;</td>
						<td title="__MSG_sort_by_country__" style="width:130px; display:none;" onclick="sortAndDisplay('country'); trackEvent('Sort','country');" class="sortTitles" id="country_title" onmouseover="this.style.textDecoration='underline';" onmouseout=" if (lastSort!='country') this.style.textDecoration='none';">__MSG_country__</td>
						<td title="__MSG_sort_by_genre__" style="width:100px;display:none;" onclick="sortAndDisplay('genre'); trackEvent('Sort','genre');" class="sortTitles" id="genre_title" onmouseover="this.style.textDecoration='underline';" onmouseout="if (lastSort!='genre') this.style.textDecoration='none';">__MSG_genre__</td>
						<td title="__MSG_sort_by_name__" style="width:200px;display:none;" onclick="sortAndDisplay('name'); trackEvent('Sort','name');" class="sortTitles" id="name_title" onmouseover="this.style.textDecoration='underline';" onmouseout="if (lastSort!='name') this.style.textDecoration='none';">__MSG_station_name__</td>
						<td style="width:73px;height:25px;font-size:0px;">&nbsp;</td>
					</tr>
					<tr><td id="more_container" colspan="5" height="372" width="518" align="center" valign="top">&nbsp;</td></tr>
				</table>
			</td>
		</tr>
			<tr id="seperator_tr"><td id="seperator_td"></td></tr>
		<tr>
			<td id="submit_header" style="width:520px; height:30px;background-color:#868d96;">
				<table cellspacing="0" cellpadding="0" border="0">
					<tr>
						<td style="width:12px; font-size:0px;"></div></td>
						<td style="width:13px; vertical-align:middle;"><div id="submit_arrow" style="width:13px;height:12px;overflow:hidden;cursor:pointer;" onclick="openCloseSubmitBox('arrowIcon');"></div></td>
						<td id="submit_stations_container" onclick="openCloseSubmitBox('submitHeaderText');" style="cursor:pointer;" ><div id="submit_stations_title">__MSG_submit_new_station__</div></td>
						<td id="close_submit_td" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';"></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td id="submit_box" style="display:none;">
				<div id="submit_div" style="height:107px;">
					<table cellspacing="0" cellpadding="0" border="0">
						<tr>
							<td style="width:20px; height:60px;font-size:0px;">&nbsp;</td>
							<td class="submit_expl" ><strong>__MSG_submit_explanation1__</strong> __MSG_submit_explanation2__</td>
							<td style="width:20px; height:60px;font-size:0px;">&nbsp;</td>
						</tr>
						<tr>
							<td colspan="3" align="center" valign="middle" style="width:518px; height:35px;">
								<table style="height:30px;" cellspacing="0" cellpadding="0" border="0">
									<tr onmouseover="setBackgroundPos('submit_left','0px -31px');" onmouseout="setBackgroundPos('submit_left','0px 0px');" onclick="submit();">
										<td id="submit_left" style="width:34px; height:30px;cursor:pointer;"></td>
										<td id="submit_center">__MSG_submit_yours__</td>
										<td id="submit_right" style="width:6px; height:30px;cursor:pointer;"></td>
									</tr>
								</table>	
							</td>
						</tr>
						<tr><td colspan="3" style="width:518px; height:12px;">&nbsp;</td></tr>
					</table>
				</div>
			</td>
		</tr>
	</table>
</div>

<script type="text/javascript">
	_IG_Analytics("UA-345375-1", "/TV_V2_Canvas");
</script>

]]>
</Content>
</Module>
	
