//CLEAR TEXT INSIDE FIELD
function doClear(theText) {
	if (theText.value == theText.defaultValue) {
		theText.value = ""
	}
}

//EXTERNAL LINKS (use instead of target="_blank")
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
	anchor.target = "_blank";
	}
}
window.onload = externalLinks;

jQuery.fn.defuscate = function( settings ) {
    settings = jQuery.extend({
        link: true
    }, settings);
    var regex = /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi;
    return this.each(function() {
        if ( $(this).is('a[@href]') ) {
            // If it's an <a> element, defuscate the href attribute
            $(this).attr('href', $(this).attr('href').replace(regex, '$1@$2'));
            // Make sure that the element's contents is not made into a link
            var is_link = true;
            //alert($(this).attr('href'));
        }
        // Defuscate the element's contents
        $(this).html($(this).html().replace(regex, (settings.link && !is_link ? '<a href="mailto:$1@$2">$1@$2</a>' : '$1@$2')));
  });
}

//ON READY (jQuery)
$(document).ready(function(){
	//DEFUSCATOR
	$('a').defuscate(); //(a) has to come before anything else
	
	//VALIDATE FORMS
	$('#myForm').validate();
	$('#newsletter').validate();
});

if(typeof sIFR == "function"){
	sIFR.replaceElement(named({sSelector:".futura", sFlashSrc:"flash/sifr_futura.swf", sColor:"#216437", sCase:"upper", sWmode:"transparent"}));
	sIFR.replaceElement(named({sSelector:".bank-gothic", sFlashSrc:"flash/sifr_bank-gothic.swf", sColor:"#003300", sCase:"upper", sWmode:"transparent"}));
};