// 
//  n e s t O r ( function.js @ adasailing.com[ v2 ] )
//  creado bajo el techo de __perceptive-studio__ el 2009-09-04
//  nestor arroba perceptive guion studio punto com
//  habiendo dicho eso, bienvenido a mi codigo
// 


function banner(rutaNombre,ancho,alto) {
	document.write('<object type="application/x-shockwave-flash" data="' + rutaNombre + '.swf" width="' + ancho + '" height="' + alto + '"><param name="movie" value="' + rutaNombre + '.swf"><param name="quality" value="high"><img src="' + rutaNombre + '.png" width="' + ancho + '" height="' + alto + '" alt="El archivo flash no se pudo cargar"></object>')
}

function youtube(src) {
	document.write('<object width="425" height="344"><param name="movie" value="' + src + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + src + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>')
}


/*
# OBTEJO FECHA-HORA
- imprime la fecha u hora, segun se le indique
- sintaxis(fecha):
- <script type="text/javascript" charset="utf-8">dateTime('fecha')</script>
- sintaxis(hora):
- <div id="relog"><script type="text/javascript" charset="utf-8">dateTime('hora')</script></div>
*/
function dateTime(arg) {
	time = new Date();
	hr = time.getHours();
	min = time.getMinutes()
	seg = time.getSeconds()
	hora = hr + ':' + min + ':' + seg;

	dia = time.getDate();
	mes = time.getMonth();
	ano = time.getFullYear();
	if ( arg == 'fecha') {
		document.write('Hoy es ' + dia + ' de ' + mes + ' del ' + ano);
	} else {
		document.getElementById('relog').innerHTML = hora;
		setTimeout("fechaHora('relog')",1000)
	}
}

// ======================================= asignarAsunto =======================================
function asignarAsunto() {
	asunto = document.contactForm.subject[document.contactForm.subject.selectedIndex].value
	if (asunto == 'contacto') {
		document.contactForm.day.disabled = true
		document.contactForm.month.disabled = true
		document.contactForm.hour.disabled = true
		document.contactForm.phone.disabled = true
	} else {
		document.contactForm.day.disabled = false
		document.contactForm.month.disabled = false
		document.contactForm.hour.disabled = false
		document.contactForm.phone.disabled = false
	}
}

// ======================================= fixHeight =======================================
function fixHeight() {
	hWin = document.documentElement.clientHeight; // alto ventana navegador
	hBase = document.getElementById('base').offsetHeight; // alto contenido base de mi sitio "base"
	basePadding_top = 20;
	basePadding_bottom = 20;
	hNewBase = hWin - (basePadding_top + basePadding_bottom);
	if (hBase < hWin) document.getElementById('base').style.height = hNewBase + "px";
}


// ======================================= extLink =======================================
function extLink() {
	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";
		}
	}
}

// ======================================= objAjax =======================================
function objAjax() {
   var xmlhttp = false;
   try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
      try {
         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
         xmlhttp = false;
      }
   }

   if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
      xmlhttp = new XMLHttpRequest();
   }
   return xmlhttp;
}

// ======================================= showQuery =======================================
function showQuery(action,script,objResul) {
   divResultado = document.getElementById(objResul);
   ajax = objAjax();
   
   if ( action == 'insert' ) {
      comm_name = document.commForm.comm_name.value;
      comm_from = document.commForm.comm_from.value;
      comm_msg = document.commForm.comm_msg.value;
      ajax.open("GET", script + '.php?action=' + action + '&comm_name=' + comm_name + '&comm_from=' + comm_from + '&comm_msg=' + comm_msg);
   } else {
      ajax.open("GET", script + '.php?action=' + action);
   }
      
   ajax.onreadystatechange = function() {
      if ( ajax.readyState == 4 ) {
         divResultado.innerHTML = ajax.responseText
      }
   }
   ajax.send(null)
}

// ======================================= JQUERY CODE =======================================
$(function() {
	$('#set_1 a').lightBox(); // id de un set de imagenes
});

$(document).ready(function() {
	fixHeight();
	extLink();
	// showQuery('','/ajax/comm','commView');
});