function checkInputs(doc, errmsg, errcolor, validcolor, errbg, validbg, type)
{
	var inputs = $$('.required');

	//defaults
	var focused = false;
	
	if(errmsg == undefined) errmsg = '&nbsp;'; // set emtpy error message
	if(errcolor == undefined) errcolor = '#ff9933'; // set error color
	if(errbg == undefined) errbg = '#fff2e5'; // set error background
	if(validcolor == undefined) validcolor = '#b4babc'; // set valid color
	if(validbg == undefined) validbg = '#ffffff'; // set valid background color
	
	var iserror = 0;
	var gerror = 0;
	
	/* Special condition for cart.checkout */
	if ($(doc).name == 'cart_checkout') {
		if ($('terms_checkbox').checked == false) {
			Effect.Pulsate($('cart_checkout_accept_terms'),{duration:1, pulses: 2});
			gerror += 1;
		}
	}
		
	
	for (var index = 0; index < inputs.length; ++index) {
		
		var item = inputs[index];
		var inputValue = item.value;
		var titleValue = item.getAttribute('title');
		iserror = 0;
		
		// extra code for sepcial fields
		if(titleValue == 'agb') {
			//alert(item.checked);
		}
		// reset colors
		item.setStyle({ backgroundColor: validbg, borderColor: validcolor });
		
		if ($(doc).id == 'user_edit') {
			if ($('password').value != $('password_repeat').value)  {
				$('password').setStyle({ backgroundColor:errbg });
				$('password_repeat').setStyle({ backgroundColor:errbg });
				Effect.Pulsate($('password'),{duration:1, pulses: 2});
				Effect.Pulsate($('password_repeat'),{duration:1, pulses: 2});
			}
		}
		
		if(titleValue == 'email' || titleValue == 'shipping_email') {
			
			if (inputValue == '' || inputValue.length < 6 || (inputValue.indexOf("@") < 1)  || (inputValue.indexOf(".") < 1) ) {
				iserror = 1; 
				gerror += 1; 
			}
		}
		else if(titleValue == 'zip' || titleValue == 'shipping_zip' ) {
			if (inputValue == '') {
				iserror = 1; 
				gerror += 1; 
			}
		}
		else if(titleValue == 'agb') {
			
			if($('agbtitle')) { $('agbtitle').setStyle({ color:'#333333' }); }			
			if (item.checked == false) {
				
				$('agb_error').setStyle({ color:errcolor });
				iserror = 1; 
				gerror += 1; 
			}
		}
		else if(titleValue == 'terms_conditions') {
			if(!item.checked) {
				iserror = 1; 
				gerror += 1; 
			}
		}
		else if(titleValue != '' && inputValue == '') {			
			iserror = 1; 
			gerror += 1; 
		}
		
		if(iserror==1){
			item.setStyle({ backgroundColor:errbg });
			Effect.Pulsate(item,{duration:1, pulses: 2});
			
			if(!focused) item.focus();
			focused = true;
		}
	}
	
	if(gerror > 0){
		if($('errormsg')) {
			$('errormsg').innerHTML = errmsg;
		}
	}
	
	if (gerror == 0) {
		if (type == 'return')
			return true;
		else
			$(doc).submit();
	}	
}


