function Paycheck(theForm)
{

var a,i;
var c,c1,ct;
var x=theForm.dat.value;

x=new Date(x);

var m = x.getMonth()+1;
var y = x.getYear();
var d = x.getDate();
var s = new String(y);


l=s.length
if (l>2 && l<4)
{
s=s.substring(1,3)
y=parseInt(s)
}

for(i=0;i<s.length;i++);

if (i<4)
y = y + 2000

nos=0
for(i=1;i<=theForm.nick.value;i++)
{

nn=theForm.elements[nos].selectedIndex;
l = theForm.elements[nos].options.length;

Bdd=theForm.elements[nos+1].selectedIndex;
Bmm=theForm.elements[nos+2].selectedIndex;
Byy=theForm.elements[nos+3].selectedIndex;

dtd=theForm.elements[nos+1].options[Bdd].value;
dtm=theForm.elements[nos+2].options[Bmm].value;
dtyv=theForm.elements[nos+3].options[Byy].value;


//alert(dtd-d)
//alert(theForm.elements[nos+14].value)

 
if (nn==0 && l>1)
{
    alert("Please select the recipient.");
    theForm.elements[nos].focus();
    return false;
}
else if (nn==0 && l==1)
{
    //if (theForm.elements[nos+5].value=="DB")
    if (theForm.elements[nos+14].value=="DB")  
    alert("Please add a recipient for Doorbandhan.");
    else 
    alert("Please add a recipient.");
    theForm.elements[nos].focus();
    return false;
}

if (Bdd==0)
{
    alert("Please select the date.");
    theForm.elements[nos+1].focus();
    return false;
}

if (Bmm==0)
{
    alert("Please select the month.");
    theForm.elements[nos+2].focus();
    return false;
}

if (Byy==0)
{
    alert("Please select the year.");
    theForm.elements[nos+3].focus();
    return false;
}


if((dtm == 2 || dtm == 4 || dtm == 6 || dtm == 9 || dtm == 11) && dtd == 31)
{
    alert("Please select the day again as this month does not have 31 days.");
    theForm.elements[nos+1].focus();
    return false;
}

if(dtm == 2 && dtd == 30)
{
    alert("Please select the day again as this month does not have 30 days.");
    theForm.elements[nos+1].focus();
    return false;
}

if(dtyv %4 !=0 && dtm == 2 && dtd ==29)
{
    alert("This is not a leap year.");
    theForm.elements[nos+1].focus();
    return false;
}


//if the  selected day is above  the current day

if(dtyv-y==0 && dtm-m==0 && d-dtd>0)
{
    alert("Invalid entry.");
    theForm.elements[nos+1].focus();
    return false;
}

//if the  selected month is below  the current month 

if(dtyv-y==0 && m-dtm>0)
{
    alert("Invalid entry.");
    theForm.elements[nos+2].focus();
    return false;
}


//if the  selected year is above the current year 

if(y-dtyv>0)
{
    alert("Invalid entry.");
    theForm.elements[nos+3].focus();
    return false;
}
if ((theForm.elements[nos+14].value!="DB")&&(theForm.elements[nos+14].value!="PR"))

{

	if (theForm.elements[nos+4].selectedIndex!=0 && theForm.elements[nos+12].checked==false)
	{
		alert("Please check greeting card.");
		theForm.elements[nos+12].focus()
		return false;
	}

}

if ((theForm.elements[nos+14].value!="DB")&&(theForm.elements[nos+14].value!="PR"))
{

	if (theForm.elements[nos+5].value!="" && theForm.elements[nos+4].selectedIndex==0 && theForm.elements[nos+12].checked==false)
	{  
		alert("Please select the occasion.");
		//theForm.elements[nos+5].value=""
		theForm.elements[nos+4].focus();
		return false;
	}

}

if ((theForm.elements[nos+14].value!="DB")&&(theForm.elements[nos+14].value!="PR"))
{

if (theForm.elements[nos+5].value!="" && theForm.elements[nos+4].selectedIndex!=5 && theForm.elements[nos+12].checked==true)
{  
    alert("Please select other in occasion.");
    theForm.elements[nos+5].value=""
    theForm.elements[nos+4].focus();
    return false;
}

}

if (theForm.elements[nos+6].selectedIndex==0)
{
    alert("Please select the delivery time.");
    theForm.elements[nos+6].focus();
    return false;
}

if ((theForm.elements[nos+14].value!="DB")&&(theForm.elements[nos+14].value!="PR"))
{

if (theForm.elements[nos+7].value!="" && theForm.elements[nos+4].selectedIndex==0 && theForm.elements[nos+12].checked==false)
{  
    alert("Please select the occasion.");
    //theForm.elements[nos+7].value=""
    theForm.elements[nos+4].focus();
    return false;
}

}

if ((theForm.elements[nos+14].value!="DB")&&(theForm.elements[nos+14].value!="PR"))
{

if (theForm.elements[nos+12].checked==true && theForm.elements[nos+4].selectedIndex==0)
{
    alert("Please select the occasion.");
    theForm.elements[nos+4].focus()
    return false;
}

}

if ((theForm.elements[nos+14].value!="DB")&&(theForm.elements[nos+14].value!="PR"))
{

if (theForm.elements[nos+4].selectedIndex==5 && theForm.elements[nos+5].value=="")
{
    alert("Please enter the occasion.");
    theForm.elements[nos+5].focus()
    return false;
}

}

/*if (theForm.elements[nos+12].checked==false && theForm.elements[nos+4].selectedIndex!=0)
{
    alert("Please check greeting card.");
    theForm.elements[nos+12].focus()
    return false;
}*/


/*if (theForm.elements[nos+4].selectedIndex!=5 && theForm.elements[nos+12].checked==true)
{  
    theForm.elements[nos+5].value=""
    return false;
}
*/

//if itemcode is sarees
//if (theForm.elements[nos+5].value=="Toy" || theForm.elements[nos+5].value=="DB")
if (theForm.elements[nos+14].value=="SR")
{
    if(y-dtyv==0  && m-dtm==0 && (dtd-d==0 || dtd-d==1 || dtd-d==2))
    {
        alert("Saree orders need to be placed atleast 3 days in advance.");
        theForm.elements[nos+1].focus();
        return false;
    }

    //For 30 days in a month

    if((m == 4 || m == 6 || m == 9 || m == 11) && d == 29)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1))
        {
            alert("Saree orders need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }
    
    if((m == 4 || m == 6 || m == 9 || m == 11) && d == 30)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
        {
        alert("Saree orders need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }
    

    //For 31 days in a month

    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 30)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1))
        {
            alert("Saree orders need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }
    
    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 31)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
        {
        alert("Saree orders need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }
    
    //For the month of feburary
    if (y%4 != 0)
    {
        if (m==2 && d==27)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
        alert("Saree orders need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==28)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
        alert("Saree orders need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

    }
    else
    {
       
        if (m==2 && d==28)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
        alert("Sarees order need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==29)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
        alert("Sarees order need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }
    }
}  //end of if loop checking whether item code is of saree


//if item is silver 
if (theForm.elements[nos+14].value=="SL")
{
    if(y-dtyv==0  && m-dtm==0 && (dtd-d==0 || dtd-d==1 || dtd-d==2 || dtd-d==3))
    {
        alert("Silver items need to be placed atleast 4 days in advance.");
        theForm.elements[nos+1].focus();
        return false;
    }
    
    //For 30 days in a month
    
    if((m == 4 || m == 6 || m == 9 || m == 11) && (d==28))
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1))
        {
            alert("Silver items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    if((m == 4 || m == 6 || m == 9 || m == 11) && (d==29))
    {
        if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
        {
            alert("Silver items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        } 
    }

    if((m == 4 || m == 6 || m == 9 || m == 11) && (d==30))
    {
        if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
        {
            alert("Silver items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        } 
    }

    //For 31 days in a month
    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 29)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1))
        {
            alert("Silver items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 30)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
        {
            alert("Silver items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 31)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
        {
            alert("Silver items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    //For the month of february

    if (y%4!=0)
    {
        if(m==2 && d==26)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Silver items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==27)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Silver items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==28)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Silver items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }
    }//end of the if part of the loop

//code for leap year
    else if (y%4==0)
    {
        if(m==2 && d==27)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Silver items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==28)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Silver items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==29)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Silver items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }
    }
}


//if item is jewellery 
if (theForm.elements[nos+14].value=="GJ")
{
    if(y-dtyv==0  && m-dtm==0 && (dtd-d==0 || dtd-d==1 || dtd-d==2 || dtd-d==3))
    {
        alert("Jewellery items need to be placed atleast 4 days in advance.");
        theForm.elements[nos+1].focus();
        return false;
    }
    
    //For 30 days in a month
    
    if((m == 4 || m == 6 || m == 9 || m == 11) && (d==28))
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1))
        {
            alert("Jewellery items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    if((m == 4 || m == 6 || m == 9 || m == 11) && (d==29))
    {
        if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
        {
            alert("Jewellery items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        } 
    }

    if((m == 4 || m == 6 || m == 9 || m == 11) && (d==30))
    {
        if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
        {
            alert("Jewellery items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        } 
    }

    //For 31 days in a month
    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 29)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1))
        {
            alert("Jewellery items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 30)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
        {
            alert("Jewellery items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 31)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
        {
            alert("Jewellery items need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    //For the month of february

    if (y%4!=0)
    {
        if(m==2 && d==26)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Jewellery items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==27)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Jewellery items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==28)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Jewellery items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }
    }//end of the if part of the loop

//code for leap year
    else if (y%4==0)
    {
        if(m==2 && d==27)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Jewellery items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==28)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Jewellery items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==29)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Jewellery items need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }
    }
}

//if item is festival jewellery
if (theForm.elements[nos+14].value=="fs")
{
    if(y-dtyv==0  && m-dtm==0 && (dtd-d==0 || dtd-d==1 || dtd-d==2 || dtd-d==3))
    {
        alert("Jewellery items need to be placed atleast 3 days in advance.");
        theForm.elements[nos+1].focus();
        return false;
    }
    
    //For 30 days in a month
    
    if((m == 4 || m == 6 || m == 9 || m == 11) && (d==28))
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1))
        {
            alert("Jewellery items need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    if((m == 4 || m == 6 || m == 9 || m == 11) && (d==29))
    {
        if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
        {
            alert("Jewellery items need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        } 
    }

    if((m == 4 || m == 6 || m == 9 || m == 11) && (d==30))
    {
        if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
        {
            alert("Jewellery items need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        } 
    }

    //For 31 days in a month
    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 29)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1))
        {
            alert("Jewellery items need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 30)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
        {
            alert("Jewellery items need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 31)
    {
        if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
        {
            alert("Jewellery items need to be placed atleast 3 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }
    }

    //For the month of february

    if (y%4!=0)
    {
        if(m==2 && d==26)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Jewellery items need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==27)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Jewellery items need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==28)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Jewellery items need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }
    }//end of the if part of the loop

//code for leap year
    else if (y%4==0)
    {
        if(m==2 && d==27)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Jewellery items need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==28)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Jewellery items need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if (m==2 && d==29)
        {
            if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Jewellery items need to be placed atleast 3 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }
    }
}
/*
//if itemcode is jewellery old
if (theForm.elements[nos+5].value=="GJ")
{
    if (theForm.elements[nos+6].value=="Bangles")
    {
        if(y-dtyv==0  && m-dtm==0 && (dtd-d==1 || dtd-d==2 || dtd-d==3))
        {
            alert("Orders need to be placed atleast 4 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }

        //For 30 days in a month
        if((m == 4 || m == 6 || m == 9 || m == 11) && (d==28))
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Orders need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 4 || m == 6 || m == 9 || m == 11) && (d==29))
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Orders need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 4 || m == 6 || m == 9 || m == 11) && (d==30))
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Orders need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        //For 31 days in a month
        if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 29)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Orders need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 30)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Orders need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 31)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Orders need to be placed atleast 4 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        //For the month of february
    
        if (y%4!=0)
        {
            if(m==2 && d==26)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1))
                {
                    alert("Orders need to be placed atleast 4 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if(m==2 && d==27)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
                {
                    alert("Orders need to be placed atleast 4 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if(m==2 && d==28)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
                {
                    alert("Orders need to be placed atleast 4 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }
        }
        //code for leap year
        else
        {

            if(m==2 && d==27)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1))
                {
                    alert("Orders need to be placed atleast 4 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if(m==2 && d==28)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
                {
                    alert("Orders need to be placed atleast 4 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if(m==2 && d==29)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
                {
                    alert("Orders need to be placed atleast 4 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }
        }// end of the if loop for the month of feburary
    }//end of the if loop for type is bangle

    //code for chains (jewellery)

    else if (theForm.elements[nos+6].value=="Chain")
    {
        if(y-dtyv==0  && m-dtm==0 && (dtd-d==1 || dtd-d==2 || dtd-d==3 || dtd-d==4 || dtd-d==5 || dtd-d==6))
        {
            alert("Orders need to be placed atleast 7 days in advance.");
            theForm.elements[nos+1].focus();
            return false;
        }

        //for 30 days in a month

        if((m == 4 || m == 6 || m == 9 || m == 11) && d == 25)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 4 || m == 6 || m == 9 || m == 11) && d == 26)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 4 || m == 6 || m == 9 || m == 11) && d == 27)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 4 || m == 6 || m == 9 || m == 11) && d == 28)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 4 || m == 6 || m == 9 || m == 11) && d == 29)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4 || dtd==5))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 4 || m == 6 || m == 9 || m == 11) && d == 30)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4 || dtd==5 || dtd==6))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        //For 31 days in a month

        if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 26)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 27)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 28)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 29)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 30)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4 || dtd==5))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        if((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && d == 31)
        {
            if(dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4 || dtd==5 || dtd==6))
            {
                alert("Orders need to be placed atleast 7 days in advance.");
                theForm.elements[nos+1].focus();
                return false;
            }
        }

        //for the month of feburary
        if (y%4 != 0)
        {

            if (m==2 && d==23)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==24)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==25)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==26)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==27)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4 || dtd==5))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==28)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4 || dtd==5 || dtd==6))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }
        }
        else
        {

            if (m==2 && d==24)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==25)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==26)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==27)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==28)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4 || dtd==5))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }

            if (m==2 && d==29)
            {
                if (dtyv-y==0 && dtm-m==1 && (dtd==1 || dtd==2 || dtd==3 || dtd==4 || dtd==5 || dtd==6))
                {
                    alert("Orders need to be placed atleast 7 days in advance.");
                    theForm.elements[nos+1].focus();
                    return false;
                }
            }
        }//end of code for the month of feb
    }//end of code for item type as chain
    
}
*/  //end of the if loop for itemcode is GJ
//nos=nos+7
nos=nos+16
}
//end of the for loop

/*
if(theForm.occasion.selectedIndex == 0 && theForm.checkgreeting.checked==true)
{
    alert("Please choose the occasion.");
    theForm.occasion.focus()
    return false;
}

if(theForm.occasion.selectedIndex==5 && theForm.other.value=="")  
{
alert("Please enter the occasion");
theForm.other.focus()
return false;
}

if(theForm.occasion.selectedIndex==0 && theForm.greetmessg.value!="")  
{
alert("Please choose the occasion.");
theForm.occasion.focus()
return false;
}
*/

if(theForm.payment.selectedIndex==0)
{
alert("Please choose your payment mode.");
theForm.payment.focus()
return false;
}

return true;
}


//For doorbandhan
function dbcheck(theForm)
{
alert("door")
if(theForm.Address.value=="")
{
alert("Please enter your delivery address.");
theForm.Address.focus();
return false;
}

if(theForm.city.selectedIndex == 0)
{
alert("Please select your city.");
theForm.city.focus();
return false;
}

if(theForm.State.value=="")
{
alert("Please enter your state.");
theForm.State.focus();
return false;
}

//if((theForm.Delivery.checked) && (theForm.LandMark.value!="") && (theForm.phone.value==""))

if(theForm.phone.value=="") 
{
alert("Please enter your telephone number.");
theForm.phone.focus();
return false;
}
else
{
a = theForm.phone.value;
 var i=0;
 for(i=0;i<a.length;i++)
 {
  if(a.charAt(i) < '0' || a.charAt(i) > '9') 
  {
   if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
    {
     alert("Characters and Special symbols are not allowed in the Phone field.");
     theForm.phone.select();
     theForm.phone.focus();
     return false;
    }
   }
 }
}



if(theForm.LandMark.value=="")
{
alert("Please enter a land mark that is near by.");
theForm.LandMark.focus();
return false;
}


if(theForm.payment.selectedIndex == 0)
{
alert("Please choose your payment mode.");
theForm.payment.focus()
return false;
}


if(theForm.Bdd.selectedIndex == 0)
 {
  alert("Please select the day.");
  theForm.Bdd.focus();
  return false;
 }

if(theForm.Bmm.selectedIndex == 0)
 {
  alert("Please select the month.");
  theForm.Bmm.focus();
  return false;
 }

if(theForm.Byy.selectedIndex == 0)
 {
  alert("Please select the year.");
  theForm.Byy.focus();
  return false;
 }

var a,i;
var c,c1,ct;

var x=theForm.dat.value;

x=new Date(x);

var m = x.getMonth()+1;
var y = x.getYear();
var d = x.getDate();

for(i=0;i<y;i++);

if (i == 2)
y = y + 2000


//alert("date = "+d+" month = "+m+" year = "+ y)

var dtm = theForm.Bmm.selectedIndex;
var dtd = theForm.Bdd.selectedIndex;
var dty = theForm.Byy.selectedIndex;

var dtyv =theForm.Byy[dty].value;
var dtmv =theForm.Bmm[dtm].value;
var dtdv =theForm.Bdd[dtd].value;

//ct=birthr.dcnt.value;


if(theForm.Bdd.selectedIndex == 0)
 {
  alert("Please select the day.");
  theForm.Bdd.focus();
  return false;
}
 
if(theForm.Bmm.selectedIndex == 0)
 {
  alert("Please select the month.");
  theForm.Bmm.focus();
  return false;
 }

if(theForm.Byy.selectedIndex == 0)
 {
  alert("Please select the year.");
  theForm.Byy.focus();
  return false;
 }

if((dtm == 2 || dtm == 4 || dtm == 6 || dtm == 9 || dtm == 11) && dtd == 31)
{
alert("Please select the day again as this month does not have 31 days.");
theForm.Bdd.focus();
return false;
}

if(dtm == 2 && dtd == 30)
{
alert("Please select the day again as this month does not have 30 days.");
theForm.Bdd.focus();
return false;
}

if(dtyv %4 !=0 && dtm == 2 && dtd ==29)
{
alert("This is not a leap year.");
theForm.Bdd.focus();
return false;
}

//if the  selected day is above  the current day

if(dtyv-y==0 && dtmv-m==0 && d-dtdv>0)
{
alert("Invalid entry.");
theForm.Bdd.focus();
return false;
}

//if the  selected month is below  the curruent month 

if(dtyv-y==0 && m-dtmv>0)
{
alert("Invalid entry.");
theForm.Bmm.focus();
return false;
}


//if the  selected year is above the curruent year 


if(y-dtyv>0)
{
alert("Invalid entry.");
theForm.Byy.focus();
return false;
}
return true;
}



function cityfocus()
{
document.check.city.blur();
}
