function calculate_total(form,jack)
{
var subtot=0;
var nettot=0;

if(jack =='ebiz'){
var qtycount=0;
for (var i= 0; i<document.forms[0].elements.length;i++){
var name=document.forms[0].elements[i].name+"";
var service=new Array(9);
var price=new Array(9);
service[0]="Web Site Package";
price[0]=135;
service[1]="eBiz Millennium eCommerce";
price[1]=63;
service[2]="Domain Name registration/renew";
price[2]=17;
service[3]="50 MB FTP with PHP 4 support";
price[3]=69;
service[4]="Popular search engine optimization";
price[4]=49;
service[5]="POP 3 mailbox with 10 Mb quota";
price[5]=17;
service[6]="SPAM and Virus protection for email";
price[6]=35;
service[7]="Sponsored 1st page listing in Google";
price[7]=450;
service[8]="Dedicated eBiz server";
price[8]=875;

if(name.indexOf("qty_")==0){
var value=document.forms[0].elements[i].value*1;
if(value>0)
{
//alert("service "+service[qtycount]+" rate "+price[qtycount]+" val "+value);
subtot=price[qtycount]*1*value;
nettot+=subtot;
}
qtycount++;
}
}
//alert("nettot"+nettot);
form.nettot.value=nettot;
return;
}else if(jack =='voip'){
var qtycount=0;
for (var i= 0; i<document.forms[0].elements.length;i++){
var name=document.forms[0].elements[i].name+"";
var service=new Array(22);
var price=new Array(22);
var priceinr=new Array(22);
var priceeur=new Array(22);
var pricegbp=new Array(22);


service[0]="BicServer EcoSecure System";
price[0]=1250;
priceinr[0]=65000;
priceeur[0]=960;
pricegbp[0]=835;
service[1]="Thin Client - 1024x768 display";
price[1]=95;
priceinr[1]=4750;
priceeur[1]=73;
pricegbp[1]=64;
service[2]="Thin Client - 1280x820 display";
price[2]=125;
priceinr[2]=5750;
priceeur[2]=95;
pricegbp[2]=85;
service[3]="Thin Client - 1440x900 display";
price[3]=145;
priceinr[3]=6750;
priceeur[3]=112;
pricegbp[3]=97;
service[4]="Thin Client - 1440x900 display, WiFi 802 b/s";
price[4]=165;
priceinr[4]=7500;
priceeur[4]=127;
pricegbp[4]=110;
service[5]="BicFone Terminal without monitor, keyboard, mouse";
price[5]=250;
priceinr[5]=12500;
priceeur[5]=192;
pricegbp[5]=168;
service[6]="BicFone Terminal with Power over Ethernet (PoE) ";
price[6]=290;
priceinr[6]=14500;
priceeur[6]=222;
pricegbp[6]=195;
service[7]="BicFone Terminal with PoE, 18.5. monitor(LED lighting), keyboard, mouse ";
price[7]=450;
priceinr[7]=22500;
priceeur[7]=345;
pricegbp[7]=300;
service[8]="BICSERVER IP PBX OFFICE edition";
price[8]=815;
priceinr[8]=39000;
priceeur[8]=645;
pricegbp[8]=550;
service[9]="BICSERVER IP PBX BUSINESS edition";
price[9]=1125;
priceinr[9]=54000;
priceeur[9]=890;
pricegbp[9]=760;
service[10]="BICSERVER IP PBX CORPORATE edition";
price[10]=1545;
priceinr[10]=74000;
priceeur[10]=1225;
pricegbp[10]=1040;
service[11]="BICSERVER IP PBX CALL CENTER edition";
price[11]=2585;
priceinr[11]=124000;;
priceeur[11]=2050;
pricegbp[11]=1745;
service[12]="BICSERVER IP PBX ENTERPRISE edition";
price[12]=1960;
priceinr[12]=94000;
priceeur[12]=1550;
pricegbp[12]=1321;
service[13]="Single line Grandstram BT-201 IP phone";
price[13]=95;
priceinr[13]=4500;
priceeur[13]=75;
pricegbp[13]=65;
service[14]="Single line Call Center model";
price[14]=105;
priceinr[14]=5000;
priceeur[14]=85;
pricegbp[14]=70;
service[15]="2 line Call Center model.";
price[15]=135;
priceinr[15]=6500;
priceeur[15]=107;
pricegbp[15]=90;
service[16]="2 line Call Center POE model.";
price[16]=155;
priceinr[16]=7500;
priceeur[16]=123;
pricegbp[16]=105;
service[17]="Analog Telephony Adaper (ATA)";
price[17]=45;
priceinr[17]=2250;
priceeur[17]=35;
pricegbp[17]=30;
service[18]="Call Center Autodialer software.";
price[18]=520;
priceinr[18]=25000;
priceeur[18]=412;
pricegbp[18]=350;
service[19]="VoIP to GSM mobile gateway";
price[19]=200;
priceinr[19]=9000;
priceeur[19]=160;
pricegbp[19]=135;
service[20]="Analog Telephony TDM card.";
price[20]=85;
priceinr[20]=4250;
priceeur[20]=68;
pricegbp[20]=58;
service[21]="Digium 1 E1 card";
price[21]=730;
priceinr[21]=35000;
priceeur[21]=580;
pricegbp[21]=495;
service[22]="1 E1 card w/o echo cancel";
price[22]=520;
priceinr[22]=25000;
priceeur[22]=412;
pricegbp[22]=350;
service[23]="4 E1 card w/o echo cancel";
price[23]=940;
priceinr[23]=45000;
priceeur[23]=745;
pricegbp[23]=635;
service[24]="25\" EP Monoaural Call Center Headset";
price[24]=12;
priceinr[24]=550;
priceeur[24]=10;
pricegbp[24]=8;
service[25]="RJ9 Monoaural Call Center Headset with noise cancelation";
price[25]=20;
priceinr[25]=950;
priceeur[25]=15;
pricegbp[25]=13;
service[26]="ExSky : 8 port Skype to PBX gateway";
price[26]=925;
priceinr[26]=44500;
priceeur[26]=735;
pricegbp[26]=625;
service[27]="SiSky : 8 port Skype to Asterisk IPBX gateway";
price[27]=415;
priceinr[27]=20000;
priceeur[27]=328;
pricegbp[27]=280;
service[28]="Geographically protable telephone nos.";
price[28]=15;
priceinr[28]=750;
priceeur[28]=12;
pricegbp[28]=10;
service[29]="Geographically portable toll free nos.";
price[29]=25;
priceinr[29]=1200;
priceeur[29]=20;
pricegbp[29]=14;


if(name.indexOf("qty_")==0){
var value=document.forms[0].elements[i].value*1;
if(value>0)
{
//alert("service "+service[qtycount]+" rate "+price[qtycount]+" val "+value);
if(form.curr.options[0].selected==true){
subtot=price[qtycount]*1*value;
form.mail_options.value="PlainTemplate=bicnetinord2.tmpl,TemplateMissing=n/a";
}

if(form.curr.options[1].selected==true){
subtot=priceinr[qtycount]*1*value;
form.mail_options.value="PlainTemplate=bicnetinord2.tmpl,TemplateMissing=n/a";
}

if(form.curr.options[2].selected==true){
subtot=priceeur[qtycount]*1*value;
form.mail_options.value="PlainTemplate=bicnetinord2.tmpl,TemplateMissing=n/a";
}

if(form.curr.options[3].selected==true){
subtot=pricegbp[qtycount]*1*value;
form.mail_options.value="PlainTemplate=bicnetinord2.tmpl,TemplateMissing=n/a";
}

nettot+=subtot;
}
qtycount++;
}

}
form.nettot.value=nettot;
return;
}else if(jack =='vconsult'){
var qtycount=0;
for (var i= 0; i<document.forms[0].elements.length;i++){
var name=document.forms[0].elements[i].name+"";
var service=new Array(3);
var price=new Array(3);
service[0]="Asterisk installation";
price[0]=175;
service[1]="Asterisk configuraton";
price[1]=45;
service[2]="Asterisk custom development";
price[2]=55;

if(name.indexOf("qty_")==0){
var value=document.forms[0].elements[i].value*1;
if(value>0)
{
//alert("service "+service[qtycount]+" rate "+price[qtycount]+" val "+value);
subtot=price[qtycount]*1*value;
nettot+=subtot;
}
qtycount++;
}

}
form.nettot.value=nettot;
return;
}else if(jack =='outsource'){
var qtycount=0;
for (var i= 0; i<document.forms[0].elements.length;i++){
var name=document.forms[0].elements[i].name+"";
var service=new Array(5);
var price=new Array(5);
service[0]="Non technical back end processes";
price[0]=750;
service[1]="Technical back end process";
price[1]=950;
service[2]="Non technical front end process";
price[2]=950;
service[3]="Technical front end support";
price[3]=1450;
service[4]="Senior Consultant / Project Manager";
price[4]=45;

if(name.indexOf("qty_")==0){
var value=document.forms[0].elements[i].value*1;
if(value>0)
{
//alert("service "+service[qtycount]+" rate "+price[qtycount]+" val "+value);
subtot=price[qtycount]*1*value;
nettot+=subtot;
}
qtycount++;
}

}
form.nettot.value=nettot;
return;
}else{
alert("Invalid selection");
form.nettot.value=0;
}

}

function isValid(form,jack,theObj)
{
if(theObj.value=='')
{theObj.value=0;}
else{
if(isNaN(theObj.value)){
alert("Please enter valid quantity");
theObj.value=0;
}
if(theObj.value*1<0)
{alert("Quantity has to be a positive numeric value");
theObj.value=0;
}
}
calculate_total(form,jack);
}

function elearnApply(form){
var flag=true;
if(form.realname.value=='')
{
alert("Please enter your name.");
flag=false;
form.realname.focus();
return;
}
if(form.email.value=='')
{
alert("Please enter your email.");
flag=false;
form.email.focus();
return;
}
if(form.username.value=='')
{
alert("Please enter your BicneT eLearning account username.");
flag=false;
form.username.focus();
return;
}
if(form.termscon.checked==false){
alert("Please read terms and conditions.");
flag=false;
return;
}
if(flag==true){
form.submit();
}
}

function jobApply(form){
var flag=true;
if(form.realname.value=='')
{
alert("Please enter your name.");
flag=false;
form.realname.focus();
return;
}
if(form.tel.value=='')
{
alert("Please enter telephone number");
flag=false;
form.ccode.focus();
return;
}
if(form.email.value=='')
{
alert("Please enter email address");
flag=false;
form.email.focus();
return;
}
if(flag==true){
form.submit();
}
}

function subOrder(form,jack){
calculate_total(form,jack);

var flag=true;
if(form.nettot.value==0 || form.nettot.value=='')
{
alert("You have not ordered any service. Please enter the  quantity for the service you wish to order.");
flag=false;
form.qty_0.focus();
return;
}

if(form.realname.value=='')
{
alert("Please enter your name.");
flag=false;
form.lname.focus();
return;
}
if(form.addr1.value=='')
{
alert("Please enter address");
flag=false;
form.addr1.focus();
return;
}
if(form.city.value=='')
{
alert("Please enter city");
flag=false;
form.city.focus();
return;
}
if(form.zip.value=='')
{
alert("Please enter zipcode");
flag=false;
form.zip.focus();
return;
}
if(form.state.value=='')
{
alert("Please enter state");
flag=false;
form.state.focus();
return;
}
if(form.tel.value=='')
{
alert("Please enter telephone number");
flag=false;
form.ccode.focus();
return;
}
if(form.email.value=='')
{
alert("Please enter email address");
flag=false;
form.email.focus();
return;
}
///check for credit card
///if(form.paymode[0].checked){
if(1==1){
	len1=form.cardno1.value.length;
        len2=form.cardno2.value.length;
        len3=form.cardno3.value.length;
        len4=form.cardno4.value.length;

	        if (form.cardname.value=="" )
                {
                alert("Please enter complete Card Details");
                form.cardname.focus();
                flag=false ;
                }else if( form.cardno1.value=="" || isNaN(form.cardno1.value) ||
len1 != 4)
                {
                alert("Card Number is not valid");
                flag=false ;
                form.cardno1.focus();
                }
                else if( form.cardno2.value=="" || isNaN(form.cardno2.value) ||
len2 != 4)
                {
                alert("Card Number is not valid"); 
		flag=false ;
                form.cardno2.focus();
                }
                else if( form.cardno3.value=="" || isNaN(form.cardno3.value) ||
len3 != 4)
                {
                alert("Card Number is not valid");
                flag=false ;
                form.cardno3.focus();
                }
                else if( form.cardno4.value=="" || isNaN(form.cardno4.value) ||
len4 != 4)
                {
                alert("Card Number is not valid");
                flag=false ;
                form.cardno4.focus();
                }
                else {
                arr= new Array(13);
                arr[1]=31;
              arr[2]=28;
            arr[3]=31; 
		arr[4]=30;
           arr[5]=31;
          arr[6]=30;
         arr[7]=31;
        arr[8]=31;
        arr[9]=30;
        arr[10]=31;
        arr[11]=30;
        arr[12]=31;

                date1 = new Date();
                ar=date1 + "";
                 var dlen = ar.length;
                dlen1=dlen -4;
                year=ar.substring(dlen1,dlen);
                day=date1.getDate();
                month=date1.getMonth();
		//year=date1.getYear()+1900;
		year=date1.getFullYear();
ind=form.expmonth.options[form.expmonth.options.selectedIndex].value * 1;
                      day1=arr[ind];
                        month1=ind;
                        month1--;  
		ind2=form.expyear.options[form.expyear.options.selectedIndex].value *1;
                        year1=ind2;
		//alert(" "+year+" -> "+month+" -> "+year1+" ->"+month1);
                date2=day1 + month1 + year1;
                sec1=Date.UTC(year,month,day);
                sec2=Date.UTC(year1,month1,day1);
                if(sec1 > sec2)
                {
                        alert("Your card has expired");
	                flag=false ;
                }
                else {
                //alert("Valid");
                //alert("Str" + str);
                //return;
                }
                //alert("Str" + str);
                //return;
        }


}
if(flag){
form.method="post";
form.action="http://scripts.bicnet.info/bicfrm.php";
form.submit();
}
}

function validemail(form,str)
{
if(str=='')
{return;}
var anyString=str;
x=anyString.indexOf("@");
if(x==(-1))
{
alert ("Please enter a Valid Email Address");
 form.email.value="";
 form.email.focus();
}

if (x!=(-1))
{
y=anyString.charAt(x-1);
z=anyString.charAt(x+1);
//alert ("Please Enter A Valid Email Address"+y);
                if((y=="")||(z==""))
                {
                alert("Please enter a Valid Email Address");
                form.email.value="";
                form.email.focus();
		}
}
}
function chkCard(form){
var flag=true;
if(isNaN(form.cardamt.value)){
alert("Card face value has to be valid amount between 10 and 50");
flag=false;
form.cardamt.value=10;
return;
}
var amt=form.cardamt.value*1;
if(amt<10 || amt>50)
{
alert("Please enter a value between 10 and 50");
flag=false;
form.cardamt.value=10;
return;
}
if(flag)
{
form.action="ordvcard.cgi";
form.method='post';
form.submit();
}

}

function loadDefaultCurren(form,count,jack){
var prefixshow="us";
var prefixhide="inr";
var costshow="cost_us";
var costhide="cost_inr";
var cost1show="cost1_us";
var cost1hide="cost1_inr";
if(form.curr.options[0].selected==true){
prefixshow="us";
prefixhide="inr";
prefixhide1="gbp";
prefixhide2="eur";
}else if(form.curr.options[2].selected==true){
prefixshow="eur";
prefixhide="us";
prefixhide1="inr";
prefixhide2="gbp";
}else if(form.curr.options[3].selected==true){
prefixshow="gbp";
prefixhide="us";
prefixhide1="inr";
prefixhide2="eur";
}else{
prefixshow="inr";
prefixhide="us";
prefixhide1="us";
prefixhide2="eur";
}

for(i=0;i<count;i++){
$show="qty_"+i+"_"+prefixshow;
$hide="qty_"+i+"_"+prefixhide;
$hide1="qty_"+i+"_"+prefixhide1;
$hide2="qty_"+i+"_"+prefixhide2;
document.getElementById($show).style.display="";
document.getElementById($hide).style.display="none";
document.getElementById($hide1).style.display="none";
document.getElementById($hide2).style.display="none";
}

$costshow="cost_"+prefixshow;
$costhide="cost_"+prefixhide;
$costhide1="cost_"+prefixhide1;
$costhide2="cost_"+prefixhide2;
document.getElementById($costshow).style.display="";
document.getElementById($costhide).style.display="none";
document.getElementById($costhide1).style.display="none";
document.getElementById($costhide2).style.display="none";
$costshow1="cost1_"+prefixshow;
$costhide1="cost1_"+prefixhide;
$costhide11="cost1_"+prefixhide1;
$costhide12="cost1_"+prefixhide2;
document.getElementById($costshow1).style.display="";
document.getElementById($costhide1).style.display="none";
document.getElementById($costhide11).style.display="none";
document.getElementById($costhide12).style.display="none";
calculate_total(form,jack);
}
