//provide a random timestamp with each call to foil caching
function getTimestamp()
{
	var t = new Date();
	var r = "" + t.getFullYear() + t.getMonth() + t.getDate() + t.getHours() + t.getMinutes() + t.getSeconds(); 

	return(r);
}

function grabTitle(target)
{
	var url = 'http://www.cynocast.com/admin/services/grabtitle.php';
	var pars = 'site=' + target + '&ts=' + getTimestamp();
	
	$('title').className = 'grabloader';
	
	var myAjax = new Ajax.Updater( 'grabsuccess', url, { method: 'get', parameters: pars, evalScripts: true });
}

function saveBookmark(app, script, toSave)
{
	var url = 'http://www.cynocast.com/bookmarks.php';
	var pars = 'a=' + app + '&s=' + script + '&save=' + toSave + '&ts=' + getTimestamp();
	
	var myAjax = new Ajax.Updater( 'bookmark_'+toSave, url, { method: 'get', parameters: pars });
	
	new Effect.Highlight($('saved_li'));	
}

function deleteBookmark(app, script, toDelete)
{
	var url = 'http://www.cynocast.com/bookmarks.php';
	var pars = 'a=' + app + '&s=' + script + '&delete=' + toDelete + '&ts=' + getTimestamp();
	
	var myAjax = new Ajax.Updater( 'bookmarklist', url, { method: 'get', parameters: pars });
}

function updateURLTable(view, channel) {
   try {
	var url = (view == 'saved') ? '/bookmarks.php' : '/channelinfo.php';
	var pars = 'view=' + view + '&a=' + channel + '&b=' + window.last_id;
	//var pars = {'view':view, 'a':channel, 'ts':getTimestamp()};
	 
	/*jQuery.get(url, pars, function(r) {
	   
	});*/
	//new Ajax.Updater('history', url, {method:'get', parameters:pars, evalScripts:true, onComplete:buildCarousel});
	}
	catch(e){alert('Error found in updateURLTable')}
}

function updateURLTableForScript(view, script, page)
{
	if(view == 'saved')
		var url = 'http://www.cynocast.com/bookmarks.php';
	else
		var url = 'http://www.cynocast.com/urltable.php';
		
	var pars = 'view=' + view + '&s=' + script + '&p=' + page + '&ts=' + getTimestamp();	

	if(view == 'all')
		var myAjax = new Ajax.Updater('history', url, { method: 'get', parameters: pars, evalScripts: true, onComplete: buildCarouselAll });
	else
		var myAjax = new Ajax.Updater('history', url, { method: 'get', parameters: pars, evalScripts: true, onComplete: buildCarousel });
}

/* old bookmarks function
function updateBookmarks(app, toSave, toDelete)
{
	var url = 'http://www.cynocast.com/bookmarks.php';
	var pars = 'a=' + app + '&save=' + toSave + '&delete=' + toDelete;
	
	var myAjax = new Ajax.Updater( 'bookmarkmenu', url, { method: 'get', parameters: pars });
}
*/

function setButtonBar(c)
{
	var url = 'http://www.cynocast.net/admin/services/setbuttonbar.php';
	var pars = 'c=' + c + '&ts=' + getTimestamp();	
	var myAjax = new Ajax.Updater( 'buttonbar_confirmation', url, { method: 'get', parameters: pars });
}

function setButtonBar2(s)
{
	var url = 'http://www.cynocast.net/admin/services/setbuttonbar.php';
	var pars = 's=' + s + '&ts=' + getTimestamp();	
	var myAjax = new Ajax.Updater( 'buttonbar_confirmation', url, { method: 'get', parameters: pars });
}
