ts = new Array(6);

for(i = 0; i < ts.length; i++)
{
    ts[i] = new Array(3);
}

ts[0][0] = 40;
ts[0][1] = 64;

ts[1][0] = 48;
ts[1][1] = 72;

ts[2][0] = 64;
ts[2][1] = 104;

ts[3][0] = 96;
ts[3][1] = 152;

ts[4][0] = 136;
ts[4][1] = 192;

ts[5][0] = 200;
ts[5][1] = 264;

tc = new Array(6);

for(i = 0; i < tc.length; i++)
{
    tc[i] = new Array(3);
}

tc[0][0] = 100;
tc[0][1] = 160;

tc[1][0] = 120;
tc[1][1] = 180;

tc[2][0] = 160;
tc[2][1] = 260;

tc[3][0] = 240;
tc[3][1] = 380;

tc[4][0] = 340;
tc[4][1] = 480;

tc[5][0] = 500;
tc[5][1] = 660;

/*##########*/
anl = new Array();
anm = new Array();
anh = new Array();
apl = new Array();
apm = new Array();
aph = new Array();
bnl = new Array();
bnm = new Array();
bnh = new Array();
bpl = new Array();
bpm = new Array();
bph = new Array();
cnl = new Array();
cnm = new Array();
cnh = new Array();
cpl = new Array();
cpm = new Array();
cph = new Array();
dnl = new Array();
dnm = new Array();
dnh = new Array();
dpl = new Array();
dpm = new Array();
dph = new Array();
enl = new Array();
enm = new Array();
enh = new Array();
epl = new Array();
epm = new Array();
eph = new Array();
fnl = new Array();
fnm = new Array();
fnh = new Array();
fpl = new Array();
fpm = new Array();
fph = new Array();
gnl = new Array();
gnm = new Array();
gnh = new Array();
gpl = new Array();
gpm = new Array();
gph = new Array();


anl[1] = 0.15
anl[2] = 0.05
anl[3] = 0.02
anl[4] = 0.01
anl[5] = 0.09
anl[6] = 0.07

anm[1] = 0.34
anm[2] = 0.10
anm[3] = 0.09
anm[4] = 0.04
anm[5] = 0.40
anm[6] = 0.23

anh[1] = 0.48
anh[2] = 0.17
anh[3] = 0.38
anh[4] = 0.20
anh[5] = 0.56
anh[6] = 0.27

apl[1] = 0.75
apl[2] = 0.37
apl[3] = 0.73
apl[4] = 0.25
apl[5] = 0.13
apl[6] = 0.08

apm[1] = 1.18
apm[2] = 0.59
apm[3] = 1.15
apm[4] = 0.44
apm[5] = 0.47
apm[6] = 0.23

aph[1] = 1.64
aph[2] = 0.82
aph[3] = 1.78
aph[4] = 0.77
aph[5] = 1.92
aph[6] = 0.73

bnl[1] = 0.25
bnl[2] = 0.11
bnl[3] = 0.04
bnl[4] = 0.02
bnl[5] = 0.14
bnl[6] = 0.12

bnm[1] = 0.55
bnm[2] = 0.20
bnm[3] = 0.17
bnm[4] = 0.08
bnm[5] = 0.66
bnm[6] = 0.42

bnh[1] = 0.76
bnh[2] = 0.31
bnh[3] = 0.67
bnh[4] = 0.44
bnh[5] = 1.03
bnh[6] = 0.62

bpl[1] = 1.10
bpl[2] = 0.66
bpl[3] = 0.70
bpl[4] = 0.41
bpl[5] = 0.17
bpl[6] = 0.11

bpm[1] = 1.77
bpm[2] = 1.13
bpm[3] = 1.40
bpm[4] = 0.77
bpm[5] = 0.67
bpm[6] = 0.42

bph[1] = 2.41
bph[2] = 1.56
bph[3] = 2.40
bph[4] = 1.36
bph[5] = 3.77
bph[6] = 1.17

cnl[1] = 0.49
cnl[2] = 0.19
cnl[3] = 0.07
cnl[4] = 0.05
cnl[5] = 0.25
cnl[6] = 0.22

cnm[1] = 1.06
cnm[2] = 0.38
cnm[3] = 0.29
cnm[4] = 0.06
cnm[5] = 1.20
cnm[6] = 0.80

cnh[1] = 1.38
cnh[2] = 0.56
cnh[3] = 1.21
cnh[4] = 0.86
cnh[5] = 2.09
cnh[6] = 1.29

cpl[1] = 2.02
cpl[2] = 1.09
cpl[3] = 0.91
cpl[4] = 0.60
cpl[5] = 0.28
cpl[6] = 0.22

cpm[1] = 3.21
cpm[2] = 1.91
cpm[3] = 1.72
cpm[4] = 1.17
cpm[5] = 1.20
cpm[6] = 0.80

cph[1] = 4.24
cph[2] = 2.65
cph[3] = 3.18
cph[4] = 2.14
cph[5] = 3.13
cph[6] = 2.06

dnl[1] = 0.92
dnl[2] = 0.37
dnl[3] = 0.13
dnl[4] = 0.09
dnl[5] = 0.47
dnl[6] = 0.42

dnm[1] = 2.00
dnm[2] = 0.70
dnm[3] = 0.60
dnm[4] = 0.31
dnm[5] = 2.26
dnm[6] = 1.54

dnh[1] = 2.80
dnh[2] = 1.08
dnh[3] = 2.40
dnh[4] = 1.72
dnh[5] = 3.93
dnh[6] = 2.43

dpl[1] = 3.41
dpl[2] = 1.85
dpl[3] = 1.32
dpl[4] = 0.91
dpl[5] = 0.47
dpl[6] = 0.42

dpm[1] = 5.31
dpm[2] = 3.37
dpm[3] = 2.62
dpm[4] = 1.82
dpm[5] = 2.26
dpm[6] = 1.54

dph[1] = 7.21
dph[2] = 4.52
dph[3] = 4.89
dph[4] = 3.53
dph[5] = 4.80
dph[6] = 3.40

enl[1] = 1.82
enl[2] = 1.14
enl[3] = 0.28
enl[4] = 0.18
enl[5] = 0.80
enl[6] = 0.84

enm[1] = 3.71
enm[2] = 2.16
enm[3] = 1.27
enm[4] = 0.69
enm[5] = 3.17
enm[6] = 3.04

enh[1] = 5.19
enh[2] = 3.30
enh[3] = 5.01
enh[4] = 3.87
enh[5] = 6.23
enh[6] = 6.75

epl[1] = 4.99
epl[2] = 3.81
epl[3] = 2.03
epl[4] = 1.44
epl[5] = 0.68
epl[6] = 0.82

epm[1] = 8.01
epm[2] = 6.92
epm[3] = 3.99
epm[4] = 3.01
epm[5] = 2.96
epm[6] = 3.03

eph[1] = 10.17
eph[2] = 9.56
eph[3] = 7.71
eph[4] = 5.73
eph[5] = 6.15
eph[6] = 7.07

fnl[1] = 1.38
fnl[2] = 1.28
fnl[3] = 0.20
fnl[4] = 0.28
fnl[5] = 0.75
fnl[6] = 1.17

fnm[1] = 3.09
fnm[2] = 2.44
fnm[3] = 0.77
fnm[4] = 0.64
fnm[5] = 2.95
fnm[6] = 3.55

fnh[1] = 4.17
fnh[2] = 3.77
fnh[3] = 3.46
fnh[4] = 4.01
fnh[5] = 4.21
fnh[6] = 4.36

fpl[1] = 4.40
fpl[2] = 4.31
fpl[3] = 1.72
fpl[4] = 2.24
fpl[5] = 0.67
fpl[6] = 1.15

fpm[1] = 7.11
fpm[2] = 7.97
fpm[3] = 3.34
fpm[4] = 5.21
fpm[5] = 2.71
fpm[6] = 3.64

fph[1] = 9.53
fph[2] = 11.17
fph[3] = 6.15
fph[4] = 9.95
fph[5] = 5.20
fph[6] = 6.28

gnl[1] = 0.69
gnl[2] = 0.29
gnl[3] = 0.10
gnl[4] = 0.06
gnl[5] = 0.36
gnl[6] = 0.32

gnm[1] = 1.60
gnm[2] = 0.55
gnm[3] = 0.44
gnm[4] = 0.23
gnm[5] = 1.73
gnm[6] = 1.17

gnh[1] = 2.19
gnh[2] = 0.84
gnh[3] = 1.77
gnh[4] = 1.27
gnh[5] = 2.90
gnh[6] = 1.81

gpl[1] = 2.61
gpl[2] = 1.44
gpl[3] = 1.12
gpl[4] = 0.77
gpl[5] = 0.38
gpl[6] = 0.32

gpm[1] = 4.11
gpm[2] = 2.57
gpm[3] = 2.18
gpm[4] = 1.50
gpm[5] = 1.73
gpm[6] = 1.17

gph[1] = 5.60
gph[2] = 3.51
gph[3] = 3.99
gph[4] = 2.82
gph[5] = 3.98
gph[6] = 2.75

function cal() {
alert(a[1]);
}

function model() {
document.getElementById('Geo').selectmodel.value=document.getElementById('Geo').a.value;
var k=document.getElementById('Geo').selectmodel.value+document.getElementById('Geo').selectvideo.value+document.getElementById('Geo').selectcompress.value;
hdd(k);
}

function video(v) {
document.getElementById('Geo').selectvideo.value=document.getElementById('Geo').b[v].value;
var k=document.getElementById('Geo').selectmodel.value+document.getElementById('Geo').selectvideo.value+document.getElementById('Geo').selectcompress.value;
hdd(k);
}

function compress(v) {
document.getElementById('Geo').selectcompress.value=document.getElementById('Geo').c[v].value;
var k=document.getElementById('Geo').selectmodel.value+document.getElementById('Geo').selectvideo.value+document.getElementById('Geo').selectcompress.value;
hdd(k);
}

function format(v) {
document.getElementById('Geo').selectformat.value=document.getElementById('Geo').FORMAT[v].value;
var k=document.getElementById('Geo').selectmodel.value+document.getElementById('Geo').selectvideo.value+document.getElementById('Geo').selectcompress.value;
hdd(k);
}

function hdd (k) {
if (k == "anl")
document.getElementById('Geo').hdd.value = anl[document.getElementById('Geo').selectformat.value];
if (k == "anm")
document.getElementById('Geo').hdd.value = anm[document.getElementById('Geo').selectformat.value];
if (k == "anh")
document.getElementById('Geo').hdd.value = anh[document.getElementById('Geo').selectformat.value];
if (k == "apl") 
document.getElementById('Geo').hdd.value = apl[document.getElementById('Geo').selectformat.value];
if (k == "apm") 
document.getElementById('Geo').hdd.value = apm[document.getElementById('Geo').selectformat.value];
if (k == "aph") 
document.getElementById('Geo').hdd.value = aph[document.getElementById('Geo').selectformat.value];
if(k == "bnl") 
document.getElementById('Geo').hdd.value = bnl[document.getElementById('Geo').selectformat.value];
if(k == "bnm") 
document.getElementById('Geo').hdd.value = bnm[document.getElementById('Geo').selectformat.value];
if(k == "bnh") 
document.getElementById('Geo').hdd.value = bnh[document.getElementById('Geo').selectformat.value];
if(k == "bpl")
document.getElementById('Geo').hdd.value = bpl[document.getElementById('Geo').selectformat.value];
if(k == "bpm")
document.getElementById('Geo').hdd.value = bpm[document.getElementById('Geo').selectformat.value];
if(k == "bph")
document.getElementById('Geo').hdd.value = bph[document.getElementById('Geo').selectformat.value];
if(k =="cnl") 
document.getElementById('Geo').hdd.value = cnl[document.getElementById('Geo').selectformat.value];
if(k =="cnm") 
document.getElementById('Geo').hdd.value = cnm[document.getElementById('Geo').selectformat.value];
if(k =="cnh") 
document.getElementById('Geo').hdd.value = cnh[document.getElementById('Geo').selectformat.value];
if(k == "cpl") 
document.getElementById('Geo').hdd.value = cpl[document.getElementById('Geo').selectformat.value];
if(k == "cpm") 
document.getElementById('Geo').hdd.value = cpm[document.getElementById('Geo').selectformat.value];
if(k == "cph") 
document.getElementById('Geo').hdd.value = cph[document.getElementById('Geo').selectformat.value];
if(k == "dnl") 
document.getElementById('Geo').hdd.value = dnl[document.getElementById('Geo').selectformat.value];
if(k == "dnm") 
document.getElementById('Geo').hdd.value = dnm[document.getElementById('Geo').selectformat.value];
if(k == "dnh") 
document.getElementById('Geo').hdd.value = dnh[document.getElementById('Geo').selectformat.value];
if(k == "dpl") 
document.getElementById('Geo').hdd.value = dpl[document.getElementById('Geo').selectformat.value];
if(k == "dpm") 
document.getElementById('Geo').hdd.value = dpm[document.getElementById('Geo').selectformat.value];
if(k == "dph") 
document.getElementById('Geo').hdd.value = dph[document.getElementById('Geo').selectformat.value];
if(k == "enl") 
document.getElementById('Geo').hdd.value = enl[document.getElementById('Geo').selectformat.value];
if(k == "enm") 
document.getElementById('Geo').hdd.value = enm[document.getElementById('Geo').selectformat.value];
if(k == "enh") 
document.getElementById('Geo').hdd.value = enh[document.getElementById('Geo').selectformat.value];
if(k == "epl") 
document.getElementById('Geo').hdd.value = epl[document.getElementById('Geo').selectformat.value];
if(k == "epm") 
document.getElementById('Geo').hdd.value = epm[document.getElementById('Geo').selectformat.value];
if(k == "eph") 
document.getElementById('Geo').hdd.value = eph[document.getElementById('Geo').selectformat.value];
if(k == "fnl") 
document.getElementById('Geo').hdd.value = fnl[document.getElementById('Geo').selectformat.value];
if(k == "fnm") 
document.getElementById('Geo').hdd.value = fnm[document.getElementById('Geo').selectformat.value];
if(k == "fnh") 
document.getElementById('Geo').hdd.value = fnh[document.getElementById('Geo').selectformat.value];
if (k == "fpl") 
document.getElementById('Geo').hdd.value = fpl[document.getElementById('Geo').selectformat.value];
if (k == "fpm") 
document.getElementById('Geo').hdd.value = fpm[document.getElementById('Geo').selectformat.value];
if (k == "fph") 
document.getElementById('Geo').hdd.value = fph[document.getElementById('Geo').selectformat.value];
if(k == "gnl") 
document.getElementById('Geo').hdd.value = gnl[document.getElementById('Geo').selectformat.value];
if(k == "gnm") 
document.getElementById('Geo').hdd.value = gnm[document.getElementById('Geo').selectformat.value];
if(k == "gnh") 
document.getElementById('Geo').hdd.value = gnh[document.getElementById('Geo').selectformat.value];
if (k == "gpl") 
document.getElementById('Geo').hdd.value = gpl[document.getElementById('Geo').selectformat.value];
if (k == "gpm") 
document.getElementById('Geo').hdd.value = gpm[document.getElementById('Geo').selectformat.value];
if (k == "gph") 
document.getElementById('Geo').hdd.value = gph[document.getElementById('Geo').selectformat.value];
day()
}
function day() {
document.getElementById('Geo').daygb.value=document.getElementById('Geo').days.value*document.getElementById('Geo').hdd.value;
}

function totDays() {


if (document.getElementById('Geo').size.value == 0 ){
alert ("Select a Hard Disk Size!!")
document.getElementById('Geo').size.focus();
return;
}

if ( (document.getElementById('Geo').a[1].selected == false ) && (document.getElementById('Geo').a[2].selected == false ) && (document.getElementById('Geo').a[3].selected == false ) && (document.getElementById('Geo').a[4].selected == false ) && (document.getElementById('Geo').a[5].selected == false )&& (document.getElementById('Geo').a[6].selected == false )&&(document.getElementById('Geo').a[7].selected == false)){
alert ("Selecione o Modelo!!!");
document.getElementById('Geo').a.focus();
return;
}

if ( (document.getElementById('Geo').FORMAT[0].checked == false ) && (document.getElementById('Geo').FORMAT[1].checked == false ) && (document.getElementById('Geo').FORMAT[2].checked == false ) && (document.getElementById('Geo').FORMAT[3].checked == false ) && (document.getElementById('Geo').FORMAT[4].checked == false ) && (document.getElementById('Geo').FORMAT[5].checked == false ) ){
alert ("Selecione o Codec de Gravação!!!");
document.getElementById('Geo').a.focus();
return;
}

if ( (document.getElementById('Geo').c[0].checked == false ) && (document.getElementById('Geo').c[1].checked == false ) && (document.getElementById('Geo').c[1].checked == false ) ){
alert ("Selecione a Qualidade de Gravação!!!");
document.getElementById('Geo').a.focus();
return;
}

if ( (document.getElementById('Geo').b[0].checked == false ) && (document.getElementById('Geo').b[1].checked == false )){
alert ("Selecione a complexidade do vídeo Gravado!!!");
document.getElementById('Geo').a.focus();
return;
}

if(document.getElementById('Geo').daysNeeded.value == '0'){
	alert ("Selecione o número de dias para Gravação!!!");
	document.getElementById('Geo').a.focus();
	return;
}


if (document.getElementById('Geo').size.value/document.getElementById('Geo').daygb.value<1) {
document.getElementById('Geo').totTime.value = 1
}
else {
document.getElementById('Geo').totTime.value=document.getElementById('Geo').size.value/document.getElementById('Geo').daygb.value;

var number = document.getElementById('Geo').totTime.value; // ì?´ì „ê°’ 
var removechar = "."; // ë¬¸ìž?ì—´ì—?ì„œ ì œê±°í•  ë¬¸ìž? 

dec = number.indexOf(removechar); 
if (dec == -1) {
document.getElementById('Geo').totTime.value=document.getElementById('Geo').totTime.value;
}
else {
tmp = number.substring(0,dec); 
document.getElementById('Geo').totTime.value = tmp;
}
}
}

function hdSize() {
if ( (document.getElementById('Geo').a[1].selected == false ) && (document.getElementById('Geo').a[2].selected == false ) && (document.getElementById('Geo').a[3].selected == false ) && (document.getElementById('Geo').a[4].selected == false ) && (document.getElementById('Geo').a[5].selected == false )&& (document.getElementById('Geo').a[6].selected == false )&&(document.getElementById('Geo').a[7].selected == false )){
alert ("Selecione o Modelo!!!");
document.getElementById('Geo').a.focus();
return;
}

if ( (document.getElementById('Geo').FORMAT[0].checked == false ) && (document.getElementById('Geo').FORMAT[1].checked == false ) && (document.getElementById('Geo').FORMAT[2].checked == false ) && (document.getElementById('Geo').FORMAT[3].checked == false ) && (document.getElementById('Geo').FORMAT[4].checked == false ) && (document.getElementById('Geo').FORMAT[5].checked == false ) ){
alert ("Selecione o Codec de Gravação!!!");
document.getElementById('Geo').a.focus();
return;
}

if ( (document.getElementById('Geo').c[0].checked == false ) && (document.getElementById('Geo').c[1].checked == false ) && (document.getElementById('Geo').c[1].checked == false ) ){
alert ("Selecione a Qualidade de Gravação!!!");
document.getElementById('Geo').a.focus();
return;
}

if ( (document.getElementById('Geo').b[0].checked == false ) && (document.getElementById('Geo').b[1].checked == false )){
alert ("Selecione a complexidade do vídeo Gravado!!!");
document.getElementById('Geo').a.focus();
return;
}

valor = document.getElementById('Geo').daygb.value*document.getElementById('Geo').daysNeeded.value;

if(document.getElementById('Geo').daysNeeded.value == '0'){
	alert ("Selecione o número de dias para Gravação!!!");
	document.getElementById('Geo').a.focus();
	return;
}

document.getElementById('totHDSize').innerHTML = valor;
//document.getElementById('totHDSize').innerHTML = custRound(document.getElementById('Geo').totHDSize.value,3);

}


function custRound(x,places) {
return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
}

/*###############################################################*/



function DoAns()
{
    var resolution_object;
    var webform=document.getElementById('webform');
    
    resolutin = webform.resolution_input;
    complexity = webform.complexity_input;
    
    for(i = 0; i < webform.resolution_input.length; i++)
    {
        if(webform.resolution_input[i].checked)
            resolution_object = webform.resolution_input[i].value;
    }

    var complexity_object;
    for(i = 0; i < webform.complexity_input.length; i++)
    {
        if(webform.complexity_input[i].checked)
            complexity_object = webform.complexity_input[i].value;
    }

    card_number = parseInt(webform.gv_card.value);
    resolution = parseInt(resolution_object);
    complexity = parseInt(complexity_object);
    camera_count = parseInt(webform.camera_count_input.value);
    
    if ( (webform.gv_card[1].selected == false ) && (webform.gv_card[2].selected == false ) && (webform.gv_card[3].selected == false ) && (webform.gv_card[4].selected == false ) && (webform.gv_card[5].selected == false )&& (webform.gv_card[6].selected == false )){
	alert ("Selecione o Modelo!!!");
	return;
	}
	
	if ( (webform.resolution_input[0].checked == false ) && (webform.resolution_input[1].checked == false )){
	alert ("Selecione a Resolução!!!");
	return;
	}
	
	if ( (webform.complexity_input[0].checked == false ) && (webform.complexity_input[1].checked == false )){
	alert ("Selecione a complexidade dos Vídeos!!!");
	return;
	}

    if(document.getElementById('webform').camera_count_input.value == "")
    {
        alert("Voce deve preencher um número de Cameras!!!");
        return;
    }


    if(camera_count > 200)
    {
        //ans.innerHTML = "";
        alert("O numero de Cameras não pode ser maior que 200.");
        return;
    }

    if(camera_count <= 0)
    {
        //ans.innerHTML = "";
        alert("O Número de cameras tem de  ser maior ou igual a 1.");
        return;
    }

    bandwidth = 0;
    if(complexity == 0)
        bandwidth = ts[card_number][resolution] * camera_count;
    else
        bandwidth = tc[card_number][resolution] * camera_count;
	document.getElementById('ans').innerHTML = bandwidth.toString();
    //webform.ans.value 
}
