function wrong_login_agent(web_link)
{
	alert("Your password or username is incorrect please try again.");
	window.location.href = web_link;
}

function wrong_login_customer(web_link)
{
	alert("Your password or username is incorrect please try again.");
	window.location.href = web_link;
}

function showEmail(user, domain, tld, title){
   var emailId = user + "\u0040" + domain + "." + tld;
   var url = "mailto:" + emailId;

   if(!title){
       title = emailId;
   }
   document.write("<a href='" + url + "'>" + title + "</a>");
}

function open_window(link,width,height)
{
    window.open (link,'app',"location=1,status=1,scrollbars=1,width="+width+",height="+height);
}

function display_mortgage_alert_box()
{
	alert("For a PROGRESS REPORT on a MORTGAGE ALREADY SUBMITTED\n\nCall MUSTAFA: 0208 150 3160. Existing clients only.");

}

function email_wrong(email,error_message) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
return (false)
}
alert(error_message)
document.getElementById("email").value = '';
document.getElementById("email").focus();
return (true)
}


function validation(form_name,alert_message)
{
    for(i=0; i<document.getElementById(form_name).elements.length; i++)
    {
        curr_element = document.getElementById(form_name).elements[i];
        if(curr_element.value=='')
		{ 
			// eger value si bos ise, false geri döndürür bu da formu submit yapmaz
            alert(alert_message);
//            document.getElementById(curr_element.id).focus();
//			document.getElementById(curr_element.id).style.border='1px solid #cccccc';
            return false;
        }
    }
    return true;
}

function validate_form()
{
    var i;
    for(i=0;i<id_array.length;i++)
    {
        element_id = id_array[i];
        type = type_array[i];
        value = document.getElementById(element_id).value;
        document.getElementById(element_id).style.border='1px solid #cccccc';
        var validate_result = return_validate_result(value,type);
        if(!validate_result)
        {
            alert("Please fill all required fields ("+element_id+")");
            document.getElementById(element_id).style.border='2px solid #FF0000';
            document.getElementById(element_id).focus();
            return false;
        }
    }
    return true;
}
