function ValidateForm()
{       
		var ErrorMessage="";
		var frm = new Object(document.request_frm); 
		ErrorMessage += CheckEmpty(frm.firstname,"First Name");
		//ErrorMessage += CheckEmpty(frm.lastname,"Last Name");
		ErrorMessage += CheckEmpty(frm.organization,"Organization");
		ErrorMessage += ValidateEmail(frm.email,"Email Address");
		ErrorMessage += ValidatePhonenumber(frm.work_phone1,"Work Phone Number");
		ErrorMessage += ValidatePhonenumber(frm.work_phone2,"Work Phone Number");
		ErrorMessage += ValidatePhonenumber(frm.work_phone3,"Work Phone Number");
		
		ErrorMessage += ValidatePhonenumber(frm.home_phone1,"Home Phone Number");
		ErrorMessage += ValidatePhonenumber(frm.home_phone2,"Home Phone Number");
		ErrorMessage += ValidatePhonenumber(frm.home_phone3,"Home Phone Number");

//		ErrorMessage += ValidatePhonenumber(frm.work_phone,"Work Phone Number");
//		ErrorMessage += ValidatePhonenumber(frm.home_phone,"Home Phone Number");
		ErrorMessage += ValidatePhonenumber(frm.fax,"Fax");
		ErrorMessage += ValidatePhonenumber(frm.zip,"Zip");
		ErrorMessage += CheckEmpty(frm.city,"City");
		ErrorMessage += CheckEmpty(frm.country,"Country");
		return (ShowErrorMessage(ErrorMessage));
}





function LTrim(strText)
{
	while (strText.charCodeAt(0) == 160 || strText.charCodeAt(0) == 32)
	{
		strText = strText.substring(1, strText.length); 
	}
	return strText; 
}
function RTrim(strText)
{
// this will get rid of trailing spaces 
	while (strText.charCodeAt(strText.length-1) == 160 ||strText.charCodeAt(strText.length-1) == 32)
	{
		strText = strText.substring(0, strText.length-1); 
	}
	return strText; 
}
function Trim(strText)
{
	return LTrim(RTrim(strText));
}
function isSubset(sub, sup)
{
	var index;

	for(index=0;index < sub.length; index++)
	{
		if ( sup.indexOf(sub.charAt(index)) < 0)
		{
			return false;
		}
	}
	return true;
}
function ValidateName(obj, objTitle)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ValidateCorName(obj1, obj, objTitle)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 0123456789";
	var ErrorMessage = "";
	
	if (Trim(obj1.value).length != 0)
	{
		if (Trim(obj.value).length == 0)
		{
			ErrorMessage = objTitle + " Should not be empty\n";
			return ErrorMessage;
		}
		
		if (!isSubset(obj.value, ValidChars))
		{
			ErrorMessage = "Invalid format in " + objTitle + "\n";
			return ErrorMessage;
		}
		
		return "";
	}
	return "";
}

function ValidateFilebox(obj, objTitle)
{

	if (Trim(obj.value).length == 0)
	{
			ErrorMessage = objTitle + " Should not be empty\n";
			return ErrorMessage;
	}
	return "";
}

function ValidateCCHolderName(obj, objTitle,required)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -";
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0 && required)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}


function ValidateAlNum(obj, objTitle,required)
{
	var ValidChars = "0123456789";
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0 && required)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ValidateName1(obj, objTitle,required)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0 && required)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ValidateAddress(obj, objTitle,required)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ,#()-/0123456789";
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0 && required)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ValidateCompany(obj, objTitle,required)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -.0123456789";
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}
function ValidateUserName(obj, objTitle)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
	var StartChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	
	
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value.charAt(0), StartChars))
	{
		ErrorMessage = objTitle + " Should Start with an Alphabet\n";
		return ErrorMessage;
	}

	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ValidateUserName1(obj, objTitle)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
			
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
} 

function ValidateVersionNumber(obj, objTitle)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.";
	var StartChars = "0123456789";
	
	
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value.charAt(0), StartChars))
	{
		ErrorMessage = objTitle + " Should Start with a Number\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}
function ComparePassword(obj,obj1,objTitle)
{

if (Trim(obj.value)!=Trim(obj1.value))
 {
		ErrorMessage = objTitle + " Password and retype password should be the same\n";
		return ErrorMessage;
	}
	return "";
	
}
function ValidatePassword(obj, objTitle)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	var StartChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	
	
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value.charAt(0), StartChars))
	{
		ErrorMessage = objTitle + " Should Start with an Alphabet\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ValidateCreditCard(obj, objTitle) 
{
   var number = obj.value;
   var ErrorMessage = "";
   
   var ValidChars = "0123456789";


	if (Trim(obj.value).length == 0)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle;
		return ErrorMessage;
	}      
	
   if (number.length > 16 || number.length < 13 )
   { 
		ErrorMessage = "Number of digits in "  + objTitle + " Must be between 13 and 16\n";
		return ErrorMessage;
   }
   
   return "";
   
}

function ValidateOnlyNumeric(obj, objTitle) 
{
   var number = obj.value;
   var ErrorMessage = "";
   
   var ValidChars = "0123456789";


	if (Trim(obj.value).length == 0)
	{
		ErrorMessage = objTitle + " Should not be empty\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}      
	return "";
   
}

function CheckEmpty(obj, objTitle)
{
	var ErrorMessage="";
	var str=Trim(obj.value);
	if (str.length == 0)
	{
		return ErrorMessage=objTitle + " Should not be Empty\n";
	} 
	return "";
}
function ValidateText(obj, objTitle,isRequired)
{
	var ErrorMessage="";
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890-=`~!@#$%^&*()_+|?{[}],.;:";
	
	
	if (isRequired)
	{
		ErrorMessage = CheckEmpty(obj,objTitle);
		
		if (ErrorMessage.length > 0)
		{
			return ErrorMessage; 
		}
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	return "";
}

function ValidateMultiLine(obj, objTitle,isRequired)
{
	var ErrorMessage="";
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890-=!()?{[}],.;:" + unescape('%0D%0A');
	

	if (isRequired)
	{
		ErrorMessage = CheckEmpty(obj,objTitle);
		
		if (ErrorMessage.length > 0)
		{
			return ErrorMessage; 
		}
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	return "";
}

function CheckEmptyCombo(obj, objTitle)
{
	var ErrorMessage="";
	
	if (obj.selectedIndex <=0)
	{
		ErrorMessage= "Select a value in " + objTitle + "\n";
	} 
	
	return ErrorMessage;
}


function ValidateEmail(obj, objTitle) 
{
	var ErrorMessage="";
	var address = obj.value;
	
   //if (address != '' && address.search) 
   //{
     // if (address.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) 
//      {
		
//	   }
//	   else
//	    {
//			ErrorMessage = "Invalid format in " + objTitle + "\n";
//		}
  // }
  
  
  if (!emailCheck(obj.value))
  {
	ErrorMessage = "Invalid format in " + objTitle + "\n";
  }
   return ErrorMessage;
 }
 
function CheckDate(objFrm,objTo,objFrmTitle,objToTitle)
{
	var ErrorMessage="";
	
	ErrorMessage += CheckEmpty(objFrm,objFrmTitle);
	ErrorMessage += CheckEmpty(objTo, objToTitle);
	
	if (ErrorMessage.length > 0)
	{
		return ErrorMessage;
	}
	
	if (Date.parse(objFrm.value) > Date.parse(objTo.value))
	{
		ErrorMessage=objFrmTitle + " Should not be Greater than " + objToTitle;
	}
	
	return ErrorMessage;
  
}
//****************check dob in user registration********************
/*
function CheckDOB(objFrm,objfrmtitle)
{
var currentTime = new Date()
		var day = currentTime.getDate()
		var month = currentTime.getMonth()
		var year = currentTime.getFullYear()
		//var hr = currentTime.getHours()
		
		var dob = year + "-" + month + "-" + day  

	
	if (Date.parse(objFrm.value)) > dob
	{
		ErrorMessage=objFrmTitle + " Should not be Greater than current date ";
	}
	
	return ErrorMessage;
  
}
*/
//******************************************************************
function ValidateFileName(obj, objTitle,required)
{
	var ErrorMessage="";
	var objval = Trim(obj.value);
	
	if (objval.length <=0 && required)
	{
		ErrorMessage = objTitle + " Should not be empty\n"; 
		return ErrorMessage;
	}
	
//	if(!objval.match(/^([A-Z]:\\\w)?(\\?[\w\-\.]+\w+)+$/i))
//	{
//		ErrorMessage = "Invalid File Format in " + objTitle + "\n";
//	}
	return ErrorMessage;

}


function ValidateInteger(obj,objTitle,required)
{
	var ErrorMessage="";
	var ValidChars = "1234567890";
	var tval=Trim(obj.value);
	
	if ((tval.length == 0) && required)
	{
		ErrorMessage = objTitle + " Should not be Empty or Zero "  + "\n";
		return ErrorMessage;
	}
	
	if ((CInt(tval) == 0) && required)
	{
		ErrorMessage = objTitle + " Should not be Empty or Zero "  + "\n";
		return ErrorMessage;
	}

	
	if (!isSubset(obj.value,ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ValidateCurrency(obj,objTitle,required)
{
	var ErrorMessage="";
	var ValidChars = "1234567890.";
	var tval=Trim(obj.value);
	var index;
	var dots;
	var digitafterdot;
	
	if (tval.length == 0 && required)
	{
		ErrorMessage = objTitle + " Should not be Empty or Zero "  + "\n";
		return ErrorMessage;
	}
	
	if (parseFloat(tval) == 0 && required)
	{
		ErrorMessage = objTitle + " Should not be Empty or Zero "  + "\n";
		return ErrorMessage;
	}

	if (!isSubset(obj.value,ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	dots=0;
	digitafterdot=0;
	
	for (index=0;index < tval.length;index++)
	{
		if (tval.charAt(index) == ".")
		{
			dots++;
		}
		else
		{
			if (dots > 0)
			{
				digitafterdot++;
			}
		}
	}
	
	if (dots > 1)
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	if (digitafterdot > 2)
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ShowErrorMessage(errMsg)
{
	var ErrorMessage="";
	if (errMsg.length == 0)
	{
		document.request_frm.submit();
		return true;
	}
	else
	{
		ErrorMessage = "The Following has to be done\n\n" + errMsg + "\n Please Re-Enter\n";			
		alert(ErrorMessage);
		return false
	}
}

function ShowErrorMessage1(errMsg)
{
	var ErrorMessage="";
	if (errMsg.length == 0)
	{
		return true;
	}
	else
	{
		ErrorMessage = "The Following has to be done\n\n" + errMsg + "\n \n";			
		alert(ErrorMessage);
		return false
	}
}

function CInt(txt)
{
	var ValidChars = "0123456789";
	var index=0;
	var isFound = false;
	var numString="";
	
	if (Trim(txt) == "")
	{
		return 0;
	}
	
	while (index < txt.length)
	{
		if (txt.charAt(index) != "0")
		{
			if (ValidChars.indexOf(txt.charAt(index)) < 0)
			{
			
			} 
			else
			{
				isFound = true;
			}
		}
		if (isFound && ValidChars.indexOf(txt.charAt(index)) >= 0)
		{
			numString += txt.charAt(index);
		}	
		index++;
	}
	
	if (Trim(numString) == "")
	{
		return 0;
	}
	else
	{
		return (parseInt(numString));
	}
		
}



function emailCheck (emailStr) 
{

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:#$%^&*\\\\\\\"\\\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) 
{
	return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) 
{
	if (user.charCodeAt(i)>127) 
	{
		return false;
   }
}
for (i=0; i<domain.length; i++) 
{
	if (domain.charCodeAt(i)>127) 
	{
		return false;
    }
}


if (user.match(userPat)==null) 
{
	return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) 
{

// this is an IP address

	for (var i=1;i<=4;i++) 
	{
		if (IPArray[i]>255) 
		{
			return false;
		}
	}
	return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;

for (i=0;i<len;i++) 
{
	if (domArr[i].search(atomPat)==-1) 
	{
		return false;
	}
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) 
{
	return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) 
{
	return false;
}
return true;
}

function ValidateFile(obj,objTitle,Type)
{
	
	if (obj.value!="")
	{
	var ErrorMessage = "";
	var a;
	var str;
	a=obj.value.split(".");
	str=a[1];
		
	if (Type=="D")
	{
		if (str.toUpperCase()!="DOC")
		 {
		ErrorMessage = "Invalid file Type  in " + objTitle + "\n";
		return ErrorMessage;
		 }
				
	}
	}
	return "";
}


function ImageValidateFile(obj,objTitle,Type)
{
	if (obj.value!="")
	{
		var ErrorMessage = "";
		var a;
		var str;
		a=obj.value.split(".");
		str=a[1];
		if (a.length>1)
		{   
			if (Type=="I")
			{
				if ((str.toUpperCase()!="BMP") && (str.toUpperCase()!="JPG") && (str.toUpperCase()!="JPEG") && (str.toUpperCase()!="GIF") && (str.toUpperCase()!="PNG"))
				{
					ErrorMessage = "Invalid file Type  in " + objTitle + "\n";
					return ErrorMessage;
				}
			}
		}
	}
	return "";
}


function FlashValidateFile(obj,objTitle)
{
	if (obj.value!="")
	{
		var ErrorMessage = "";
		var a;
		var str;
		a=obj.value.split(".");
		str=a[1];
		if (a.length>1)
		{   
				if (str.toUpperCase()!="SWF") 
				{
					ErrorMessage = "Invalid file Type  in " + objTitle + "\n";
					return ErrorMessage;
				}
		}
	}
	return "";
}



function ValidateDropdownlist(obj, objTitle)
{
	
	var ErrorMessage = "";
	
	if (obj.selectedIndex == 0)
	{
		
		ErrorMessage = "Please select" + objTitle + "\n";
		return ErrorMessage;
	}
	return "";
}
function CheckSelectedDate(obj, objTitle)

{

	var HoldDate=new Date();

	var ErrorMessage = "";

	HoldDate=new Date();

	if (Date.parse(obj.value)>=Date.parse(HoldDate))

		{
			ErrorMessage =  objTitle + " Should not be a future date." + "\n";

			return ErrorMessage;
		}

	return "";

}


/*function CheckSelectedDate(obj, objTitle)
{

var HoldDate=new Date();
var dd,mm,yyyy;
mm=HoldDate.getMonth()+1;
dd=HoldDate.getDate();
yyyy=HoldDate.getYear();
    
if ((mm>=1)&& (mm<=9))
  {
   mm="0" + mm;
  }
if ((dd>=1)&& (dd<=9))
  {
  dd="0" + dd;
  }

var ErrorMessage = "";
HoldDate=new Date();
var currentDate=(mm + "/" + dd + "/" + yyyy);
alert(obj.value+' '+currentDate);
if (obj.value>=currentDate)
{
ErrorMessage =  objTitle + " Should not be a future date." + "\n";
return ErrorMessage;
}
return "";
}*/




function ValidatePhonenumber(obj,objTitle,required)
{
	var ErrorMessage="";
	var ValidChars = "1234567890";
	var tval=Trim(obj.value);
	
	if ((tval.length == 0) && required)
	{
		ErrorMessage = objTitle + " Should not be Empty or Zero "  + "\n";
		return ErrorMessage;
	}
		
	if (!isSubset(obj.value,ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ValidateUKZip(obj, objTitle)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 0123456789";
	
	var ErrorMessage = "";
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function ValidateLanguage(obj, objTitle)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,. ";
	
	var ErrorMessage = "";
	
	if (Trim(obj.value).length == 0)
	{
		ErrorMessage = objTitle + " Should not be Empty or Zero "  + "\n";
		return ErrorMessage;
	}
	
	if (!isSubset(obj.value, ValidChars))
	{
		ErrorMessage = "Invalid format in " + objTitle + "\n";
		return ErrorMessage;
	}
	
	return "";
}

function checkpreview(mylist)
	{
	var ErrorMessage = "";
	if (mylist.selectedIndex<0)
	     {
	      ErrorMessage ="Please select one Attachment";
	      return ErrorMessage;
	     }
	     return "";
	 } 
	 
	 
	 
	 
	 
	 		/**
		* DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
		*/
		// Declaring valid date character, minimum year and maximum year
		var dtCh= "/";
		var minYear=1900;
		var maxYear=2100;

		function isInteger(s){
			var i;
			for (i = 0; i < s.length; i++){   
				// Check that current character is number.
				var c = s.charAt(i);
				if (((c < "0") || (c > "9"))) return false;
			}
			// All characters are numbers.
			return true;
		}

		function stripCharsInBag(s, bag){
			var i;
			var returnString = "";
			// Search through string's characters one by one.
			// If character is not in bag, append to returnString.
			for (i = 0; i < s.length; i++){   
				var c = s.charAt(i);
				if (bag.indexOf(c) == -1) returnString += c;
			}
			return returnString;
		}

		function daysInFebruary (year){
			// February has 29 days in any year evenly divisible by four,
			// EXCEPT for centurial years which are not also divisible by 400.
			return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
		}
		function DaysArray(n) {
			for (var i = 1; i <= n; i++) {
				this[i] = 31
				if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
				if (i==2) {this[i] = 29}
		} 
		return this
		}

		function isDate(dtStr,title){
			var daysInMonth = DaysArray(12)
			var pos1=dtStr.indexOf(dtCh)
			var pos2=dtStr.indexOf(dtCh,pos1+1)
			var strDay=dtStr.substring(0,pos1)
			var strMonth =dtStr.substring(pos1+1,pos2)
			var strYear=dtStr.substring(pos2+1)
			strYr=strYear
			if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
			if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
			for (var i = 1; i <= 3; i++) {
				if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
			}
			month=parseInt(strMonth)
			day=parseInt(strDay)
			year=parseInt(strYr)
			if (pos1==-1 || pos2==-1){
				
				return (title + " format should be : dd/mm/yyyy")
				//return false
			}
			if (strMonth.length<1 || month<1 || month>12){
				return ("Please enter a valid month for " + title)
				//return false
			}
			if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
				return  ("Please enter a valid day for " + title)
				//return false
			}
			if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
				return ("Please enter a valid 4 digit year between "+minYear+" and "+maxYear+" for " + title)
				//return false
			}
			if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
				return ("Please enter a valid date for " + title)
				//return false
			}
			return "";
		}

		function isValidDate(myDateStr,title)
		{
			return (isDate(myDateStr,title));
		}
		
		function CheckLength(obj, objTitle, objLength)

{

        var ErrorMessage="";

        var str=Trim(obj.value);

        if (str.length > objLength)

        {

                return ErrorMessage=objTitle + " Should not be Greater than " + objLength + " Characters\n";

        } 

        return "";

}


function LengthValidateAddress1(source,arguments)
   {
    
    var sText=document.getElementById("Address1").value;
    if (sText.length>250) 
    {
   
       arguments.IsValid = false;
       return;
    }
 
  return;
}

function LengthValidateAddress2(source,arguments)
   {
    
    var sText=document.getElementById("Address2").value;
    if (sText.length>250) 
    {
   
       arguments.IsValid = false;
       return;
    }
 
  return;
}

function CheckPicture(source,arguments)
{
var a=arguments.Value;

if(a!="")
 { 
  var b=a.substring(a.lastIndexOf(".")+1);
  
if (b=="gif" || b=="GIF" || b=="bmp" || b=="BMP" || b=="jpg" || b=="JPG" || b=="jpeg" || b=="JPEG")
   {
    
   }
  else
  {
   arguments.IsValid = false;
   return;	
  }
}
 return;
} 

function previewSong(source,arguments)
{
var a=arguments.Value;

if(a!="")
 { 
  var b=a.substring(a.lastIndexOf(".")+1);
  
if (b=="MP3" || b=="mp3")
   {
    
   }
  else
  {
   arguments.IsValid = false;
   return;	
  }
}
 return;
}


function qtycheck(selform,chkvalue)  // Quantity Check 
{
	if (selform.principleqty.value < chkvalue)
    	{
	       return "Quantity Shold be atleast 25\n"; 
 		}
}
		