﻿
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


    
    function setTotalPrice()
    {
		   var sum=0;
		   $('.chk:checked').each(
		   function(i)
		   {
		   sum+=parseInt($('#price'+this.value).html().replace(/\,/g,''))*parseInt($('#Duration').val());
		   });
		   $('#TotalPrice').val(sum);
		   $('#spn_TotalPrice').html(' مجموع :'+addCommas(sum)+' ریال '); 
		   
		  
		  
		  
    }
    
    
    function setPrices(Duration1)
         {
        var Duration = document.forms['form1'].elements['Duration'];
        var Year = document.forms['form1'].elements['Year'];
        var Month = document.forms['form1'].elements['Month'];
        var Day = document.forms['form1'].elements['Day'];
        var duration = parseInt(Duration.options[Duration.selectedIndex].value);
        var hyear = parseInt(Year.options[Year.selectedIndex].value);
        var hmonth = parseInt(Month.options[Month.selectedIndex].value);
        var hday = parseInt(Day.options[Day.selectedIndex].value);
       
        var fday = parseInt( document.forms['form1'].elements['fday'].value);
        var fmonth = parseInt( document.forms['form1'].elements['fmonth'].value);
        var fyear = parseInt( document.forms['form1'].elements['fyear'].value);
        var tday = parseInt( document.forms['form1'].elements['tday'].value);
        var tmonth = parseInt( document.forms['form1'].elements['tmonth'].value);
        var tyear = parseInt( document.forms['form1'].elements['tyear'].value);
        var Amount = parseInt( document.forms['form1'].elements['Amount'].value);
        var Percent =parseFloat(parseInt(document.forms['form1'].elements['Percent'].value)/100);
         
        var pfday = parseInt( document.forms['form1'].elements['pfday'].value);
        var pfmonth = parseInt( document.forms['form1'].elements['pfmonth'].value);
        var pfyear = parseInt( document.forms['form1'].elements['pfyear'].value);
        var ptday = parseInt( document.forms['form1'].elements['ptday'].value);
        var ptmonth = parseInt( document.forms['form1'].elements['ptmonth'].value);
        var ptyear = parseInt( document.forms['form1'].elements['ptyear'].value);
        
        var flag = false;
        var flag2 = false;
        // ------
        
        if (fday != 0 && fmonth != 0 && fyear != 0 && tday != 0 && tmonth != 0 && tyear != 0)
                    {
                        var F = fyear * 500 + fmonth * 40 + fday;
                        var T = tyear * 500 + tmonth * 40 + tday;
                        var h = hyear * 500 + hmonth * 40 + hday;
                        if (h >= F && h <= T)
                            flag = true;
                        else    
                            flag = false;
                            
                            

                    }
        // ------
        
        // ------
        if (pfday != 0 && pfmonth != 0 && pfyear != 0 && ptday != 0 && ptmonth != 0 && ptyear != 0)
                    {
                        var F = pfyear * 500 + pfmonth * 40 + pfday;
                        var T = ptyear * 500 + ptmonth * 40 + ptday;
                        var h = hyear * 500 + hmonth * 40 + hday;
                       
                        if (h >= F && h <= T)
                        {
                            flag2 = true;
                            }
                        else    
                            flag2 = false;

                    }
        // ------
        
        var priceBase = document.all.item('priceBase');
        var price = document.all.item('price');
        var totals = document.all.item('total');
        
        var action = document.all.item('action');
        var res = document.all.item('respic');
        
        var action1 = document.all.item('action1');
        var res1 = document.all.item('respic1');
       
        var price = 0;
        var i=0;
    if (priceBase!=null) 
    {
        if(priceBase.length!=null)
        {
	      for (i=0; i<priceBase.length; i++)
	       {
	            document.all.item('price')[i].innerHTML=
	            document.all.item('priceBase')[i].innerHTML.replace(/\,/g,'');
	            if(flag)
	            {
	                if(Amount!=0)
	                {
	                    document.all.item('price')[i].innerHTML=
	                    
	                    addCommas(
	                    parseInt(document.all.item('priceBase')[i].innerText.replace(/\,/g,''))+Amount
	                
	                );
	                }
	                else if(Percent!=0)
	                {
	                    document.all.item('price')[i].innerHTML=
	                    addCommas(
	                    parseInt(document.all.item('priceBase')[i].innerText.replace(/\,/g,''))+
	                    parseInt(document.all.item('priceBase')[i].innerText.replace(/\,/g,''))*Percent
	                    );
	                    //alert(Percent);
	                }
	            } 
	            
	            document.all.item('total')[i].innerHTML=
	            addCommas(
	            parseInt(document.all.item('price')[i].innerHTML.replace(/\,/g,''))*duration);
	            
	       }
        }
        else 
        {
           document.all.item('price').innerHTML=
           addCommas(
	       parseInt(document.all.item('priceBase').innerHTML.replace(/\,/g,''))
	       );
           if(flag)
	            {
	                if(Amount!=0)
	                {
	                    document.all.item('price').innerHTML=
	                    addCommas(
	                    parseInt(document.all.item('priceBase').innerHTML.replace(/\,/g,''))+Amount
	                    );
	                }
	                else if(Percent!=0)
	                {
	                    document.all.item('price').innerHTML=
	                    addCommas(
	                    parseInt(document.all.item('priceBase').innerHTML.replace(/\,/g,''))+
	                    parseInt(document.all.item('priceBase').innerHTML.replace(/\,/g,''))*Percent
	                    
	                    );
	                }
	            } 
           totals.innerText= 
           addCommas(
           parseInt(document.all.item('price').innerHTML.replace(/\,/g,''))*duration
           
           );
        }
    }
		  
    if(flag2)
    {
    if (res!=null) 
    {  
        if(res.length!=null)
        {
	      for (i=0; i<res.length; i++)
	       {
	       
	            document.all.item('respic')[i].onclick=function(){};;
	            document.all.item('respic')[i].src='Images/notres.jpg';
	            
	       }
	       
	    }
	    else
	    {		 
	            document.all.item('respic').onclick=function(){};
	            document.all.item('respic').src='Images/notres.jpg';
	          
	    }
	    
	}
	
	if (res1!=null) 
    {
        if(res1.length!=null)
        {
	      for (i=0; i<res1.length; i++)
	       {
	       
	           document.all.item('respic1')[i].onclick=function(){};;
	           document.all.item('respic1')[i].src='Images/notres.jpg';
	          
	       }
	       
	    }
	    else
	    {
	            document.all.item('respic1').onclick=function(){};;
	            document.all.item('respic1').src='Images/notres.jpg';
	            
	    }
	    
	}
	}
	else
	{
	if (res!=null) 
    {
        if(res.length!=null)
        {
	      for (i=0; i<res.length; i++)
	       {
	            document.all.item('respic')[i].onclick=
	            document.all.item('action')[i].onclick;//alert(document.all.item('res',i).onclick);
	            document.all.item('respic')[i].src='Images/res.jpg';
	       }
	       
	    }
	    else
	    {
	            document.all.item('respic').onclick=
	            document.all.item('action').onclick;
	            
	            document.all.item('respic').src='Images/res.jpg';
	            
	            
	    }
	    
	}
	
	if (res1!=null) 
    {
        if(res1.length!=null)
        {
	      for (i=0; i<res1.length; i++)
	       {
	            document.all.item('respic1')[i].onclick=
	            document.all.item('action1')[i].onclick;//alert(document.all.item('res',i).onclick);
	            document.all.item('respic1')[i].src='Images/order.jpg';
	       }
	       
	    }
	    else
	    {
	            document.all.item('respic1').onclick=
	            document.all.item('action1').onclick;
	            document.all.item('respic1').src='Images/order.jpg';
	    }
	    
	}
	}
	
   
           
         }

    var ee='00';
         function setText(elementSelect,selectTarget,percent)
         {
         var eeee=document.getElementById('TotalPrice');
         
    var hotelPrice = parseInt( 
        eeee.value.replace(/\,/g,'')
    
    
    );
         var price = parseInt(elementSelect.options[elementSelect.selectedIndex].value)*(hotelPrice*percent);
           price = parseInt(price);
    selectTarget.innerHTML=price+' ریال ';
    
    
   
    calcTotal();
           
         }
         function calcTotal()
         {

         var NumberAdult=document.getElementById('NumberAdult');
         var Number6t12=document.getElementById('Number6t12');
         var Number2t6=document.getElementById('Number2t6');
         var NumberLesst2=document.getElementById('NumberLesst2');
         
         var n1=parseInt(NumberAdult.options[NumberAdult.selectedIndex].value);
         var n2=parseInt(Number6t12.options[Number6t12.selectedIndex].value);
         var n3=parseInt(Number2t6.options[Number2t6.selectedIndex].value);
         var n4=parseInt(NumberLesst2.options[NumberLesst2.selectedIndex].value);
         var hotelPrice = document.forms['form1'].elements['TotalPrice'].value.replace(/\,/g,'');
         var total = hotelPrice;

        document.forms['form1'].elements['FinalPrice'].value = hotelPrice;
        
         document.all.PriceTotal.innerHTML = addCommas(hotelPrice)+ ' ریال ';
         
         }
         
         function refresh()
         {
         var pMethod=document.getElementById('pMethod');
         var Radio1 = document.getElementById('Radio1');
         var Radio2 = document.getElementById('Radio2');
         var Radio3 = document.getElementById('Radio3');
         var Radio4 = document.getElementById('Radio4');
         
         var pContent=document.getElementById('pContent');
         
         if (Radio1.checked)
            {
            pContent.innerHTML ='';
            }
            else if (Radio2.checked)
            {
            pContent.innerHTML = '<span lang="fa">&#1588;&#1605;&#1575; &#1576;&#1575; &#1583;&#1575;&#1588;&#1578;&#1606; &#1581;&#1587;&#1604;&#1576; &#1576;&#1575;&#1606;&#1705;&#1740; &#1583;&#1585; &#1740;&#1705;&#1740; &#1575;&#1586; &#1576;&#1575;&#1606;&#1705;&#1607;&#1575;&#1740; &#1586;&#1740;&#1585; &#1605;&#1740;&#1578;&#1608;&#1575;&#1606;&#1740;&#1583; &#1605;&#1576;&#1604;&#1594; &#1582;&#1608;&#1583; &#1585;&#1575; &#1576;&#1589;&#1608;&#1585;&#1578; </span>online <span lang="fa">&#1575;&#1586; &#1591;&#1585;&#1740;&#1602; &#1575;&#1740;&#1606;&#1578;&#1585;&#1606;&#1578; &#1662;&#1585;&#1583;&#1575;&#1582;&#1578; &#1606;&#1605;&#1608;&#1583;&#1607; &#1608; &#1585;&#1587;&#1740;&#1583; &#1575;&#1604;&#1705;&#1578;&#1585;&#1608;&#1606;&#1740;&#1705;&#1740; &#1570;&#1606; &#1585;&#1575;&#1578;&#1608;&#1587;&#1591; </span>email <span lang="fa">&#1582;&#1608;&#1583; &#1705;&#1607; &#1583;&#1585; &#1601;&#1585;&#1605; &#1576;&#1575;&#1604;&#1575; &#1602;&#1740;&#1583; &#1705;&#1585;&#1583;&#1607; &#1575;&#1740;&#1583; &#1575;&#1586; &#1591;&#1585;&#1601; &#1576;&#1575;&#1606;&#1705; &#1605;&#1585;&#1576;&#1608;&#1591;&#1607; &#1608; &#1588;&#1585;&#1705;&#1578; &#1570;&#1578;&#1575;&#1604;&#1606;&#1583; &#1583;&#1585;&#1740;&#1575;&#1601;&#1578; &#1606;&#1605;&#1575;&#1740;&#1740;&#1583;.</span>';
            pContent.innerHTML +=
            '<br><br><select name="bank"><option value="parsian" selected>پارسیان</option><option value="saman" selected>سامان</option></select>';
            }
            else if(Radio3.checked)
            {
            pContent.innerHTML = 
            '&#1588;&#1605;&#1575; &#1605;&#1740;&#1578;&#1608;&#1575;&#1606;&#1740;&#1583; &#1576;&#1607; &#1740;&#1705;&#1740; &#1575;&#1586; &#1588;&#1605;&#1575;&#1585;&#1607; &#1581;&#1587;&#1604;&#1576;&#1607;&#1575;&#1740; &#1586;&#1740;&#1585; &#1605;&#1576;&#1604;&#1594; &#1582;&#1608;&#1583; &#1585;&#1575; &#1662;&#1585;&#1583;&#1575;&#1582;&#1578; &#1606;&#1605;&#1608;&#1583;&#1607; &#1608; &#1588;&#1605;&#1575;&#1585;&#1607; &#1601;&#1740;&#1588; &#1576;&#1575;&#1606;&#1705;&#1740; &#1585;&#1575; &#1576;&#1585;&#1575;&#1740; &#1605;&#1575; &#1575;&#1586; &#1607;&#1585; &#1591;&#1585;&#1740;&#1602; &#1575;&#1586; &#1580;&#1605;&#1604;&#1607; </span>email <span lang="fa">&#1548; &#1578;&#1604;&#1601;&#1606; &#1608; &#1740;&#1575; &#1583;&#1585; &#1576;&#1575;&#1705;&#1587; &#1586;&#1740;&#1585; &#1608;&#1575;&#1585;&#1583; &#1606;&#1605;&#1608;&#1583;&#1607; &#1608; &#1575;&#1585;&#1587;&#1575;&#1604; &#1606;&#1605;&#1575;&#1740;&#1740;&#1583;.'
            +
            '<table cellspacing="0" border="0" width="536" id="table5"><tr><td style="border: 0px solid #C0C0C0;" width="89">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#FF9900">نام بانک</font></span></td><td style="border: 0px solid #C0C0C0;" width="61">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#FF9900">&#1705;&#1583; '
				+'&#1588;&#1593;&#1576;&#1607;</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="102">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#FF9900">&#1606;&#1575;&#1605; '
				+'&#1588;&#1593;&#1576;&#1607;</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="116">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#FF9900">'
				+'&#1588;&#1605;&#1575;&#1585;&#1607; &#1581;&#1587;&#1575;&#1576;</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="60">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#FF9900">&#1606;&#1608;&#1593; '
				+'&#1581;&#1587;&#1575;&#1576;</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="89">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#FF9900">'
				+'&#1576;&#1606;&#1575;&#1605;</font></span></td>'
			+'</tr>'
			+'<tr>'
				+'<td style="border: 0px solid #C0C0C0; " width="89">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">ملت</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="61">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">63230</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="102">'
				+'<font size="1" face="Tahoma" color="#666666"><span lang="fa">کارگر شمالی'
				+'</span></font></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="116">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">'
				+'82282869</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="60">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">'
				+'جام</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="89">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">'
				+'توران گشت شرق)آتالند(</font></span></td>'
			+'</tr>'
			+'<tr>'
				+'<td style="border: 0px solid #C0C0C0; " width="89">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">'
				+'&#1587;&#1575;&#1605;&#1575;&#1606;</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="61">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">810</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="102">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">'
				+'&#1601;&#1575;&#1591;&#1605;&#1740;</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="116">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">'
				+'1-276646-40</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="60">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">'
				+'&#1580;&#1575;&#1585;&#1740;</font></span></td>'
				+'<td style="border: 0px solid #C0C0C0; " width="89">'
				+'<span lang="fa"><font size="1" face="Tahoma" color="#666666">'
				+'توران گشت شرق)آتالند(</font></span></td>'
			+'</tr>'
		+'</table>';
            pContent.innerHTML += 
            '<BR><BR><INPUT TYPE="TEXT" onmousedown="event.cancelBubble = true;return true;" onmouseup="event.cancelBubble = true;return true;" onselectstart="event.cancelBubble = true;return true;" Name="FactorNumber"/>';
            }
            else if(Radio4.checked)
            {
            pContent.innerHTML = 
            '&#1576;&#1593;&#1583; &#1575;&#1586; &#1608;&#1575;&#1585;&#1583; &#1705;&#1585;&#1583;&#1606; &#1570;&#1583;&#1585;&#1587; &#1589;&#1581;&#1740;&#1581; &#1582;&#1608;&#1583; &#1583;&#1585; &#1601;&#1585;&#1605; &#1576;&#1575;&#1604;&#1575;&#1548; &#1605;&#1585;&#1575;&#1581;&#1604; &#1579;&#1576;&#1578; &#1606;&#1575;&#1605; &#1578;&#1608;&#1585; &#1588;&#1605;&#1575;&nbsp; &#1575;&#1606;&#1580;&#1575;&#1605; &#1588;&#1583;&#1607; &#1608; &#1705;&#1604;&#1740;&#1607; &#1605;&#1583;&#1575;&#1585;&#1705; &#1608; &#1576;&#1604;&#1740;&#1591; &#1608; &#1576;&#1585;&#1711;&#1607; &#1585;&#1587;&#1740;&#1583; &#1578;&#1608;&#1587;&#1591; &#1662;&#1740;&#1705; &#1605;&#1608;&#1578;&#1608;&#1585;&#1740; &#1576;&#1607; &#1607;&#1605;&#1575;&#1606; &#1570;&#1583;&#1585;&#1587;&#1740; &#1705;&#1607; &#1602;&#1740;&#1583; &#1705;&#1585;&#1583;&#1607; &#1575;&#1740;&#1583; &#1601;&#1585;&#1587;&#1578;&#1575;&#1583;&#1607; &#1588;&#1583;&#1607; &#1608; &#1662;&#1587; &#1575;&#1586; &#1583;&#1585;&#1740;&#1575;&#1601;&#1578; &#1662;&#1608;&#1604;&#1548; &#1576;&#1607; &#1588;&#1605;&#1575; &#1578;&#1581;&#1608;&#1740;&#1604; &#1583;&#1575;&#1583;&#1607; &#1605;&#1740;&#1588;&#1608;&#1583;.';
            }
            else if(Radio5.checked)
            {		
            pContent.innerHTML =
            '<span lang="fa">';
        pContent.innerHTML +=
        '<font face="Tahoma" size="1" color="#333333">&#1570;&#1583;&#1585;&#1587; &#1583;&#1601;&#1578;&#1585; &#1605;&#1585;&#1705;&#1586;&#1740;:</font></span><BR><span lang="fa"><font face="Tahoma" size="1" color="#666666">&#1578;&#1607;&#1585;&#1575;&#1606;&#1548; &#1575;&#1606;&#1578;&#1607;&#1575;&#1740; &#1582;&#1740;&#1575;&#1576;&#1575;&#1606; &#1705;&#1575;&#1585;&#1711;&#1585; &#1588;&#1605;&#1575;&#1604;&#1740;&#1548; &#1705;&#1608;&#1670;&#1607; &#1588;&#1575;&#1606;&#1586;&#1583;&#1607;&#1605;&#1548; &#1705;&#1608;&#1662;&#1607; &#1605;&#1583;&#1585;&#1587;&#1607;&#1548; &#1662;&#1575;&#1585;&#1705; &#1593;&#1604;&#1605; &#1608; &#1601;&#1606;&#1575;&#1608;&#1585;&#1740; &#1583;&#1575;&#1606;&#1588;&#1711;&#1575;&#1607; &#1578;&#1607;&#1585;&#1575;&#1606;&#1548; &#1605;&#1585;&#1705;&#1586; &#1585;&#1588;&#1583;&#1548; &#1591;&#1576;&#1602;&#1607; &#1575;&#1608;&#1604;&#1548; &#1588;&#1585;&#1705;&#1578; &#1570;&#1578;&#1575;&#1604;&#1606;&#1583;.</font></span>';
            }
            
            }

    function OpenOrderBox( tos)
    {
    
    document.all.item('PriceAdult').innerHTML=
    document.all.item('Price6t12').innerHTML=
    document.all.item('Price2t6').innerHTML=
    document.all.item('PriceLesst2').innerHTML='';
    
    document.all.item('others'+'A').innerHTML='';
    document.all.item('others'+'B').innerHTML='';
    document.all.item('others'+'C').innerHTML='';
    document.all.item('others'+'D').innerHTML='';
    
    document.all.item('NumberAdult').options[0].selected = true;
    document.all.item('Number6t12').options[0].selected = true;
    document.all.item('Number2t6').options[0].selected = true;
    document.all.item('NumberLesst2').options[0].selected = true;
     
    document.all.item('BDur').innerHTML=
    document.all.item('Duration').options[document.all.item('Duration').selectedIndex].value;
    document.all.item('BDay').innerHTML=
    document.all.item('Day').options[document.all.item('Day').selectedIndex].value;
    document.all.item('BMonth').innerHTML=
    document.all.item('Month').options[document.all.item('Month').selectedIndex].value;
    document.all.item('BYear').innerHTML=
    document.all.item('Year').options[document.all.item('Year').selectedIndex].value;
  
    document.forms['form1'].elements['nod'].value=document.all.item('Duration').options[document.all.item('Duration').selectedIndex].value;
    document.forms['form1'].elements['tos'].value=tos;

    setText(document.all.NumberAdult,document.all.PriceAdult,1);
    document.all.item('orderBox').style.position='absolute';
    document.all.item('orderBox').style.visibility='visible';
    document.all.item('orderBox').style.display='block';
    document.all.item('orderBox').style.posTop=460;
    document.all.item('orderBox').style.posLeft=ee.clientX;
   
   
   if (navigator.appName == "Microsoft Internet Explorer")
                {
                 window.location.href='#boxHead';
                }
                else if (navigator.appName == "Netscape")
                {
                 location.hash="boxHead";
                }
   
    
    }

  

 function ArrangeTextBoxes(cls)
 {
 
 var NumberAdult=document.getElementById('NumberAdult');
         var Number6t12=document.getElementById('Number6t12');
         var Number2t6=document.getElementById('Number2t6');
         var NumberLesst2=document.getElementById('NumberLesst2');
         
         var n1=parseInt(NumberAdult.options[NumberAdult.selectedIndex].value);
         var n2=parseInt(Number6t12.options[Number6t12.selectedIndex].value);
         var n3=parseInt(Number2t6.options[Number2t6.selectedIndex].value);
         var n4=parseInt(NumberLesst2.options[NumberLesst2.selectedIndex].value);

   var n =0;
    var i =0;
    var th = new Array(
    "",
    "اول"
    ,"دوم"
    ,"سوم"
    ,"چهارم"
    ,"پنجم"
    ,"ششم"
    ,"هفتم"
    ,"هشتم"
    ,"نهم"
    ,"دهم");
    if(cls=="A")
    {
        n = n1;
        i = 2;
    }
    else if(cls=="B")
    {
        n = n2;
        i = 1;
    }
    else if(cls=="C")
    {
        n = n3;
        i = 1;
    }
    else if(cls=="D")
    {
        n = n4;
        i = 1;
    }
    re1 = /\[0\]/g;
    re2 = /nnn/g;
    
var textboxes = 
document.getElementById('textboxes');
    var str = textboxes.innerHTML;
    
  var acc = "";           
             while(i<=n)
             {
                 
                if (navigator.appName == "Microsoft Internet Explorer")
                {
                 acc +=  str.replace(re1, cls+i).replace(re2, th[i]);
                }
                else if (navigator.appName == "Netscape")
                {
                 acc +=  str.replace(re1, cls+i).replace(re2, th[i]);
                }
                
                //str = str.replace(re2, th[i]);
                
                i++;
                

             }
             var others=
             document.getElementById('others'+cls);
            others.innerHTML = acc;//+"<BR>";
                 
 }

 function CheckTextBoxes()
 {
        var NumberAdult=document.getElementById('NumberAdult');
         var Number6t12=document.getElementById('Number6t12');
         var Number2t6=document.getElementById('Number2t6');
         var NumberLesst2=document.getElementById('NumberLesst2');
         
         var n1=parseInt(NumberAdult.options[NumberAdult.selectedIndex].value);
         var n2=parseInt(Number6t12.options[Number6t12.selectedIndex].value);
         var n3=parseInt(Number2t6.options[Number2t6.selectedIndex].value);
         var n4=parseInt(NumberLesst2.options[NumberLesst2.selectedIndex].value);
         
         
         if(document.forms['form1'].elements['Name'].value==""||
            document.forms['form1'].elements['Family'].value==""||
            document.forms['form1'].elements['Age'].value=="")
            {
                //alert('1');
                return false;
            }
         
         var i = 2;
         while(i<=n1)
         {
            if(document.forms['form1'].elements['NameA'+i].value==""||
            document.forms['form1'].elements['FamilyA'+i].value==""||
            document.forms['form1'].elements['AgeA'+i].value=="")
            {
             //alert('A');
                return false;
            }
            i++;
         }
         i=1;
         while(i<=n2)
         {
            if(document.forms['form1'].elements['NameB'+i].value==""||
            document.forms['form1'].elements['FamilyB'+i].value==""||
            document.forms['form1'].elements['AgeB'+i].value=="")
            {
                //alert('B');
                return false;
            }
            i++;
         }
         i=1;
         while(i<=n3)
         {
            if(document.forms['form1'].elements['NameC'+i].value==""||
            document.forms['form1'].elements['FamilyC'+i].value==""||
            document.forms['form1'].elements['AgeC'+i].value=="")
            {
            //alert('C');
                return false;
            }
            i++;
         }
         i=1;
         while(i<=n4)
         {
            if(document.forms['form1'].elements['NameD'+i].value==""||
            document.forms['form1'].elements['FamilyD'+i].value==""||
            document.forms['form1'].elements['AgeD'+i].value=="")
            {
            //alert('D');
                return false;
            }
            i++;
         }
         
         return true;
         
 }

    
    

    function getNextSibling(startBrother)
{
endBrother=startBrother.nextSibling;
while(endBrother.nodeType!=1)
{
endBrother = endBrother.nextSibling;
}
return endBrother;
} 

function getFirstChild(elm)
{
if ( !elm.childNodes.length )
{
return;
}
var children = elm.childNodes.length;
for ( var i = 0; i <= children; ++i )
{
if ( elm.childNodes[i].nodeType == 1 )
{
return elm.childNodes[i];
}
}
return;
}



