function openCenteredWindow(url, name, width, height, features) {
  if(screen.width){
	  var winl = (screen.width-width)/2;
	  var wint = (screen.height-height)/2;
  } else {
		winl = 0;
		wint =0;
  }
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + height + ',';
  settings += 'width=' + width + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(url, name, settings);
  win.window.focus();
}

function openMapaPopup(context_path) {
	openCenteredWindow(context_path + '/popups/mapa.php', 'mapa_popup', 350, 250, 'scrollbars=no')
}

function openPoliticasPopup(context_path) {
	openCenteredWindow(context_path + '/popups/politicas.php', 'politicas_popup', 350, 250, 'scrollbars=no')
}

function openProjectNotePopup(id) {
	openCenteredWindow('popup_nota.php?type=project&id=' + id, 'project_note_popup', 350, 350, 'scrollbars=no')
}

function openTaskNotePopup(id) {
	openCenteredWindow('popup_nota.php?type=task&id=' + id, 'task_note_popup', 350, 350, 'scrollbars=no')
}

function openGalleryPopup(id) {
	openCenteredWindow('popup_galeria.php?id=' + id, 'gallery_popup', 500, 500, 'scrollbars=no')
}

function openPortfolioGalleryPopup(id) {
	openCenteredWindow('galeria.php?id=' + id, 'portfolio_gallery_popup', 500, 500, 'scrollbars=no')
}

function openForgotPasswordPopup(context_path) {
	openCenteredWindow(context_path + '/popups/clave.php', 'forgot_popup', 350, 160, 'scrollbars=no')
}

function openClientsHelpPopup() {
	openCenteredWindow('ayuda.php', 'clients_help_popup', 600, 440, 'scrollbars=no')
}

function answerTaskNote(id) {
	opener.location = 'contacto.php?type=task&id=' + id;
	self.close();
}

function answerProjectNote(id) {
	opener.location = 'contacto.php?type=project&id=' + id;
	self.close();
}

function readTaskNote(id) {
	window.location = 'read_note.do.php?type=task&id=' + id;
}

function readProjectNote(id) {
	window.location = 'read_note.do.php?type=project&id=' + id;
}

function deleteTaskNote(id) {
	window.location = 'delete_note.do.php?type=task&id=' + id;
}

function deleteProjectNote(id) {
	window.location = 'delete_note.do.php?type=project&id=' + id;
}
