document.createElement("header");
document.createElement("main");
document.createElement("footer");
document.createElement("section");

$(document).ready(function(){
    Cufon.replace(".cufon");

    $("a[rel='colorbox']").colorbox();

    $("#banners").cycle({
        pager: "#banners-navs"
    });
    
    $('a[rel="external"]').click(function() { 
        this.target = "_blank";
    });

    $("#enquiry-form").validationEngine();

    // SAFEMAIL
    $("span.safemail").each(function(){
        exp = $(this).text().search(/\((.*?)\)/) != -1 ? new RegExp(/(.*?) \((.*?)\)/) : new RegExp(/.*/);
        match = exp.exec($(this).text());
        addr = match[1] ? match[1].replace(/ at /,"@").replace(/ dot /g,".") : match[0].replace(/ at /,"@").replace(/ dot /g,".");
        emaillink = match[2] ? match[2] : addr;
        subject = $(this).attr('title') ? "?subject="+$(this).attr('title').replace(/ /g,"%20") : "";
        $(this).after('<a class="link" href="mailto:'+addr+subject+'">'+emaillink+'</a>'); //supposed to be ">'+ emaillink +'<"
        $(this).remove();
    });
    
    $("input.safemail").each(function(){
        $(this).val($(this).val().replace(/ at /,"@").replace(/ dot /g,"."));
    });

    // REPLACE TEXT
    // must implement:
    // <input class="replace left" type="text" value="type keywords(s)" />
    // <input class="replace" type="hidden" value="type keywords(s)" />
    $(".replace").click(function(){
        if($(this).val() == $(this).siblings(".replace").val()) {
            $(this).val("");
        }
    }).blur(function(){
        if($(this).val() == "") {
            $(this).val($(this).siblings(".replace").val());
        }
    });

    $("#banners-navs a").html(" ");
    
    $(".scroll-pane").jScrollPane({ showArrows:true });
});

