// set defaults as globals:
users_ws=1; // may not be 0 for e5
years_ws=1;
users_mb=1; // may not be 0 for e5
years_mb=1;
support_ws='NoSupport';
os_ws = 'auswahl';
os_num_ws = 1;
support_mb='NoSupport';
os_mb = 'auswahl';
os_num_mb = 1;
var elem5;
var id_ws = '';
var id_mobile = '';
var num = document.forms.length;
if (!lang) var lang=0;
// let's initialize
function initAll(myform) {
	
	if(document.getElementById('antivir_workstation')) {
		document.getElementById('rd_ws').checked=true;
		document.getElementById('gl_ws').checked=false;
	} else {
		document.getElementById('rd_mb').checked=true;
		document.getElementById('gl_mb').checked=false;
	}
	myform.userDial.value=1;
	//document.form1.osSelector.value="Linux";
	myform.osSelector.value="auswahl";
	myform.userDial.focus();
}
function calc(u, d, s, myos){
elem5 = 'http://esales.element5.de/showprices.html?productid=';
if(myos == 'ws') {
	if(u)users_ws = u;
	if(d)years_ws = d;
	if(s)support_ws = s;
	id_ws = WorkStationID[years_ws][support_ws];
	elem5 += id_ws+'&quantity='+users_ws+'&currencies=EUR&hidecurrencylbl=1&vat=19';
	//document.getElementsByName('PreisWs').location.href = elem5;
	PreisWs.location.href = elem5;
}
else {
	if(myos == 'mobile') {
		if(u)users_mb = u;
		if(d)years_mb = d;
		if(s)support_mb = s;	
		id_mobile = MobileID[years_mb][os_num_mb][support_mb];
		elem5 += id_mobile+'&quantity='+users_mb+'&currencies=EUR&hidecurrencylbl=1&vat=19';
		//document.getElementsByName('PreisMobile').location.href = elem5;
		PreisMobile.location.href = elem5;
	}
}
}
/**
define OS for the workstation
**/
function whichOS(a){
	os_ws = a; // to be added to URL
}
/**
define OS for the mobile
**/
function whichOSMobile(a){
	arr_os = a.split(",");
	arr_os_el = arr_os[1];
	// to be added to URL
	os_num_mb = arr_os[0];
	os_mb = OperatingSystems[os_num_mb][arr_os_el];
}
function URL(myos){
	// get ID from external array
	var kp = ''; // default is none
	var buylink;
	var buylink_start;
	buylink_start = 'https://secure.element5.com/esales/cart.html?';
	var buylink_mid;
	buylink_mid = '&languageid='+av_languages[lang][5]+'&backlink='+document.location;
	var buylink_end;
	buylink_end = '&affiliate=AffiliateNo'+affiliate+'&qpc=7m05v&cookies=1';
	if(myos == 'ws') {
		id_ws = WorkStationID[years_ws][support_ws];
		buylink_start2 = '&PRODUCT['+id_ws+']='+users_ws;
		buylink_mid2 = '&HADDITIONAL1['+id_ws+']='+os_ws;
	}
	else {
		id_mobile = MobileID[years_mb][os_num_mb][support_mb];
		buylink_start2 = '&PRODUCT['+id_mobile+']='+users_mb;
		buylink_mid2 = '&HADDITIONAL1['+id_mobile+']='+os_mb;
	}
	buylink = buylink_start + buylink_start2 + buylink_mid + buylink_mid2 + buylink_end;
	window.location.href = buylink;
}
function checkBoxStatus(myform, myos){
// determine checkbox status and call calc()
	var supportType;
	if(myform.gold.checked==true)
	supportType = "Gold";
	else
	supportType = "NoSupport";
	calc('','',supportType, myos);
}
function wait(myform, myos){
// wait for checkbox value to be set before processing
	if(myos == "ws") frm = "document.form1";
	else frm = "document.form0";
	var command = "checkBoxStatus("+frm+",'"+myos+"')";
	window.setTimeout(command, 200);
}
function textInput(a, myform, myos){
	// checks for characters other digits and prevents 0
	var isNumber = true; // let's be positive first
	for(i=0;i<myform.userDial.value.length;++i){
	if(myform.userDial.value.charAt(i) < "0" || myform.userDial.value.charAt(i) > "9")
		isNumber = false;
	}
	if(a==0)isNumber = false;
	// if no value is entered, empty price
	if(a=='')PreisWs.location.href='http://www.avira.com/includes/js/konfigurator/i/_.gif';
	//if the value > 250 set alert
	if(a > 100) {
		alert(av_languages[lang][2][0]);
		myform.reset();
		calc(1,'','', myos);
		isNumber = false;
	} else {
		// finally, do it!
		if(isNumber==true) calc(a,'','', myos);
	}
}
// Überprüfung der Formulardaten
function CheckFormular(myform, myos)
{
	if(isNaN(myform.userDial.value))
  	{
    		alert(av_languages[lang][2][1]);
  	}
  	if((myform.userDial.value > 100) && (myos == 'ws'))
  	{
    		//alert("Die im AntiVir Onlineshop bestellbare Lizenzgröße ist auf 250 begrenzt!\nWenn Sie eine größere Lizenz als 250 ordern möchten,\nkontaktieren Sie uns bitte telefonisch unter\n+49 (0) 7542-500 0 oder per Email: sales@antivir.de.\n\n© H+BEDV Datentechnik GmbH");
    		myform.reset();
  	}
 }