function gebid(id) {
	return document.getElementById(id) ;
}

// CSS Browser Selector   v0.2.3
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
var css_browser_selector = function() {
	var 
		ua = navigator.userAgent.toLowerCase(),
		is = function(t){ return ua.indexOf(t) != -1; },
		h = document.getElementsByTagName('html')[0],
		b = (!(/opera|webtv/i.test(ua)) && /msie (\d)/.test(ua)) ? ((is('mac') ? 'ieMac ' : '') + 'ie ie' + RegExp.$1)
			: is('gecko/') ? 'gecko' : is('opera') ? 'opera' : is('konqueror') ? 'konqueror' : is('applewebkit/') ? 'webkit safari' : is('mozilla/') ? 'gecko' : '',
		os = (is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : is('win') ? ' win' : '';
	var c = b+os+' js';
	h.className += h.className?' '+c:c;
}();


// external links
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";
 }
}



// mailing list
function erase(){
	if (gebid("mailing-box").value == 'name@domain.com') {
		gebid("mailing-box").value =''
	};
}
function to_default(){
	if (gebid("mailing-box").value == '') {
		gebid("mailing-box").value = 'name@domain.com'
	}
}

function init_mailing(){
	if(gebid("mailing-box")!=undefined) {
		gebid("mailing-box").onfocus = erase;
		gebid("mailing-box").onblur = to_default;
	}
}

function start() {
	externalLinks() ;
	init_mailing() ;
}

window.onload = start ;



function validate_email(email) {
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    return regex.test(email);
}

function validate_comment(form_id) {
	var msg = "" ;
	
	msg = "Please provide a valid e-mail address and enter a comment." ;

	if (gebid("comment").value=="" ||
		gebid("email").value=="" ||
		!validate_email(gebid("email").value)) {
		alert(msg) ;
		return false ;
	}
	else {
		gebid(form_id).submit() ;
		return true;
	}
}

