function isNumeric(value) {

  if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) {
	alert("Bitte numerische Werte eingeben")

	return false;
  }
  return true;
}


var counter=0

function mul1(x,y,a)
{ 
  
  var qty="qty"+y;
  
  var total="total"+y;
  var weight="weight"+y;
  var weights="weights"+y;
  var text="text"+y;
  var z=document.getElementById(qty).value;
  isNumeric(z)
  var total1=z*x;
  var totalw=z*a;
  document.getElementById(text).innerHTML="SFr.  "+truncate(total1);
  //document.getElementById(weight).innerHTML=totalw;
  document.getElementById(total).value=total1;
  document.getElementById(weights).value=totalw;
  var gtotal=document.getElementById(total).value
  //counter=counter+parseFloat(gtotal)
  submit_form()
  }
  
 
function submit_form()
	{        var total=0

		     dml=document.forms['form1'];
		// get the number of elements from the document
 		 	 len = dml.elements.length;  // 15
			 
			 for( i=0 ; i<len ; i++)   // loop is run 15 times
			 {
				//check the textbox with the elements name
				if (dml.elements[i].name=='total[]')
				{
				        dml.elements[i].focus();
						var total= total + parseFloat(dml.elements[i].value)
			     }
				
			 }
		
		 //alert(total)
		document.getElementById("Sum").innerHTML="SFr.  "+truncate(total);
		document.getElementById("gtotal").value="SFr.  "+truncate(total);	
	}
	function truncate(num) {
string = "" + num;
if (string.indexOf('.') == -1)
return string + '.00';
seperation = string.length - string.indexOf('.');
if (seperation > 3)
return string.substring(0,string.length-seperation+3);
else if (seperation == 2)
return string + '0';
return string;
} 

function printDiv(id)
{
	content = document.getElementById(id).innerHTML;
	var newWin=window.open('','PrintWindow','width=1024,height=400');
	newWin.document.open();
	newWin.document.write('<html><body>'+content+'</body></html>');
	newWin.document.close();
    newWin.window.print();
	setTimeout(function(){newWin.close();},10);
}

function clearcontent(id, defaultValue)
{
	var temp = document.getElementById(id).value;
	
	if(temp == 'Provide a password' || temp == 'Enter your password again' || temp == 'Password should be same')
	{
		document.getElementById(id).value = "";
		document.getElementById(id).type = "password";	
	}
	
	if(temp == 'Provide verification code' || temp == 'Invalid email-id')
	{
		document.getElementById(id).value = "";
	}
	
	if(document.getElementById(id).value == defaultValue){
		document.getElementById(id).value = "";
		if(id == 'password' || id == 'reenterpassword') { 
			document.getElementById(id).type = "password";
		}
	}
	
}

function fillcontent(id, defaultValue)
{
	if(document.getElementById(id).value == ""){
		if(id == 'password' || id == 'reenterpassword') { 
			document.getElementById(id).type = "text";
		}
		document.getElementById(id).value = defaultValue;	
	}
}

function toggleaccount()
{
	document.getElementById('createanaccount').style.display = '';
	document.getElementById('logintoaccount').style.display = 'none';
}

function togglelogin()
{
	document.getElementById('logintoaccount').style.display = '';
	document.getElementById('createanaccount').style.display = 'none';
}

