function launchRankings(obj)
	{
		var catid = obj.value;
		
		if (catid != '')
		{
			$('RankingRow').style.display = '';
			ajax('/controllers/ajax.php?a=rankingsInCat&category_id='+catid+'&TargetId=RankingId');
		}
		
	}
	
	function launchRankingsNew(obj)
	{
		var catid = obj.value;

		if (catid != '')
		{
			
			ajax_json('/controllers/ajax.php?a=rankingsInCatNew&category_id='+catid+'&TargetId=RankingId');
		}
		
	}

function ajax(url, onLoading)
{
	new Ajax.Request(url, {
	method: 'get',
	onSuccess: function(transport) {
		eval(transport.responseText);
		//alert(transport.responseText);
	},
	onLoading: function(){
		launchOnLoading(onLoading);
	},
	onFailure : function(transport){
		alert(transport.status);
	}
	
	});
}

function ajax_json(url)
{
	new Ajax.Request(url, {
	method: 'get',
	onSuccess: function(transport) {
		buildMainSelect(eval(transport.responseText));
		//alert(transport.responseText);
	},
	
	onFailure : function(transport){
		alert(transport.status);
	}
	
	});
}

function buildMainSelect(json)
{
    var form = document.getElementById('editForm');
    var selectObj = document.createElement('select');
    selectObj.setAttribute('name','ranking_id');
    selectObj.setAttribute('id','ranking_id');
    selectObj.className='selectStyle';
    
    buildOption("<Select Ranking>", "", selectObj);
    
    for( var i = 0; i < json.length; i++)
    {
        var count = json[i]['sites_count'];
        var toplist_url = json[i]['toplist_url'];
        var text = toplist_url + ' (' + count + ')';
        var toplist_id = json[i]['toplist_id'];
        buildOption(text, toplist_id, selectObj);
    }
    form.appendChild(selectObj);
    var RankingId = document.getElementById('RankingId');
    RankingId.innerHTML = '';
    RankingId.appendChild(selectObj);
}

function buildOption(text, value, selectObj)
{
    var oOption = document.createElement("option");
    var text=document.createTextNode(text);
    oOption.setAttribute("value", value);
    oOption.appendChild(text);
    selectObj.appendChild(oOption);
}


function launchOnLoading(param)
{
	if (param == 'wait')
	{
		//$('info_form').style.display = 'none';
		$('loadingTD').style.display = '';
	}
	else if (param == 'wait_new')
	{
		//$('loader2').style.display = '';
	}
	else if (param == 'loading_gmail')
	{
		var el = document.getElementById('progress');
		el.innerHTML = "<span style=font-size:14px;color:#fff;padding:3px;>loading...</span>";
	}
}

function ajax_debug(url)
{
	new Ajax.Request(url, {
	method: 'get',
	onSuccess: function(transport) {
		alert(transport.responseText);
	}
	});
}

function $(id)
{
	return document.getElementById(id);
}

function show_hide(id)
{
	if ($(id).style.display == 'none')
		$(id).style.display = '';
	else
		$(id).style.display = 'none';
}

function showId(id)
{
	$(id).style.display = '';
}

function hideId(id)
{
	$(id).style.display = 'none';
}

