﻿
    function doMediaSearch(searchBoxID, queryString)
    {
        var searchBox = document.getElementById(searchBoxID);
        window.location.href = appRoot +'/Search.aspx?'+queryString+'&Query='+searchBox.value;
    }

    function showMedia(url)
    {
        openPage(url);
    }
    

    function showRelatedAudio(url)
    {
        openPage(url);
    }
    
    function showRelatedVideo(url)
    {
        openPage(url);
    }
		
	function init() {
		fixTabHeight();
		setupHighlights();
	}
	
	function openLiveStats()
	{
	    openPage('http://203.166.101.35/2gb');
	}

	function openStats(url)
	{
		urlWin = window.open(url,'listenWin','width=670,height=500,scrollbars=yes,resizeable=no,menubar=no,statusbar=no');
    	urlWin.focus();
	}
	
	function openListenLive()
	{
		listenWin = window.open('http://www.2gb.com/rugbyleaguelive/listenlive/','listenWin','width=360,height=650,scrollbars=no,resizeable=no,menubar=no,statusbar=no,directories=no,location=no');
    	listenWin.focus();
	}
	
    function SubmitButtonOnEnterKey(event, buttonid)
    {
	    var ENTER_KEY = 13;
	    var button = document.getElementById(buttonid); 
	    if (typeof button == 'object')
	    { 
		    if(navigator.appName.indexOf("Netscape")>(-1))
		    {
			    if (event.keyCode == ENTER_KEY)
			    { 
				    button.click(); 
				    return false; 
			    } 
		    } 
		    if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		    { 
			    if (event.keyCode == ENTER_KEY)
			    { 
				    button.click(); 
				    return false; 
			    } 
		    } 
	    } 
        return true;
    }

    function urlencode(str) {
        str = escape(str);
        str = str.replace('+', '%2B');
        str = str.replace('%20', '+');
        str = str.replace('*', '%2A');
        str = str.replace('/', '%2F');
        str = str.replace('@', '%40');
        return str;
    }
    	
    function getSearch(queryString)
    {
        inputList = document.getElementsByTagName("INPUT");
        var keywords = '';
        var types = '';
        var mediaTypes = '';
        var text = '';
        var useMedia = false;
        for(i=0;i<inputList.length;i++){
          if (inputList[i].name.indexOf('SearchCat') != -1)
          {
            if (inputList[i].value != '' && inputList[i].checked)
                keywords = keywords+(keywords==''?'':',')+inputList[i].value;
          }
          if (inputList[i].name.indexOf('MediaType') != -1)
          {
            if (inputList[i].value != '' && inputList[i].checked)
            {
            mediaTypes = mediaTypes+(mediaTypes==''?'':',')+inputList[i].value;
            useMedia = true;
            }
          }
          if (inputList[i].name.indexOf('SearchType') != -1)
          {
            if (inputList[i].value != '' && inputList[i].checked)
                types = inputList[i].value;
          } 
          if (inputList[i].name.indexOf('txtSearchMM') != -1)
          {
            if (inputList[i].value.length > 0 && inputList[i].value != 'Search')
            text = inputList[i].value;
          }
          if (inputList[i].name.indexOf('SearchText') != -1)
          {
            if (inputList[i].value.length > 0 && inputList[i].value != 'Search')
            text = inputList[i].value;
          }
        }
          if (useMedia == true)
            types = types+(types==''?'':',')+'1';
        
        window.location.href = appRoot + '/Search.aspx?SearchKeyword='+keywords+'&smt='+mediaTypes+'&st='+types+'&Query='+text;
        
    }