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


/*
# OBJETO BANNER
- obtengo la ruta y el nombre del archivo swf, el ancho y el alto.... e imprimo en el documento html
- este objeto es creado para seguir las normas xhtml
- sintaxis:
- <script type="text/javascript" charset="utf-8">banner('rutaNombre',ancho,alto)</script> 
*/
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>')
}

/*
# 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)
	}
}

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
	}
}

/*
# OBJETO AJUSTE ALTURA
- ajusta la base de la pagina para que siempre ocupe el alto de la ventana
- esta se declara en el body
- sintaxis:
- <body onLoad="ajusteAlto()"></body>
*/
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";
}

function fixWidth() {
	wWin = document.documentElement.clientWidth; // ancho ventana navegador
	wBase = 900; // ancho contenido base de mi sitio "base"
	qtyAlign = (wWin - wBase) / 2; // valor a alinear
	document.getElementById('base').style.marginLeft = qtyAlign  + 'px';
	document.getElementById('base').style.marginRight = qtyAlign + 'px';

	document.getElementById('footerCol1').style.marginLeft = qtyAlign + "px";
	document.getElementById('footerCol2').style.marginRight = qtyAlign + "px";
}


/*
# OBJETO SIGUIENTE CONTENIDO
- muestra al presionar cierto link/boton un contenido enumerado diferente, ej. un banner con imagenes dif
<div id="nextCont"></div> // aqui apareceran las cosas
<a href="#" onclick="nextCont()"></a> // este sera el control para mostrar el siguiente contenido
*/
var next_cont = 1;

function nextCont() {
	if ( next_cont >= 1 ) {
		if ( next_cont == 6 ) { next_cont = 0; }
		next_cont = next_cont + 1;
	}
	document.getElementById('nextCont').innerHTML = '<img src="img/aboutus/clientes_' + next_cont + '.jpg" width="633" height="50" alt="Clientes ' + next_cont + '" />';
}

/*
# OBJETO LINKS EXTERNOS
- para cumplir con las normas xhtml estrict, cuando un link sea dirigido fuera del sitio llevara la propiedad rel
<a href="http://google.com" rel="external"></a>
*/
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";
		}
	}
}

// ======================================= JQUERY CODE =======================================
/*
# DECLARACION DE GALERIAS
- por cada galeria se debe declarar su correspondiente linea indicando su nombre entre el "()"
$('#NOMBRE DE LA GALERIA a').lightBox();
*/
$(function() {
	$('#set_1 a').lightBox(); // id de un set de imagenes
});

$(document).ready(function() {
	fixHeight();
	extLink();
	/*
	// cargar un contenido especifico en una lugar especifico con ajax
	$.ajax({
		type: "GET",
		url: "ruta/archivo" + "extencion",
		data: "formato=d-m-Y",
		success: function(datos) {
			$('#base').html(datos).show('sl');
		}
	});
	*/

	/*
	$("div").hide("slow");
	$("div").show("slow");
	$("div").slideUp("slow");
	$("div").slideDown("slow");
	$("div").fadeOut("slow");
	$("div").fadeIn("slow");
	$("div").animate({width:200, height:200}, "slow");
	$("div").animate({top:60, left:100}, "slow");
	$("div").animate({width:300, height:300}, "slow");
	$("div").animate({top:20, left:50}, "slow");
	$("div").animate({width:100, height:100}, "slow");
	$("div").animate({top:0, left:0}, "slow");
	$("div").animate({width:400, height:400}, "slow");
	*/


	// al presionar cualquier link desaparecera lentamente
	$('sdiv').click(function(event) {
		event.preventDefault();
		$(this).hide('slow');
	});

	// zebraDo en listas
	// #services es el lugar dnd se encuentre el zebrado ke ay ke poner especificamente para ke no cause conflictos
	$('#services tr:even').addClass('alt');
	$('#services tr')
	.hover(
		function() { $(this).addClass('over'); },
		function() { $(this).removeClass('over'); }
	)
	/*.toggle(
		function() { $(this).addClass('checked'); },
		function() { $(this).removeClass('checked'); }
	)*/;
});