// Define Form Object
var obj
obj = "document.form1."

//Common Validate Function to Check Blank Values
function validate(arrFields)
{
	var FieldsArr = arrFields.split(",");
	var arrLen = FieldsArr.length;
	returnStr = "";
	
	for (i=0;i<arrLen;i++)
	{
		indFields = FieldsArr[i].split(":");
		if(eval(obj+indFields[0]+".value")=="")
		{
			returnStr = FieldsArr[i];
			break;
		}
	}
	return returnStr;
}

//function to check email
function chkEmail(strEmail)
{
	if(eval(obj+strEmail+".value").indexOf("@")< 1 || eval(obj+strEmail+".value").indexOf(".")< 1 || eval(obj+strEmail+".value").length < 5)
		return false;
	else
		return true;	
} 

//Function to Check Login Characters
function chkLogin(strLogin)
{
	blnflag = true;
	strLen = strLogin.length;
	for(i=0;i<strLen;i++)
	{
		theChar="";
		theChar=strLogin.substring(i,i+1)
		theChar=theChar.toLowerCase();
		if((theChar < "0" || theChar > "9") && (theChar < "a" || theChar > "z") && (theChar!="_"))
		{
			blnflag = false;
			break;
		}
	}
	return blnflag;
}

//Function to Check Equality 
function chkEquality(firstVal,secondVal)
{
	if (eval(obj+firstVal+".value")!=eval(obj+secondVal+".value"))
		return false;
	else
		return true;	
}


// admin login Page Validations
function login_validate()
{
	arrFlds = "txtUsername:UserName,txtPassword:Password";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
}

//login Page Validations
function logincart_validate()
{
	if(document.form2.txtUsername.value == "")
	{
		alert("UserName cannot be Blank!");
		document.form2.txtUsername.focus();
		return false;
	}
	if(document.form2.txtPassword.value == "")
	{
		alert("Password cannot be Blank!");
		document.form2.txtPassword.focus();
		return false;
	}
}

// Category Checked
function category_validate()
{
	arrFlds = "txtCategory:Category Name";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert("\"" + indFields[1] + "\" cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
}

// Add New Employee Validations
function employee_validate()
{
	arrFlds = "txtFName:First Name,txtLName:Last Name,cblDept:Department Name,txtDesgn:Designation,txtEmail:Email Address,txtUserNM:User Name,txtPassword:Password";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	else if(!chkEmail("txtEmail"))
	{
		alert("Invalid Email Format ! Should be in somename@hostname.com");
		eval(obj+"txtEmail.focus()");
		eval(obj+"txtEmail.select()");
		return false;
	}
	else if (!chkLogin(eval(obj+"txtUserNM.value")))
	{
		alert("Invalid Username ! \n Should be consisting of only alphabets,numbers and underscore");
		eval(obj+"txtUserNM.focus()");
		eval(obj+"txtUserNM.select()");
		return false;
	}
	else if (!chkEquality("txtPassword","txtCPassword"))
	{
		alert("Password Do Not match ! Please Re-Enter");
		eval(obj+"txtPassword.focus()");
		eval(obj+"txtPassword.select()");
		return false;
	}
}

//Edit Employee Details
function employee_editvalidate()
{
	arrFlds = "txtFName:First Name,txtLName:Last Name,cblDept:Department Name,txtDesgn:Designation,txtEmail:Email Address";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	else if(!chkEmail("txtEmail"))
	{
		alert("Invalid Email Format ! Should be in somename@hostname.com");
		eval(obj+"txtEmail.focus()");
		eval(obj+"txtEmail.select()");
		return false;
	}
	else if (eval(obj+"txtPassword.value")!="")
	{
		if (!chkEquality("txtPassword","txtCPassword"))
		{
		alert("New Password Do Not match ! Please Re-Enter");
		eval(obj+"txtPassword.focus()");
		eval(obj+"txtPassword.select()");
		return false;
		}
		if (eval(obj+"txtOPassword.value")=="") 
		{
		alert("You Have to Enter Old Password to Incorporate New Change in Password");
		eval(obj+"txtOPassword.focus()");
		eval(obj+"txtOPassword.select()");
		return false;	
		}
	}	
}

//Chech Add File Category 
function addcat_validate()
{
	arrFlds = "txtCatNM:Category Name";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
}

//Chech Add Board
function addboard_validate()
{
	arrFlds = "txtBoardNM:Board Name";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	else if (eval(obj+"poll_type[1].checked"))
	{
		if (eval(obj+"cblDept.selectedIndex")< 0)
		{
			alert("Please select Department for File !!");
			return false;
		}
	}
}

//Check File Upload Program
function uploadFile_validate()
{
	obj1 = "document.form2.";
	arrFlds = "cblCat:Category Name,txtFileDesc:Field Description,txtFileNM: File Name";
	errMsg = validate(arrFlds);
	flag = false
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		flag = true;
	}
	else if (eval(obj1+"poll_type[1].checked"))
	{
		if (eval(obj1+"cblDept.selectedIndex")< 0)
		{
			alert("Please select Department for File !!");
			flag = true;
		}
	}
	
	if (flag)
		return false;
	else
	{
		if (eval(obj1+"poll_type[1].checked==true"))
			pollVal = "private";
		else
			pollVal = "public";
		deptLen = eval(obj1+"cblDept.length");
		deptIDs = ""
		for(i=0;i<deptLen;i++)
		{
			if(eval(obj1+"cblDept[i].selected"))
			deptIDs = deptIDs + eval(obj1+"cblDept[i].value") + ","
		}	
		if (deptIDs!="")
			deptIDs = deptIDs.substring(0,deptIDs.length-1)
					
		eval(obj+"poll_type.value=pollVal");
		eval(obj+"cblDept.value=deptIDs");
		return true;
	}
	
}

//Edit File Upload Program
function editFile_validate()
{
	obj1 = "document.form2.";
	arrFlds = "cblCat:Category Name,txtFileDesc:Field Description";
	errMsg = validate(arrFlds);
	flag = false
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		flag = true;
	}
	else if (eval(obj1+"poll_type[1].checked"))
	{
		if (eval(obj1+"cblDept.selectedIndex")< 0)
		{
			alert("Please select Department for File !!");
			return false;
		}
	}
	
	if (flag)
		return false;
	else
	{
		if (eval(obj1+"poll_type[1].checked==true"))
			pollVal = "private";
		else
			pollVal = "public";
		deptLen = eval(obj1+"cblDept.length");
		deptIDs = ""
		for(i=0;i<deptLen;i++)
		{
			if(eval(obj1+"cblDept[i].selected"))
			deptIDs = deptIDs + eval(obj1+"cblDept[i].value") + ","
		}	
		if (deptIDs!="")
			deptIDs = deptIDs.substring(0,deptIDs.length-1)
					
		eval(obj+"poll_type.value=pollVal");
		eval(obj+"cblDept.value=deptIDs");
		return true;
	}
	
}

// Check Add News Function
function news_validate()
{
	obj1 = "document.form2."
	var eDate = new Date(eval(obj+"txtEDate.value"));
	var sDate = new Date(eval(obj+"txtSDate.value"));
	var flag = false
	arrFlds = "txtNTitle:News Title,txtNews:News,txtSDate:Start Date,txtEDate:End Date";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		flag = true;
	}
	else if (eDate-sDate < 0)
	{
		alert("News Start Date should be less than or equal to the News End date !!");
		flag = true;
	}
	else if (eval(obj1+"poll_type[1].checked"))
	{
		if (eval(obj1+"cblDept.selectedIndex")< 0)
		{
			alert("Please select Department for News !!");
			flag = true;
		}
	}
	
	if (flag)
		return false;
	else
	{
		if (eval(obj1+"poll_type[1].checked==true"))
			pollVal = "private";
		else
			pollVal = "public";
		deptLen = eval(obj1+"cblDept.length");
		deptIDs = ""
		for(i=0;i<deptLen;i++)
		{
			if(eval(obj1+"cblDept[i].selected"))
			deptIDs = deptIDs + eval(obj1+"cblDept[i].value") + ","
		}	
		if (deptIDs!="")
			deptIDs = deptIDs.substring(0,deptIDs.length-1)
					
		eval(obj+"poll_type.value=pollVal");
		eval(obj+"cblDept.value=deptIDs");
		return true;
	}
	
	
}

// Check Add Poll Function
function pollAdd_validate()
{
	var eDate = new Date(eval(obj+"txtEDate.value"));
	var sDate = new Date(eval(obj+"txtSDate.value"));
	arrFlds = "txtPoll:Poll Question,txtChoice1:Choice 1,txtChoice2:Choice 2,txtSDate:Publish Date";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	else if (eval(obj+"txtChoice4.value")!="")
	{
		if (eval(obj+"txtChoice3.value")=="")
		{
		alert("Choice 3 cannot be blank if Choice 4 is entered !!");
		eval(obj+"txtChoice3.focus()");
		return false;
		}
	}
	if (eDate-sDate < 0)
	{
		alert("Poll Start Date should be less than or equal to the Poll End date !!");
		return false;
	}
	else if (eval(obj+"poll_type[1].checked"))
	{
		if (eval(obj+"cblDept.selectedIndex")< 0)
		{
			alert("You have chosen Department Poll ! Please select atleast one department");
			return false;
		}
	}
	
	
}


// check poll clicks
function poll_validate()
{
	obj1 = "document.pollform.";
	flag = false;
	ch_len = eval(obj1+"Chpoll.length");
	for (i=0;i<ch_len;i++)
	{
		if (eval(obj1+"Chpoll[i].checked"))
		{
			flag = true;
			break;
		}
	}
	if (flag)
		return true;
	else
	{
		alert("Please select one Option !!");
		return false;
	}
}

// On Change Event, show poll question and choices
function show_question()
{
	strVal = eval(obj+"cblQuestion.value");
	if (strVal!="")
	{
		strArr = strVal.split("##");
	//eval(obj+"txtPoll.value="+obj+"cblQuestion.options["+obj+"cblQuestion.selectedIndex].text");
	eval(obj+"txtPoll.value=strArr[1]");
	eval(obj+"txtChoice1.value=strArr[2]");
	eval(obj+"txtChoice2.value=strArr[3]");
	if (strArr.length > 3)
		eval(obj+"txtChoice3.value=strArr[4]");
	if (strArr.length > 4)
		eval(obj+"txtChoice4.value=strArr[5]");	
	}
	else
	{
		strVar = "Can't Say"
		eval(obj+"txtPoll.value=''");
		eval(obj+"txtChoice1.value='Yes'");
		eval(obj+"txtChoice2.value='No'");
		eval(obj+"txtChoice3.value=strVar");
		eval(obj+"txtChoice4.value=''");
	}
}

// CheckALL Function Needs CheckBox Name
function checkAll(chkNM)
{
	//Find the Length of the Checkbox
	intLen = eval(obj+chkNM+".length");
	if(intLen==null || intLen == "undefined")
		eval(obj+chkNM+".checked=true");
	else
	{
		for(i=0;i<intLen;i++)
		{
			eval(obj+chkNM+"["+i+"].checked=true");
		}
	}
		eval(obj+"ckhALL.checked=true");
		
}

function checkAll1(chkNM,strChk)
{
	//Find the Length of the Checkbox
	intLen = eval(obj+chkNM+".length");
	if(intLen==null || intLen == "undefined")
		eval(obj+chkNM+".checked=true");
	else
	{
		for(i=0;i<intLen;i++)
		{
			eval(obj+chkNM+"["+i+"].checked=true");
		}
	}
		eval(obj+strChk+".checked=true");
		
}

//Check & Remove ALL
function ChkRemoveAll(chk)
{
	intLen = eval(obj+chk+".length");
	if (eval(obj+"ckhALL.checked"))
	{
		checkAll(chk);
	}
	else
	{
		if(intLen==null || intLen == "undefined")
			eval(obj+chk+".checked=false");
		else
		{
			for(i=0;i<intLen;i++)
			{
				eval(obj+chk+"["+i+"].checked=false");
			}	
		}
			eval(obj+"ckhALL.checked=false"); 
	}	
}

//Check & Remove ALL
function ChkRemove1All(chk,allChk)
{
	intLen = eval(obj+chk+".length");
	if (eval(obj+allChk+".checked"))
	{
		checkAll1(chk,allChk);
	}
	else
	{
		if(intLen==null || intLen == "undefined")
			eval(obj+chk+".checked=false");
		else
		{
			for(i=0;i<intLen;i++)
			{
				eval(obj+chk+"["+i+"].checked=false");
			}	
		}
			eval(obj+allChk+".checked=false"); 
	}	
}

//Delete Checked IDs,need to pass CheckBox Name,DeletePage Name, User & Session Values

function deleteAll(chkNM,strPage,strUser,strSession)
{
	intLen = eval(obj+chkNM+".length");
	strIDs = "";
	if(intLen==null || intLen == "")
	{
		if(eval(obj+chkNM+".checked"))
		{
			strIDs = eval(obj+chkNM+".value") + ",";
		}
	}
	else
	{
		for(i=0;i<intLen;i++)
		{
			if(eval(obj+chkNM+"["+i+"].checked"))
			{
				strIDs = strIDs + eval(obj+chkNM+"["+i+"].value") + ","
			}
		}
	}
	if(strIDs=="")
	{
		alert("Please select IDs to Delete !");
	}
	else
	{
		strIDs = strIDs.substring(0,strIDs.length-1);
		if(confirm("Are You Sure you want to Delete the Checked Records ?"))
		{
			strUrl = strPage + "?user=" + strUser + "&ses=" + strSession + "&IDs=" + strIDs;
			window.open(strUrl,"delwin","width=500,height=450");
		}
	}	
}




//Check Section
function chk_section(strField,strType)
{
	var arr = new Array(5);
	arr[0] = "Oadd";
	arr[1] = "Oedit";
	arr[2] = "Odelete";
	arr[3] = "Oview";
	arr[4] = "Oother";
	
	flag = true
	
	if (strType=="clear")
		flag = false;
	
	for(i=0;i<5;i++)
	{
		eval(obj+strField+"_"+arr[i]+".checked=flag");
	}
}

//Open Attachment Pop-Up
function attachments()
{
	alert("This section is undere Construction");
}

//Delete Message
function delete_message(id,user,ses)
{
	if (confirm("Are you Sure you want to Delete this Message ?"))
	{
		strUrl = "delete_message.asp?user="+user+"&ses="+ses+"&ids="+id;
		window.open(strUrl,"delwin","width=500,height=450");
	}	
}

//display Image
function dis_bigImage(ImageNM)
{
	strUrl = "dis_image.asp?img=" + ImageNM;
	window.open(strUrl,"DisImage","width=500,height=450,scrollbars=yes");
}

//Send Message Validations
function sendmessage_validate()
{
	arrFlds = "cblReceiver:Receiver Field,txtSubject:Subject Field;txtMessage:Message";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
}

//To Disable Department Select when Public Option is choosen
function dis_dept()
{
	if (eval(obj+"poll_type[0].checked"))
	{
		eval(obj+"cblDept.disabled=true");
		eval(obj+"cblDept.selectedIndex=-1");
	}
	else
		eval(obj+"cblDept.disabled=false");
}

function dis_dept1()
{
	obj1 = "document.form2.";
	if (eval(obj1+"poll_type[0].checked"))
	{
		eval(obj1+"cblDept.disabled=true");
		eval(obj1+"cblDept.selectedIndex=-1");
	}
	else
		eval(obj1+"cblDept.disabled=false");
}

// Check Add Topic Form
function addTopic_validate()
{
	arrFlds = "txtTopicHD:Topic Heading,txtTopic:Topic ";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
}

// Check Add Reply Form
function addReply_validate()
{
	arrFlds = "txtReplyHD:Reply Heading,txtReply:Reply ";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
}

// Delete Function
function fdelete(tid,rid,typ,user,ses,fid,pid)
{
	flag = true;
	if(typ=="topic")
	{
		if (!confirm("Are you Sure you want to delete this Topic ? \n\n All Corresponding Replies would be deleted!!"))
			flag = false;
	}
	if(flag)
	{
		strUrl = "delete_forum.asp?user="+user+"&ses="+ses+"&topicid="+tid+"&replyID="+rid+"&type="+typ+"&forumID="+fid+"&parentID="+pid;
		//alert(strUrl);
		window.open(strUrl,"delete","width=500,height=400");
	}
}

// Add Project Validate 
function addProject_validate()
{
	var eDate = new Date(eval(obj+"txtEDate.value"));
	var sDate = new Date(eval(obj+"txtSDate.value"));
	arrFlds = "txtPTitle:Project Title,txtProject:Project Description,cblMngr:Project Manager,txtSDate:Start Date";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	else if (eDate!="" && eDate-sDate < 0)
	{
		alert("Project Start Date should be less than Project End date !!\n\nPlease leave Blank in case you want to enter at later date");
		eval(obj+"txtEDate.value=''");
		return false;
	}
	else if (eval(obj+"cblDept.selectedIndex")< 0)
	{
		alert("Please select Team Department for Project !!");
		return false;
	}
}

// Add Task Validate 
function addTask_validate()
{
	obj1 = "document.form2."
	var eDate = new Date(eval(obj+"txtEDate.value"));
	var sDate = new Date(eval(obj+"txtSDate.value"));
	arrFlds = "txtTTitle:Task Title,txtTask:Task Description,txtSDate:Start Date";
	errMsg = validate(arrFlds);
	if (eval(obj1+"cblProject.value")=="")
	{
		alert("Please select Project !!");
		eval(obj1+"cblProject.focus()");
		return false;
	}
	else if (eval(obj1+"cblUser.value")=="")
	{
		alert("Please select Users ! There should be one User for Task !!");
		eval(obj1+"cblUser.focus()");
		return false;
	}
	else if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	else if (eDate!="" && eDate-sDate < 0)
	{
		alert("Task Start Date should be less than Task End date !!\n\nPlease leave Blank in case you want to enter at later date");
		eval(obj+"txtEDate.value=''");
		return false;
	}
	else
	{
		pid = eval(obj1+"cblProject.value");
		lvl = eval(obj1+"cblTask.value");
		
		userLen = eval(obj1+"cblUser.length");
		userIDs = ""
		for(i=0;i<userLen;i++)
		{
			if(eval(obj1+"cblUser[i].selected"))
			userIDs = userIDs + eval(obj1+"cblUser[i].value") + ","
		}	
		if (userIDs!="")
			userIDs = userIDs.substring(0,userIDs.length-1)
					
		eval(obj+"taskUsers.value=userIDs");
		eval(obj+"task_level.value=lvl");
		eval(obj+"PID.value=pid");
		return true;
	}
}

function change_project(str)
{
	obj1 = "document.form2.";
	pid= eval(obj1+"cblProject.value");
	url = "add_task.asp?"+str+"&pid="+pid;
	window.location.href=url;
}

var theImages = new Array()

theImages[0] = '1.jpg'
theImages[1] = '2.jpg'


var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showBanner(loc)
{
	if (loc=="home")
		document.write('<img src="images/banner/'+theImages[whichImage]+'" width="480" height="60" border="0" alt="" vspace="3">');
	else
		document.write('<img src="../images/banner/'+theImages[whichImage]+'" width="480" height="60" border="0" alt="" vspace="3">');

}


// Book Page Validations
function book_validate()
{
	
	
	if (eval(obj+"txtcode.value")=="")
	{
		alert("Enter Item Code");
		eval(obj+"txtcode.focus()");
		return false;
	}
		
	
	if (eval(obj+"cboCategory.value")=="0")
	{
		alert("Please Select Category");
		eval(obj+"cboCategory.focus()");
		return false;
	}
	if (eval(obj+"cboPublisher.value")=="0")
	{
		alert("Please Select Publisher");
		eval(obj+"cboPublisher.focus()");
		return false;
	}
	if (eval(obj+"cboCurrency.value")=="0")
	{
		alert("Please Select Currency");
		eval(obj+"cboCurrency.focus()");
		return false;
	}
	
	if (eval(obj+"txtListPrice.value")=="0")
	{
		alert("List Price cannnot be zero");
		eval(obj+"txtListPrice.focus()");
		return false;
	}
	
	arrFlds = "cboCategory:Category,cboPublisher:Publisher,txtBook:Book Name,txtAuthor:Author Name,txtIsbn:Isbn,cboCurrency:Currency,txtListPrice:List Price,txtStock:Stock";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	if(isNaN(eval(obj+"txtListPrice.value")))
	{
		alert("List Price allow only numbers!");
		eval(obj+"txtListPrice.focus()");
		return false;
	}	
	if(isNaN(eval(obj+"txtStock.value")))
	{
		alert("Stock allow only numbers!");
		eval(obj+"txtStock.focus()");
		return false;
	}	
		
	if(eval(obj+"txtOurPrice.value") != "0")
	{
		if(isNaN(eval(obj+"txtOurPrice.value")))
		{
			alert("Our Price allow only numbers!");
			eval(obj+"txtOurPrice.focus()");
			return false;
		}
	
		if(eval(obj+"txtDiscount.value") != "0")
		{
			alert("You cannot enter both our Price and Discount!");
			eval(obj+"txtDiscount.focus()");
			return false;
		}	
	
	
	}
		
	if(isNaN(eval(obj+"txtDiscount.value")))
	{
		alert("Discount allow only numbers!");
		eval(obj+"txtDiscount.focus()");
		return false;
	}	
	
return qtyUpdate()

}


//quantity numetric

function qtyUpdate()
	{
		
	//alert('hello')	
		var i
		i=0
		var ConQty 
		ConQty = document.frm1.T_Count.value
		
		//alert(ConQty)
		
		if (eval(ConQty) == eval(0)) 
		{
		 	if(document.frm1.txtQty.value == "")
		 	{
		 		alert ("Quantity: Cannot be blank !")
		 		Qty1=document.frm1.QtyHide.value
				document.frm1.txtQty.value=Qty1
		 		return (false);
		 	}
		 	
		 	if(document.frm1.txtQty.value == 0)
		 	{
		 		alert ("Quantity: Cannot be zero !")
		 		Qty1=document.frm1.QtyHide.value
				document.frm1.txtQty.value=Qty1
		 		return (false);
		 	}
		 	
		 	if(document.frm1.txtQty.value != "")
		 	{
		 		if (isNaN(document.frm1.txtQty.value))
		 		{ 
					alert ("1 Quantity should be in digit !")
		 			Qty1=document.frm1.QtyHide.value
					document.frm1.txtQty.value=Qty1
		 			return (false);
				}
				
				if (eval(document.frm1.txtQty.value) > eval(document.frm1.MaxQTY.value))
		 		{
		 			alert(""+ document.frm1.BookName.value + " \n\ \n\Only " + document.frm1.MaxQTY.value + " Pieces Available in Stock.")
		 			Qty1=document.frm1.QtyHide.value
		 			document.frm1.txtQty.value=Qty1
		 			return false;
		 		}
		 		
		 	}
		}
		else
		{
			for (i=0; i<=ConQty; i++)
			{
				if(document.frm1.txtQty[i].value == "")
		 		{
		 			alert ("Quantity: Cannot be blank !")
		 			Qty1=document.frm1.QtyHide[i].value
	 				document.frm1.txtQty[i].value=Qty1
		 			return (false);
		 		}
				
				if(document.frm1.txtQty[i].value == 0)
		 		{
		 			alert ("Quantity: Cannot be zero !")
		 			Qty1=document.frm1.QtyHide[i].value
	 				document.frm1.txtQty[i].value=Qty1
		 			return (false);
		 		}
				
				if(document.frm1.txtQty[i].value != "")
		 		{
		 			if (isNaN(document.frm1.txtQty[i].value))
		 			{ 
						alert ("Quantity should be in digit !")
		 				Qty1=document.frm1.QtyHide[i].value
	 					document.frm1.txtQty[i].value=Qty1
		 				return (false);
					}

					if (eval(document.frm1.txtQty[i].value) > eval(document.frm1.MaxQTY[i].value))
		 			{
		 				alert(""+ document.frm1.BookName[i].value + " \n\ \n\Only " + document.frm1.MaxQTY[i].value + " Pieces Available in Stock.")
		 				Qty1=document.frm1.QtyHide[i].value
	 					document.frm1.txtQty[i].value=Qty1
		 				return false;
		 			}
		 			
		 		}
			}
		}	
	return true;	
	}

// Group Page Validations
function group_validate()
{
	
	if (eval(obj+"cboPublisher.value")=="0")
	{
		alert("Please Select Publisher");
		eval(obj+"cboPublisher.focus()");
		return false;
	}
	if (eval(obj+"cboCurrency.value")=="0")
	{
		alert("Please Select Currency");
		eval(obj+"cboCurrency.focus()");
		return false;
	}
	arrFlds = "cboPublisher:Publisher,txtGroupName:Group Name,cboCurrency:Currency,txtGroupPrice:Group Price";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	if(isNaN(eval(obj+"txtGroupPrice.value")))
	{
		alert("Group Price allow only numbers!");
		eval(obj+"txtGroupPrice.focus()");
		return false;
	}	
	
	
}


// Standard Page Validations
function std_validate()
{
	
	
	if (eval(obj+"cboCategory.value")=="0")
	{
		alert("Please Select Category");
		eval(obj+"cboCategory.focus()");
		return false;
	}

	arrFlds = "cboCategory:Category,txtBook:Standard Name,cboCurrency:Currency";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}

	if ((eval(obj+"cboCurrency.value")=="0") && (eval(obj+"cboGroup.value")=="0"))
	{
		alert("Please Select either a Group or Currency");
		eval(obj+"cboGroup.focus()");
		return false;
	}

	if ((eval(obj+"cboCurrency.value")!="0") && (eval(obj+"cboGroup.value")!="0"))
	{
		alert("Both the Group and Currency can't be selected.");
		eval(obj+"cboGroup.focus()");
		return false;
	}
	
	if(eval(obj+"txtListPrice.value") == "")
	{
		alert("Enter List Price!");
		eval(obj+"txtListPrice.focus()");
		return false;
	}	
	
	if(eval(obj+"txtListPrice.value") == "0")
	{
		alert("List Price cannot be zero!");
		eval(obj+"txtListPrice.focus()");
		return false;
	}	
	
	if(isNaN(eval(obj+"txtListPrice.value")))
	{
		alert("List Price allow only numbers!");
		eval(obj+"txtListPrice.focus()");
		return false;
	}	
	
	if(eval(obj+"txtOurPrice.value") != "")
	{
		if(isNaN(eval(obj+"txtOurPrice.value")))
		{
			alert("Our Price allow only numbers!");
			eval(obj+"txtOurPrice.focus()");
			return false;
		}
	}
	if (eval(obj+"txtStock.value")=="")
	{
		alert("Enter stock");
		eval(obj+"txtStock.focus()");
		return false;
	}
		
	if(eval(obj+"txtStock.value") != "")
	{
		if(isNaN(eval(obj+"txtStock.value")))
		{
			alert("Stock allow only numbers!");
			eval(obj+"txtOurPrice.focus()");
			return false;
		}
	}
	
	
	
	if(eval(obj+"txtOurPrice.value") != "")
	{
		if(isNaN(eval(obj+"txtOurPrice.value")))
		{
			alert("Our Price allow only numbers!");
			eval(obj+"txtOurPrice.focus()");
			return false;
		}
	
		if(eval(obj+"txtDiscount.value") != "")
		//if(isNaN(eval(obj+"txtDiscount.value")))
		{
			alert("You cannot enter both our Price and Discount!");
			eval(obj+"txtDiscount.focus()");
			return false;
		}	
	
	
	}
	
	
	if(isNaN(eval(obj+"txtDiscount.value")))
	{
		alert("Discount allow only numbers!");
		eval(obj+"txtDiscount.focus()");
		return false;
	}	
	
	
	if(eval(obj+"txtTotPage.value") != "")
	{
		if(isNaN(eval(obj+"txtTotPage.value")))
		{
			alert("Total Page allow only numbers!");
			eval(obj+"txtTotPage.focus()");
			return false;
		}
	}
}


// Package price Validations
function price_validation()
{
	if (eval(obj+"cboCategory.value")=="0")
	{
		alert("Please Select Category");
		//eval(obj+"cboCategory.focus()");
		return false;
	}
	if (eval(obj+"cboPackage.value")=="0")
	{
		alert("Please Select Package");
		return false;
	}
	if (eval(obj+"cboCity.value")=="0")
	{
		alert("Please Select City");
		return false;
	}
	if (eval(obj+"cboHotel.value")=="0")
	{
		alert("Please Select Hotel");
		return false;
	}
	if (eval(obj+"cboDay.value")=="0")
	{
		alert("Please Select Days");
		return false;
	}
	arrFlds = "txtSGL:SGL Price,txtDBL:DBL Price,txtTriple:Triple Price";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	if(isNaN(eval(obj+"txtSGL.value")))
	{
		alert("SGL Price allow only numbers!");
		eval(obj+"txtSGL.focus()");
		return false;
	}	
	if(isNaN(eval(obj+"txtDBL.value")))
	{
		alert("DBL Price allow only numbers!");
		eval(obj+"txtDBL.focus()");
		return false;
	}
	if(isNaN(eval(obj+"txtTriple.value")))
	{
		alert("Triple Price allow only numbers!");
		eval(obj+"txtTriple.focus()");
		return false;
	}	
	if(eval(obj+"txtDiscount.value") != "")
	{	
		if(isNaN(eval(obj+"txtDiscount.value")))
		{
			alert("Special Discount allow only numbers!");
			eval(obj+"txtDiscount.focus()");
			return false;
		}	
	}	
}

// Check signup Validation
function singup_validate()
{
	
	arrFlds = "txtFName:First Name,txtLName:Last Name,txtEmail:Email,txtAddress:Address,txtCity:City,txtState:State,txtZip:Zip Code";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert("\"" + indFields[1] + "\" cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
		
	if (!chkEmail("txtEmail"))
	{
		alert("\"Email\" address not valid!");
		eval(obj+"txtEmail.focus()");
		return false;
	}
	
}

// Check edit profilr Validation
function editsingup_validate()
{
	arrFlds = "txtUserName:UserName,txtPassword:Password,txtFName:First Name,txtLName:Last Name,txtEmail:Email,txtAddress:Address,txtCity:City,txtState:State,txtZip:Zip Code";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert("\"" + indFields[1] + "\" cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	if (eval(obj+"txtCPassword.value")!=eval(obj+"txtPassword.value"))
	{
		alert("\"Password\" field value not same!");
		eval(obj+"txtPassword.focus()");
		return false;
	}
	
	if (!chkEmail("txtEmail"))
	{
		alert("\"Email\" address not valid!");
		eval(obj+"txtEmail.focus()");
		return false;
	}
}

// Check edit Customer validation
function editcustomer_validate()
{
	arrFlds = "txtFName:First Name,txtLName:Last Name,txtEmail:Email,txtAddress:Address,txtCity:City,txtState:State,txtZip:Zip Code";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert("\"" + indFields[1] + "\" cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	if (!chkEmail("txtEmail"))
	{
		alert("\"Email\" address not valid!");
		eval(obj+"txtEmail.focus()");
		return false;
	}
}



// Check forget Validation
function forget_validate()
{
	arrFlds = "txtEmail:Email";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert("\"" + indFields[1] + "\" cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	if (!chkEmail("txtEmail"))
	{
		alert("\"Email\" address not valid!");
		eval(obj+"txtEmail.focus()");
		return false;
	}
}

function Change_package()
{
	if (document.Cat.cblPackages.value == 0)
		alert("Please select category");
	else
		document.location.href = "category.asp?catid=" + document.Cat.cblPackages.value	
}

// Check Car Rental Validation
function carrental_validate()
{
	arrFlds = "txtName:Name,txtEmail:Email,txtAddress:Address,txtPhone:Phone,txtCarPlace:Car Picking Place,txtQuery:Query";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert("\"" + indFields[1] + "\" cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	
	if (!chkEmail("txtEmail"))
	{
		alert("\"Email\" address not valid!");
		eval(obj+"txtEmail.focus()");
		return false;
	}
	
	if (eval(obj+"cboCountry.value") == "0")
	{
		alert("Please select \"Country\"");
		eval(obj+"cboCountry.focus()");
		return false;
	}
	if (eval(obj+"cboCar.value") == "0")
	{
		alert("Please select \"Car Preference\"");
		eval(obj+"cboCar.focus()");
		return false;
	}
	//Car Picking date/time
	if (eval(obj+"cboPMM.value") == "0")
	{
		alert("Please select \"Car Picking Month\"");
		eval(obj+"cboPMM.focus()");
		return false;
	}
	if (eval(obj+"cboPDD.value") == "0")
	{
		alert("Please select \"Car Picking Day\"");
		eval(obj+"cboPDD.focus()");
		return false;
	}
	if (eval(obj+"cboPYY.value") == "0")
	{
		alert("Please select \"Car Picking Year\"");
		eval(obj+"cboPYY.focus()");
		return false;
	}
	if (eval(obj+"cboPHH.value") == "0")
	{
		alert("Please select \"Car Picking Hour\"");
		eval(obj+"cboPHH.focus()");
		return false;
	}
	if (eval(obj+"cboPM.value") == "0")
	{
		alert("Please select \"Car Picking Min\"");
		eval(obj+"cboPM.focus()");
		return false;
	}
	//Car Returning date/time
	if (eval(obj+"cboRMM.value") == "0")
	{
		alert("Please select \"Car Returning Month\"");
		eval(obj+"cboRMM.focus()");
		return false;
	}
	if (eval(obj+"cboRDD.value") == "0")
	{
		alert("Please select \"Car Returning Day\"");
		eval(obj+"cboRDD.focus()");
		return false;
	}
	if (eval(obj+"cboRYY.value") == "0")
	{
		alert("Please select \"Car Returning Year\"");
		eval(obj+"cboRYY.focus()");
		return false;
	}
	if (eval(obj+"cboRHH.value") == "0")
	{
		alert("Please select \"Car Returning Hour\"");
		eval(obj+"cboRHH.focus()");
		return false;
	}
	if (eval(obj+"cboRM.value") == "0")
	{
		alert("Please select \"Car Returning Min\"");
		eval(obj+"cboRM.focus()");
		return false;
	}
}

// Check Flight Booking Validation
function flight_validate()
{
	arrFlds = "txtName:Name,txtEmail:Email,txtAddress:Address,txtPhone:Phone,txtFromCity:Fly Form City,txtToCity:Fly To City,txtQuery:Query";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert("\"" + indFields[1] + "\" cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	
	if (!chkEmail("txtEmail"))
	{
		alert("\"Email\" address not valid!");
		eval(obj+"txtEmail.focus()");
		return false;
	}
	if (eval(obj+"cboCountry.value") == "0")
	{
		alert("Please select \"Country\"");
		eval(obj+"cboCountry.focus()");
		return false;
	}
	if (eval(obj+"cboFFCountry.value") == "0")
	{
		alert("Please select \"Fly From Country\"");
		eval(obj+"cboFFCountry.focus()");
		return false;
	}
	if (eval(obj+"cboFTCountry.value") == "0")
	{
		alert("Please select \"Fly To Country\"");
		eval(obj+"cboFTCountry.focus()");
		return false;
	}
	if (eval(obj+"cboMM.value") == "0")
	{
		alert("Please select \"Date of Travel Month\"");
		eval(obj+"cboMM.focus()");
		return false;
	}
	if (eval(obj+"cboDD.value") == "0")
	{
		alert("Please select \"Date of Travel Day\"");
		eval(obj+"cboDD.focus()");
		return false;
	}
	if (eval(obj+"cboYY.value") == "0")
	{
		alert("Please select \"Date of Travel Year\"");
		eval(obj+"cboYY.focus()");
		return false;
	}
	if (eval(obj+"cboNo.value") == "0")
	{
		alert("Please select \"No. of Passengers\"");
		eval(obj+"cboNo.focus()");
		return false;
	}
}

function cart_validation()
{
		len = document.form1.txtNo.value;
		len = parseInt(len)
		blnFlag = false; 
		for(i=1;i<=len;i++)
		{
				if (eval("document.form1.cboCity" + i + ".value")=="0")
				blnFlag = true;
		}
		if(blnFlag)
		{
			alert("Please Select city & hotel");
			return false;
		}
}	

function validate_newsletter()
{
	
	if (frmNews.txtEmail.value == "")
	{
		alert("Please enter \"Email\"");
		frmNews.txtEmail.focus();
		return false;
	}
	if(frmNews.txtEmail.value.indexOf("@")< 1 || frmNews.txtEmail.value.indexOf(".")< 1 || frmNews.txtEmail.value.length < 5)
	{
		alert("Please Enter Valid \"Email\"");
		frmNews.txtEmail.focus();
		return false;
	}	
	
}

//Contact Validation
function contactus_validate()
{
	arrFlds = "txtEmail:Email,txtSubject:Subject,txtQuery:Query/Comment";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert("\"" + indFields[1] + "\" cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	
	if (!chkEmail("txtEmail"))
	{
		alert("\"Email\" address not valid!");
		eval(obj+"txtEmail.focus()");
		return false;
	}
}

function isNum()
{
		if (document.form1.txtTax.value=="")
		{
		alert("Enter Tax");
		document.form1.txtTax.focus();
		return false;
		}
	if (isNaN(document.form1.txtTax.value)==true)
		{
		alert("Enter a Valid Number for Tax Percentage");
		document.form1.txtTax.focus();
		document.form1.txtTax.select();
		return false;
		}
	
}



function custompackage_validate()
{
	if (eval(obj+"cboCity.value") == "")
	{
		alert("Please select \"Cities\"");
		eval(obj+"cboCity.focus()");
		return false;
	}
	
	arrFlds = "txtQuery:Special Comment,txtName:Name,txtEmail:Email,txtAddress:Address,txtPhone:Phone";
	errMsg = validate(arrFlds);
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert("\"" + indFields[1] + "\" cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
			
	if (!chkEmail("txtEmail"))
	{
		alert("\"Email\" address not valid!");
		eval(obj+"txtEmail.focus()");
		return false;
	}
	
	if (eval(obj+"cboCountry.value") == "0")
	{
		alert("Please select \"Country\"");
		eval(obj+"cboCountry.focus()");
		return false;
	}
	
	if (eval(obj+"cboFMM.value") == "0")
	{
		alert("Please select \"From Date of Visit Month\"");
		eval(obj+"cboFMM.focus()");
		return false;
	}
	if (eval(obj+"cboFDD.value") == "0")
	{
		alert("Please select \"From Date of Visit Day\"");
		eval(obj+"cboFDD.focus()");
		return false;
	}
	if (eval(obj+"cboFYY.value") == "0")
	{
		alert("Please select \"From Date of Visit Year\"");
		eval(obj+"cboFYY.focus()");
		return false;
	}
	
	if (eval(obj+"cboTMM.value") == "0")
	{
		alert("Please select \"To Date of Visit Month\"");
		eval(obj+"cboTMM.focus()");
		return false;
	}
	if (eval(obj+"cboTDD.value") == "0")
	{
		alert("Please select \"To Date of Visit Day\"");
		eval(obj+"cboTDD.focus()");
		return false;
	}
	if (eval(obj+"cboTYY.value") == "0")
	{
		alert("Please select \"To Date of Visit Year\"");
		eval(obj+"cboTYY.focus()");
		return false;
	}
}


