
// JavaScript Document
var tot;
var control;
var texto;
var itemname;
var itemnum;
var tiempo;
var textot;
var t3;
var t3m;
var t3y;
var totbox;
var totybox;
var a3;
var itemnu;

var clientname = '';


tot=0;
totbox='';
totybox='';
t3m = 'M';
t3y = 'Y';

itemname = new Array('Enterprise Standard Hosted IM Network - ','Enterprise Premium Hosted IM Network - ','Enterprise Collaborative Hosted IM Network - ');
itemnum = new Array('HSTSTD','HSTPREMIUM','HSTCOLLABORATIVE');


function CalcularPrecio(canti,edition,discount,clients) {
    cant = eval(canti);
    ControldePack(cant);
    
    cli = eval(clients)
    cant = eval(canti);
    ControldePack(cant);

	if (cli == 1){
		clientname = "PC client";
	}
	if (cli == 2){
		clientname = "Web-based";		
	}
	if (cli == 3){
		clientname = "Both";
	}
	
	
	
	if (cant >= 110) 
	{	
	    		
				if (edition == '1')
					{
						
					tot = (100 * precioCLE[0])+((cant-100) * precioCLE[1]);
					itemna = itemname[0]+cant+ ' Users - ' + clientname;
					itemnu = itemnum[0]+cant;
					}
				if (edition == '2')
					{
					tot=(100 * precioCPE[0])+((cant-100) * precioCPE[1]);
					itemna = itemname[1]+cant+ ' Users - ' + clientname;
					itemnu = itemnum[1]+cant;
					}
				if (edition == '3')
					{
					tot=(100 * precioCPCE[0])+((cant-100) * precioCPCE[1]);
					itemna = itemname[2]+cant+ ' Users - ' + clientname;
					itemnu = itemnum[2]+cant;
					}
	}
	else
	{
		
			if (cant >= 10) 
			{
			    if (edition == '1')
				{
					tot = cant * precioCLE[0];
					itemna = itemname[0]+cant+ ' Users - ' + clientname;
					itemnu = itemnum[0]+cant;
				}
				if (edition == '2')
				{
					tot=cant * precioCPE[0];
					itemna = itemname[1]+cant+ ' Users - ' + clientname;
					itemnu = itemnum[1]+cant;
				}
				if (edition == '3')
				{
					tot=cant * precioCPCE[0];
					itemna = itemname[2]+cant+ ' Users - ' + clientname;
					itemnu = itemnum[2]+cant;
				}
			 }
	}
	
    tot = tot*eval(precioIMC[cli-1]);
	
	if (discount == 'Y')
	{              
		toty=tot*12 * 0.9;
		toty=toty.toFixed(2);
		a3 = toty;
		toty = toty + ' per Year';
		t3= t3y; 
		document.f.total.value=toty;
	}
	else if (discount == 'M'){              
		tot = tot.toFixed(2);
		t3 = t3m;
		toty = tot + ' per Month';
		a3 = tot;
		document.f.total.value=toty;
		
	}
	
document.f.cantus.value=cant;	
	
};//end function

function ControldePack(valor){

if ( valor >= 1000 )
	{

		cant=1000;

 	}
else
 	{
  		if (((valor%10)!=0)||(valor == 0))
		{
  		valor=valor-valor%10+10;
  		cant=valor;
  		};
 	};

}; // end function	

CalcularPrecio(cantus,edition,discount,clients);

