$(function(){
	$("#share_item_button").click(function(){
		$("#share_form").submit();
		return false;
	});
	
    $("#share_form").validate({
        rules: {
            'email': {
                required: true,
                email: true,
                minlength: 4,
                maxlength: 50
            }
        },
        messages: {
            'email': {
                required: "The e-mail is blank.",
                minlength: "Too short.",
                maxlength: "Too long."
            }
        }
    });
	
	//CALL ME NOW
	$("#call_button_new_zeeland").click(function(){
		$("#call_form_new_zeeland").submit();
		return false;
	});
	$("#call_form_new_zeeland").validate({
        rules: {
            'call_me[number]': {
                required: true,
                minlength: 6,
                maxlength: 50
            }
        },
        messages: {
            'call_me[number]': {
                required: "The field is blank.",
                minlength: "Too short.",
                maxlength: "Too long."
            }
        }
    });

	$("#call_button_australia").click(function(){
		$("#call_form_australia").submit();
		return false;
	});
	$("#call_form_australia").validate({
        rules: {
            'call_me[number]': {
                required: true,
                minlength: 6,
                maxlength: 50
            }
        },
        messages: {
            'call_me[number]': {
                required: "The field is blank.",
                minlength: "Too short.",
                maxlength: "Too long."
            }
        }
    });
	
	
	//WISHLIST
	$("#send_wishlist_button").click(function(){
		$("input.text").each(function(){
			if($(this).val() == "Enter email address" || $(this).val() == "Name of client" ||
				$(this).val() == "clientmail@hotmail.com" ||$(this).val() == "friendofmine@gmail.com")
				
				$(this).val("");
		});
		
		$("#send_wishlist_form").submit();
		return false;
	});
	$("#send_wishlist_form").validate({
        rules: {
            'name': {
                required: true,
                minlength: 4,
                maxlength: 50
            },
			'email': {
				required: true,
                email: true,
                minlength: 4,
                maxlength: 50
			},
			'friend_email': {
				required: false,
                email: true,
                minlength: 4,
                maxlength: 50
			}
        },
        messages: {
            'name': {
                required: "Please enter your name.",
                minlength: "Too short.",
                maxlength: "Too long."
            },
			'email': {
                required: "The e-mail is blank.",
                minlength: "Too short.",
                maxlength: "Too long."
            },
			'friend_email': {
				email: "Not an e-mail.",
                minlength: "Too short.",
                maxlength: "Too long."
			}
        }
    });
	
	$("#search_form").validate({
        rules: {
            'search': {
                required: true,
                minlength: 2,
                maxlength: 50
            }
        },
        messages: {
            'search': {
                required: " ",
                minlength: " ",
                maxlength: " "
            }
        }
    });
	
	$("#create_user_form").validate({
        rules: {
			'te_user[email]': {
				email: true,
                required: true,
                minlength: 4,
                maxlength: 50
            },
			'te_user[password]': {
                required: true,
                minlength: 4,
                maxlength: 50
            },
			'te_user[password_confirmation]': {
                required: true,
                equalTo: "#te_user_password"
            }
        },
        messages: {
			'te_user[email]': {
                required: "The e-mail is blank.",
                minlength: "Too short.",
                maxlength: "Too long."
            },
        }
    });
	
	$("#newsletter_form").validate({
        rules: {
			'cm-name': {
                required: true,
                minlength: 4,
                maxlength: 50
            },
			'cm-kihrlr-kihrlr': {
				email: true,
                required: true,
                minlength: 4,
                maxlength: 50
            }
        }
    });
	
	$("#newsletter_un_form").validate({
        rules: {
			'cm-kihrlr-kihrlr': {
				email: true,
                required: true,
                minlength: 4,
                maxlength: 50
            }
        }
    });
	
	$("#contact_form").validate({
        rules: {
			'contact[contact_name]': {
                required: true,
                minlength: 2,
                maxlength: 50
            },
			'contact[contact_email]': {
				email: true,
                required: true,
                minlength: 4,
                maxlength: 50
            }
        }
    });

	$("#contact_requests_form").validate({
        rules: {
			'contact[name]': {
                required: true,
                minlength: 2,
                maxlength: 50
            },
			'contact[email]': {
				email: true,
                required: true,
                minlength: 4,
                maxlength: 50
            },
			'contact[address]': {
                required: true,
                minlength: 6,
                maxlength: 200
            }
        }
	});
	
	/*NGTV Campaign*/
	$("#ngtv_campaign_form").validate({
        rules: {
			'campaign[contact_name]': {
                required: true,
                minlength: 2,
                maxlength: 50
            },
			'campaign[contact_email]': {
				email: true,
                required: true,
                minlength: 4,
                maxlength: 50
            },
			'campaign[terms_and_conditions]' : {
				required: true
			}
        }
	});
});
