function update_user_profile(me)
{
	me.value= "PROCESSING.....";
	me.disabled = true;
	hideErrorMsg2();
	$('profilepage').request({onComplete: responseUpdateProfile});
}

function responseUpdateProfile($originalRequest)
{
	var errormsg = "";
	var $error_msg2 = "";

	$errors = $originalRequest.responseText;
	$errors = $errors.split("<");
   	$errors = $errors[0].split("-");
	$ctr = parseInt(eval($errors[0]));
	
	if( !isNaN($ctr) || $ctr > 0 )
	{
		for( $x = 1; $x <= $ctr; $x++ )
		{
			$error_msg = $errors[$x].split(".");
			$($error_msg[0] + "_label").style.color="red";
			
			$error_msg2 = $errors[$x].split(",");
			$error_msg2 = $error_msg2[0].split(".");
			
			if($error_msg2[1]!=""){
				
				showErrorMsg2($error_msg2[1]);
				$x = $cnt;
				document.getElementById("btn_submit").value= "Update Profile";
				document.getElementById("btn_submit").disabled = false;
				break;
			}
		}
	}
	else 
	{
		document.getElementById("success_form").submit();
	}
}

function showErrorMsg2(txt)
{
	$('Error_message').style.display = "block";
   
    if(txt.match("invalid")=="invalid")
	{	
		$('Error_message').innerHTML = "Email address is in valid format.";
	}		
	else if(txt.match("Already")=="Already")
	{
		$('Error_message').innerHTML =  "Email Already Used.";
	}
	else if(txt.match("Matched")=="Matched")
	{
		$('Error_message').innerHTML =  "Password Not Matched.";
	}
	else
	{
		$('Error_message').innerHTML = "Please fill-in the required field(s) colored in red.";
	}
}

function hideErrorMsg2()
{
	$('Error_message').innerHTML = "&nbsp;";
}

function checkoutCart()
{
	var flag = false;
	var courier = 0;
	
	flag = confirm('Are you sure you want to checkout?');
    
	if(flag==true)
	{
		courier = document.getElementById("selected_courier").value;
		document.getElementById("cart_checkout").selected_courier.value = courier;
		document.getElementById("cart_checkout").submit();
	}
	
	return flag;
}



