/* CONTACT FORM */
function send_contact() {
	var errors=false;
	if ($('input#name').val()=="") {
		$('#error-name').show();
		errors=true;
	} else {
		$('#error-name').hide();
	}
	if ($('input#email').val()=="") {
		$('#error-email').show();	
		errors=true;
	} else {
		$('#error-email').hide();	
	}
	if ($('textarea#comments').val()=="") {
		$('#error-comments').show();	
		errors=true;
	} else {
		$('#error-comments').hide();	
	}
	
	if (!errors) {
		var dataString = 'name='+$('input#name').val() + '&company='+$('input#company').val() + '&address='+$('input#address').val() + '&email='+$('input#email').val() + '&phone='+$('input#phone').val() + '&fax='+$('input#fax').val() + '&comments='+$('textarea#comments').val(); 
		$.ajax({  
			type: "POST",  
			url: "sendmail.php",  
			data: dataString,  
			success: function(response) {  
				$('#contact-content').html("<br />"+response+"<br /><br /><br />");
			}  
		});  
	}
}

/* DOCTOR SEARCHER */
function search_doctor(folder) {
	window.location="../"+folder+"/?n="+$('input#n').val() + "&s="+$('select#s').val() + "&c="+$('select#c').val() + "&i="+$('select#i').val()
}

/* GALLERY */
var thumbnails_position=0;
var thumbnails_items;
var currentphotoid=1;

function thumbnails_bottom() {
	$('#thumbnails-list-content').animate({
		top: '+=71'
	}, 1000, function() {
		// Animation complete.
	});

	//new Effect.Move('thumbnails-list-content', { x: 0, y: -71, mode: 'relative' });
	//thumbnails_position++;
	//if (thumbnails_position==thumbnails_items-4) $('fast-button-bottom').hide();
	//if (thumbnails_position>0) $('fast-button-top').show();

}
function thumbnails_top() {
	//new Effect.Move('thumbnails-list-content', { x: 0, y: +71, mode: 'relative' });
	//thumbnails_position--;
	//if (thumbnails_position<=0) $('fast-button-top').hide();
	//if (thumbnails_position<thumbnails_items-4) $('fast-button-bottom').show();
}

function open_photo(photoid,categoryid,subcategoryid) {

	var img="gallery/"+categoryid+"/"+subcategoryid+"/photo-"+photoid+".jpg";

	$('thumbnail-'+currentphotoid).removeClassName('active');
	$('thumbnail-'+photoid).addClassName('active');
	currentphotoid=photoid;
	
/*
	// Prototype version - doesn't work in IE
	document.getElementById("loading").style.visibility="visible";
	
	new Ajax.Request(img, {
		method: 'get',
		contentType: 'text/html; charset=windows-1251',
		onSuccess: function(response) {
			if (response.readyState==4) {
				if (response.status==200) {
					$('photo').src=img;
					document.getElementById("loading").style.visibility="hidden";
				}
			}
		}
	});
*/


	// Non-Prototype version
	function XMLHTTP(){
		var cxm = null;
		try{
			cxm = new XMLHttpRequest();
		}catch(e){
			cxm = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return cxm;
	}
	
	$('photo').setOpacity(0.3);
	document.getElementById("loading").style.visibility="visible";
	
	var im = document.getElementById("photo");
	var param="";
	
	cmx = XMLHTTP();
	cmx.open("get", img, true);
	cmx.setRequestHeader('Content-Type', "application/x-www-form-urlencoded");
	cmx.onreadystatechange = function(){
		if (cmx.readyState == 4){
			if(cmx.status == 200){    
				im.src=img;
				document.getElementById("loading").style.visibility="hidden";
				$('photo').setOpacity(1.0);
				return;
			}
		}
	};
	cmx.send(null);
}
