function menu() {
	var menu = document.getElementById('header').getElementsByTagName('ul')[0]
	var current_location = String(window.location).substr(String(window.location).lastIndexOf('/')+1)

	if (current_location != '') {
		for ( var i=0; i<menu.getElementsByTagName('li').length; i++ ) {
			if (menu.getElementsByTagName('li')[i].getElementsByTagName('a')[0].href.indexOf(current_location) != -1 ) {
				menu.getElementsByTagName('li')[i].getElementsByTagName('a')[0].className = "active";
			}
		}
	} else {
		menu.getElementsByTagName('li')[0].getElementsByTagName('a')[0].className = "active";
	}
}






PositionX = 50;
PositionY = 50;
defaultWidth  = 600;
defaultHeight = 600;

if (parseInt(navigator.appVersion.charAt(0))>=4) {
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}

var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function pop_image(imageURL,imageTitle){
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...<\/title><meta http-equiv="imagetoolbar" content="no"><style>body{margin:0px;}<\/style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');       
			writeln('window.innerWidth=document.images["George"].width;');
			writeln('window.innerHeight=document.images["George"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('<\/sc'+'ript>');
			writeln('<\/head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			writeln('<img alt="" name="George" src='+imageURL+' style="display:block"><\/body><\/html>');
			close();		
	}
}



function is_email(str) {
	var valid = true
	var mail = String(str).toLowerCase()
	if ( mail.length < 7 || mail.indexOf('@') == -1 || mail.indexOf('.') == -1 ) valid = false
	return valid
}
function set_form() {
	var name_txt = 'write here your name'
	var email_txt = 'write here your e-mail address'
	var msg_txt = 'write your message here...'
	
	var form_name = document.getElementById('contact_form').getElementsByTagName('fieldset')[0].getElementsByTagName('input')['name']
	var form_email = document.getElementById('contact_form').getElementsByTagName('fieldset')[0].getElementsByTagName('input')['email']
	var form_msg = document.getElementById('contact_form').getElementsByTagName('fieldset')[0].getElementsByTagName('textarea')['message']
	var form_submit = document.getElementById('contact_form').getElementsByTagName('fieldset')[0].getElementsByTagName('input')['form_submit']
	
	form_name.value = name_txt
	form_email.value = email_txt
	form_msg.value = msg_txt
	
	form_name.onfocus = function() { if (this.value == name_txt) this.value = '' }
	form_name.onblur = function() { if (this.value == '') this.value = name_txt }
	form_email.onfocus = function() { if (this.value == email_txt) this.value = '' }
	form_email.onblur = function() { if (this.value == '') this.value = email_txt }
	form_msg.onfocus = function() { if (this.value == msg_txt) this.value = '' }
	form_msg.onblur = function() { if (this.value == '') this.value = msg_txt }
	
	var submit_value = form_submit.value
	form_submit.onmouseover = function() {
		this.value = this.title
	}
	form_submit.onfocus = form_submit.onmouseover
	form_submit.onmouseout = function() {
		this.value = submit_value
	}
	form_submit.onblur = form_submit.onmouseout
	
	document.getElementById('contact_form').onsubmit = function() { 
		var errors = ''
		if ( form_name.value == '' || form_name.value == name_txt) errors += '- name field has not been filled\n'
		if ( form_email.value == '' || form_email.value == email_txt) {
			errors += '- email field has not been filled\n'
			} else {
			if ( is_email(form_email.value) == false ) errors += '- email field appears to have a non valid address\n'		
		}
		if ( form_msg.value == '' || form_msg.value == msg_txt) errors += '- message textbox has no message\n'
		
		if (errors != '') {
			errors = 'please check the following error(s)\n\r\n\r' + errors
			alert(errors)
			return false
		} else {
			return true
		}
	}
}

function change_video(path) {
	var auto_start = false
	var path = path.substr(path.indexOf('video=')+6)
	
	video_code = 	'<object type="application/x-shockwave-flash" data="flvplayer.swf?file='+ path +'&autoStart='+ auto_start +'" width="320" height="260" wmode="transparent">'
  	video_code +=	'<param name="movie" value="flvplayer.swf?file='+ path +'&autoStart='+ auto_start +'" />'
	video_code +=	'<param name="wmode" value="transparent" />'
	video_code +=	'</object>'
	
	document.getElementById('video').innerHTML = video_code;
}


var w3 = (document.getElementsByTagName && document.createElement)
if (w3) {
	window.onload = function () {
		menu()
		if( String(window.location).indexOf('contact')!= -1) { 
			if( String(window.location).indexOf('sent')!= -1) {
				//return
				//alert('existe el sent')
			} else {
				set_form() 
			}
		}
	}
}