<!--
function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function openTarget (form, windowName) {
  if (!windowName)
  windowName = 'formTarget' + (new Date().getTime());
  form.target = windowName;
  open ('', windowName, 'width=500,height=380,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no');
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function ss(w){window.status=w;return true;}

function showhide() {
var tr, i = 0, table = document.getElementById('campaigns');
var toggles = table.getElementsByTagName('tr');
while (tr = toggles.item(i++))
if (tr.className == 'sources') { if(tr.style.display == 'block') { tr.style.display = 'none'; } else { tr.style.display = 'block'; }  }
}

function submeterMyPlaygolf (action, favtype, id) {

if (action == 'add') { var favtitle = prompt('Digite nome que deseja para este favorito', document.title); (favtitle == null)? favtitle = document.title : favtitle = favtitle }

var url  = '/includes/ajax_ap.inc.php';
var pars = (action == 'add')? 'action=myplaygolf_'+action+'&type='+favtype+'&title='+favtitle+'&url='+escape(location.href) : 'action=myplaygolf_'+action+'&id='+id;

	  var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				parameters: pars, 
				onSuccess: function (res) {
					stripped = res.responseText.replace(/(<([^>]+)>)/ig,""); 
					alert(stripped);
					
					if (action == 'delete') { $('link'+id).remove(); }
				 },
				onFailure: reportError
			});	
	
}

/// INI CONTACTOS
function submeterNewsletter (button) {
	
 // Processar dados : AJAX
 //   $('ajaxmsg').update('<img src="/images/waitstatus.gif" alt="Please wait..." width="16" height="16" style="vertical-align:middle" />');
	
	if($('ajaxmsg')!=null) { $('ajaxmsg').remove(); }
	
	new Insertion.After ($(button).id, '<div id="ajaxmsg" style="font-size:10px;"><img src="/images/waitstatus.gif" alt="Please wait..." width="16" height="16" style="vertical-align:middle" id="waitstatus" /></div>');
 
    //var idnews    = $F('idnews');
	var idnews    = 1;
	var idcountry = 0;
    //var nome      = $F('nome_news');
	var nome      = '';
	var email     = $F('email_news');
 
	var url  = '/includes/ajax_newsletter.inc.php';
	var pars = 'newsletter_action=subscribe&idnews='+idnews+'&nome='+nome+'&email='+email+'&idcountry='+idcountry;
	
	//urchinTracker('/novo_registo_newsletter');
	
	if (email == 'Insira o seu email') { $('ajaxmsg').update(''); alert('Para subscrever insira um email correcto.'); return; };   if (nome == 'Insira o seu nome') { nome = ''; }
	
	  var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				parameters: pars, 
				onSuccess: function (res) {
					//$('ajaxmsg').update( res.responseText );
					stripped = res.responseText.replace(/(<([^>]+)>)/ig,""); 
					alert(stripped);
					$('ajaxmsg').remove();
				 },
				onFailure: reportError
			});	

 
}

function submeterContacto () {
	
	// Processar dados : AJAX
	$('cb_form').hide(); 
	$('cb_ajaxwait').show();

	var params = Form.serialize('form_contact');
	var url  = '/includes/ajax_sendform.inc.php';
	var action = 'send';
	var pars = 'action='+action+'&'+params;

	//urchinTracker('/formulario/' + action);
		
	var myAjax = new Ajax.Updater(
			{success: 'cb_ajaxwait'},  
			url, 
			{
				method: 'post', 
				parameters: pars,
				onFailure: reportError
	});

	return false;
}


/* user */

function resetPassword (f) {
	
   // Processar dados : AJAX
   new Insertion.After ('submit_resetpassword'+ f, '<img src="/images/waitstatus.gif" alt="Please wait..." width="16" height="16" style="vertical-align:middle" id="waitstatus'+ f+ '" />');
	
	var email = $F('password_email'+ f);
	var url   = '/includes/ajax_useraccount.inc.php';
	
	var action = (f == 1)? 'resetpassword' : 'resendemail';	
	var pars  = 'action='+action+'&email='+email;
		
	var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				parameters: pars, 
				onSuccess: function (res) {
				  Element.toggle('password'+ f);	
				  Element.remove('waitstatus'+ f);
                  alert(res.responseText);
				 },
				onFailure: reportError
			});	
}

function loginUser (button, refreshType) {
	
	if($('loginUsermsg')!=null) $('loginUsermsg').remove()
	new Insertion.After ($(button).id, '<div id="loginUsermsg" style="font-size:10px;"><img src="/images/waitstatus.gif" alt="Please wait..." width="16" height="16" style="vertical-align:middle" id="waitstatus" /></div>')

	if(button.id=='submit_login2') {
		var email = $F('login_email2')
		var pass  = $F('login_password2')
	} else {
		var email = $F('login_email')
		var pass  = $F('login_password')
	}
	
	var url   = '/includes/ajax_useraccount.inc.php';
	var pars  = 'action=validate&email='+email+'&password='+pass+ '&rememberMe=1';
	
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'post', 
			parameters: pars, 
			onSuccess: function (res) {
			  
			if (res.responseText.indexOf('T:') >= 0) { //alert ( res.responseText.substr(2) );

				$('loginUsermsg').update( res.responseText.substr(2) );
				if (refreshType == null) { window.location='/result.php?acc=loginok'; } else {  location.reload(true); }
			  
			} else if (res.responseText.indexOf('F:') >= 0) {//alert ( res.responseText.substr(2) );

				$('loginUsermsg').update( res.responseText.substr(2) );
			}
			  
		},
		onFailure: reportError
		});	
}

function sendfriend() {

	var params  = Form.serialize('form_contact');
	var url  = 'includes/ajax_sendform.inc.php';
	var pars = 'action=sendfriend&'+ params;

    var myAjax = new Ajax.Request(
			url,
			{
				method: 'post', 
				parameters: pars, 
				onSuccess: function (res) {

				$('cb_form').update(res.responseText+ "<br /><br /><a href='#' onclick='self.close();'>Fechar Janela</a>")
			},
			onFailure: reportError
		});	
	return false;
}

function submitUser (action, silent, redirectUrl) {
	
   // Processar dados : AJAX
   // silent: para processar silenciosamente sem interacção
   if (silent == null) {
     Element.hide('cb_ajaxform'); 
     Element.show('cb_ajaxwait');
   }
	
	var params = Form.serialize('form_register');
	var action = ($('iduser') != null)? 'update' : 'insert';
	var url  = '/includes/ajax_useraccount.inc.php';
	var pars = 'action='+action+'&'+params;

	//if(action=='update'){if($F('file')!=""){micoxUpload(document.form_register, '/includes/upload/filerecieve.php?id_user='+ $F('iduser'),'recebe_up_3','<img src=\'/images/waitstatus.gif\' id=\'fileuploading\' title=\'Upload in progress...\'>', 'Erro ao carregar');}}
	
	var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				parameters: pars, 
				onSuccess: function (res) {
				    var response = res.responseText.split('|');
				   if(!(response[0]>0)){
						if (silent == null) { 
							$('cb_ajaxwait').update(response[1] );
						}
						return;
				   }
				   else{
					   
						(redirectUrl != null)? window.location=redirectUrl : '';
						$('cb_ajaxwait').update(response[1]);
				   }
				 },
				onFailure: reportError
			});
}


function reportError () { alert('Sorry. There was an error.'); }
/// FIM CONTACTOS

//	INI GOOGLEMAPS
function verifica_gmapsdir(e) {if(e.charCode=='') gmapsdir()}
function handleErrors(){
   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	 alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it is ambiguous. Try to insert location like this: Street, City, Country \nError code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	 alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);

   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	 alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	 alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	 alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);

   else alert("An unknown error occurred." + gdir.getStatus().code);

}
//	FIM GOOGLEMAPS
// -->
