var browser = navigator.appName;
function doSaveAs()
{
	if (document.execCommand)
	{
		document.execCommand("SaveAs")
	}
	else 
	{
		alert("Save-feature available only in Internet Exlorer 5.x or greater.")
	}
}
function doPost(id, sm)
{
	if(browser=="Netscape")
	{
		docSm = document.getElementById("sm");
		docId = document.getElementById("id");
		docSm.value = sm;
		docId.value = id;
		document.form.action = "viewPic.php?id="+id;
		document.form.submit();

		/*
		search = document.getElementById("search");
		document.form.action = "viewPic.php?id="+id;
		document.form.submit();
		*/
	}
	else
	{
		window.form.action="viewPic.php?id="+id;
		window.form.sm.value = sm;
		window.form.id.value = id;
		window.form.submit();
	}
}
function doSetSortMode(sm, id)
{
	
	if(browser=="Netscape")
	{
		docSm = document.getElementById("sm");
		docId = document.getElementById("id");
		docSm.value = sm;
		docId.value = id;
		document.form.submit();
	}
	else
	{
		var f = window.form;
		f.sm.value = sm;
		f.id.value = id;
		f.submit();
	}
	
}

function setUserId()
{
	if(browser=="Netscape")
	{
		uid = document.getElementById("uid");
		pwd = document.getElementById("pwd");
		if(uid.value.length==0)
		{
			uid.focus();	
		}
		else
		{
			pwd.focus();
		}
	}
	else
	{
		f = window.form;
		if(f.uid.value.length == 0)
		{
			f.uid.focus();	
		}	
		else
		{	
			f.pwd.focus();
		}
	}
}
function setControlFocus(id)
{
		ctrl = document.getElementById(id);
		ctrl.focus();
		ctrl.select();
}
function classChange(element,newclass) 
{
	element.className = newclass;
}
function setNewsContext(url)
{
	loc = "newsReader.php?news_url=" + url;
	top.frames["news"].location=loc;
}
function getNewsContext()
{
	var selObj = document.getElementById('news_url');
	selObj.options[0].selected=true;
	setNewsContext(selObj.value);
}
function openWindow(url, width, height)
{
	window.open (url,"about","height=" + height + ",width=" + width + ",resizable=yes,status=yes,location=no,statusbar=no,toolbar=no,menubar=no,scrollbars=yes,directories=no");
}
function doFormSubmit()
{
	if(browser=="Netscape")
	{
		document.form.submit();
	}
	else
	{
		window.form.submit();
	}

}
function doChangeChannel(channelId)
{
    ch = document.getElementById("channelChanged");
	ch.value = channelId;

	if(browser=="Netscape")
	{
		document.form.submit();
	}
	else
	{
		window.form.submit();
	}

}
function hidediv(id) 
{
	//safe function to hide an element with a specified id
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else 
	{
		if (document.layers) 
		{ // Netscape 4
			document.id.display = 'none';
		}
		else 
		{ // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
function showdiv(id) 
{
	//safe function to show an element with a specified id
		  
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else 
	{
		if (document.layers) 
		{ // Netscape 4
			document.id.display = 'block';
		}
		else
		{ // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
function togglediv(id)
{
	var currentSateOn = false;
	
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		if(document.getElementById(id).style.display == 'block')
		{
			currentSateOn = true;
		}
	}
	else 
	{
		if (document.layers) 
		{ // Netscape 4
			if(document.id.display == 'block')
			{
				currentSateOn = true;
			}
		}
		else 
		{ // IE 4
			if(document.all.id.style.display == 'block')
			{
				currentSateOn = true;
			}
		}
	}

	if(currentSateOn)
	{
		hidediv(id);
	}
	else
	{
		showdiv(id);
	}
	
}


