function calc(x)
	{
	y=document.getElementsByName(x);
//alert(y[0].name);
var pack=y[0].name;
a=y[2].value;
a=a.replace(/,/g,'');
c=y[2].value;
c=c.replace(/,/g,'');
//alert(a);
//alert(y[2].value);
//y[3].value=y[3].value.replace(/,/g,'');
//y1.value=y1.value.replace(/,/g,'');
				if(pack=='Scout Email[]')
				{
				d=String(y[0].value*c);
y[3].value=ThousandSeparator(d);
				}
		if(a>0 && pack!='Scout Email[]')
		{
b=String(y[0].value*y[1].value*a);
		y[3].value=ThousandSeparator(b);
//alert(y[3].value);
		}
			if(y[1].value==0 || isNaN(parseInt(y[1].value)) || !(y[2].value))
			{
e=y[2].value;
e=e.replace(/,/g,'');

			f=String(y[0].value*e);
y[3].value=ThousandSeparator(f);
//alert(y[3].value);
			}
				
	}

function ajaxFunction(str,tab)
{
var site_url=window.location.href.split("index")
	var xmlHttp;
		try
  		{
  		// Firefox, Opera 8.0+, Safari
 		 xmlHttp=new XMLHttpRequest();
  		}
			catch (e)
  			{
 			 // Internet Explorer
  				try
   				 {
   				 xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  				  }
 					 catch (e)
    						{
    							try
      							{
     							 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
     							 }
    								catch (e)
     								 {
     								 alert("Your browser does not support AJAX!");
      								return false;
      								}
   						 }

  			}
y=document.getElementsByName(str);
		if(y[0].name=="Job Posting[]")
		{
		var d;
			switch (y[0].value)
			{
			case "1":
			case "2":
			case "3":
			d="01";
			break;
				case "4":
				case "5":
				case "6":
				d="03";
			break;
			case "7":
			case "8":
			case "9":
			d="06";
			break;
				case "10":
				case "11":
				case "12":
				d="12";
				break;
			}
		}		
					else if(y[0].name!="Directory Entry[]")
					{
					switch (y[0].value)
						{
						case "1":
						case "2":
						case "3":
						d="1 to 3 Months";
						break;
						case "4":
						case "5":
						case "6":
						d="4 to 6 Months";
						break;
						case "7":
						case "8":
						case "9":
						d="7 to 9 Months";
						break;
						case "10":
						case "11":
						case "12":
						d="10 to 12 Months";
						break;
						}
					}
								else
								{
									switch (y[0].value)
									{
									case "1":
									case "2":
									case "3":
									case "4":
									case "5":
									case "6":
									//alert("dir");
									d="6 Months";
									break;
									case "7":
									case "8":
									case "9":
									case "10":
									case "11":
									case "12":
									d="12 Months";
									break;
									}
								}
var url=site_url[0]+"ajax.php?dir=ajaxModule&page=packages&duration="+d+"&qua="+y[1].value+"&tab="+tab;
//alert(tab);
//alert(url);
	if (xmlHttp!=null)
	 {
	 xmlHttp.onreadystatechange=state_Change;
	 xmlHttp.open("GET",url,true);
	 xmlHttp.send(null);
	 }


								function state_Change()
								{
								var tot;
								y=document.getElementsByName(str);
//alert(tab)
									var tem=document.getElementById("temp")
									if (xmlHttp.readyState==4)
 									 {// 4 = "loaded"
									 if (xmlHttp.status==200)
									    {// 200 = "OK"
									  // y[2].value=ThousandSeparator(xmlHttp.responseText);
										tem.innerHTML=xmlHttp.responseText;
										//alert(document.getElementById(tab.name))
										y[2].value=ThousandSeparator(document.getElementById(tab).innerHTML)

									 calc(str);
										y[4].value=document.getElementById(tab+'1').innerHTML
									    }
									  else
									    {
									    alert("Problem retrieving data:" + xmlHttp.statusText);
									    }
									  }
								}

}
 function ThousandSeparator(Value)
    {
   
       // Separator Length. Here this is thousand separator
       var separatorLength = 3;

       var OriginalValue=Value;

       var TempValue = "" + OriginalValue;

       var NewValue = "";

       // Store digits after decimal
       //var pStr;

       // store digits before decimal
       var dStr;

       // Add decimal point if it is not there
       //if (TempValue.indexOf(".")==-1){TempValue+="."}
        
       //dStr=TempValue.substr(0,TempValue.indexOf("."));
			dStr=Value;
 //alert(dStr.length);
      // pStr=TempValue.substr(TempValue.indexOf("."))   

       // Add "0" for remaining digits after decimal point
      // while (pStr.length-1< decimalDigits){pStr+="0"}

      // if(pStr =='.') pStr ='';
    
        if(dStr.length > separatorLength)
        {
//alert("asdf");
            // Logic of separation    
            while( dStr.length > separatorLength)
            {
                NewValue = "," + dStr.substr(dStr.length - separatorLength) + NewValue;
                dStr = dStr.substr(0,dStr.length - separatorLength);
            }

            NewValue = dStr + NewValue;
             
        }
        else
        {
            NewValue = dStr;
        }


        //  Add decimal part
        //NewValue = NewValue + pStr;

        // Show Final value
       //alert(NewValue);
       
        return NewValue;

    }
    
 
