function IsNumeric(PossibleNumber)
{	
	var PNum = new String(PossibleNumber);	
	var regex = /[^0-9.]/;	
	return !regex.test(PNum);
}

function IsEmpty(obj, obj_type)
{
	if (obj_type == "text" || obj_type == "password" || obj_type == "textarea" || obj_type == "file")	{
		var objValue;
		
		objValue = obj.value.replace(/\s+$/,"");
		
		if (objValue.length == 0) {
			//obj.focus();
			return true;
		} else {
			return false;
		}
	} else if (obj_type == "select") {
		for (i=0; i < obj.length; i++) {
			if (obj.options[i].selected) {
				if(obj.options[i].value == "") {
					obj.focus();
					return true;
				} else {
					return false;
				}
			}
			
		}
		return true;	
	} else if (obj_type == "radio" || obj_type == "checkbox") {
		if (!obj[0] && obj) {
			if (obj.checked) {
				return false;
			} else {
				obj.focus();
				return true;	
			}
		} else {
			for (i=0; i < obj.length; i++) {
				if (obj[i].checked) {
					return false;
				}
			}
			obj[0].focus();
			return true;
		}
	} else {
		return false;
	}
}
function validate_userlogin()
{
	
	
	var temp = false;
	// LoginId
	if(document.getElementById("LoginId").value == "" || document.getElementById("LoginId").value == null)
	{
		alert("Login Id should not be null");
		document.getElementById("LoginId").focus();
		document.getElementById("LoginId").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("LoginId").style.border="1px solid lightblue";
		
	// Password
	if(document.getElementById("Password").value == "" || document.getElementById("Password").value == null)
	{
		alert("Password should not be null");
		document.getElementById("Password").focus();
		document.getElementById("Password").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("Password").style.border="1px solid lightblue";
	
		if(temp == false)
		document.forms[0].submit();
	
}


function validate_newuser()
{
	
	
	var temp = false;
	// LoginId
	if(document.getElementById("txtLoginId").value == "" || document.getElementById("txtLoginId").value == null)
	{
		alert("Login Id should not be null");
		document.getElementById("txtLoginId").focus();
		document.getElementById("txtLoginId").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtLoginId").style.border="1px solid lightblue";
		
	// Password
	if(document.getElementById("txtPassword").value == "" || document.getElementById("txtPassword").value == null)
	{
		alert("Password should not be null");
		document.getElementById("txtPassword").focus();
		document.getElementById("txtPassword").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtPassword").style.border="1px solid lightblue";
		
		// txtName
	if(document.getElementById("txtName").value == "" || document.getElementById("txtName").value == null)
	{
		alert("Name should not be null");
		document.getElementById("txtName").focus();
		document.getElementById("txtName").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtName").style.border="1px solid lightblue";
		
	// txtAddress
	if(document.getElementById("txtAddress").value == "" || document.getElementById("txtAddress").value == null)
	{
		alert("Address should not be null");
		document.getElementById("txtAddress").focus();
		document.getElementById("txtAddress").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtAddress").style.border="1px solid lightblue";
		
		//txtEmailId
	if(document.getElementById("txtEmailId").value == "" || document.getElementById("txtEmailId").value == null)
	{
		alert("Email Id should not be null");
		document.getElementById("txtEmailId").focus();
		document.getElementById("txtEmailId").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
	{
		var str=document.getElementById("txtEmailId").value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(str))
			document.getElementById("txtEmailId").style.border="1px solid lightblue";
		else
		{
			alert("Please input a valid Email Id");
			document.getElementById("txtEmailId").focus();
			document.getElementById("txtEmailId").style.border="1px solid red";
			temp = true;
			return false;
		}
	}	
	
		if(temp == false)
		document.forms[0].submit();
	
}


function validate_forgetpassword()
{
	
	
	var temp = false;
	// LoginId
	if(document.getElementById("txtLoginId").value == "" && document.getElementById("txtEmailId").value == "" )
	{
		alert("Login Id / EmailId should not be null");
		document.getElementById("txtLoginId").focus();
		document.getElementById("txtLoginId").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtLoginId").style.border="1px solid lightblue";	
	
	
		if(temp == false)
		document.forms[0].submit();
	
}


function validate_addnewproduct()
{
	
	
	var temp = false;
	// txtProductName
	if(document.getElementById("txtProductName").value == "" || document.getElementById("txtProductName").value == null)
	{
		alert("Product Name should not be null");
		document.getElementById("txtProductName").focus();
		document.getElementById("txtProductName").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtProductName").style.border="1px solid lightblue";	
	
	if(document.getElementById("txtCategoryName").value == "" || document.getElementById("txtCategoryName").value == null)
	{
		alert("Category Name should not be null");
		document.getElementById("txtCategoryName").focus();
		document.getElementById("txtCategoryName").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtCategoryName").style.border="1px solid lightblue";	
	
	
	if(document.getElementById("txtUnitPrice").value == "" || document.getElementById("txtUnitPrice").value == null)
	{
		alert("Unit Price should not be null");
		document.getElementById("txtUnitPrice").focus();
		document.getElementById("txtUnitPrice").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtUnitPrice").style.border="1px solid lightblue";	
		
	if( ! IsNumeric(document.getElementById("txtUnitPrice").value ))
	{
		alert("Unit Price should be NUMERIC");
		document.getElementById("txtUnitPrice").focus();
		document.getElementById("txtUnitPrice").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtUnitPrice").style.border="1px solid lightblue";

	if(document.getElementById("txtDiscountPrice").value != "" || document.getElementById("txtDiscountPrice").value != null)
	{
		if( ! IsNumeric(document.getElementById("txtDiscountPrice").value ))
		{
			alert("Discount Price should be NUMERIC");
			document.getElementById("txtDiscountPrice").focus();
			document.getElementById("txtDiscountPrice").style.border="1px solid red";
			temp = true;
			return false;
		}
		else
			document.getElementById("txtDiscountPrice").style.border="1px solid lightblue";
	}
		
	
	if(document.getElementById("txtDate").value == "" || document.getElementById("txtDate").value == null)
	{
		alert("Stock Date should not be null");
		document.getElementById("txtDate").focus();
		document.getElementById("txtDate").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtDate").style.border="1px solid lightblue";	
		if(temp == false)
		document.forms[0].submit();	
}


function validate_addnewcategory()
{
	
	var temp = false;
	// LoginId
	if(document.getElementById("txtCategoryName").value == "" || document.getElementById("txtCategoryName").value == null)
	{
		alert("Category Name should not be null");
		document.getElementById("txtCategoryName").focus();
		document.getElementById("txtCategoryName").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtCategoryName").style.border="1px solid lightblue";	


		if(temp == false)
		document.forms[0].submit();
	
}
function validate_search()
{
	
	var temp = false;
	// txtCategoryName
	if(document.getElementById("txtCategoryName").value == "" || document.getElementById("txtCategoryName").value == null)
	{
		alert("Category Name should not be null");
		document.getElementById("txtCategoryName").focus();
		document.getElementById("txtCategoryName").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtCategoryName").style.border="1px solid lightblue";	

	if(document.getElementById("txtFromRs").value == "" || document.getElementById("txtFromRs").value == null)
	{
		alert("From Rs should not be null");
		document.getElementById("txtFromRs").focus();
		document.getElementById("txtFromRs").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtFromRs").style.border="1px solid lightblue";	
		
	if( ! IsNumeric(document.getElementById("txtFromRs").value ))
	{
		alert("From Rs should be NUMERIC");
		document.getElementById("txtFromRs").focus();
		document.getElementById("txtFromRs").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtFromRs").style.border="1px solid lightblue";

	if(document.getElementById("txtToRs").value == "" || document.getElementById("txtToRs").value == null)
	{
		alert("To Rs should not be null");
		document.getElementById("txtToRs").focus();
		document.getElementById("txtToRs").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtToRs").style.border="1px solid lightblue";	
		
	if( ! IsNumeric(document.getElementById("txtToRs").value ))
	{
		alert("To Rs should be NUMERIC");
		document.getElementById("txtToRs").focus();
		document.getElementById("txtToRs").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtToRs").style.border="1px solid lightblue";
		if(temp == false)
		document.forms[0].submit();	
}


function validate_addMediaSchedule()
{
	
	var temp = false;
	// txtProductName
	if(document.getElementById("txtProductName").value == "" || document.getElementById("txtProductName").value == null)
	{
		alert("Product Name should not be null");
		document.getElementById("txtProductName").focus();
		document.getElementById("txtProductName").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtProductName").style.border="1px solid lightblue";	
		
	//txtChannelName
	if(document.getElementById("txtChannelName").value == "" || document.getElementById("txtChannelName").value == null)
	{
		alert("Channel Name should not be null");
		document.getElementById("txtChannelName").focus();
		document.getElementById("txtChannelName").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtChannelName").style.border="1px solid lightblue";	
		
	//txtTime			
	if(document.getElementById("txtTime").value == "" || document.getElementById("txtTime").value == null)
	{
		alert("Time should not be null");
		document.getElementById("txtTime").focus();
		document.getElementById("txtTime").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtTime").style.border="1px solid lightblue";	
		
	//txtDate
	if(document.getElementById("txtDate").value == "" || document.getElementById("txtDate").value == null)
	{
		alert("Date should not be null");
		document.getElementById("txtDate").focus();
		document.getElementById("txtDate").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtDate").style.border="1px solid lightblue";		

		if(temp == false)
		document.forms[0].submit();
	
}

function validate_addNews()
{
	
	var temp = false;
	// LoginId
	if(document.getElementById("txtNews").value == "" || document.getElementById("txtNews").value == null)
	{
		alert("News should not be null");
		document.getElementById("txtNews").focus();
		document.getElementById("txtNews").style.border="1px solid red";
		temp = true;
		return false;
	}
	else
		document.getElementById("txtNews").style.border="1px solid lightblue";	


		if(temp == false)
		document.forms[0].submit();
	
}

//created by manish

function valcarmessage()
{
if(document.getElementById('ddlCountry').value=="--Select One--")
{
alert("Select a Country");
document.getElementById('ddlCountry').focus();
return false;
}

if(document.getElementById('ddlFromcity').value=="--Select One--")
{
alert("Select a Pick Up City");
document.getElementById('ddlFromcity').focus();
return false;
}

if(document.getElementById('ddlTocity').value=="--Select One--")
{
alert("Select a Destination City ");
document.getElementById('ddlCountry').focus();
return false;
}

if(document.getElementById('txtFromdate').value=="")
{
alert("Cannot Blank From Date");
document.getElementById('txtFromdate').focus();
return false;
}

if(document.getElementById('txtTodate').value=="")
{
alert("Cannot Blank From Date");
document.getElementById('txtTodate').focus();
return false;
}

if(document.getElementById('txtFirstname').value=="")
{
alert("Cannot Blank First Name");
document.getElementById('txtFirstname').focus();
return false;
}

if(document.getElementById('txtAddress').value=="")
{
alert("Cannot Blank Address");
document.getElementById('txtAddress').focus();
return false;
}

if(document.getElementById('txtCountry').value=="")
{
alert("Cannot Blank Country Name");
document.getElementById('txtCountry').focus();
return false;
}

if(document.getElementById('txtCity').value=="")
{
alert("Cannot Blank City Name");
document.getElementById('txtCity').focus();
return false;
}

if(document.getElementById('txtEmail').value=="")
{
alert("Cannot Blank Email");
document.getElementById('txtEmail').focus();
return false;
}

if (document.getElementById("txtEmail").value!="")
     {
     var str=document.getElementById("txtEmail").value;
     var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
     if (filter.test(str))
			 return true;
		else
		{
			alert("Please input a valid Email Id");
			document.getElementById("txtEmail").focus();
         	return false;
		}
    
    }
    
    
}

function funcitypackage()
{

if(document.getElementById('ddlCountry').value=="--Select One--")
{
alert("Select a Country");
document.getElementById('ddlCountry').focus();
return false;
}

if(document.getElementById('ddlCity').value=="--Select One--")
{
alert("Select a  City");
document.getElementById('ddlCity').focus();
return false;
}


if(document.getElementById('txtFirstname').value=="")
{
alert("Cannot Blank First Name");
document.getElementById('txtFirstname').focus();
return false;
}

if(document.getElementById('txtAddress').value=="")
{
alert("Cannot Blank Address");
document.getElementById('txtAddress').focus();
return false;
}

if(document.getElementById('txtCountry').value=="")
{
alert("Cannot Blank Country Name");
document.getElementById('txtCountry').focus();
return false;
}

if(document.getElementById('txtCity').value=="")
{
alert("Cannot Blank City Name");
document.getElementById('txtCity').focus();
return false;
}

if(document.getElementById('txtEmail').value=="")
{
alert("Cannot Blank Email");
document.getElementById('txtEmail').focus();
return false;
}

if (document.getElementById("txtEmail").value!="")
     {
     var str=document.getElementById("txtEmail").value;
     var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
     if (filter.test(str))
			 return true;
		else
		{
			alert("Please input a valid Email Id");
			document.getElementById("txtEmail").focus();
         	return false;
		}
    
    }



}




function funcruise()
{

if(document.getElementById('ddlCountry').value=="--Select One--")
{
alert("Select a Country");
document.getElementById('ddlCountry').focus();
return false;
}

if(document.getElementById('txtIn').value=="")
{
alert("Cannot Blank Daparting In ");
document.getElementById('txtIn').focus();
return false;
}


if(document.getElementById('txtFirstname').value=="")
{
alert("Cannot Blank First Name");
document.getElementById('txtFirstname').focus();
return false;
}

if(document.getElementById('txtAddress').value=="")
{
alert("Cannot Blank Address");
document.getElementById('txtAddress').focus();
return false;
}

if(document.getElementById('txtCountry').value=="")
{
alert("Cannot Blank Country Name");
document.getElementById('txtCountry').focus();
return false;
}

if(document.getElementById('txtCity').value=="")
{
alert("Cannot Blank City Name");
document.getElementById('txtCity').focus();
return false;
}

if(document.getElementById('txtEmail').value=="")
{
alert("Cannot Blank Email");
document.getElementById('txtEmail').focus();
return false;
}

if (document.getElementById("txtEmail").value!="")
     {
     var str=document.getElementById("txtEmail").value;
     var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
     if (filter.test(str))
			 return true;
		else
		{
			alert("Please input a valid Email Id");
			document.getElementById("txtEmail").focus();
         	return false;
		}
    
    }



}






function funtransfer()
{


if(document.getElementById('txtFirstname').value=="")
{
alert("Cannot Blank First Name");
document.getElementById('txtFirstname').focus();
return false;
}

if(document.getElementById('txtAddress').value=="")
{
alert("Cannot Blank Address");
document.getElementById('txtAddress').focus();
return false;
}

if(document.getElementById('txtCountry').value=="")
{
alert("Cannot Blank Country Name");
document.getElementById('txtCountry').focus();
return false;
}

if(document.getElementById('txtCity').value=="")
{
alert("Cannot Blank City Name");
document.getElementById('txtCity').focus();
return false;
}

if(document.getElementById('txtEmail').value=="")
{
alert("Cannot Blank Email");
document.getElementById('txtEmail').focus();
return false;
}

if (document.getElementById("txtEmail").value!="")
     {
     var str=document.getElementById("txtEmail").value;
     var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
     if (filter.test(str))
			 return true;
		else
		{
			alert("Please input a valid Email Id");
			document.getElementById("txtEmail").focus();
         	return false;
		}
    
    }



}



function funvisa()
{

if(document.getElementById('ddlCountry').value=="--Select One--")
{
alert("Select a Country");
document.getElementById('ddlCountry').focus();
return false;
}

if(document.getElementById('ddlCity').value=="0")
{
alert("Select a  Current Nationality");
document.getElementById('ddlCity').focus();
return false;
}


if(document.getElementById('txtDays').value=="")
{
alert("Cannot Blank Validity of Visa");
document.getElementById('txtDays').focus();
return false;
}

if (document.getElementById("txtDays").value!="")
     {
     var digits="0123456789";
     var temp;
     for (var i=0;i<document.getElementById("txtDays").value.length;i++)
     {
               temp=document.getElementById("txtDays").value.substring(i,i+1);
               if (digits.indexOf(temp)==-1)
               {
                        alert("Please enter correct Values");
                        document.getElementById("txtDays").focus();
                        return false;
               }
               
     }
     
     }


if(document.getElementById('ddlMonth').value=="0")
{
alert("Select a Month");
document.getElementById('ddlMonth').focus();
return false;
}

if(document.getElementById('ddlYear').value=="--Select Year--")
{
alert("Select a Year");
document.getElementById('ddlYear').focus();
return false;
}

if(document.getElementById('ddlAdults').value=="0" && document.getElementById('ddlSenior').value=="0" && document.getElementById('ddlChildren').value=="0")
{
alert("Select atleast One Either Children Or Senior Or Adults.");
document.getElementById('ddlAdults').focus();
return false;
}

if(document.getElementById('txtFirstname').value=="")
{
alert("Cannot Blank First Name");
document.getElementById('txtFirstname').focus();
return false;
}

if(document.getElementById('txtAddress').value=="")
{
alert("Cannot Blank Address");
document.getElementById('txtAddress').focus();
return false;
}

if(document.getElementById('txtCountry').value=="")
{
alert("Cannot Blank Country Name");
document.getElementById('txtCountry').focus();
return false;
}

if(document.getElementById('txtCity').value=="")
{
alert("Cannot Blank City Name");
document.getElementById('txtCity').focus();
return false;
}

if(document.getElementById('txtEmail').value=="")
{
alert("Cannot Blank Email");
document.getElementById('txtEmail').focus();
return false;
}

if (document.getElementById("txtEmail").value!="")
     {
     var str=document.getElementById("txtEmail").value;
     var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
     if (filter.test(str))
			 return true;
		else
		{
			alert("Please input a valid Email Id");
			document.getElementById("txtEmail").focus();
         	return false;
		}
    
    }



}


//package_view.ascx.cs

//function package_view()
//{
//if(document.getElementById('txtFirstname').value=="")
//{
//alert("Cannot Blank Full Name");
//document.getElementById('txtFirstname').focus();
//return false;
//}

/*if(document.getElementById('txtAddress').value=="")
{
alert("Cannot Blank Address");
document.getElementById('txtAddress').focus();
return false;
}

if(document.getElementById('txtCountry').value=="")
{
alert("Cannot Blank Country Name");
document.getElementById('txtCountry').focus();
return false;
}

if(document.getElementById('txtCity').value=="")
{
alert("Cannot Blank City Name");
document.getElementById('txtCity').focus();
return false;
}

if(document.getElementById('txtEmail').value=="")
{
alert("Cannot Blank Email");
document.getElementById('txtEmail').focus();
return false;
}

if (document.getElementById("txtEmail").value!="")
     {
     var str=document.getElementById("txtEmail").value;
     var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
     if (filter.test(str))
			 return true;
		else
		{
			alert("Please input a valid Email Id");
			document.getElementById("txtEmail").focus();
         	return false;
		}
    
    }
}*/




//RequestedAmountForm
function checksNumeric()
{
if(document.getElementById('txtRequestedmoney').value=="")
{
alert("Requested amount should not be null");
document.getElementById('txtRequestedmoney').focus();
return false;
}

if (document.getElementById("txtRequestedmoney").value!="")
     {
     var digits="0123456789.";
     var temp;
     for (var i=0;i<document.getElementById("txtRequestedmoney").value.length;i++)
     {
               temp=document.getElementById("txtRequestedmoney").value.substring(i,i+1);
               if (digits.indexOf(temp)==-1)
               {
                        alert("Please enter only number");
                        document.getElementById("txtRequestedmoney").focus();
                        return false;
               }
               
     }
     
     }
}


//changeagentpassword

function checkf()
{

if(document.getElementById("txtOldpassword").value == "" || document.getElementById("txtOldpassword").value == null)
	{
		alert("Old password should not be null");
		document.getElementById("txtOldpassword").focus();
		return false;
	}
if(document.getElementById("txtNewpassword").value == "" || document.getElementById("txtNewpassword").value == null)
	{
		alert("New password should not be null");
		document.getElementById("txtNewpassword").focus();
		return false;
	}
//if(document.getElementById("txtPassword").value != "" )
       else
		{
		var r=document.getElementById("txtNewpassword").value;
		var s=document.getElementById("txtconfirm").value;
		if(r!=s)
		{
		alert("Password and Repassword should be same");
		document.getElementById("txtconfirm").focus();
		return false;
        }
}
}

//Travel Agent Markup Price
function checkNumerics()
{
if(document.getElementById('txtmarkupprice').value=="")
{
alert("MarkUp price should not be null");
document.getElementById('txtmarkupprice').focus();
return false;
}

if (document.getElementById("txtmarkupprice").value!="")
     {
     var digits="0123456789.";
     var temp;
     for (var i=0;i<document.getElementById("txtmarkupprice").value.length;i++)
     {
               temp=document.getElementById("txtmarkupprice").value.substring(i,i+1);
               if (digits.indexOf(temp)==-1)
               {
                        alert("Please enter only number");
                        document.getElementById("txtmarkupprice").focus();
                        return false;
               }
               
     }
     
     }
}
