/* Foto */
var lastthumbnail = '';
var lastimage = 1;

function thumbnailOver(obj) {
	var currentthumbnail=obj.id.replace('hotspot','');
	if(currentthumbnail != lastthumbnail) {
		if(obj.className.indexOf('selected') != -1) return;
		obj.className= 'hotspot over';
		var thumbnail = document.getElementById('thumbnail'+lastthumbnail);
		if(thumbnail) fadeOut(thumbnail.id);
		var thumbnail = document.getElementById('thumbnail'+currentthumbnail);
		lastthumbnail = '';
		if(thumbnail) {
			fadeIn(thumbnail.id);
			lastthumbnail = currentthumbnail;
			var left = (obj.offsetLeft-(thumbnail.offsetWidth/2-obj.offsetWidth/2));
			if(left < 0) left = 0;
			thumbnail.style.left=left+'px';
		}
	}
}

function thumbnailOut(obj) {
	var currentthumbnail=obj.id.replace('hotspot','');
	if(currentthumbnail == lastthumbnail) {
		var thumbnail = document.getElementById('thumbnail'+currentthumbnail);	
		fadeOut(thumbnail.id);
		if(obj.className.indexOf('selected') != -1) return;
		obj.className= 'hotspot';
		lastthumbnail = '';
	}
}

function thumbnailClick(obj) {
	// Oculta la imagen actual
	var hotspot = document.getElementById('hotspot'+lastimage).className ='hotspot';
	if(hotspot) hotspot.className = 'hotspot';
	var imgdiv = document.getElementById('imgdiv'+lastimage);
	if(imgdiv) imgdiv.style.display = 'none';
	// Muestra la imagen actual
	var currentimage = obj.id.replace('hotspot','');
	var hotspot = document.getElementById('hotspot'+currentimage);
	if(hotspot) hotspot.className = 'hotspot selected';
	var imgdiv = document.getElementById('imgdiv'+currentimage);
	var img = document.getElementById('img'+currentimage);
	if(img.src.indexOf('spacer.gif') != -1) {
		img.src = img.getAttribute('vsmsrc');
		img.onload = function() {fadeIn('imgdiv'+currentimage)};
	} else {
		fadeIn('imgdiv'+currentimage);
	}
	document.getElementById('picnumber').innerHTML = currentimage;
	lastimage = currentimage;
	thumbnailOut(obj);
}

function frmSubmit(obj,lang,fnok,fnerr){
	var status = vsmSubmit(obj, lang);
	if (status){
		vsmAjaxForm(obj, fnok, fnerr, false);
	}
	return status;
}

function expandSentData() {
	document.getElementById('sentdata').style.display = '';
	document.getElementById('sentEmail').value = 'E-Mail del destinatario';
	var message = document.getElementById('message');
	message.value = 'Mensaje';
	message.style.textAlign = 'center';
	message.style.height = '76px';
	message.style.paddingTop = '64px';	
	document.getElementById('nameFrom').value = 'Tu nombre';
	document.getElementById('sbmtEmail').disabled = false;
	document.getElementById('sentResult').style.display = 'none';
}

function okSentMail() {
	document.getElementById('sentResult').style.display ='';
	document.getElementById('sentdata').style.display = 'none';	
}

function errSentMail(txt) {
	alert(txt);
	document.getElementById('sbmtEmail').disabled = false;
}

function deleteTitle(textArea) {
	if (textArea.value == 'Mensaje') textArea.value = '';
	textArea.style.paddingTop = '0px';
	textArea.style.height = '140px';
	textArea.style.textAlign = 'left';
}

function deleteValue(input, value) {
	if (input.value == value) input.value = '';
}

function validateFieldValue(fld){
	var fieldValue = vsmTrim(fld.value.toLowerCase());
	switch (fld.name) {
		case 'name':
			if (fieldValue == 'nombre') {
				status= 'El campo Nombre es inválido.';
				fld.value = 'Nombre';
				if (vsmsubmit) fld.className = 'vsmformerror';
				return false;
			}
			break;
		case 'webpage': 
			if (fieldValue == 'página/blog') fld.value = '';
			break;
		case 'message':
			if (fieldValue == 'mensaje') fld.value = '';
			break;
		case 'nameFrom':
			if (fieldValue == 'tu nombre') fld.value = '';
			break;
	}
	return true;	
}

currentfontsize = 10;

function bigger() {
	if (currentfontsize < 16) currentfontsize++;
	var vsmcontent = document.getElementById('vsmcontent');
	if (vsmcontent) vsmcontent.style.fontSize = currentfontsize + 'pt';
}

function smaller() {
	if (currentfontsize > 7) currentfontsize--;
	var vsmcontent = document.getElementById('vsmcontent');
	if (vsmcontent) vsmcontent.style.fontSize = currentfontsize + 'pt';
}
