// JavaScript Document

var images = new Array();
function init( idCatalog, imagePreviewId ){
	
	childsLI = document.getElementById( idCatalog ).getElementsByTagName('li');
	for(i=0; i < childsLI.length; i++){
		actualElement = childsLI[i];
		//link = document.getElementById( idCatalog ).getElementsByTagName('a');
		link = actualElement.getElementsByTagName('a')
		link = link[0];
		//image = document.getElementById( idCatalog ).getElementsByTagName('img');
		image = actualElement.getElementsByTagName('img');
		image = image[0];
		
		link.target='_self';
		imageId = 'image_' + i;
		image.id = imageId;
		link.href= 'javascript:changeImage("' + imagePreviewId + '","'+ imageId +'");';
																							
	}

}

function changeImage( idActualImg, nextImage ){
	nextImage = document.getElementById( nextImage );
	idActualImg.alt = nextImage.alt;
	
	div = document.getElementById('divDescription');
	img = document.getElementById('imagenView');
	div.innerHTML = "<span class='description_image'>" + nextImage.alt + "</span>";
	
	linkImagePreview = document.getElementById( idActualImg );
	imagePreview = linkImagePreview.getElementsByTagName('img');
	imagePreview = imagePreview[0];
	
	linkImagePreview.target='_blank';
	
	absImgSrc= nextImage.absSrc ? nextImage.absSrc : (nextImage.getAttribute ? nextImage.getAttribute('absSrc') : nextImage.src);
	
	linkImagePreview.href= absImgSrc;
	
	imagePreview.src= nextImage.previewSrc ? nextImage.previewSrc : (nextImage.getAttribute ? nextImage.getAttribute('previewSrc') : nextImage.src);
}



function loadLowSRC( imageId ){
	var img=document[ imageId ];
	img.imgRolln=img.src;
	img.src=img.lowsrc?img.lowsrc:img.getAttribute?img.getAttribute('lowsrc'):img.src;
	
}
function resetSRC( imageId ){
	document[ imageId ].src=document[ imageId ].imgRolln;
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------																						
function addEventListener(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
		{
			element.addEventListener(eventType, handler, capture);
		}
		else if (element.attachEvent)
		{
			element.attachEvent('on' + eventType, handler);
		}
	}
	catch (e) {}
}
function removeClass(ele, className){
	if (!ele || !className || !this.hasClassName(ele, className))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
}

function addClassName(ele, className){
	if (!ele || !className || this.hasClassName(ele, className))
		return;
	ele.className += (ele.className ? " " : "") + className;
}
