//Open popup windows
function url(FileType, sFileName)
	{
		
		if (FileType=='HTML')
			{
				window.open(sFileName,"","width=400,height=380,status=no,scrollbars=yes,resizable=no,location=no,menubar=no,toolbar=no,top=75,left=200");
			}
		else
			{
				window.open(sFileName,"","width=333,height=520,status=no,scrollbars=no,resizable=no,location=no,menubar=no,toolbar=no,top=20,left=425");
			}

	}


//Check viewcart items for checkout
function CheckCart(cartcount)

	{
		if (cartcount<=0)
			{
				alert('Your cart is empty');
				return true;
			}
			
		else
			{
			return false;
			}
	}

//Check for empty values
function CheckEmpty(obj,sFieldName,objtype)
	{
	var inputData,i,co=0,dot,at,ati;
	inputData=obj.value; 	
		
	if (objtype=='text')
		{
		for (i=0;i<=inputData.length-1;i++)
			{
				if (inputData.substr(i,1)==' ')
				{
					co=co+1;
				}
			}
		if ((inputData=='')||(inputData.length==co))
			{
				alert("The " + sFieldName + " must be filled out");
				obj.focus(); 
				return true;
			}
		else
			{
				return false;
			}
		}
	else
		{
		if (inputData==0)
			{
				alert("Select the " + sFieldName);
				obj.focus(); 
				return true;
			}
		else
			{
				return false;
			}
		}
	}
		
//Email check
function CheckEmail(obj)	
		{
		var inputData,i,co=0,dot,at,ati;
		co=0,ati=0;
		inputData=obj.value; 
		for (i=0;i<=inputData.length-1;i++)
			{
				if ((inputData.substr(i,1)==' ') || (inputData.substr(i,1)=="'") )
					{
					co=co+1;
					}
				if (inputData.substr(i,1)=='@')
					{
					ati=i;
					at='True';
					}
				if ((inputData.substr(i,1)=='.') && (at=='True') && (i>ati))
					{
					dot='True';
					}
			}

		if( dot!='True' || at!='True' || (inputData.substr(0,1)!=' ' && co>0))//dot,@ and space checking in email id
			{
				alert('Please enter your valid email address');
				obj.focus(); 
				return true;
			}
		else
			{
				return false;
			}
		
		}

//Single quote check
function CheckSinglequote(obj)
	{
		var i,inputData,sqfound;
		sqfound=false;
		inputData=obj.value;
		for (i=0;i<=inputData.length-1;i++)
			{
				if (inputData.substr(i,1)=="'")	
					{
						sqfound=true;
						alert('Please remove single quotes');
						obj.focus(); 
						return true;
					}			
			}		
		if (!sqfound)
			{
				return false;
			}
		
	}

//Special Character check (<,>,|)
function CheckSpecialCharacter(obj)
	{
		var i,inputData,sqfound;
		sqfound=false;
		inputData=obj.value;	
		for (i=0;i<=inputData.length-1;i++)
			{
				if ((inputData.substr(i,1)=="<") || (inputData.substr(i,1)==">") || (inputData.substr(i,1)=="|"))	
					{
						sqfound=true;
						alert('Please remove special character(s)');
						obj.focus(); 
						return true;
					}			
			}		
		if (!sqfound)
			{
				return false;
			}
		
	}

//Check for <script>
function CheckScriptContent(obj)
	{
		var i,inputData,sqfound;
		sqfound=false;
		inputData=obj.value;	
		re = /(script>)/i; 
		found = inputData.match(re); 
		if (found+1!='1')		
			{
				sqfound=true;
				alert('Please remove special words/characters');
				obj.focus(); 
				return true;
			}			
		if (!sqfound)
			{
				return false;
			}
	}

//Check Data Validity
function CheckDataValidity(obj,rule)
	{

	var Data;
	Data=obj.value;
	if (rule=="Man")
		{
		if ((isNaN(Data)==true) || (Data<1) || (Data.indexOf('.')!=-1) || (Data.length==0) )
			{
				alert('Enter valid data');
				obj.focus();
				return true;
			}
		}
	if (rule=="NotMan")
		{
		if ((isNaN(Data)==true) || (Data<0) || (Data.indexOf('.')!=-1))
			{
				alert('Enter valid data');
				obj.focus();
				return true;
			}
		}
	if (rule=="ManNeg")
		{
		if ((isNaN(Data)==true) || (Data.indexOf('.')!=-1) || (Data.length==0) )
			{
				alert('Enter valid data');
				obj.focus();
				return true;
			}
		}
	if (rule=="money")
		{
		if ((isNaN(Data)==true) || (Data.length==0) || (Data<=0) )
			{
				alert('Enter valid data');
				obj.focus();
				return true;
			}
		}
		
	}

function checkDate(DayObj,MonthObj,YearObj) 
{
 
  	var myDayStr = DayObj.value;
	var myMonthStr = MonthObj.value;
	var myYearStr = YearObj.value;
	var myDateStr = myDayStr + ' ' + myMonthStr + ' ' + myYearStr;

/* Using form values, create a new date object
which looks like "Wed Jan 1 00:00:00 EST 1975". */
var myDate = new Date( myDateStr );

// Convert the date to a string so we can parse it.
var myDate_string = myDate.toGMTString();

/* Split the string at every space and put the values into an array so,
using the previous example, the first element in the array is "Wed", the
second element is "Jan", the third element is "1", etc. */
var myDate_array = myDate_string.split( ' ' );

/* If we entered "Feb 31, 1975" in the form, the "new Date()" function
converts the value to "Mar 3, 1975". Therefore, we compare the month
in the array with the month we entered into the form. If they match,
then the date is valid, otherwise, the date is NOT valid. */
	if ( myDate_array[2] != myMonthStr ) 
		{
  		alert( myDateStr + ' is NOT a valid date.' );
		DayObj.focus();
		return true;
		} 	
		else 
		{
			 return false;
		}
 
}
 

//Function to restrict the number of input in Text Area
		function MaxTextArea(obj,limit)
		{
			var input,CharCount;
			input=obj.value;
			CharCount=input.length;
			
			if (document.layers)
				{
					var ltempV = event.which;
				}
			if (document.all)
				{
				var ltempV = event.keyCode;
				}
			if 	((ltempV==46))
					{
						if (CharCount>0)
							{
								CharCount=CharCount-1;
							}
					}
			else
				{
					CharCount=CharCount+1;
				}
			if (CharCount>limit)
				{
					event.keyCode=0;
					return true;
				}
		}	


//Function to check the entered date for not biggerthan the current date
			function CompareDate(Date1,Date2) 
			{ 
				var Day1,Month1,Year1,Date1Data,Date2Data;
				var Day2,Month2,Year2;
				DateData1=Date1;
				DateData2=Date2;

				
				var myDate_array1 = DateData1.split( '/' );
				Day1=myDate_array1[0];
				Month1=myDate_array1[1];
				Year1=myDate_array1[2];
				
				
				var myDate_array2 = DateData2.split( '/' );
				Day2=myDate_array2[0];
				Month2=myDate_array2[1];
				Year2=myDate_array2[2];

				//Get integer Values of Date1
				if(Day1.length==2)
					{
						if(Day1.substr(0,1)==0)
							{
								Day1=Day1.substr(1,1);
							}
					}
				if(Month1.length==2)
					{
						if(Month1.substr(0,1)==0)
							{
								Month1=Month1.substr(1,1);
							}
					}
				Day1=parseInt(Day1);
				Month1=parseInt(Month1);
				Year1=parseInt(Year1);
				
				//Get integer Values of Date2
				if(Day2.length==2)
					{
						if(Day2.substr(0,1)==0)
							{
								Day2=Day2.substr(1,1);
							}
					}
				if(Month2.length==2)
					{
						if(Month2.substr(0,1)==0)
							{
								Month2=Month2.substr(1,1);
							}
					}
				Day2=parseInt(Day2);
				Month2=parseInt(Month2);
				Year2=parseInt(Year2);				

				if(Year2==Year1)
					{
						if(Month2==Month1)
							{
								if(Day2<Day1)	
									{
										//alert('Enter valid Date');
										return false;
									}
							}
						else
							if(Month2<Month1)
								{
									//alert('Enter valid Date');
									return false;
								}
					}
				else
					{
						if(Year2<Year1)					

						{
							//alert('Enter valid Date');
							return false;
						}
					}
			}


		function getMonthValue(MonthObj)
		{	
		
			var getMonthValue;
			switch (MonthObj.value.toUpperCase())
			{
				
				case "JAN":
				{
					getMonthValue="1";
					break;
				}
				case "FEB":
				{
					getMonthValue="2";
					break;
				}
				case "MAR":
				{
					getMonthValue="3";
					break;
				}
				case "APR":
				{
					getMonthValue="4";
					break;
				}
				case "MAY":
				{
					getMonthValue="5";
					break;
				}
				case "JUN":
				{
					getMonthValue="6";
					break;
				}
				case "JUL":
				{
					getMonthValue="7";
					break;
				}
				case "AUG":
				{
					getMonthValue="8";
					break;
				}
				case "SEP":
				{
					getMonthValue="9";
					break;
				}
				case "OCT":
				{
					getMonthValue="10";
					break;
				}
				case "NOV":
				{
					getMonthValue="11";
					break;
				}
				case "DEC":
				{
					getMonthValue="12";
					break;
				}
			}
			return getMonthValue;
		}

