
function clearForm(formid){
	var form=$(formid);	
	for ( var i in form){
		try{
			if(form[i].type=="textarea" || form[i].type=="text"){
				form[i].value="";	
			}
		}
		catch(e){}
	}	
}
		
function showhide(num){		
	var box=$('menu_'+num);
	if(box.getStyle('display')=='none'){
		box.setStyle({display: 'block'});
	}
	else{
		box.setStyle({display: 'none'});
	}
}

function centerBox(id){
	var box=$(id);
	var dims = box.getDimensions();
	var page_size =document.viewport.getDimensions();
	//alert(page_size.width+" : "+dims.width);
	  box.setStyle({
		position: 'absolute',
		margin: '0',
	    left: ((page_size.width-dims.width)/2).round() + 'px',
	    top:  ((page_size.height-dims.height)/2 + document.viewport.getScrollOffsets().top ).round()  + 'px'
	 });	
}

function hideMe(me){
	var me;	
	//document.getElementById('hideLayer').style.display='none';
	$(me).hide();		
	return false;
}

function removeMe(me){
	var me;		
	$(me).remove();
	return false;
}

function calculatePrice(id,price,people,days){	
	var pack_price=0;
	var room_price=$('#room_cnt_'+id).val() * price;
	if($('#room_cnt_'+id).val()>0){
		var pack_price=people * packs_prices[$('#pack_'+id).val()] * days * $('#room_cnt_'+id).val();
	}
	// packs_prices se pulni v index-a ot bazata 
	var room_total=room_price+pack_price;	
	$('#room_price_'+id).text(room_total);
	
	document.rooms_total[id]=room_total;
	
	var total=0;
	$.each(document.rooms_total, function(index, value) {
		if(value!=undefined){
			total=total + value;
		}
	}	
	);
	
	$('#total_price').text(total);
	return true;
}

function getItemPrice(id){	
	return $('#rp_'+id).val();	
}

function updataRoomPrice(id){		
	var days = $('#days').val();
	
	var room_persons = $('#room_persons_'+id).val();	
	var people = $('#people_'+id).val();	
	$('#txt_people_'+id).text(people);
	if(people>room_persons){
		var room_price=$('#rplusedin_'+id).val();
	}
	else{
		var room_price = $('#rp_'+id).val();
	}
	
	var pack_price = document.packs_prices[$('#pack_'+id).val()];	
	$('#txt_packs_price_'+id).text(pack_price*people*days);	
	$('#txt_pack_price_'+id).text(pack_price);
	
	
	var price = Number(room_price) + ( Number(pack_price) * Number(people) * Number(days) );
	$('#room_price_'+id).text(price);	
}

function updataTotal(){
	var total=0;
	$('.room_total').each(function(index) {
    total=total + Number($(this).text());
  });  	
	$('#res_total').text(total);	
}
