function showtag(tagwords, page )
{
	//alert(newsearchword);
	var str = 'ajax_gen_tags.php?tag='+tagwords;
	
	// show main page
	showpage(page, 'maindiv' , 'maindiv_loading');
	
	// show tag cloud
	showpage(str, 'tags' , 'tags_loading');
}

function set_main_window( page )
{
	showpage(page, 'maindiv' , 'maindiv_loading');
}

function showtag_seachbox(tagwords, page )
{
	var newsearchword = document.forms['searchform'].searchbox.value  ;
	
	// prototype
	//$('searchbox');
	//$F('searchbox');
	
	// jquery
	//$J('#searchbox');
	//.val();
	
	if (newsearchword!="")
	{
		if (tagwords=="")
		{
			tagwords  = newsearchword;
		}			
		else
		{
			tagwords  = tagwords + ','+newsearchword;
		}
		
		page = page + '?tag=' + tagwords;
	}
	
	
	
	showtag(tagwords, page );

}

function close_div(name)
{
	document.getElementById(name).style.display = "none";
}

//function show_dialog_div(url)
//{
//	showpage( url , 'dummywindow4_spare'); 	
//	document.getElementById('dummywindow4_spare').style.display = "block";
//}

function show_window(url,title)
{
	// show prototype window
	win1.setURL(url); 
	win1.setTitle(title);	
	if (win1.visible)
	{		
		win1.show();
	}
	else
	{
		win1.showCenter(false,100);
		win1.centered = false;
	}
}

// this corner thing is buggy
//function tag_headers_rounded()
//{
//	$j("div.rounded_tag_header1").corner("bevel 3px");
//	$j("div.rounded_tag_header2").corner("bevel 3px");			
//}


	var search_item_mark_flag;

	// this will HARD CODED the color of the moused div
	// and will set the div seach_item_desc_div to the given div
	function search_item_mark(obj , descdiv)
	{
		// I have to hard-code the color here.... sorry
		obj.style.background='#3b4f62';

		var text = $(descdiv).innerHTML;
		$('seach_item_desc_div').innerHTML = text;	
		
		search_item_mark_flag = true;
	}
	
	// this will undo the above
	function search_item_unmark(obj , descdiv)
	{
		// I have to hard-code the color here.... sorry
		obj.style.background='';
		//$(divname).style.display = 'none';		
		//var text = $('seach_item_desc_div_default_text').innerHTML;
		//$('seach_item_desc_div').innerHTML = text;
		//cmd = "$('seach_item_desc_div').innerHTML = '"+'text'+"' ";
		cmd = "$('seach_item_desc_div').innerHTML = $('seach_item_desc_div_default_text').innerHTML ";
		
		search_item_mark_flag = false;
		//if (search_item_mark_flag==false) alert('out'); 
		setTimeout("if (search_item_mark_flag==false)" + cmd,1000);
		
	}

	function showdiv( divname )
	{
		document.getElementById(divname).style.display = "block";
	}

	function hidediv( divname )
	{
		document.getElementById(divname).style.display = "none";
	}



	/* ************************************************************************************************
	*  Ajax
	************************************************************************************************* */

	// this will be a generic way to use ajax
	// but I did not build and test it yet
	function ajaxRequest (url, data , action , itemid ) 
	{
		var dt = new Date();
		var nocache = dt.getTime();
	
		var pars = "action="+action + "&data="+data + "&itemid="+itemid + "&nocache="+nocache;
	
		// show the relevent load div
		$('load_'+action+'_'+itemid).style.display = 'block';
		var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: ajaxLoad, onComplete: ajaxShowResponse} );
	}


	// this will be a generic way to use ajax
	// but I did not build and test it yet
	function ajaxLoad () 
	{
	//	$('load').style.display = 'block';
	}
	

	// this will be a generic way to use ajax
	// but I did not build and test it yet
	function ajaxShowResponse (http_request)
	{
		if (http_request.readyState == 4) 
		{
			var decoded = eval("(" + http_request.responseText + ")");
	
			if (decoded.action == "updatefiletype")
			{
					if ( decoded.result == "ok"  )
					{
						//$('status_'+decoded.action).innerHTML = "<font color=green>Valid</font>";
						$('load_'+decoded.action+'_'+decoded.itemid).style.display = 'none';
					}
					else
					{
						alert(decoded.result);
						//$('status_'+decoded.action).innerHTML = "<font color=red>" + decoded.result + "</font>";
						//document.theform.email.focus();
					}
			}
			else if (decoded.action == "updatefiledesc")
			{
	
					if ( decoded.result == "ok"  )
					{
						$('load_'+decoded.action+'_'+decoded.itemid).style.display = 'none';
					}
			}
			else
			{
				//$('status').style.display = 'none';
			}
		}
	}
	
	/* *********************************************************************************************** */
	
