function rpcall(fragment_url, element_id) {
    var element = false;

    if(element_id != "" && element_id != "JS_alert") element = document.getElementById(element_id);
	    
	var xmlhttp;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	if (!xmlhttp && document.createElement) {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	@end @*/
	if (!xmlhttp && document.createElement) {
	 xmlhttp = new XMLHttpRequest(); 
	}

    	
    xmlhttp.open("GET", fragment_url);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            if(element) element.innerHTML = xmlhttp.responseText;
            	else if(element_id == "JS_alert") alert(xmlhttp.responseText);
        }
    }
    xmlhttp.send(null);

}


function rpc(action, value, target){
	url = '/rpc/?action='+action+'&value='+value+'&rnd=';
	rpcall(url, target);
}

function set_user_image(photo_id) {
	rpc("setmemberphoto", photo_id, "JS_alert");
}

function delete_member_photo(photo_id) {
	window.location = "/members/delete.php?photo_id=" + photo_id;
}

function popup (url, width, height, name, resizable) {
	if(name=="") name = "popup";
	window.open(url, name, "location=no,menubar=no,scrollbars=yes,resizable=" + resizable + ",height=" + height + ",width="+width);
}

function popup_photo(photo) {
	if(screen.height < 1100) pHeight = screen.height-100;
		else pHeight = 900;
	if(screen.width < 1000) pWidth = screen.width-100;
		else pWidth = 900;
	popup("/photos/view-photo.php?photo=" + photo, pWidth, pHeight, "photo", "yes");
	return false;
}

function toggle_layer(layer, state) {
	if(objLayer = document.getElementById(layer)) {
		if(state == true) objLayer.style.display = "block";
			else objLayer.style.display = "none";
	}
}

function count_click(id) {
	var url = '/rpc/?action=count&value=' + id;
	new Ajax.Request(url, {
	  method: 'get'
	});
	
}