// JavaScript Document
/* imagenes dinamicas */
var n = 10; //numero imagenes index
var n2 = 2; //numero imagenes contenido
function pickRandom(range){
	var A = 0;
	var num = 0;
	num = parseInt( A + (range-A)*Math.random() );  // num is random, from A to B 
	if(num>range){
		num--;
	}
	return num;
}
/* noticias */
var nNews = 1;
var title1 = "";var title2 ="";
var ndesc1 = "";var nurl1 = "";var nimg1 = "";
var ndesc2 = "";var nurl2 = "";var nimg2 = "";


function isImgValid(img){
	img = img.toLowerCase();
	if( img == null || img.length <5 || img.substring(img.length - 1) == "/" || ( img.substring(img.length - 4) != ".jpg" && img.substring(img.length - 4) != "jpeg" && img.substring(img.length - 4) != ".gif" && img.substring(img.length - 4) != ".tif" && img.substring(img.length - 4) != "tiff" )){
		return false;
	}
	return true;
	
}

function writeNews(number){	
	document.write("<h3>"+((number==1)?title1:title2)+"</h3>");
	if(number == 1){
		if(!isImgValid( nimg1 ) ){
			nimg1 = "/imagenes/notax.JPG"; 
		}
		document.write("<img src=\""+nimg1+ "\" alt=\"Noticia 1\" width=\"83\" height=\"57\" class=\"fotoNoticia\" border=\"0\" />"+ndesc1);				
	}else{
		if (!isImgValid( nimg2 ) ){
			nimg2 = "/imagenes/notay.JPG"; 
		}
		document.write("<img src=\""+nimg2+ "\" alt=\"Noticia 2\" width=\"83\" height=\"57\" class=\"fotoNoticia\" border=\"0\" />"+ndesc2);
	}
	document.write("<br/><a href=\""+((number==1)?nurl1:nurl2)+"\">Ver m&aacute;s <img src=\"imagenes/b3.gif\" alt=\"Ver m&aacute;s\" width=\"7\" height=\"7\" border=\"0\" /></a>");			
}
/* Buscador */
function ESSubmitSearch(form) {
var value = form.Search.value;
if (value) {
value = escape(value);
location.href = "http://www.aserca.gob.mx/EasySearch/Result.aspx?Search=" + value;
}
return false;
}