var noscript = document.getElementById('noscript');
document.getElementsByTagName('head')[0].removeChild(noscript);

jQuery(document).ready(function(){
	input();
	noSpam();
	if ( jQuery.browser.mozilla || jQuery.browser.webkit){
		ContentFlowGlobal.init();
	}
});

function noSpam() {
    if (document.getElementById) {
		var at = "@";
	  	var links = document.getElementsByTagName('a');
	  
	  	for (var i = 0; i < links.length; i++) {
		  	var linkElem = links[i];
			
		  	if (linkElem.className == 'escape') {
		  		var mail = linkElem.firstChild; var domain = linkElem.lastChild;
		  		mail.nextSibling.firstChild.innerHTML = at;
		  		linkElem.href = "mailto:" + mail.data + at + domain.data;
		  	}
			
	  	} // End for
	  
    } // End if
}

function input(){
	jQuery('input[type=password], input[type=text]').each(function(){
		var $this = jQuery(this);
		if($this.attr('alt') !== '' && jQuery.trim($this.attr('value')) === ''){
			$this.after('<span class="label">'+$this.attr('alt')+'</span>');
			var $label = $this.next('.label');
			$label.css({
				'color':'#aaa',
				'padding':'10px',
				'position':'absolute',
				'top':$this.position().top-2,
				'left':$this.position().left,
				'text-shadow':'none'
			});
			if($this.attr('value') !== ''){
				$this.next('.label').hide();
			}
		}
	});
	
	jQuery('.label').click(function(){
		jQuery(this).hide();
		jQuery(this).prev('input').focus();
	});
	
	jQuery('input[type=password], input[type=text]').focus(function(){
		if(jQuery(this).attr('alt') !== ''){
			jQuery(this).next('.label').hide();
		}
	});
	
	jQuery('input[type=password], input[type=text]').blur(function(){
		if(jQuery(this).attr('alt') !== '' && jQuery(this).attr('value') === ''){
			jQuery(this).next('.label').show();
		}
	});
}
