
function isProperWS(string)
{
	if (!string) return false;
		var iChars = '|,\<>[]{&}`\;()@$#%';

	for (var i = 0; i < string.length; i++)
	{
		if (iChars.indexOf(string.charAt(i)) != -1)
			return false;
	}

	return true;
}





function trim(strText)
{
    // this will get rid of leading spaces
    while (strText.substring(0,1) == ' ')
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

return strText;
}


function isEmail(string) 
{
	if (!string)
	{
		return false;
	}
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	{
	    return true;
	}
	else
	{
		return false;
	}
}

function clearBox()
{
	if (document.frmWordSearch.txtArchiveSearch.value == "Enter search term")
	{
		document.frmWordSearch.txtArchiveSearch.value="";
	}
	else
	{
		// Do nothing
	}
	
}


function checkEnter(e)
{ 
var characterCode							//literal character code will be stored in this variable

	 if(e && e.which)
	 {										//if which property of event object is supported (NN4)
		e = e
		characterCode = e.which				//character code is contained in NN4's which property
	 }
	 else
	 {							
		e = event						
		characterCode = e.keyCode			//character code is contained in IE's keyCode property
	 }
	 
	 
	 if(characterCode == 13)
	 {										//if generated character code is equal to ascii 13 (if enter key)
		//document.forms[0].submit()			//submit the form
		StartWordSearch()
		return false 
	 }
	 else
	 {
		return true 
	 }
}



function ViewArticle(URL)
{
	WARCWindow3 = window.open(URL,'popupWindow','width=800,height=500,"IJMR Article Viewer",top=20,left=20,resizable=yes,toolbar=no,menubar=yes,location=no,status=yes,directories=no,scrollbars=yes');
				if (!WARCWindow3.opener)
					WARCWindow3.opener = self;
}	


function PrintFrame()
{
	parent.Article.focus();	
	window.parent.frames[1].print();
}



function HomepageLogin()
{
			
	if (document.frmLoginHome.txtUsername.value.length <=0)
	{
		alert("Please make sure you have entered a valid username");
		return
	}
			
	if (document.frmLoginHome.txtPassword.value.length <=0)
	{
		alert("Please make sure you have entered a valid password");
		return
	}
			
	if (document.frmLoginHome.txtPassword.value.length <=0)
	{
		alert("Please make sure you have entered a valid password");
		return
	}


	result = isProperWS(document.frmLoginHome.txtUsername.value)
		
	if (result != true)
	{
		alert("Invalid characters used in your username, '*|,\":<>[]{}`\';()@&$#%'")
		return;
	}
			
	result = isProperWS(document.frmLoginHome.txtPassword.value)
			
	if (result != true)
	{
		alert("Invalid characters used in your password, '*|,\":<>[]{}`\';()@&$#%'")
		return;
	}
			
	//Username = trim(document.frmLoginHome.txtUsername.value.substring(0,3))
		
			
						
	document.frmLoginHome.submit();
}	
