/*---------------------------------------------------------*
*
*----------------------------------------------------------*/

function toggleVisible(vs_tagId, vs_objLink, vs_sTextOpen, vs_sTextClose)
{
	if (!vslGetHTMLElement(vs_tagId))
		return false;

	var vs_node = vslGetHTMLElement(vs_tagId);

	if (vs_node.style.display == 'none')
	{
		vs_node.style.display = 'block';
		vs_node.style.visibility = 'visible';
		if(vs_sTextOpen!='') vs_objLink.innerHTML=vs_sTextClose;
	}
	else
	{
		vs_node.style.display = 'none';
		vs_node.style.visibility = 'hidden';
		if(vs_sTextClose!='') vs_objLink.innerHTML=vs_sTextOpen;
	}
}

/*---------------------------------------------------------*
*
*----------------------------------------------------------*/

function toggleVisibleTBody(vs_tagId, vs_tagIdLink, vs_sTextOpen, vs_sTextClose)
{
	if (!vslGetHTMLElement(vs_tagId))
		return false;

	var vs_node = vslGetHTMLElement(vs_tagId);
	var vs_domLinkNode = vslGetHTMLElement(vs_tagIdLink);

	if (vs_node.style.display == 'none')
	{
		vs_node.style.display = '';
		vs_node.style.visibility = 'visible';
		vs_domLinkNode.innerHTML = vs_sTextClose;
	}
	else
	{
		vs_node.style.display = 'none';
		vs_node.style.visibility = 'hidden';
		vs_domLinkNode.innerHTML = vs_sTextOpen;
	}
}

/*---------------------------------------------------------*
*
*----------------------------------------------------------*/

function doFormSearch(vs_urlBase)
{
	if (!vs_urlBase || vs_urlBase == "")
			return true;
	
	var vs_form = vslGetHTMLElement("snipForm");
	var vs_province = vs_form.provinces.options[vs_form.province.selectedIndex];

	if(!vs_province || vs_province == '')
			return true;
	
	var vs_type = vs_form.type.options[vs_form.type.selectedIndex];
	var vs_searchUrl = vs_urlBase + "/" + vs_province.value;
	
	if(vs_type && vs_type.value != '')
			vs_searchUrl += "/" + vs_type.value + ".html";
	
	location.href = vs_searchUrl;
	return false;
}

/*---------------------------------------------------------*
*
*----------------------------------------------------------*/

function miniMap(nLat, nLon,nZoom)
{
	if(nZoom == false || nZoom == undefined || nZoom == "undefined") 
		nZoom = 16;
		var mapId = "item_map";
	vslSEL(mapId);
	var oGMap = new GMap2(document.getElementById(mapId));
	if (!oGMap)
		return(false);

	gvaMiniMaps = oGMap;
	gvaMiniMapsLL = new Array(nLat, nLon);

	oGMap.addControl(new GScaleControl());
	oGMap.language='PL';

	var oLatLng = new GLatLng(nLat, nLon);
	gvaMiniMapsLL = oLatLng;

	var oIcon = new GIcon();
 
	oIcon.image = "/vimages/default/marker.png";
	oIcon.iconSize = new GSize(19, 25);
	oIcon.iconAnchor = new GPoint(7, 31);
	oIcon.infoWindowAnchor = new GPoint(7, 7);

	oGMap.addControl(new GSmallMapControl());
	oGMap.addControl(new GScaleControl());
	oGMap.addControl(new GMapTypeControl());

	oGMap.setCenter(oLatLng, nZoom);
	oGMap.savePosition();

	oGMap.addOverlay(new GMarker(oLatLng, oIcon));
}

/*---------------------------------------------------------*
*
*----------------------------------------------------------*/

function bigMap(item_map , lat , lng , zoom) {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById(item_map));
	point = new GLatLng(lat, lng, true);
	map.addControl(new GMapTypeControl());
	map.setCenter(point, parseInt(zoom));
	map.disableDragging();
	map.savePosition();
	return map;
  }
  else{
	alert("");
  }
}

/*---------------------------------------------------------*
*
*----------------------------------------------------------*/

function loadNext(numberCont)
{
	aCurrentImg[numberCont] = aCurrentImg[numberCont]+1;
	if(aCurrentImg[numberCont]>=aNumImg[numberCont])
		aCurrentImg[numberCont]=0

	var nNextIndex = aCurrentImg[numberCont];
	var imgCont=document.getElementById("mainimage_"+numberCont);
 	var image = aaImages[numberCont][nNextIndex];
	imgCont.src="/images/projects/big/"+image;
	imgCont.alt="";
	imgCont.name=image;
	var num_img=document.getElementById("num_img_"+numberCont);
	num_img.innerHTML=(parseInt(nNextIndex)+1);
}

function loadPrevious(numberCont)
{
	aCurrentImg[numberCont] = aCurrentImg[numberCont]-1;
	if(aCurrentImg[numberCont]<0)
		aCurrentImg[numberCont]=aNumImg[numberCont]-1;

	var nNextIndex = aCurrentImg[numberCont];
	var imgCont=document.getElementById("mainimage_"+numberCont);
 	var image = aaImages[numberCont][nNextIndex];
 	imgCont.src="/images/projects/big/"+image;
	imgCont.alt="";
	imgCont.name=image;
	var num_img=document.getElementById("num_img_"+numberCont);
	num_img.innerHTML=(parseInt(nNextIndex)+1);
}

function loadImage(image){
	var contImgBig=document.getElementById("imgBig");
	var contImgSmall=document.getElementById("img"+image);
	contImgBig.src= contImgSmall.src.replace("small", "big");
	return false;
}


function loadBackgroundImage(image)
{
	var contImgBig=document.getElementById("imgBig");
	var contImgSmall=document.getElementById("img"+image);
	contImgBig.style.backgroundImage = contImgSmall.style.backgroundImage.replace("small", "big");

}


function slideRight(){
	rotateLeft(aImages);
	var cont;
	for (i=1;i<6;i++){
		cont=document.getElementById("img"+i);
		cont.style.backgroundImage="url('/images/projects/small/"+aImages[i-1]+"')";
		cont.name=aImages[i-1];
		cont.alt="";
	}
}

function slideLeft(){
	rotateRight(aImages);
	var cont;
	for (i=1;i<6;i++){
		cont=document.getElementById("img"+i);
		cont.style.backgroundImage="url('/images/projects/small/"+aImages[i-1]+"')";
		cont.name=aImages[i-1];
		cont.alt="";
	}
}

function rotateRight(aImages){
	var aux = aImages[(aImages.length)-1];
	for (i=1;i<aImages.length;i++){
		aImages[(aImages.length)-i]=aImages[(aImages.length)-i-1]
	}
	aImages[(aImages.length)-i]=aux;
}

function rotateLeft(aImages){
	var aux = aImages[0];
	for (i=aImages.length;i>1;i--){
		aImages[(aImages.length)-i]=aImages[(aImages.length)-i+1]
	}
	aImages[(aImages.length)-1]=aux;
}

function cerrar(){
		var contents = document.getElementById("box");
		if(this.lightboxType == 'id') {
			var body = document.getElementsByTagName("body").item(0);
			Element.hide(this.lightboxCurrentContentID);
			body.appendChild($(this.lightboxCurrentContentID));
		}
		var box =document.getElementById('box')
		contents.innerHTML = '';

		document.getElementsByTagName("body").item(0).setStyle({
			overflow: '',
			marginRight: ''
		});

		if (/MSIE 6./i.test(navigator.userAgent))
			document.styleSheets[0].addRule("select", 'display:block');

		Event.stopObserving(document, 'keydown', this.onGlobalKeyDown);

		return false;
}

function scrollFormOver(obj)
{
	var scroll = obj.style.backgroundPosition;

	if(scroll == '' || scroll == '0px 0px')
		obj.style.backgroundPosition = '0px -24px';
	else
		obj.style.backgroundPosition = '0px 0px';
}

function changeBorder(div,color)
{
	document.getElementById(div).style.border='1px solid '+color
}

