var link_nohandler= window.clientInformation ? null : window.undefined;
var base_url = 'http://www.pdp-architects.co.uk';

function link_down() {
    this.onfocus= this.blur;
}

function link_up() {
    this.onfocus= link_nohandler;
}

function link_bind() {
    for (var i= document.links.length; i-->0;) {
        document.links[i].onmousedown= link_down;
        document.links[i].onmouseup= link_up;
    }
}

function changeImgSrc(id,v) { var el = document.getElementById(id); if (el) el.setAttribute('src',v); }

function changeLinks(id, col) {
	
	var el = document.getElementById(id);
	
	document.getElementById('floorplans_nav').style.display='none';
	
	document.getElementById('front_aspect').style.color='#'+col;
	document.getElementById('rear_aspect').style.color='#'+col;
	document.getElementById('enquire').style.color='#'+col;
	document.getElementById('floorplans').style.color='#'+col;

	el.style.color='#333333';
}

function updateProjectsPhotos(table,item) {
	// alert(table + ' ' + base_url + "/includes/ajax.php");
		
	$("#projectsPhotosContainer").load(base_url + "/includes/ajax.php", { action: 'updategallery', thetable: table, itemuid: item });
}

function updateGallery(table) {
	// alert(table + ' ' + base_url + "/includes/ajax.php");
		
	$("#data").load(base_url + "/includes/ajax.php", { action: 'updategallery', thetable: table });
}

function deleteItem(uid, table) {
	
	if ( confirm('Are you sure you wish to delete this item?\nThis can NOT be undone.') ) {
		
		$("#data").load(base_url + "/includes/ajax.php", { action: 'deleteitem', theuid: uid, thetable: table });
		 		
 		document.getElementById('id_' + uid).style.display='none';
 		
 		// window.location = base_url + '/cms/news/edit/' + newsid + '/';
 
 	} else {
		 return false;
	}
}

function addHomePhotosUrl(uid, table) {
	
	// alert(uid + ' ' + table + ' ' + base_url + "/includes/ajax.php");
	
	$("#data").load(base_url + "/includes/ajax.php", { action: 'addHomePhotosUrl', theuid: uid, thetable: table });
	
	// if ( confirm('Are you sure you wish to add a label to this image?\nThis can NOT be undone.') ) {
// 		return true;
// 	}  else {
// 		 return false;
// 	}
}


function addPhotoLabel(uid, table) {
	
	// alert(uid + ' ' + table + ' ' + base_url + "/includes/ajax.php");
	
	$("#data").load(base_url + "/includes/ajax.php", { action: 'addProjectsPhotosLabel', theuid: uid, thetable: table });
	
	// if ( confirm('Are you sure you wish to add a label to this image?\nThis can NOT be undone.') ) {
// 		return true;
// 	}  else {
// 		 return false;
// 	}
}

function deletePhoto(uid, table) {
	
	if ( confirm('Are you sure you wish to delete this image?\nThis can NOT be undone.') ) {
		
		$("#blank").load(base_url + "/includes/ajax.php", { action: 'deletephoto', theuid: uid, thetable: table });
		 		
 		document.getElementById('id_' + uid).style.display='none';
 		
 		// window.location = base_url + '/cms/news/edit/' + newsid + '/';
 
 	} else {
		 return false;
	}
}