/*
var mouseX;
var mouseY;

if(document.all){
}else if(document.getElementById){
	document.captureEvents( Event.MOUSEMOVE );
	document.onmousemove = getCoord;
}

function getCoord(event){
	mouseX = event.pageX;
	mouseY = event.pageY;
}

function SetToPointer(id){
	if(mouseY){
		document.getElementById(id).style.left=mouseX;
		document.getElementById(id).style.top=mouseY;
	}else{
		document.getElementById(id).style.left=event.clientX;
		document.getElementById(id).style.top=event.clientY + document.body.scrollTop;
	}
	SwitchEditor2(id,true);
	return false;
}

function SwitchEditor(id){
	obj=document.getElementById(id);
	if(obj.className=="editor_invisible")obj.className="editor_visible";
	else obj.className="editor_invisible";
	return false;
}

function SwitchEditor2(id,val){
	obj=document.getElementById(id);
	if(val==true)obj.className="editor_visible";
	else obj.className="editor_invisible";
	return false;
}
*/
var root_path = 'http://fotochel.me';

function vRate(itm,mark){
	for(i=1;i<=5;i++){
		if(i<=mark)document.getElementById(itm+'_'+i).src= root_path+"/images/sr.jpg";
		else document.getElementById(itm+'_'+i).src= root_path+"/images/sg.jpg";
	}
	return false;
}
function uRate(itm){
	for(i=1;i<=5;i++)document.getElementById(itm+'_'+i).src= root_path+"/images/sg.jpg";
	return false;
}
function Rate(itm,mark){
	//alert(itm);
	//document.getElementById(itm).className="editor_invisible";
	//document.getElementById(itm+'_vote').className="editor_visible";
	
	document.getElementById(itm).style.visibility = 'hidden';
	document.getElementById(itm+'_vote').style.visibility = 'visible';
	
	document.getElementById(itm+'_img').src= root_path+"/images/s"+mark+".jpg";
	window.prompt('url', root_path+'/rate.php?id='+itm+'&mark='+mark);
	
	makeRequest(root_path+'/rate.php?id='+itm+'&mark='+mark,0,0,'rate',itm);
	return false;
}

function makeRequest(url,val,id,part,itm) {
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				http_request.overrideMimeType('text/xml');
// Читайте ниже об этой строке
				}
			} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Не вышло :( Невозможно создать экземпляр класса XMLHTTP ');
		return false;
	}
	http_request.onreadystatechange = function(){
		alertContents(http_request,val,id,part,itm);
	};
	http_request.open('GET', url, true);
	http_request.send(null);
}

function alertContents(http_request,val,id,part,itm) {
	alert(http_request + "\n" + val + "\n" + id + "\n" + part + "\n" + itm);
	var r=false;
	var v=0;
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			if(part=='rate'){
				if(http_request.responseText=='1')document.getElementById(itm+'_img').src= root_path+"/images/s1.jpg";
				else if(http_request.responseText=='2')document.getElementById(itm+'_img').src= root_path+"/images/s2.jpg";
				else if(http_request.responseText=='3')document.getElementById(itm+'_img').src= root_path+"/images/s3.jpg";
				else if(http_request.responseText=='4')document.getElementById(itm+'_img').src= root_path+"/images/s4.jpg";
				else if(http_request.responseText=='5')document.getElementById(itm+'_img').src= root_path+"/images/s5.jpg";
				else document.getElementById(itm+'_img').src= root_path+"/images/s3.jpg";
			}
		}else{
			alert('С запросом возникла проблема.');
		}
	}
}

/*
function onlinePreview(id){
	
	if(src=document.getElementById('file_'+id).value=="")return false;
	
	format=document.getElementById('format_'+id).value;
	x_pos=format.search(/x/i);
	f_width=format.substr(0,x_pos);
	f_height=format.substr(x_pos+1);

	if(src=document.getElementById('file_'+id).value!="val"){
		src=document.getElementById('file_'+id).value;
		src=src.replace(/\\/g,'/');
		document.getElementById('pre_'+id+'_none').src=src;	
		document.getElementById('pre_'+id).src=src;
	}

	i_width=document.getElementById('pre_'+id+'_none').width;
	i_height=document.getElementById('pre_'+id+'_none').height;
	
	div_width=75;
	
	tmp_width=f_width;
	if(i_width>i_height){
		t=f_width;
		f_width=f_height;
		f_height=t;
	}

	//Фрейм
	tb_width=div_width;
	tb_height=f_height*div_width/f_width;tb_height=Math.round(tb_height);
	document.getElementById('image_iframe_'+id).style.width=tb_width+'px';
	document.getElementById('image_iframe_'+id).style.height=tb_height+'px';
	
	//Картинка
	if(document.getElementById('margin_'+id).checked){
		//Отступ, чтобы было видно поля.
		if(i_width>i_height){
			pre_w=i_width*tb_height/i_height;pre_w=Math.round(pre_w);
			pre_h=tb_height;
			document.getElementById('pre_'+id).width=pre_w;
			document.getElementById('pre_'+id).height=pre_h;

			pad=tb_width-pre_w;
			document.getElementById('image_iframe_'+id+'_controll').style.padding="0px 0px 0px 0px";
		}else{
			pre_w=div_width;
			pre_h=i_height*div_width/i_width;pre_h=Math.round(pre_h);
			document.getElementById('pre_'+id).width=pre_w;
			document.getElementById('pre_'+id).height=pre_h;
			
			pad=(tb_height-pre_h)/2;pad=Math.round(pad);
			document.getElementById('image_iframe_'+id).style.height=(tb_height-pad)+'px';
			
			if(pad<0)pad=0;
			document.getElementById('image_iframe_'+id+'_controll').style.padding=pad+"px 0px 0px 0px";
		}
	}else{
		if(i_width>i_height){
			pre_w=div_width;
			pre_h=i_height*div_width/i_width;pre_h=Math.round(pre_h);
			document.getElementById('pre_'+id).width=pre_w;
			document.getElementById('pre_'+id).height=pre_h;
			
			document.getElementById('image_iframe_'+id+'_controll').style.padding="0px 0px 0px 0px";
		}else{
			pre_w=i_width*tb_height/i_height;pre_w=Math.round(pre_w);
			pre_h=tb_height;
			document.getElementById('pre_'+id).width=pre_w;
			document.getElementById('pre_'+id).height=pre_h;
			
			//Отступ, чтобы было видно поля.
			pad=(pre_w-tb_width)/2;pad=Math.round(pad);
			document.getElementById('image_iframe_'+id+'_controll').style.padding="0px 0px 0px 0px";
		}
	}

	document.getElementById('pre_'+id).focus();
	
	document.getElementById('image_iframe_'+id+'_controll').style.width='75px';
	document.getElementById('image_iframe_'+id+'_controll').style.height=tb_height+'px';

	//Quality
	quality=(i_width*24.5)/(f_width*10);
//	alert(quality);
	if(quality<180){
		col='#F7A8A8';
		t='плохое';
	}else if(quality<250){
		col='#FFF4B7';
		t='удовлетв.';
	}else{
		col='#BEF3B1';
		t='хорошее';
	}
	document.getElementById('quality_'+id).value=t;
	document.getElementById('quality_'+id).style.background=col;
	
	return 1;
}

function onlinePreview_light(id){
	if(document.getElementById('file_'+id).value=="")return false;
	src=document.getElementById('file_'+id).value;
	document.getElementById('pre_'+id).src=src;
	return 1;
}

var elapse = 500; // this is interval in milliseconds
var timer = null;

function onTimer(i){
	// stop it when the function run over the time
	if (i > 1) {
		id=document.getElementById('after_upload').value;
		onlinePreview(id);
		return true;
	}else if (i > 5) {
		id=document.getElementById('after_upload').value;
		onlinePreview(id);
		timer = null;
		elapse = 500;
		return true;
	}else{
		i++;
		timer = window.setTimeout('onTimer(' + i + ')', elapse);
	}
}
*/
