// JavaScript Document
function checkChangeStylist(form)
{
		var fouten = "The following error(s) were found:\n\n";
		var fout = false;
		var fckHistory = FCKeditorAPI.GetInstance('history');
		var fckServices = FCKeditorAPI.GetInstance('services');
	
  	if (form.first_name.value == "")
  	{
	   fout = true;
	   fouten = fouten + "The first name is missing\n";
    }
    
  	if (form.surname.value == "")
  	{
	   fout = true;
	   fouten = fouten + "The surname is missing\n";
    }
    /*
	if (form.Image.value == "" && form.test_img.value.toString().length <= 0)
	{
	   fout = true;
	   fouten = fouten + "The image is missing\n";
    }
    
  	if (form.post_address.value == "")
  	{
        fout = true;
        fouten = fouten + "The postal address is missing\n";	   
    }
  	if (form.phy_address.value == "")
  	{
        fout = true;
        fouten = fouten + "The physical address is missing\n";	   
    }
    */
    if(form.city_id.value == 0)
    {
        fout = true;
        fouten = fouten + "Please select a city\n";
    }
    
    if(form.phone.value != "")
    {
		    if(form.phone.value.toString().length < 11)
		    {
		        fout = true;
		        fouten = fouten + "The phone number is to short\n";
		    } else
		    if(!check(form.email.value, form.phone.value, 2))
		    {
		        fout = true;
		        fouten = fouten + "The phone number is incorrect\n";
		    }
    }
    
    if(form.mobile.value != "")
    {
		    if(form.mobile.value.toString().length < 11)
		    {
		        fout = true;
		        fouten = fouten + "The mobile number is to short\n";
		    } else
		    if(!check(form.email.value, form.mobile.value, 2))
		    {
		        fout = true;
		        fouten = fouten + "The mobile number is incorrect\n";
		    }
    }
    
    if (form.website.value != "")
    {
        if(!ValidateLink(form.website.value))
        {
            fout = true;
            fouten = fouten + "The website is incorrect,\n  please use the following format: http://www.userurl.com\n";
        }
    }
    
    if(form.email.value == "")
    {
        fout = true;
        fouten = fouten + "The email addresss is missing\n";
    } else
    if(!check(form.email.value, "", 1))
    {
        fout = true;
        fouten = fouten + "The email addresss is incorrect\n";
    }
    
    /* Business DATA */
  	if (form.business_name.value == "")
  	{
	   fout = true;
	   fouten = fouten + "The business name is missing\n";
    }
    
  	if (fckHistory.GetHTML() == "<br type=\"_moz\" />")
  	{
        fout = true;
        fouten = fouten + "The history is missing\n";	   
    }
  	if (fckServices.GetHTML() == "<br type=\"_moz\" />")
  	{
        fout = true;
        fouten = fouten + "The services are missing\n";	   
    }
    
	if (fout)
		alert(fouten);
	else
		form.submit();
}

var W3CDOM = (document.createElement && document.getElementsByTagName);

function initFileUploads()
{
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	var inP = document.createElement('input');
	inP.className = 'fakeFileButton';
	fakeFileUpload.appendChild(inP);
	var image = document.createElement('img');
	image.src='img/btn_browse.gif';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file hidden';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = clone.getElementsByTagName('input')[0];
		x[i].relatedElement.size = '35';
		x[i].onchange = x[i].onmouseout = function () {
			this.relatedElement.value = this.value;
		}
	}
}

function checkPostAListingPage1(form)
{
	var fouten = "Please fill in the following field(s):\n\n";
	var fout = false;
	
	if (form.category_id.value == 0)
	{
	   fout = true;
	   fouten = fouten + "Please select a category\n";
    }
    
	if (form.city_id.value == 0)
	{
	   fout = true;
	   fouten = fouten + "Please select a city\n";
    }
    
	if (form.first_name.value == "")
	{
	   fout = true;
	   fouten = fouten + "The first name is missing\n";
    }
	if (form.surname.value == "")
	{
	   fout = true;
	   fouten = fouten + "The surname is missing\n";
    }
	if (form.business_name.value == "")
	{
	   fout = true;
	   fouten = fouten + "The business name is missing\n";
    }    
    if(form.email.value == "")
    {
        fout = true;
        fouten = fouten + "The email addresss is missing\n";
    } else
    if(!check(form.email.value, "", 1))
    {
        fout = true;
        fouten = fouten + "The email addresss is incorrect\n";
    }

    if (form.website.value != "")
    {
        if(!ValidateLink(form.website.value))
        {
            fout = true;
            fouten = fouten + "The website is incorrect,\n  please use the following format: http://www.userurl.com\n";
        }
    }
	  
	  if (form.phone.value != "")
	  {
        if(!check(form.email.value, form.phone.value, 2))
        {
            fout = true;
            fouten = fouten + "The phone number is incorrect\n";
        }
    }
    
    if(form.mobile.value != "")
    {
        if(!check(form.email.value, form.mobile.value, 2))
        {
            fout = true;
            fouten = fouten + "The mobile number is incorrect\n";
        }
    }
	if (form.history.value == "")
	{
        fout = true;
        fouten = fouten + "The history is missing\n";	   
    }
	if (form.services.value == "")
	{
        fout = true;
        fouten = fouten + "The services are missing\n";	   
    }
    
	if (fout)
		alert(fouten);
	else
		form.submit();
}

function checkPostAListingPage2(form)
{
    var fouten = "Please fill in the following field(s):\n\n";
    var fout = false;
    
    if (form.subscription_id.value == 0)
    {
        fout = true;
        fouten = fouten + "Please select a subscription\n";	   
    }
    
    if (fout)
        alert(fouten);
    else
        form.submit();
}