


		/******************************** General Functions *****************************************/

function isEmail (theStr) 
{
	var atIndex = theStr.indexOf('@');
 	var dotIndex = theStr.indexOf('.', atIndex);
 	var flag = true;
 	theSub = theStr.substring(0, dotIndex+1)
 	if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
 	{	 
 		flag = false; 
 	}
 	else 
	{ 
 		flag = true; 
 	}
 	return(flag);
}
///////////////////////////////////////////////////////////////////////////////////////////
function IsNum(val)
{
	var count=0;
	var flag=true;
	while (count<val.length)
	{
		if (((val.substring(count,count+1)>=0)&&(val.substring(count,count+1)<=9))||(val.substring(count,count+1)==' '))
		{
		}
		else
		{
			flag=false;
		}
		count=count+1;		
	}
	return flag; 
}
///////////////////////////////////////////////////////////////////////////////////////////
function IsFloat(str)
{ 
	var val = parseFloat(str);
    if(isNaN(val))
	   	return false;
    else
	   	return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
function goToeBay(itemno)
{
	window.open('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item='+itemno,'eBay'+itemno,'');
}
///////////////////////////////////////////////////////////////////////////////////////////
function goToSeller(sellername, itemno)
{
	window.open('http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback&amp;userid='+sellername,'eBay'+itemno,'');
}
///////////////////////////////////////////////////////////////////////////////////////////
function validateAddSnipe()
{
	//alert(NoOfSnipesLeft);
	//if (NoOfSnipesLeft < 1)
	//{
	//	alert("Snipe cannot be added you donot have enough snipes in your account.\n You can get free snipes by going to free snipes page from top menu \n or you can buy snipes by going to My Acount page and pay for snipes.");
//	}	
	//else
	 if(!(IsNum(document.addSnipeForm.txtitemno.value)) || document.addSnipeForm.txtitemno.value == "")
	{
		alert("Please Provide A Numeric Item Number");
		document.addSnipeForm.txtitemno.focus();
	}
	else if((!(IsFloat(document.addSnipeForm.txtmaxbid.value))) || document.addSnipeForm.txtmaxbid.value == "")
	{
		alert("Please Enter A Valid Maximum Bid Value");
		document.addSnipeForm.txtmaxbid.focus();
	}
	else if(!(IsNum(document.addSnipeForm.txtqty.value)) || document.addSnipeForm.txtqty.value == "")
	{
		alert("Please Provide Numeric Value In Quantity Feild");
		document.addSnipeForm.txtqty.focus();
	}
	else
	{
		document.addSnipeForm.action = "addNewSnipe.php";
//		alert(document.addSnipeForm.action);
		document.addSnipeForm.submit();
	}
}
/********************************** End of general functions ******************************************/

/**********************************  Script for regStep1.php *******************************************/
							
function validateReg1()
{	
	var passLength = document.regStep1Form.txtpass1.value.length;

	if (!(isEmail(document.regStep1Form.txtemail.value)) || document.regStep1Form.txtemail.value=="")
	{
		alert("Please Enter Your Correct E-mail Address");
		document.regStep1Form.txtemail.focus();
	}
	else if(passLength < 8)
	{
		alert("Password Should Be Atleast 8 Characters Long");
		document.regStep1Form.txtpass1.value = "";
		document.regStep1Form.txtpass2.value = "";
		document.regStep1Form.txtpass1.focus();
	}
	else if(document.regStep1Form.txtpass1.value != document.regStep1Form.txtpass2.value)
	{
		alert("Passwords provided does not match. Passwords must be same");
		document.regStep1Form.txtpass1.value = "";
		document.regStep1Form.txtpass2.value = "";
		document.regStep1Form.txtpass1.focus();
	}
	else if(document.regStep1Form.txtpass1.value == "" && document.regStep1Form.txtpass2.value == "")
	{
		alert("Please Enter The Password");
		document.regStep1Form.txtpass1.focus();
	}
	else if(document.regStep1Form.txtans1.value == "")
	{
		alert("Please Provide The Answer Of First Question");
		document.regStep1Form.txtans1.focus();
	}
	else if(document.regStep1Form.txtans2.value == "")
	{
		alert("Please Provide The Answer Of Second Question");
		document.regStep1Form.txtans2.focus();
	}
	else if(!(document.regStep1Form.terms[0].checked))
	{
		alert("You Must Agree With The User Agreement, Privacy Policy And Terms Before Registering");
		document.regStep1Form.terms[0].focus();
	}
	else
	{
		//document.regStep1Form.action = "regStep2.php";
		document.regStep1Form.submit();
	}
}
///////////////////////////////////////////////////////////////////////////////////////////
/************************************** End Script for regStep1.php *************************/

/*********************************** regStep2.php *******************************************/
function validateReg2()
{
	if(document.regStep2Form.txtebayid.value == "")
	{
		alert("Please Enter Your eBay User ID");
		document.regStep2Form.txtebayid.focus();
	}
	else if(document.regStep2Form.txtebaypass1.value != document.regStep2Form.txtebaypass2.value)
	{
		alert("Passwords Provided Doesnot Match. Passwords Must Be Same");
		document.regStep2Form.txtebaypass1.value = "";
		document.regStep2Form.txtebaypass2.value = "";
		document.regStep2Form.txtebaypass1.focus();
	}
	else if(document.regStep2Form.txtebaypass1.value == "" && document.regStep2Form.txtebaypass2.value == "")
	{
		alert("Please Enter Your eBay Password");
		document.regStep2Form.txtebaypass1.focus();
	}
	else if (!(isEmail(document.regStep2Form.txtfriend.value)) && document.regStep2Form.txtfriend.value != "")
	{
		alert("Please Enter The Correct Email Address Of Your Friend");
		document.regStep2Form.txtfriend.focus();
	}
	else
	{
		//document.regStep2Form.action = "regCompleted.php";
		document.regStep2Form.submit();
	}
}
/*********************************** end of regStep2.php ************************************/

/*********************************** top.php *************************************/
function validateLogin()
{	
	if(!(isEmail(document.loginForm.txtusername.value)) || document.loginForm.txtusername.value == "")
	{
		alert("Your Login Name Is Your E-mail Address, So Please Enter Your Correct E-mail Address");
		document.loginForm.txtusername.focus();
		return false;
	}
	else if(document.loginForm.txtpassword.value == "")
	{
		alert("Please Enter Your Password");
		document.loginForm.txtpassword.focus();
		return false;
	}
	else
	{
		document.loginForm.action = "checkLogin.php";
		document.loginForm.submit();
	}
}
/*********************************** end of top.php *******************************/

/*********************************** pendingAuctions.php *****************************/
function prev(beg1,per_page_rec)
{
	document.pendingForm.beg.value = (beg1*1)- per_page_rec;
	document.pendingForm.submit();
}
///////////////////////////////////////////////////////////////////////////////////////////
function next(beg1,per_page_rec)
{
	document.pendingForm.beg.value = (beg1*1)+ per_page_rec;
	document.pendingForm.submit();
}
///////////////////////////////////////////////////////////////////////////////////////////
function gotopage(per_page_rec)
{
	//alert(per_page_rec);
	var abc = document.pendingForm.jumppage.selectedIndex;
	var val = document.pendingForm.jumppage[abc*1].value;
	document.pendingForm.beg.value = ((val*1)*per_page_rec)-per_page_rec;
	document.pendingForm.submit();
}
///////////////////////////////////////////////////////////////////////////////////////////
function deletePending()
{
	var bOK; 
	var selItems = 0; 
	selItems = SelectedItems1(); 

	if (selItems == 0) 
	{ 
		alert("First Select a record!"); 
	} 
	else  
	{  
		bOK = confirm("Are you Sure you Want to Delete The Selected Records?"); 
	
		if(bOK) 
  		{ 
 	 		document.pendingForm.action = 'deletePending.php';
			document.pendingForm.submit();
		}
 	}
}
///////////////////////////////////////////////////////////////////////////////////////////
function SelectedItems1() 
{ 
	var count=0; 
 	var i=0; 
 	var selItems=0; 
 	count=(document.pendingForm.sid.length); 
 	if (count>1) 
  	{ 
   		for(i=0;i<count;i++) 
   		{ 
    		if (document.pendingForm.sid[i].checked==true) 
     		{ 
       			selItems=selItems+1; 
     		} 
   		} 
  	} 
 	else 
 	{ 
  		if (document.pendingForm.sid.checked==true) 
  		{ 
   			selItems=selItems+1; 
  		} 
	} 
 	
	return selItems; 
}
/////////////////////////////////////////////////////////////////////////
function editAuction()
{
	pageValue = document.pendingForm.beg.value;
	var bOK; 
 	var selItems = 0; 
	var checkedSid;
 	selItems = SelectedItems1(); 
 	if (selItems == 0) 
 	{ 
 		alert("First Select a record!"); 
 	} 
 	else if (selItems > 1) 
 	{ 
 		alert("Select Only one record at a time!"); 
	} 
 	else 
 	{ 
 		var sidLength = document.pendingForm.sid.length;
		if(sidLength > 1)
		{
			for(i=0; i<sidLength; i++)
			{
				if(document.pendingForm.sid[i].checked == true)
				{
					checkedSid = document.pendingForm.sid[i].value;
				}
			}
		}
		else
		{
			if(document.pendingForm.sid.checked == true)
			{
				checkedSid = document.pendingForm.sid.value;
			}
		}
		
		window.open('editAuction.php?aid='+checkedSid+'&pval='+pageValue,'EditAuction','left=300,top=210,scrollbars=yes,resizable=no,width=500,height=360');
	}
}
/*********************************** end of pendingSnipes.php **********************/
/************************** editAuction.php ***************************/
function validateEditAuction()
{
	if(!(IsNum(document.editAuctionForm.txtqty.value)) || document.editAuctionForm.txtqty.value == "")
	{
		alert("Please Provide A Numeric Item Quantity");
		document.editAuctionForm.txtqty.focus();
	}
	else if((!(IsFloat(document.editAuctionForm.txtamount.value))) || document.editAuctionForm.txtamount.value == "")
	{
		alert("Please Enter A Valid Maximum Bid Value");
		document.editAuctionForm.txtamount.focus();
	}
	else
	{
		document.editAuctionForm.action = 'updateAuction.php';
		document.editAuctionForm.submit();
	}
}
/**********************************************************************/

/*********************************** pastAuctions.php *****************************/
function prev1(beg1,per_page_rec)
{
	document.pastForm.beg.value = (beg1*1)- per_page_rec;
	document.pastForm.submit();
}
///////////////////////////////////////////////////////////////////////////////////////////
function next1(beg1,per_page_rec)
{
	document.pastForm.beg.value = (beg1*1)+ per_page_rec;
	document.pastForm.submit();
}
///////////////////////////////////////////////////////////////////////////////////////////
function gotopage1(per_page_rec)
{
	//alert(per_page_rec);
	var abc = document.pastForm.jumppage.selectedIndex;
	var val = document.pastForm.jumppage[abc*1].value;
	document.pastForm.beg.value = ((val*1)*per_page_rec)-per_page_rec;
	document.pastForm.submit();
}
/*
function prev1(beg1)
{
	document.pastForm.beg.value = (beg1*1)-5;
	document.pastForm.submit();
}
///////////////////////////////////////////////////////////////////////////////////////////
function next1(beg1)
{
	document.pastForm.beg.value = (beg1*1)+5;
	document.pastForm.submit();
}
///////////////////////////////////////////////////////////////////////////////////////////
function gotopage1()
{
	var abc = document.pastForm.jumppage.selectedIndex;
	var val = document.pastForm.jumppage[abc*1].value;
	document.pastForm.beg.value = ((val*1)*5)-5;
	document.pastForm.submit();
}*/
///////////////////////////////////////////////////////////////////////////////////////////
function deletePast()
{
	var bOK; 
	var selItems = 0; 
	selItems = SelectedItems2(); 

	if (selItems == 0) 
	{ 
		alert("First Select a record!"); 
	} 
	else  
	{  
		bOK = confirm("Are you Sure you Want to Delete The Selected Records?"); 
	
		if(bOK) 
  		{ 
 	 		document.pastForm.action = 'deletePastSnipes.php';
			document.pastForm.submit();
		}
 	}
}
///////////////////////////////////////////////////////////////////////////////////////////
function SelectedItems2() 
{ 
	var count=0; 
 	var i=0; 
 	var selItems=0; 
 	count=(document.pastForm.sid.length); 
 	if (count>1) 
  	{ 
   		for(i=0;i<count;i++) 
   		{ 
    		if (document.pastForm.sid[i].checked==true) 
     		{ 
       			selItems=selItems+1; 
     		} 
   		} 
  	} 
 	else 
 	{ 
  		if (document.pastForm.sid.checked==true) 
  		{ 
   			selItems=selItems+1; 
  		} 
	} 
 	
	return selItems; 
}

function showHideLostAuction()
{
	if(document.pastForm.lost_auctions.value > 0 )
	{
		document.pastForm.lost_auctions.value=0;
	}
	else
		document.pastForm.lost_auctions.value =1;
	document.pastForm.submit();	
}
/////////////////////////////////////////////////////////////////////////
 /**************************** pastAuctions.php ***********************/
 
 /**************************** userOptions.php *************************/
function updateOptions1()
{
	if(!(IsNum(document.optionForm.txtresult.value)) || document.optionForm.txtresult.value == "")
	{
		alert("Results Per Page Should Be An Integer Value, Please Enter A Correct Value");
		document.optionForm.txtresult.focus();
	}
	else
	{
		document.optionForm.action = 'updateOptions.php';
		document.optionForm.submit();
	}
} 
////////////////////
function validateEbayDetail()
{
	if(document.ebayForm.txtebayuname.value == "")
	{
		alert("Please Enter Your Ebay UserId");
		document.ebayForm.txtebayuname.focus();
	}
	else if(document.ebayForm.txtebaypass.value == "")
	{
		alert("Please Enter eBay Password");
		document.ebayForm.txtebaypass.focus();
	}
	else if(!(isEmail(document.ebayForm.txtebayemail.value)) || document.ebayForm.txtebayemail.value == "")
	{
		alert("Please Enter Correct E-mail Address");
		document.ebayForm.txtebayemail.focus();
	}
	else
	{
		document.ebayForm.action = 'updateOptions.php';
		document.ebayForm.submit();
	}
}
///////////////////////
function validateYahooDetails()
{
	if(!(isEmail(document.yahooForm.txtyahoouname.value)) || document.yahooForm.txtyahoouname.value == "")
	{
		alert("Please Enter Your Correct Yahoo Email Address");
		document.yahooForm.txtyahoouname.focus();
	}
	else if(document.yahooForm.txtyahoopass.value == "")
	{
		alert("Please Enter Your Yahoo Password");
		document.yahooForm.txtyahoopass.focus();
	}
	else
	{
		document.yahooForm.action = 'updateOptions.php';
		document.yahooForm.submit();
	}
}
 /**************************** userOptions.php *************************/
 
 /**********************Forgot Password***************************/
 function validateForgotEmail()
 {
	if(!(isEmail(document.frm_forgot_password.user_name.value)) || document.frm_forgot_password.user_name.value == "")
	{
		alert("Please Enter Your Correct Email Address");
		document.frm_forgot_password.user_name.focus();
	}
	else
	{
		document.frm_forgot_password.action = 'sendPassword.php';
		document.frm_forgot_password.submit();
	}
 }
  /**********************Forgot Password***************************/

/**************************** bulkAdd.php *****************************/
function validateBulkAdd()
{
	if(document.form1.bulk_snipes.value == "")
	{
		alert("Please Enter Some Information Of The Product You Want To Bid For!");
		document.form1.bulk_snipes.focus();
	}
	else
	{
		document.form1.submit();
	}
}
/**********************************************************************/