
function addSelectClass( objectID1, objectID2 ) {
	var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34];
	jQuery.each(arr, function() {
        $('#' + this).removeClass('selectBack');
	});
	$('#panel' + objectID1 ).addClass('selectBack');
	$('#' + objectID2 ).addClass('selectBack');
}

function getDesc( divID ) {
	var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34];
	jQuery.each(arr, function() {
        $('.' + this).hide("slow");
	});
	$( "#panel" + divID ).slideToggle("slow");
}

function setJavascriptCode () {
	if( document.getElementById('p1') ) { $(function(){$('#p1').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p2') ) { $(function(){$('#p2').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p3') ) { $(function(){$('#p3').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p4') ) { $(function(){$('#p4').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p5') ) { $(function(){$('#p5').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p6') ) { $(function(){$('#p6').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p7') ) { $(function(){$('#p7').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p8') ) { $(function(){$('#p8').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p9') ) { $(function(){$('#p9').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p10') ) { $(function(){$('#p10').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p11') ) { $(function(){$('#p11').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p12') ) { $(function(){$('#p12').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p13') ) { $(function(){$('#p13').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p14') ) { $(function(){$('#p14').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p15') ) { $(function(){$('#p15').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p16') ) { $(function(){$('#p16').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p17') ) { $(function(){$('#p17').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p18') ) { $(function(){$('#p18').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p19') ) { $(function(){$('#p19').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p20') ) { $(function(){$('#p20').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p21') ) { $(function(){$('#p21').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p22') ) { $(function(){$('#p22').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p23') ) { $(function(){$('#p23').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p24') ) { $(function(){$('#p24').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p25') ) { $(function(){$('#p25').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p26') ) { $(function(){$('#p26').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p27') ) { $(function(){$('#p27').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p28') ) { $(function(){$('#p28').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p29') ) { $(function(){$('#p29').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p30') ) { $(function(){$('#p30').keyup(function(){ calCostumerSaleSum();});}); }
	if( document.getElementById('p31') ) { $(function(){$('#p31').keyup(function(){ calCostumerSaleSum();});}); }
}

function calCostumerSaleSum() {

		$.post("func/application.calc.sale.global.php", $("#saleForm").serialize(),
		function(data){
			$("#costTotal").html( data.costTotal + ' &euro;' ); 
			$("#calSum").val( data.costTotal );
			if( data.state == 'error' ) {
				alert( 'Sie müssen mindestens einen Artikel pro Artikel bestellen!' );
			}else{
				if( data.costTotal1 <= data.minSaleCost ) {
					$("#sendButton").hide();
					$("#sendCheckbox").hide();
					$("#sendText").hide();
				}else{
					$("#sendButton").show();
					$("#sendCheckbox").show();
					$("#sendText").show();
				}		
			}
		}, "json");
	
	return false;	
}

function sendCostumerSaleSum() {
	resCon = confirm( "Sind Sie sicher das Sie bestellten wollen? Bitte überprüfen Sie nochmals Ihre Angaben!" );
	if( resCon == false){
		return false;
	}else{
		$.post("func/application.calc.sale.php", $("#saleForm").serialize(),
	  function(data){
	  	if( data.status ) {
	  		self.location.href = '?go=success&in=thanx';
	  	}else{
	  		alert(data.msg);
	  	}
	  }, "json");
	}  	
  return false;
}


function setJavascriptCodeSecond () {
	if( document.getElementById('p1s') ) { $(function(){$('#p1s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p2s') ) { $(function(){$('#p2s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p3s') ) { $(function(){$('#p3s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p4s') ) { $(function(){$('#p4s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p5s') ) { $(function(){$('#p5s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p6s') ) { $(function(){$('#p6s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p7s') ) { $(function(){$('#p7s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p8s') ) { $(function(){$('#p8s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p9s') ) { $(function(){$('#p9s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p10s') ) { $(function(){$('#p10s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p11s') ) { $(function(){$('#p11s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p12s') ) { $(function(){$('#p12s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p13s') ) { $(function(){$('#p13s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p14s') ) { $(function(){$('#p14s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p15s') ) { $(function(){$('#p15s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p16s') ) { $(function(){$('#p16s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p17s') ) { $(function(){$('#p17s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p18s') ) { $(function(){$('#p18s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p19s') ) { $(function(){$('#p19s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p20s') ) { $(function(){$('#p20s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p21s') ) { $(function(){$('#p21s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p22s') ) { $(function(){$('#p22s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p23s') ) { $(function(){$('#p23s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p24s') ) { $(function(){$('#p24s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p25s') ) { $(function(){$('#p25s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p26s') ) { $(function(){$('#p26s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p27s') ) { $(function(){$('#p27s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p28s') ) { $(function(){$('#p28s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p29s') ) { $(function(){$('#p29s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p30s') ) { $(function(){$('#p30s').keyup(function(){ calCostumerSaleSumSecond();});}); }
	if( document.getElementById('p31s') ) { $(function(){$('#p31s').keyup(function(){ calCostumerSaleSumSecond();});}); }
}

function getSearchCustomers( searchText ) {
	$.post("func/application.get.searched.customer.global.php?get=" + searchText, { "func": "getNameAndTime" },
	
		function( data ){
   		$("#totalUserTd").html( 'Gesamt: ' + data.totalUser ); 
   		$("#userListTd").html( data.userList ); 
		}, "json");	
	return false;	
}


function calCostumerSaleSumSecond() {
	$.post("func/application.calc.sale.second.global.php", $("#saleFormSecond").serialize(),
	function(data){
		$("#costTotal").html( data.costTotal + ' &euro;' ); 
		$("#shippingTextTd").html( data.shippingText ); 
		$("#shippingCostTd").html( data.shippingCost + ' &euro;' );
		$("#finalCost").html( data.costTotalNetto );
		$("#calSum").val( data.costTotalNetto );
		if( data.state == 'error' ) {
			
		}else{
			if( data.costTotal == '0,00' ) {
				$("#sendButton").hide();
				$("#sendCheckbox").hide();
				$("#sendText").hide();
			}else{
				$("#sendButton").show();
				$("#sendCheckbox").show();
				$("#sendText").show();
			}
		}
	}, "json");
		
	return false;	
}

function sendCostumerSaleActionOld() {
	resCon = confirm( "Sind Sie sicher das Sie bestellten wollen? Bitte überprüfen Sie nochmals Ihre Angaben!" );
	if( resCon == false){
		return false;
	}else{
		$.post("func/application.calc.sale.action.old.php", $("#saleFormSecond").serialize(),
	  function(data){
	  	if( data.status ) {
	  		self.location.href = '?go=action.thanx';
	  	}else{
	  		alert(data.msg);
	  	}
	  }, "json");
  }
  return false;
}

function sendCostumerSaleSumSecond() {
	resCon = confirm( "Sind Sie sicher das Sie bestellten wollen? Bitte überprüfen Sie nochmals Ihre Angaben!" );
	if( resCon == false){
		return false;
	}else{
		$.post("func/application.calc.sale.second.php", $("#saleFormSecond").serialize(),
	  function(data){
	  	if( data.status ) {
	  		self.location.href = '?go=success&in=thanx';
	  	}else{
	  		if( data.msg == 'sess' ){
	  		 self.location.href = '?do=logout';
	  		}else{
	  		 alert(data.msg);
	  		}
	  		
	  	}
	  }, "json");
  }
  return false;
}

function sendCostumerSaleActionNew() {
	resCon = confirm( "Sind Sie sicher das Sie bestellten wollen? Bitte überprüfen Sie nochmals Ihre Angaben!" );
	if( resCon == false){
		return false;
	}else{
		$.post("func/application.calc.sale.action.new.php", $("#saleFormSecond").serialize(),
	  function(data){
	  	if( data.status ) {
	  		self.location.href = '?go=action.thanx';
	  	}else{
	  		$("#message").html( data.msg );
	  	}
	  }, "json");
  }
  return false;
}
