/*
general scripts
*/


function ArticlePopup(newsArticleID){
	var Url;
	var name;
	var parameters;
	
	Url = "pages/articlepopup.jsp?newsArticleID="+ newsArticleID;
	name = "BuyPopup";
	parameters = "addressbar=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=450,height=500";
	open(Url, name, parameters);		
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function checkLogin()
{

    var userName;
    var passWord;
	var form;
	
	form = document.logonForm;

	userName = form.username.value;
	passWord = form.password.value;
	
	if (userName.length < 1){
		form.username.focus(); 
		alert("Please enter a Username.");
		return;
	}
	
	if (passWord.length < 1){
		form.password.focus(); 
		alert("Please enter a password.");
		return;
	}
	
	form.submit();
	
}

function password()
{

    var userName;
   	var form;
	
	form = document.logonForm;

	userName = form.username.value;
		
	if (userName.length < 1){
		form.username.focus(); 
		alert("Please enter a Username.");
		return;
	}
	
	form.action="../../extranet/forgottenPassword.do";
	form.submit();
	
}

 function downloadNow(file,redUrl,extUrl) {
        var browser = (window.navigator.userAgent.indexOf("SV1") != -1);
        if (browser && extUrl==0) {
						window.open(file,'dlnow','toolbar=0,location=no,directories=0,status=0, scrollbars=no,resizable=0,width=1,height=1,top=0,left=0');
						window.focus();
	        	location.href = redUrl + '?idl=n';
        } else {
            location.href = redUrl;
        }
    }
	
	function CheckForm() {

	if (document.report.startdate.value == ""){
		alert("Please enter a 'Date From' before submitting the report.");
		return false;
	} else if (document.report.startdate.value != "" && document.report.enddate.value != ""){
		
		var StartDate = new String(document.report.startdate.value);
		var EndDate = new String(document.report.enddate.value);
		
		StartDate = StartDate.substring(6,10) + StartDate.substring(3,5) + StartDate.substring(0,2);
		StartDate = parseInt(StartDate);
		
		EndDate = EndDate.substring(6,10) + EndDate.substring(3,5) + EndDate.substring(0,2);
		EndDate = parseInt(EndDate);
				
		if( StartDate > EndDate) {
			alert("Please enter a 'Date To' that is larger than the 'Date From'");
			return false;
		} 
		
		return true;
	
	} else if (document.report.enddate.value == ""){
		document.report.enddate.value = document.report.startdate.value;
		return true;
	} else {
		return true;
	}
	
}


function clearForm() {
	document.report.startdate.value = "";
	document.report.enddate.value = "";
}

function resetForm() {
	document.report.companyID.selectedIndex ="All";  
	document.report.productID.selectedIndex ="All";  
	document.report.module.selectedIndex ="All";  
	document.report.userName.selectedIndex ="All";  
	document.report.ip.selectedIndex ="All";  
	
	document.report.gpCompanyID.selectedIndex ="All";  
	document.report.gpProductID.selectedIndex ="All";  
	document.report.gpModule.selectedIndex ="All";  
	document.report.gpUserName.selectedIndex ="All";  
	document.report.gpIp.selectedIndex ="All";  
	
	document.report.orderBy.selectedIndex ="NONE";  
	document.report.orderType.selectedIndex ="All";  
 
}

function groupBy(listBox ) {
	
	if (listBox == "gpCompanyID"){
		document.report.gpProductID.selectedIndex ="All";  
		document.report.gpModule.selectedIndex ="All";  
		document.report.gpUserName.selectedIndex ="All";  
		document.report.gpIp.selectedIndex ="All";  
 
	}
	
	if (listBox == "gpProductID"){
		document.report.gpCompanyID.selectedIndex ="All";  
		document.report.gpModule.selectedIndex ="All";  
		document.report.gpUserName.selectedIndex ="All";  
		document.report.gpIp.selectedIndex ="All";  
 
	}
	
	if (listBox == "gpModule"){
		document.report.gpCompanyID.selectedIndex ="All";  
		document.report.gpProductID.selectedIndex ="All";  
		document.report.gpUserName.selectedIndex ="All";  
		document.report.gpIp.selectedIndex ="All";  
 
	}
	
	if (listBox == "gpUserName"){
		document.report.gpCompanyID.selectedIndex ="All";  
		document.report.gpProductID.selectedIndex ="All";  
		document.report.gpModule.selectedIndex ="All";  
		document.report.gpIp.selectedIndex ="All";  
 
	}
	
	if (listBox == "gpIp"){
		document.report.gpCompanyID.selectedIndex ="All";  
		document.report.gpProductID.selectedIndex ="All";  
		document.report.gpModule.selectedIndex ="All";  
		document.report.gpUserName.selectedIndex ="All";  
 
	}

}