function addtolist(method, id, purchase_type, name, show_message, image, thankyou, framename, divID) {
        id = id.replace (",b",'');
        id = id.replace (",r",'');

	name = name.split (",");
        var newlocation = '../panes/list.php?method=' + method + '&property=' + id + ',' + purchase_type +  "&image=" + escape(image) + "&name=" + escape(name[0]) + "&sort=" + purchase_type + "&type=" + purchase_type;

	parent.frames[framename].location=newlocation;
	document.getElementById(divID).innerHTML="<span class='map_links1'>" + thankyou + "</span>";
}

function addtosearchlist(method, searchstr, search_type, thankyou, framename, divID) {

        var newlocation = '../panes/list.php?display=sprops&method=' + method + '&searchstr=' + searchstr + '&type=' + search_type;
	parent.frames[framename].location=newlocation;
	document.getElementById(divID).innerHTML=thankyou;
}


function fixMoreBlock() {
  //a little bit of vertical alignment magic for stock man image
  fc = document.getElementById('FeatureContainer');
  lc = document.getElementById('LeftCell');

  more = document.getElementById('More');

  if (more) {
    more.style.top = (fc.offsetHeight - lc.offsetHeight - 5)+'px';
  } //if
} //fixMoreBlock

function sleepBeforePreload() {
  fixMoreBlock();
  window.setTimeout('waitPreloadPage()', 1000); // delays the preloader to display
} //sleepBeforePreload

function waitPreloadPage() { //DOM
	if (document.getElementById){
    document.getElementById('RotateBox').style.visibility='hidden';
    document.getElementById('RotateIframe').style.visibility='hidden';
	} else {
    if (document.layers) { //NS4
      document.RotateBox.visibility = 'hidden';
      document.RotateIframe.visibility = 'hidden';
    }	else { //IE4
      document.all.RotateBox.style.visibility = 'hidden';
      document.all.RotateIframe.style.visibility = 'hidden';
    } //else
	} //else
} //waitPreloadPage

function changeSearchVersion(obj) {
  f = $('frmQuickSearch');

  if (obj.checked) {
    f.searchversion.value = 1;
  } else {
    f.searchversion.value = 0;
  } //else
} //changeSearchVersion

function getGreet() {
  var currentTime = new Date();
  var hours = currentTime.getHours();
  var text = "Morning";

  if (hours>11) text = "Afternoon";
  if (hours>17) text = "Evening";

  return text;
} //writeGreet

function id$(name) {
    if (document.getElementById) {
        return document.getElementById(name);
    } else if (document.all) {
        return document.all[name];
    } else if (document.layers) {
        return document.layers[name];
    }
}

var newsFade;
var newsDiv;
var newsSummary = false;
var newsLoadedID;

function initNews(div, summary) {
  newsDiv = div;
  newsFade = new fx.Opacity(div, {duration: 400});
  newsSummary = summary;
} //initNews

function fetchNews(id, type) {
  if (id != newsLoadedID) {
    newsLoadedID = id;
    newsFade.custom(1, 0);
    setTimeout("fetchSnippet("+id+", '"+type+"')", 500);
  } //if
} //fetchNews

function fetchSnippet(id, type) {
  if (type == 'adv') {
    var url = '../php/fetchadvice.php';
  } else {
    //var url = '../php/fetchnews.php';
    var url = 'php/fetchevents.php';
  } //else

  var params = 'id='+id+'&ajax=1&summary='+newsSummary;
  var ajaxNews = new Ajax.Request(url, {method:'get', parameters:params, onComplete: showNews});
} //fetchSnippet

function showNews(req) {
  if (newsSummary != true) {
    regex = /setCookie\(.+?\);.+?\);/
    match = regex.exec(req.responseText);
    eval(match.toString());
  } //if

  $(newsDiv).innerHTML = req.responseText;
  //$(newsDiv).style.display = 'block';
  //fixMoreBlock();
  newsFade.custom(0, 1);
} //showNews





function setCookie(cookieName, cookieValue, nDays) {
   var today = new Date();
   var expire = new Date();
   if (nDays==null || nDays==0) nDays=1;
   expire.setTime(today.getTime() + 3600000*24*nDays);

   document.cookie = cookieName+"="+escape(cookieValue)
                   + ";expires="+expire.toGMTString()
                   + ";path=/";
} //setCookie

function changephoto(id,src)
{
	var mainphoto = document.getElementById(id);
	if (mainphoto.filters)
	{
	    mainphoto.style.filter="blendTrans(duration=3)";
	    if(mainphoto.filters.blendTrans.status != 2)
	    {
        	mainphoto.filters.blendTrans.Apply();
        	mainphoto.src = src;
        	mainphoto.filters.blendTrans.Play();
	    }
	}
	else mainphoto.src = src;
}

//<![CDATA[
function fixer() {
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);

	if ((version >= 5.5) && (document.body.filters)) 
	{
		for(var i=0; i<document.images.length; i++)
	    {
			var img = document.images[i]
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			{
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText 
			
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML;
			   	i = i-1;
			 }
		}	
	}
}

function fixer2() {

	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);

	if ((version >= 5.5) && (document.body.filters)) 
	{
		
		var my_images = Array ();

		for( var i = 0; i < document.images.length; i++ ) {
			if (document.images[i].className == "sidebar_icons") {
				my_images.push (document.images[i]);
			}
		}
	 
	    for( var i=0; i< my_images.length; i++ )
	    {
			var img = my_images [i];
			
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			{
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:block;" + img.style.cssText 
			
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				//if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML;
			 }
		}	
	}
}

function menuDrop(theDiv){
    //alert(document.getElementById(theDiv).style.display);
    if(document.getElementById(theDiv).style.display == 'none'){
        document.getElementById(theDiv).style.display = 'block';
    } else {
        document.getElementById(theDiv).style.display = 'none';
    }
}
