// JavaScript Document

// Dropdown menus
function hover (el) {
  el = document.getElementById (el);
  // Hide the last:
  if (last_item) {
    last_item.className = "";
  }
  last_item = false;
  // Show this one:
  el.className = "rolo";
}
var last_item = false;
function unhover (el) {
el = document.getElementById (el);
  last_item = el;
  setTimeout ('if (last_item) { last_item.className = ""; }', 1000);
}
function hidediv(id) {
		//safe function to hide an element with a specified id
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(id).style.display = 'none';
		}
		else {
			if (document.layers) { // Netscape 4
				document.id.display = 'none';
			}
			else { // IE 4
				document.all.id.style.display = 'none';
			}
		}
	}
	

	

	
	function showdiv(id) {
		//safe function to show an element with a specified id
				
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(id).style.display = 'block';
		}
		else {
			if (document.layers) { // Netscape 4
				document.id.display = 'block';
			}
			else { // IE 4
				document.all.id.style.display = 'block';
			}
		}
	}
	function toggleDiv (id, choice) {

	var divDisplay = 'none';
		//safe function to show an element with a specified id
		if (choice == 'RS'){
		divDisplay = 'none'
		//saleList();
		}	else {
		divDisplay = 'block'
		//lettingList();
		}
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(id).style.display = divDisplay;
		}
		else {
			if (document.layers) { // Netscape 4
				document.id.display = divDisplay;
			}
			else { // IE 4
				document.all.id.style.display = divDisplay;
			}
		}
	}
	
	function f_PropDetailsORIG(p_id) {
		v_width = screen.availWidth;
		v_height = screen.availHeight/1.2;
		//alert (screen.availHeight);
		if(v_width<=640){v_width=600}
		else{v_width=850}
		v_url="/_custom/details.php?p_cont_id="+p_id;
		//v_url='http://dev1.digitalized.co.uk/dev/g_details.php?pid='.$_GET['p_cont_id'];
	//	if(pWhich==3){v_url="/_custom/details.php?p_cont_id="+p_id}
		OpenWin = this.open(v_url, "","top=25,left=25,width=" + v_width + ",height=" + v_height + ",buttons=no,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,toolbar=no,directories=no");
		$("#res_"+p_id).html("<div class='loading'></div>");
		}
	
	var OpenWin;
	function f_NewWin(page,pWidth,pHeight,pToolbar,pWinName,pFeatures) {
		var postop = 5,posleft = 5,vFeatures = pFeatures;
		if (pToolbar=="N") vToolbar = "no"; else  vToolbar = "yes";
		if (pFeatures=="" || pFeatures==null) vFeatures = "buttons=no,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,directories=no,toolbar=no";
		if (pWidth=="" || pWidth==null) v_width = screen.availwidth - 20;
		else {v_width = pWidth}
		if (pWinName=="" || pWinName==null) vWinName = "f_NewWin";
		else {vWinName = pWinName}
		posleft = (screen.availwidth - v_width) / 2;
		if (pHeight=="" || pHeight==null) v_height = screen.availheight - 100;
		else {v_height = pHeight}
		postop = (screen.availheight - v_height - 50) / 2;
		OpenWin = this.open(page, vWinName, "top="+postop+",left="+posleft+",width=" + v_width + ",height=" + v_height + ","+vFeatures+",toolbar=" + vToolbar);
		OpenWin.focus();
	//	return OpenWin;
	}
	
	/// jquery used below... maybe update above to use it?
$(document).ready(function (e) {
	
	$(function() {
	$('a[rel*=external]').click( function() {
		window.open(this.href);
		return false;
	});
});
	
 $(".s_img").click(function(){
				var	p_id=($(this).attr("id"));
				$("#res_"+p_id).html("<div class='loading'>Loading Data - Please Wait <img src='/gfx/loading.gif' /></div>");
				f_PropDetailsORIG(p_id);
			/*	$("#res_"+p_id).load("http://dev1.digitalized.co.uk/dev/ajax_details.php",
			  { 'pid':p_id, 'prn':'N', 'preg':'N' } ,
		function(response, status, xhr) {
			if (status == "error") {
				var msg = "Sorry but there was an error: ";
				$("#res_"+p_id).html(msg + xhr.status + " " + xhr.statusText);
			}
		});*/
	});
 
	$(".s_img").hover(
		
		function () {
			var	p_id=($(this).attr("id"));
			$(this).addClass("hover");
			//$("#res_"+p_id).html("<div class='loading'>Get Ful Details Sheet</div>");
		},
		function () {
			var	p_id=($(this).attr("id"));
			$(this).removeClass("hover");
			//$("#res_"+p_id).html("<div class='loading'></div>");
		}
	);
	
 
});

