var tmp;

function NewXmlHttp()
{
	var xmlHttp;
	if(window.XMLHttpRequest){ // FF, Opera, Safari
		try
		{
			xmlHttp	= new XMLHttpRequest ();
		}
		catch(e)
		{
			xmlHttp	= null;
		}
	
	}
	else if(window.ActiveXObject){ // IE..
		var xmlHttpVersion = new Array ("MSXML2.XMLHTTP.6.0",
			"MSXML2.XMLHTTP.5.0",
			"MSXML2.XMLHTTP.4.0",
			"MSXML2.XMLHTTP.3.0",
			"MSXML2.XMLHTTP",
			"Microsoft.XMLHTTP");
			for(var i=0; i<xmlHttpVersion.length; i++){
				try
				{
					xmlHttp	= new ActiveXObject(xmlHttpVersion[i]);		
				}
				catch(e){
					xmlHttp = null;	
				}
			}		
	}
	
		if(!xmlHttp){
			alert ("Błąd podczas tworzenia obiektu xmlHttp");
		}
		else{
			return xmlHttp;
			
		}
}


function Confirm(text,location) {
	if (confirm(text)) {
		parent.location.href=location;return true;
	} else {}
}

function Confirm_(text,location,pswd) {
	var echo=prompt(text,"");
	if (echo != null && echo == pswd) {parent.location.href=location;}
}


function changefoto(id){
	var t1=id.split(".");
	var t2=tmp.split(".");
	$("#foto_"+t2[0]+"").attr("class", "minifoto");
	$("#foto_"+t1[0]+"").attr("class", "minifoto2");
	
	var newConn = NewXmlHttp();	
	var url="?id="+id;
	myRand = parseInt(Math.random()*99999999);
	newConn.open("GET","obiekty/ajax/foto.php"+url+ "&rand=" + myRand, true);
	newConn.onreadystatechange = function(){ 
		if(newConn.readyState==4){		
			if(newConn.status==200){
			var odp = document.getElementById('bigfoto');		
			odp.innerHTML = newConn.responseText;
			}
		}
	};	
	newConn.send(null);
	tmp=id;
}


function chooseStar(id,ile){
	var procent=parseInt(ile*25);
	document.getElementById(''+id+'').style.width=''+procent+'%';
	document.getElementById('f_'+id+'').value=parseInt(ile);
	document.getElementById('formtext').focus();
}