function mlang(lg){
   	var _ajax = new ajax.ContentLoader('ajax.php?lang='+lg,
	   	function(){
	   		location.reload();
	    });
}

function del_img(id){
	res = window.confirm('Are you sure you want to delete the photo?');
	if (res){
	   	var _ajax = new ajax.ContentLoader('ajax.php?del_img='+id,
		   	function(){
		   		window.location.href='Photo_albom.htm';
		    });
	}
}


function del_all_img(){
	res = window.confirm('Are you sure you want to delete the photo?');
	if (res){
		for (var k=0; k<$$('.all_foto').length; k++){
			if(($$('.all_foto')[k].get('checked'))==true){
				var _ajax = new ajax.ContentLoader('ajax.php?del_img='+$$('.all_foto')[k].get('name'));
			}
		}
		window.location.href='Photo_albom.htm';
	}
}

function sen(){
	var name=urlEncode(document.getElementById('name').value);
	var email=urlEncode(document.getElementById('email').value);
	var tel=urlEncode(document.getElementById('tel').value);
	var tema=urlEncode(document.getElementById('tema').value);
	var text=urlEncode(document.getElementById('text').value);
	if (name && email && text){
		var _ajax = new ajax.ContentLoader('ajax.php?send=email&name='+name+'&email='+email+'&tel='+tel+'&tema='+name+'&text='+text,
	   	function(){
	   		document.getElementById('mess').innerHTML=this.req.responseText;
	    });
	} else {
		alert('Поля "Имя", "Emal" и "Сообщение" обязательны для заполнения!');
	}
}

var cc= new Array();
function cl(id,name){
	if(!cc[id]){
		document.getElementById(name).value='';
		cc[id]=1;
	}
}

function send_gifts(id){
	window.open('gifts-'+id+'.htm', 'gifts', 'toolbar=no,menubar=no,location=no,status=yes,directories=no,xcenter=yes,ycenter=yes,resizable=1,scrollbars=yes,dependent=yes,width=1020px,height=500px'); return false;
}

function shide(id){
	//var myFx = new Fx.Slide('div-'+id);
	//myFx.toggle();
	jQuery('#div-'+id).slideToggle('slow');
}
function lo_g_in(){
	var log=document.getElementById('fname').value;
	var pass=document.getElementById('city').value;
	if(log && pass){
		var _ajax = new ajax.ContentLoader('ajax.php?login='+log+'&pass='+pass,
		function(){
			if(this.req.responseText==1)	window.location.href="Photo_albom.htm";
			//location.reload();
		});
	}
}
function ex_i_t(){
	var _ajax = new ajax.ContentLoader('ajax.php?exlogin=ex',
		function(){
			window.location.href="Home.htm";
			//location.reload();
		});
}
function oreder_form(id){
	document.getElementById(id).submit();
}
var sum=0;

function selAll(){
	if($$('.set_all')[0].get('checked')==false){
		$$('.set_all').set('checked','true');
	} else {
		$$('.set_all').removeProperty('checked');
	}
}

function sumg(id, limit){
	var m=document.getElementsByName('zak_gifts[]');
	var _ajax = new ajax.ContentLoader('ajax.php?gifts='+m[id].value,
		function(){
			temp=this.req.responseText;
			if(m[id].checked) sum=parseFloat(sum)+parseFloat(temp);
			else sum-=temp;
			if(sum>0){
				if(sum>limit){
					document.getElementById('or').style.color='#BD4F76';
					document.getElementById('btn').style.display='none';
				}
				else{
					document.getElementById('btn').style.display='block';
					document.getElementById('or').style.color='black';
				}
				document.getElementById('or').style.display='block';
				document.getElementById('suum').innerHTML=sum;
			} else {
				document.getElementById('or').style.display='none';
				document.getElementById('btn').style.display='none';
			}
	});
	
}

function senMail(id){
	var text=urlEncode(document.getElementById('fm'+id).value);
	if (text){
		var _ajax = new ajax.ContentLoader('mail.php?fmess='+text+'&id='+id,
	   	function(){
	   		document.getElementById('jinn_'+id).style.display='none';
	   		document.getElementById('jin2_'+id).style.display='block';
	    });
	}
}

function isNotMax(oTextArea,id) {
	var kol=oTextArea.getAttribute('maxlength')-oTextArea.value.length;
	if(kol<0){
		oTextArea.value=oTextArea.value.substring(0, oTextArea.getAttribute('maxlength'));
		kol=0;
	}
	document.getElementById('kk'+id).innerHTML=kol;
}

function llo(){
	$$('.viss').slide('hide');
}
/*

hs.registerOverlay(
    	{
    		thumbnailId: null,
    		overlayId: 'controlbar',
    		position: 'top right',
    		hideOnMouseOut: true
		}
	);
	
    hs.graphicsDir = 'js/highslide/graphics/';
    hs.outlineType = 'rounded-white';
    // Tell Highslide to use the thumbnail's title for captions
    hs.captionEval = 'this.thumb.title';
    */
