
function validateUserid(userid, pwd){
	
	// This function is used to validate a given userid 
	// address for the proper syntax
	
	if (userid == ""){
		return false;
	}
	
	return true;
}
function validatenewsfile(newsfilename){
	var i;
	var count1;
	
	var isok = "";
	var charcheck;
	var hold1;
	var hold2;
	var hold3;
	
	//alert(newsfilename);
	if(newsfilename == ""){
		
		return false;
		}
	
	
	
	for (i=0; i<newsfilename.length; i++){
	charCheck = newsfilename.charAt(i);
	if(charCheck != " "){
		isok = "ok";
		break;
		}
	}

	if(isok == "")
		{
		return false;
		}
	//strip leading spaces
	hold1 = "";
	for (i; i<newsfilename.length; i++)
		{
		charCheck = newsfilename.charAt(i);
		hold1 = hold1 + charCheck;
		}



	//strip trailing spaces
	hold2 = "";
	for (i = (hold1.length - 1); i >= 0; i--)
		{
		charCheck = hold1.charAt(i);
	
		if(charCheck != " ")
			{
			break;
			}
	}

	for (count1 = 0; count1 < (i + 1); count1++)
		{
		charCheck = hold1.charAt(count1);
		hold2 = hold2 + charCheck;
		}

	//alert(hold2);
	count1 = 0;
	hold3 = "";
	
	var gotspace = 0;
	var testlen = hold2.length;
	for(count1 = 0; count1 < testlen; count1++)
		{
		charCheck = hold2.charAt(count1);
		if(charCheck == " ")
			{
			if(gotspace == 0)
				{
				hold3 = hold3 + charCheck;
				}
			gotspace = 1;
			}
		else
			{
			gotspace = 0;
			if(charCheck == "&")
				{
				charCheck = "-";
				hold3 = hold3 + charCheck;
				}
			else if(charCheck != "'" && charCheck != "\"")
				{
				hold3 = hold3 + charCheck;
				}
			}
		}
	
	
	if(hold3.length <= 0)
		{
		return false;
		}
	//newsfilename = hold2;
	//alert(hold3);
	return hold3;
	}

function newencryptpassword(password){
		
	
		var adder = 1;
		var nchar1;
		var m_rawpassword;
		var m_encpassword = "";
		m_rawpassword = password;
		var ulen = m_rawpassword.length;
		ulen--;
		while(ulen >= 0)
			{
			nchar1 = m_rawpassword.charCodeAt(ulen);
			if(adder == 1)
				{
				adder = 0;
				nchar1 = nchar1 + 256;
				m_encpassword = m_encpassword + nchar1;
				m_encpassword = m_encpassword + "*";
				}
			else
				{
				adder = 1;
				nchar1 = nchar1 + 128;
				m_encpassword = m_encpassword + nchar1;
				m_encpassword = m_encpassword + ")";
				}
			
			ulen--;
			}
		return m_encpassword;
	
		}
		
function valid_search(qsearch){
	var i;
	var charcheck;
	var isok = "";
	var hold1 = "";
	var hold2 = "";
	
	
	if(qsearch == "")
		{
		return hold2;
		}
	
	for (i=0; i < qsearch.length; i++)
		{
		charCheck = qsearch.charAt(i);
		if(charCheck != " ")
			{
			isok = "ok";
			break;
			}
		}
	
	if(isok == "")
		{
		return hold2;
		}
	//strip leading spaces
	
	
	hold1 = "";
	for (i; i < qsearch.length; i++)
		{
		charCheck = qsearch.charAt(i);
		hold1 = hold1 + charCheck;
		}
	//var testlen = hold1.length;
	//alert(testlen);
	//strip trailing spaces
	hold2 = "";
	
	for (i = (hold1.length - 1); i >= 0; i--)
		{
		charCheck = hold1.charAt(i);
			
		if(charCheck != " ")
			{
			break;
			}
		}
	
	//alert(hold1);
	for (count1 = 0; count1 < (i + 1); count1++)
		{
		charCheck = hold1.charAt(count1);
		//alert(charCheck);
		if(charCheck == "+")
			{
			//alert(charCheck);
			hold2 = hold2 + charCheck;
			}
		if(charCheck == " ")
			{
			//alert(charCheck);
			charCheck = "+";
			}
		if(charCheck != "'")
			{
			hold2 = hold2 + charCheck;
			}
		}
	//var testlen = hold2.length;
	
	//alert(testlen);
	//alert(hold2);
	return hold2;
	}
	
function valid_date(inyear, inmonth, inday)
	{
	//alert(inyear);
	//alert(inmonth);
	//alert(inday);
	if(inyear.length != 4)
		{
		return false;
		}
	if(inyear.length < 4)
		{
		return false;
		}
	var numyear = parseInt(inyear, 10);
	
	if(numyear <= 0)
		{
		return false;
		}
	if(inmonth.length <= 0)
		{
		return false;
		}
	if(inmonth.length > 2)
		{
		return false;
		}
	var nummonth = parseInt(inmonth, 10);
	//alert(nummonth);
	if(nummonth < 1)
		{
		return false;
		}
	if(nummonth > 12)
		{
		return false;
		}
	
	if(inday.length <= 0)
		{
		return false;
		}
	if(inday.length > 2)
		{
		return false;
		}
	var numday = parseInt(inday, 10);
	if(numday < 1)
		{
		return false;
		}
	if(nummonth == 2)
		{
		if(numday > 29)
			{
			return false;
			}
		}
	else
		{
		if(numday > 31)
			{
			return false;
			}
		}
	
	return true;
	}
function validatecodes(newsfilename){
	var i;
	var count1;
	var isok = "";
	var charcheck;
	var hold1;
	var hold2;
	
	
	for (i=0; i<newsfilename.length; i++){
	charCheck = newsfilename.charAt(i);
	if(charCheck != " "){
		isok = "ok";
		break;
		}
	}

	if(isok == "")
		{
		return false;
		}
	//strip leading spaces
	hold1 = "";
	for (i; i<newsfilename.length; i++)
		{
		charCheck = newsfilename.charAt(i);
		hold1 = hold1 + charCheck;
		}



	//strip trailing spaces
	hold2 = "";
	for (i = (hold1.length - 1); i >= 0; i--)
		{
		charCheck = hold1.charAt(i);
	
		if(charCheck != " ")
			{
			break;
			}
		}

	for (count1 = 0; count1 < (i + 1); count1++)
		{
		charCheck = hold1.charAt(count1);
		hold2 = hold2 + charCheck;
		}

	count1 = 0;
	hold3 = "";
	
	var gotspace = 0;
	var testlen = hold2.length;
	for(count1 = 0; count1 < testlen; count1++)
		{
		charCheck = hold2.charAt(count1);
		if(charCheck == " ")
			{
			if(gotspace == 0)
				{
				hold3 = hold3 + charCheck;
				}
			gotspace = 1;
			}
		else
			{
			gotspace = 0;
			if(charCheck == "&")
				{
				charCheck = "-";
				hold3 = hold3 + charCheck;
				}
			//else if(charCheck != "'" && charCheck != "\"")
			else if(charCheck != "'")
				{
				hold3 = hold3 + charCheck;
				}
			}
		}
	
	
	if(hold3.length <= 0)
		{
		return false;
		}
	//newsfilename = hold2;
	//alert(newsfilename);
	return  hold3;
	}
function hide_dropdowns()
	{
	//alert("test");
	return;
	/*
	
	var cobj1=window.document.getElementById("D-1");
	cobj1.style.display="none";
	var cobj1=window.document.getElementById("M-1");
	cobj1.style.display="none";
	var cobj2=window.document.getElementById("C-1");
	cobj2.style.display="none";
	var cobj3=window.document.getElementById("S-1");
	cobj3.style.display="none";
	var cobj4=window.document.getElementById("P-1");
	cobj4.style.display="none";
	*/
	}
function shownow1()
	{
	var cobj1=window.document.getElementById("D-1");
	cobj1.style.display="none";
    //var cobj5=window.document.getElementById("M-1");
	//cobj5.style.display="none";
	
	var cobj3=window.document.getElementById("S-1");
	cobj3.style.display="none";
	
	var cobj4=window.document.getElementById("P-1");
	cobj4.style.display="none";
	
	var cobj2=window.document.getElementById("C-1");
	var statenow = cobj2.style.display;
	if(statenow != "none")
		{
		cobj2.style.display="none";
		}
	else
		{
		cobj2.style.display="";
		}
	}
function shownow2()
	{
	var cobj2=window.document.getElementById("C-1");
	cobj2.style.display="none";
	//var cobj5=window.document.getElementById("M-1");
	//cobj5.style.display="none";
	
	var cobj3=window.document.getElementById("S-1");
	cobj3.style.display="none";
	
	var cobj4=window.document.getElementById("P-1");
	cobj4.style.display="none";
	
	var cobj1=window.document.getElementById("D-1");
	var statenow = cobj1.style.display;
	if(statenow != "none")
		{
		cobj1.style.display="none";
		}
	else
		{
		cobj1.style.display="";
		}
	
	}
function shownow3()
	{
	
	var cobj2=window.document.getElementById("C-1");
	
	
	cobj2.style.display="none";
	
	
	var cobj1=window.document.getElementById("D-1");
	cobj1.style.display="none";
	
	//var cobj5=window.document.getElementById("M-1");
	//cobj5.style.display="none";
	
	var cobj4=window.document.getElementById("P-1");
	cobj4.style.display="none";
	
	var cobj3=window.document.getElementById("S-1");
	var statenow = cobj3.style.display;
	if(statenow != "none")
		{
		cobj3.style.display="none";
		}
	else
		{
		cobj3.style.display="";
		}
	
	}
function shownow4()
	{
	var cobj2=window.document.getElementById("C-1");
	cobj2.style.display="none";
	
	var cobj1=window.document.getElementById("D-1");
	cobj1.style.display="none";
	
	//var cobj5=window.document.getElementById("M-1");
	//cobj5.style.display="none";
	
	var cobj3=window.document.getElementById("S-1");
	cobj3.style.display="none";
	
	
	var cobj4=window.document.getElementById("P-1");
	var statenow = cobj4.style.display;
	if(statenow != "none")
		{
		cobj4.style.display="none";
		}
	else
		{
		cobj4.style.display="";
		}
	
	}
function shownow5()
	{
	var cobj2=window.document.getElementById("C-1");
	cobj2.style.display="none";
	
	var cobj1=window.document.getElementById("D-1");
	cobj1.style.display="none";
	
	var cobj1=window.document.getElementById("P-1");
	cobj1.style.display="none";
	
	var cobj3=window.document.getElementById("S-1");
	cobj3.style.display="none";
	
	/*
	var cobj5=window.document.getElementById("M-1");
	var statenow = cobj5.style.display;
	if(statenow != "none")
		{
		cobj5.style.display="none";
		}
	else
		{
		cobj5.style.display="";
		}
	*/
	}
function show_dropdowns1()
	{
	var cobj2=window.document.getElementById("C-1");
	cobj2.style.display="";
	}
function show_dropdowns2()
	{
	var cobj1=window.document.getElementById("D-1");
	cobj1.style.display="";
	}
function show_dropdowns3()
	{
	
	var cobj1=window.document.getElementById("S-1");
	cobj1.style.display="";
	}
function show_dropdowns4()
	{
	var cobj1=window.document.getElementById("P-1");
	cobj1.style.display="";
	}