function changefoto (anket, photo , folder) {
	document.getElementById('mainfoto').src = "/photos/"+folder+"/"+photo;
	//document.getElementById('mainlink').href = "/photos/"+folder+"/"+anket+"_"+photo+".jpg";
}

function utf8_decode (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 

function change_sa (stype) {
			
	//alert(stype);
	document.getElementById("acttype0").style.display = "none";		
	document.getElementById("acttype1").style.display = "none";	
	document.getElementById("acttype2").style.display = "none";	
	document.getElementById("acttype3").style.display = "none";	
	document.getElementById("acttype4").style.display = "none";	
	document.getElementById("acttype5").style.display = "none";	

	if (stype == 0){
		document.getElementById("acttype0").style.display = "inline";	
	}
	if (stype == 1){
		document.getElementById("acttype1").style.display = "inline";	
	}		
	if (stype == 2){
		document.getElementById("acttype2").style.display = "inline";	
	}		
	if (stype == 3){
		document.getElementById("acttype3").style.display = "inline";	
	}		
	if (stype == 4){
		document.getElementById("acttype4").style.display = "inline";	
	}		
	if (stype == 5){
		document.getElementById("acttype5").style.display = "inline";	
	}		
}

function set_ue (pfield,kurs) {
			
	document.getElementById(pfield+'rub').value = Math.round(document.getElementById(pfield).value*kurs);
	
}

function checkauth(wcomm) {
	$.getJSON("http://otsos.cz/aubox.php?callback=?", function(person){
		
		if (person.pid > 0){
			if (person.ut == 1){
				document.getElementById("mauth").innerHTML='<a href="http://otsos.cz/posredlogin/">Личный кабинет</a><br><a href="http://otsos.cz/lo.php" style="margin-top: 6px; display: block;">Выход ['+person.log+']</a>';
			}
			if (person.ut == 2){
				document.getElementById("mauth").innerHTML='<a href="http://otsos.cz/lo.php" style="margin-top: 6px; display: block;">Выход ['+person.log+']</a>';
			}
			if (wcomm == 'y'){
				document.getElementById("wcomm").style.display='inline';
			}
		} else {
			document.getElementById("mauth").innerHTML='логин (email)';
			document.getElementById("aform").style.display='inline';			
			if (wcomm == 'y'){
				document.getElementById("wcommx").style.display='inline';
			}
		}
	if (location.href.search(/anket/)!=-1) {
		document.getElementById("yournick").value=person.nick;
	}
		
		//document.getElementById("mauth").innerHTML='<a href="http://otsos.cz/lo.php" style="margin-top: 6px; display: block;">Выход ['+person.log+']</a>';
	    //alert(person.pid);
	    //alert(person.log);
	    //alert(person.nick);
	});
}

function checkauthc() {
	$.getJSON("http://otsos.cz/aubox.php?callback=?", function(person){
		
		if (person.pid > 0){
			document.getElementById("mcomm").innerHTML='авторизован - можно комментировать';
		} else {
			document.getElementById("mcomm").innerHTML='не авторизован - комментировать могут только авторизованные пользователи...';
			document.getElementById("aform").style.display='inline';			
		}		
	});
}

function authevent (){
//	$('jauth').addEvent('submit', function(e) {
//		new Event(e).stop();
//		this.send({
//			update: 'mauth',
//			evalScripts: true
//		});
//	});
}
