/*function form_place(){
    $(function() {                           
                $("#inv_address1").placeholder();
                $("#inv_address2").placeholder();
                $("#inv_address3").placeholder();
                $("#inv_postcode").placeholder();
                
                $("#first_name").placeholder();
                $("#last_name").placeholder();
                $("#email_address").placeholder(); 
                $("#username").placeholder();
                $("#password").placeholder();
                $("#password_conf").placeholder();
                $("#telephone_number").placeholder();
                $("#mobile_number").placeholder();
                
                $("#del_address1").placeholder();
                $("#del_address2").placeholder();
                $("#del_address3").placeholder();
                $("#del_postcode").placeholder();
                
        });
}
 /*
function setupPlaceholder(inputid) 
{ 
    if ($.browser.webkit) return false;   
    var target = $('#'+inputid); 
    if (target.length==0) { 
        target = $('input[type="text"], input[type="email"], input[type="search"]'); 
    }   
    target.each( function(i, el) { 
        el = $(el); 
        var ph = el.attr('placeholder'); 
        if (!ph) return true;   
        el.addClass('placeholder'); 
        el.attr('value', ph);
        el.focus( function(e) { 
            if( el.val()==ph ) { 
                el.removeClass('placeholder'); 
                el.attr('value', ''); 
            } 
        });   
        el.blur( 
        function(e) { 
            if( $.trim(el.val())=='' ) { 
                el.addClass('placeholder'); 
                el.attr('value', ph); 
            } 
        }); 
    }); 
}*/ 


/* 
 * EnablePlaceholder jQuery plugin.
 * https://github.com/marioizquierdo/enablePlaceholder
 * version 1.2.1 (Aug 30, 2011)
 * 
 * Copyright (c) 2011 Mario Izquierdo
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 */
 /*
(function(){
    var a,c,b,d;a=jQuery;
    a.support.placeholder=document.createElement("input").placeholder!=null;
    a.EnablePlaceholder={
        defaults:{
            withPlaceholderClass:"placeholder"
        },alsoForModernBrowsers:false
    };
    c=function(h,f,e){
        var g;
        if(!a.support.placeholder||a.EnablePlaceholder.alsoForModernBrowsers){
            g=a.extend({
                
            },a.EnablePlaceholder.defaults,f);
            return h.each(function(){
                return e(a(this),g)
            })
        }
    };
    b=function(e,f){
        return e.bind("focus focusin keydown paste",
        function(){
            return e.clearPlaceholder(f)
        })
    };
    d=function(e,f){
        return e.bind("blur focusout",function(){
            return e.showPlaceholder(f)
        })
    };
    a.fn.enablePlaceholder=function(e){
        return c(this,e,function(f,g){b(f,g);
        d(f,g);
        a(window).unload(function(){
            f.clearPlaceholder(g);
            return true
        });
        return f.showPlaceholder(g)
        })
    };
    a.fn.showPlaceholder=function(e){
        return c(this,e,function(f,g){
            if(f.val()===""){
                return f.val(f.attr("placeholder")).addClass(g.withPlaceholderClass).data("ph_active",true)
            }
        })
    };
    a.fn.clearPlaceholder=function(e){
        return c(this,e,function(f,g){
            if(f.data("ph_active")){
                return f.val("").removeClass(g.withPlaceholderClass).data("ph_active",false)
            }
        })
    };
                a.fn.updatePlaceholder=function(f,e){
                    return this.clearPlaceholder(e).attr("placeholder",f).showPlaceholder(e)
                }
}).call(this);*/

/*
jQuery.fn.placeholder = function() 
{
    $('textarea').each(function()
    {
        var placeholder = $(this).attr("placeholder");
        $(this).html(placeholder);
        
        $(this).css({color:'#999999'});
        
        $(this).bind('focus', function()
        {
            if($(this).html()==placeholder)
            {
                $(this).html("");
                $(this).css({color:'#000'});
            }
        }
        )
        
        $(this).bind('blur', function()
        {
            if($(this).html()=="")
            {
                $(this).html(placeholder);
                $(this).css({color:'#999999'});
            }
        }
        )
    }
    );
    
    var counter=0;
    
    $('input').each(function()
    {
        var id = $(this).attr("id");
        var placeholder = $(this).attr("placeholder");
        
        if($(this).attr("type")=="password")
        {
            var thisdummy = 'dummy' + counter;
            
            $(this).hide();
            $(this).after('<input type="text" id="' + thisdummy + '"/>');
            $('#' + thisdummy).val(placeholder);
            $('#' + thisdummy).css({color:'#999999'});
            
            counter++;
            
            $('#' + thisdummy).bind('focus', function()
            {
                $("#" + id).show().val("");
                $("#" + id).show().focus();
                $(this).hide();
            }
            )
            
            $(this).bind('blur', function()
            {
                if($(this).val()=="")
                {
                    $(this).hide();
                    $("#" + thisdummy).show();
                };
            }
            )
        }
        
        if($(this).attr("type")=="text")
        {
            $(this).val(placeholder);
            $(this).css({color:'#999999'});
            
            $(this).bind('focus', function()
            {
                if($(this).val()==placeholder)
                {
                    $(this).val("");
                    $(this).css({color:'#000'});
                }
            }
            )
            
            $(this).bind('blur', function()
            {
                if($(this).val()=="")
                {
                    $(this).val(placeholder);
                    $(this).css({color:'#999999'});
                }
            }
            )
        }
    }
    );
};*/


(function($) {

/**
* Spoofs placeholders in browsers that don't support them (eg Firefox 3)
*
* Copyright 2011 Dan Bentley
* Licensed under the Apache License 2.0
*
* Author: Dan Bentley [github.com/danbentley]
*/

// Return if native support is available.
if ("placeholder" in document.createElement("input")) return;

$(document).ready(function(){
$(':input[placeholder]').not(':password').each(function() {
setupPlaceholder($(this));
});

$(':password[placeholder]').each(function() {
setupPasswords($(this));
});

$('form').submit(function(e) {
clearPlaceholdersBeforeSubmit($(this));
});
});

function setupPlaceholder(input) {

var placeholderText = input.attr('placeholder');

setPlaceholderOrFlagChanged(input, placeholderText);
input.focus(function(e) {
if (input.data('changed') === true) return;
if (input.val() === placeholderText) input.val('');
}).blur(function(e) {
if (input.val() === '') input.val(placeholderText);
}).change(function(e) {
input.data('changed', input.val() !== '');
});
}

function setPlaceholderOrFlagChanged(input, text) {
(input.val() === '') ? input.val(text) : input.data('changed', true);
}

function setupPasswords(input) {
var passwordPlaceholder = createPasswordPlaceholder(input);
input.after(passwordPlaceholder);

(input.val() === '') ? input.hide() : passwordPlaceholder.hide();

$(input).blur(function(e) {
if (input.val() !== '') return;
input.hide();
passwordPlaceholder.show();
});

$(passwordPlaceholder).focus(function(e) {
input.show().focus();
passwordPlaceholder.hide();
});
}

function createPasswordPlaceholder(input) {
return $('<input>').attr({
placeholder: input.attr('placeholder'),
value: input.attr('placeholder'),
id: input.attr('id'),
readonly: true
}).addClass(input.attr('class'));
}

function clearPlaceholdersBeforeSubmit(form) {
form.find(':input[placeholder]').each(function() {
if ($(this).data('changed') === true) return;
if ($(this).val() === $(this).attr('placeholder')) $(this).val('');
});
}
})(jQuery);


