v_focus="";
v_list="";

var class_label="label";
var class_field="field";
var class_label_error="label error";
var class_field_error="field error";


function t_class(t_l,t_c)
{
if(t_c == "")
  return;
document.getElementById(t_l).className = t_c ;
}

function t_value(t_l)
{
var value=document.getElementById(t_l).value
return(value);
}


function t_select(t_l)
{
var value=document.getElementById(t_l).options[document.getElementById(t_l).selectedIndex].value;
return(value);
}




function t_input(t_l,t_v)
{
document.getElementById(t_l).value=t_v;
}

function t_display(t_l,t_v)
{
document.getElementById(t_l).style.display = t_v;
}

function t_focus(t_l)
{
document.getElementById(t_l).focus();
}

function t_html(t_l,t_t)
{
document.getElementById(t_l).innerHTML = t_t ;
}





function check_field(t_l)
{
var t_v=t_value(t_l);
var label_id="label_id_" + t_l;
var field_id="field_id_" + t_l;

// Fehlerfall
// Class des Labels und des Fields umsetzen
if(t_v == "")
  {
  t_class(label_id,class_label_error);
  t_class(field_id,class_field_error);
  return false;
  }

t_class(label_id,class_label);
t_class(field_id,class_field);
return true;
}



function validate_order()
{
var ret_code=1;

if(!check_field('Ecom_OrderNr'))
  ret_code=0;

if(ret_code == 0)
  {
  t_display('Ecom_Message_Error','block');
  return false;
  }
return true;
}

// ueberpruefung
function validate_password()
{
var ret_code=1;

if(!check_field('Ecom_PasswordOld'))
  ret_code=0;

if(!check_field('Ecom_PasswordNew'))
  ret_code=0;

if(!check_field('Ecom_PasswordNewRepeat'))
  ret_code=0;

if(ret_code == 0)
  {
  t_display('Ecom_Message_Error','block');
  return false;
  }
return true;
}


function x_request()
{
if(window.XMLHttpRequest)
  {
  xmlHttp = new XMLHttpRequest();
  }
  else
     if(window.ActiveXObject)
       {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
       }
}



function validate_login()
{
var cDate = new Date();
var cTime=cDate.getTime();
var cValue="";
var ret_code=1;

var c_nr=t_value('Ecom_kundennr');
var c_email=t_value('Ecom_Email');
var c_password=t_value('Ecom_Password');
var c_kundenid=t_value("Ecom_kundenid");

t_display('Ecom_Message_Error','none');

if(!check_field('Ecom_kundennr'))
  ret_code=0;

if(!check_field('Ecom_Password'))
  ret_code=0;

if(ret_code == 0)
  {
  t_display('Ecom_Message_Error','block');
  return false;
  }

t_display('Ecom_Message_Error','none');

var xmlUrl = "/index.php?eID=login&typ=login&user=" + c_nr + "&pass=" + $.md5(c_password) + "&cEmail=" + c_email+ "&ckundenid=" + c_kundenid +  "&cTime=" + cTime;

x_request();

if(!xmlHttp)
  return(0);

ret_code=0;
xmlHttp.open("GET", xmlUrl, true);
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
  {
  cValue=xmlHttp.responseText;
  if(cValue == "0")
    {
    t_html('Ecom_Message_Error','Ihre eingegebenen Daten sind nicht richtig');
    t_display('Ecom_Message_Error','block');
    return false;
    }

  if(cValue == "1")
    {
    t_display('Ecom_Message_Error','none');
    document.cart_order_form.cl_code.value="1";;
    document.cart_order_form.submit();
    }
  }
}
xmlHttp.send(null);
return false;
}

$(document).ready(function()
{
	$('FORM.validate').submit(function() 
	{
		$('DIV.message.error.standard').hide();
		$('DIV.message.error.email').hide();
		var valid = true;
		$(this).find('INPUT.required').each(function()
		{
			if ( $(this).val() == "" ) 
			{
				$(this).parent().parent().addClass('error');
				$('DIV.message.error.standard').show();
				valid = false;
			}
		});
		if (valid) {
			$(this).find('INPUT.email').each(function()
			{
				var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/
				if (!filter.test($(this).val()))
				{
					$(this).parent().parent().addClass('error');
					$('DIV.message.error.email').show();
					valid = false;
				}
			});
		}
		return valid;
	});
});

