$(document).ready(function() {

	$("a.anchor").click(function () {
		elementClick = $(this).attr("href");
		destination = $(elementClick).offset().top;
		$("html:not(:animated)"+( ! $.browser.opera ? ",body:not(:animated)" : "")).animate({ scrollTop: destination}, 600 );
		return false;
 	});
 	
 	$("#coda-slider-1").codaSlider();
	$("img.vredmed").parent("div").addClass("picl");
	$("img.vredmed").parent("p").addClass("picl");
	$(".picr").cornerz({radius:8});
	$(".picl").cornerz({radius:8});
	$(".rc").cornerz({radius:8});
	$(".rcdiv").cornerz({radius:8});
	$(".gallery div").cornerz({radius:8});
 	 	
	$("a.spoiler").click(function(){
		var name = $(this).attr("id");
		$("." + name + "-hide").hide();
		$("." + name + "-show").show();
		return false;
	});

	$(".tip").mouseout(function(){
		$(".popup").hide();
	});

	$(".tip").mousemove(function(e){
		var popid = $(this).attr("rel");
		var left = parseInt(e.pageX) - parseInt(jQuery(".inputformboxmin").offset().left);
		var top = parseInt(e.pageY) - parseInt(jQuery(".inputformboxmin").offset().top);
		var height = parseInt(jQuery("#" + popid).height());
		var width = parseInt(jQuery("#" + popid).width());
		if(left + width - 10 >= jQuery(".inputformboxmin").width()){
			jQuery("#" + popid).css('left', (left - width - parseInt(jQuery("#" + popid).css("paddingLeft")) - parseInt(jQuery("#" + popid).css("paddingRight")) - parseInt(jQuery("#" + popid).css("borderLeftWidth")) - parseInt(jQuery("#" + popid).css("borderRightWidth")) - 2) + 'px');
		}else{
			jQuery("#" + popid).css('left', (left + 1) + 'px');
		}
		if($(document).scrollTop() >= e.pageY - height - parseInt(jQuery("#" + popid).css("paddingTop")) - parseInt(jQuery("#" + popid).css("paddingBottom")) - parseInt(jQuery("#" + popid).css("borderTopWidth")) - parseInt(jQuery("#" + popid).css("borderBottomWidth"))){
			jQuery("#" + popid).css('top', ( top - parseInt(jQuery("#" + popid).css("paddingTop")) + 4) + 'px');
		}else{
			jQuery("#" + popid).css('top', ( top - height - parseInt(jQuery("#" + popid).css("paddingTop")) - parseInt(jQuery("#" + popid).css("paddingBottom")) - parseInt(jQuery("#" + popid).css("borderTopWidth")) - parseInt(jQuery("#" + popid).css("borderBottomWidth")) - 2) + 'px');
		}
		jQuery("#" + popid).show();
	});

});

function helpp (id, popid, yoffset) {
	if ( jQuery("#" + popid).css("display") != 'none' ){
		jQuery("#" + popid).hide();
	}else{
		var left = parseInt(jQuery("#" + id).offset().left) - parseInt(jQuery(".inputformboxmin").offset().left);
		var top = parseInt(jQuery("#" + id).offset().top) - parseInt(jQuery(".inputformboxmin").offset().top);
		var height = parseInt(jQuery("#" + popid).height());
		jQuery("#" + popid).css('left', left + 'px');
		jQuery("#" + popid).css('top', ( top - height - 5 ) + 'px');
		jQuery("#" + popid).show();
	}
}

function textcopy (fromobj, toobj) {
  var fromobject = document.getElementById( fromobj );
  var toobject = document.getElementById( toobj );
  if ( toobject.value == '' ) {
    toobject.value = fromobject.value;
  }
}


var booking = {
	env : {
		b_simple_weekdays: ['пн','вт','ср','чт','пт','сб','вс'],
		b_simple_weekdays_for_js: ['пн','вт','ср','чт','пт','сб','вс'],
		b_long_weekdays: ['понедельник','вторник','среда','четверг','пятница','суббота','воскресенье']
	}
}

function addzero( value )
{
while( value.length<2 ) value = String("0") + value;
return value;
}
    
function checkDateOrder(frm, ci_day, ci_month_year, co_day, co_month_year) {
	if (document.getElementById) {
		var frm = document.getElementById(frm);
		// create date object from checkin values
		// set date to 12:00 to avoid problems with one
		// date being wintertime and the other summertime
		var my = frm[ci_month_year].value.split("-");
	    var ci = new Date (my[0], my[1]-1, frm[ci_day].value, 12, 0, 0, 0);

        // create date object from checkout values
	    my = frm[co_month_year].value.split("-");
	    var co = new Date (my[0], my[1]-1, frm[co_day].value, 12, 0, 0, 0);

		// if checkin date is at or after checkout date,
		// add a day full of milliseconds, and set the
		// selectbox values for checkout date to new value
	    if (ci >= co){
    	    co.setTime(ci.getTime() + 1000 * 60 * 60 * 24);
	        frm[co_day].value =  co.getDate();
    	    var com = co.getMonth()+1;
	        frm[co_month_year].value = co.getFullYear() + "-" + com;
    	}
	}
}

