// JavaScript Document
//confirm delete

	function onay() { return confirm("Are you sure?"); }


function CheckCatalogForm(){
	// Make quick references to our fields
	var auctionNumber = document.getElementById('aucNo');
	var auctionCategory = document.getElementById('aucCat');
	var CatStatus = document.getElementById('CatStatus');
	
	
	// Check each input in the order that it appears in the form!
	if(isSelected(auctionNumber, "Please select auction number")){
	  if(isSelected(auctionCategory, "Please select auction category")){
		   if(isSelected(auctionCategory, "Please specify catalog status")){
	    
									
							return true;
		                     }
						   }
						}
				  return false;
}

function isSelected(elem, helperMsg){
	if(elem.value != 0){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}


function CheckUserForm(){
	// Make quick references to our fields
	var userName = document.getElementById('username');
	var Abb = document.getElementById('code');
	var Email = document.getElementById('email');	
	var Password = document.getElementById('password');
	var ConfirmedPassword = document.getElementById('password_confirm');
	
	//alert ('here');
		
	// Check each input in the order that it appears in the form!
	
	        if(isEmpty(userName, "Provide username")){
		      if(isEmpty(Abb, "User's abbreviation is required")){
			   if(emailValidator(Email, "Please provide a valid email address")){
	            									
							return true;
						 }
				   	}
				}	
			return false;
}

function isEmpty(elem, helperMsg){
	if(elem.value != ''){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}


function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
	
}

/*function changePassword(userId)
{
	window.location.href = 'userindex.php?view=modify&userId=' + userId;
}*/

function ChangeStatus(userId)
{
	if (confirm('Are you sure?')) {
		window.location.href = 'index.php?task=users&a=Cs&userId=' + userId;
	}
}

function getCode(task,co)
{
	window.location.href = 'index.php?task='+ task +'&whsecoId='+co;
}
function limitRecords(task,limit)
{
	window.location.href = 'index.php?task='+ task +'&limit='+limit;
}
function sortrecords(task,broker)
{
	window.location.href = 'index.php?task='+ task +'&broker='+broker;
}

function sr(task,cat)
{
	window.location.href = 'index.php?task='+ task +'&cat='+cat;
}
function sortby(task,sale)
{
	window.location.href = 'index.php?task='+ task +'&sale='+sale;
}

