function CMain() {

	this.firstDiv = '';
	this.actDiv = '';
	this.maxDiv = '';
	this.rdiv = 'cd';
	this.ldiv = 'ld';
	this.fadeTime = 700;
	
	this.switchTo = function(__to) {
		$('#' + this.rdiv + '_' + this.actDiv).hide();
		$('#' + this.ldiv + '_' + this.actDiv).removeClass('selected');
		$('#' + this.ldiv + '_' + __to).addClass('selected');
		$('#' + this.rdiv + '_' + __to).fadeIn(this.fadeTime);
		this.actDiv = __to;
	};
	
	
	this.checkContactForm = function() {
		var err = '';
		if($("input[name='cname']").val() == '') {
			err = 'meno.';
		} else if($("input[name='cemail']").val() == '') {
			err = 'kontaktný mail.';
		} else if($("textarea[name='message']").val() == '') {
			err = 'text správy.';
		}
		if(err != '') {
			alert('Prosím vypľnte ' + err);
			return false;
		}
		return true;
	}
	
	this.init = function() {
		var self = this;
		var tmp = new String(window.location.href);
		
		// if(tmp.lastIndexOf("#")) {
		// 	tmp = tmp.slice(tmp.lastIndexOf("#") + 1);
		// 	if(tmp == "" || !tmp) tmp = tmp.slice(tmp.lastIndexOf("/") + 1);
		// }
		if(tmp.lastIndexOf("/")) {
			tmp = tmp.slice(tmp.lastIndexOf("/") + 1);
		}
		
		$(document).ready(function(){
			$("#top\\-doctor").hide();
			$("#top\\-doctor").fadeIn(self.fadeTime);
			$('#' + self.ldiv + '_' + tmp).addClass('selected');
			$('#' + self.rdiv + '_' + tmp).fadeIn(self.fadeTime);
			self.actDiv = tmp;

			$('#gallery a').lightBox({fixedNavigation:true});
			
			$('#content .right-col a[title]').qtip({
				content: {
					text: false
				},
				position: {
					corner: {
						tooltip: 'bottomRight',
						target: 'topLeft'
					}
				},
				style: {
						name: 'cream',
						border: {
						   width: 5,
						   radius: 0,
						},
						tip: 'bottomRight'
					}
			});
			
			$('#content .left-col a[title]').qtip({
				content: {
					text: false
				},
				position: {
					corner: {
						tooltip: 'bottomleft',
						target: 'topRight'
					}
				},
				style: {
						name: 'cream',
						border: {
						   width: 5,
						   radius: 0,
						},
						tip: 'bottomLeft'
					}
			});

			$("#cf_send").click( function () {
				if(self.checkContactForm() === true) {
					var xdata = 'contact=true';
					xdata += '&name=' + $("input[name='cname']").val();
					xdata += '&email=' + $("input[name='cemail']").val();
					xdata += '&phone=' + $("input[name='cphone']").val();
					xdata += '&message=' + $("textarea[name='message']").val();
					$("#cf_form").fadeOut(200);
					$.ajax({
						type: "POST",
						url: "/ajax.php?a=cf",
						data: xdata,
						success: function(msg){
							$("#cf_thanks").fadeIn(400);
							document.forms.contactForm.reset();
						}
					});
				}
			});
			
		});
	};
	
	this.init();
}

cm = new CMain();

function switchTo(tt,to) {
	tt.href = '#';
	cm.switchTo(to);
	return false;
}
