// JavaScript Document
var xmlHttp

var curOp
var imageString
var propIDString

function setDefault(str,propID){ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	imageString=str;
	propIDString=propID;
	curOp = "setDef";
	var url="setimage.php";
	url=url+"?newDef="+str;	
	url=url+"&propID="+propID;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
//	document.getElementById('defImage').src='/images/properties/' + propID + '/' + imageStr + '';
}

function delImage(str,propID){ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}

	imageString=str;
	propIDString=propID;
	curOp = "delImg";
	var url="delimage.php";
	url=url+"?delImg="+str;	
	url=url+"&propID="+propID;
	url=url+"&sid="+Math.random();
	alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("reponseTxt").innerHTML=xmlHttp.responseText;
		if(curOp == 'setDef'){
			document.getElementById('defImage').src='/images/properties/' + propIDString + '/' + imageString + '';
//			document.getElementById('defText').style.display = 'none';
		}
		if(curOp == 'delImg'){
			curFile = "cont" + imageString;
			delMe = document.getElementById(curFile);
			delMe.style.display = 'none';
//			if(document.getElementById('defImage').src='/images/properties/' + propIDString + '/' + imageString + ''){
//				document.getElementById('defImage').src='';
//				document.getElementById('defText').style.display = '';
//			}
		}
	} 
}
