

var waitTime = 2*1000;
var nbTryMax = 10;
var p = new Array();
function createPreloader(image,nopic, source, callback, nbtry,id)
{
	p[id] = new ImagePreloader(image,nopic, source, callback, nbtry,id);
}

function ImagePreloader(image,nopic, source, callback, nbtry,id)
{
   // store the call-back
   this.callback = callback;
   // initialize internal state.
   this.aImage = image;
   this.aSource = source;
   // for each image, call preload()
   this.preload(image,source,nopic,nbtry,id);
}

ImagePreloader.prototype.preload = function(image,source ,nopicid,nbtry,id)
{
   // create new Image object and add to array
   var oImage = new Image;

   // set up event handlers for the Image object
   oImage.onload = ImagePreloader.prototype.onload;
   oImage.onerror = ImagePreloader.prototype.onerror;
   oImage.onabort = ImagePreloader.prototype.onabort;

   // assign pointer back to this.
   oImage.oImagePreloader = this;
   oImage.bLoaded = false;
   oImage.nbTry = nbtry;
   oImage.aSource = source;
   // assign the .src property of the Image object
   oImage.nopicid = nopicid;
   oImage.picid = id;
   
   oImage.src = image;
}

ImagePreloader.prototype.onComplete = function(src)
{
	this.aSource.src = src;
}

ImagePreloader.prototype.onload = function()
{
   this.bLoaded = true;
   this.aSource.src = this.src;
}

ImagePreloader.prototype.onerror = function()
{
   this.bError = true;
   this.nbTry++;
   //todo: faire de la gestion d erreur; 
   if(this.nbTry < nbTryMax)
   {	
        window.setTimeout('p'+this.picid+' = new ImagePreloader("'+this.src+'","'+this.nopicid+'",document.getElementById("'+this.aSource.id+'"),loading,'+this.nbTry+','+this.picid+')',waitTime);
   }
   else if(this.nbTry == nbTryMax)
   {
	this.src = this.nopicid;
   }	
}

ImagePreloader.prototype.onabort = function()
{
   this.bAbort = true;
   this.oImagePreloader.onComplete(this.nopicid);
}

function loading(source, image)
{
	source.src = image;
}

var scrollcurrentScrollIndex = 1;
var scrolltxtArray;
var scrollfirstDiv;
var scrollsecondDiv;
var scrollwidth=0;
var scrollheight=0;
var scrollrefHeight=100;
var scrollpause=2000;
var scrolltopDiv ;
var scrollbottomDiv;
var scrollinterval;
var scrollstep=1;
var scrollincrement=60;

function scrollText(texte, parentDiv, pause, increment, step)
{
  if( pause ) scrollpause=pause;
  if( increment ) scrollincrement = increment; 
  if( step ) scrollstep = step;
	scrolltxtArray = texte;
	scrollwidth=parentDiv.style.pixelWidth;
	scrollrefHeight = parentDiv.style.pixelHeight +1;
  	
	scrollfirstDiv = document.createElement("DIV");
	scrollsecondDiv = document.createElement("DIV");
	scrollfirstDiv.style.position='absolute';
	scrollfirstDiv.style.width=scrollwidth+'px';
	scrollfirstDiv.style.left='0px'
	scrollfirstDiv.style.top='0px';
	scrollfirstDiv.innerHTML=scrolltxtArray[0];

	scrolltopDiv = scrollfirstDiv;
	parentDiv.appendChild(scrollfirstDiv);
	scrollheight=Math.max(scrollfirstDiv.offsetHeight, scrollrefHeight);
	
	if( scrolltxtArray.length == 1 )
		scrolltxtArray[1] = scrolltxtArray[0];
		
	if( scrolltxtArray.length > 1 )
	{
	  	scrollsecondDiv.style.position='absolute';
	  	scrollsecondDiv.style.width=scrollwidth+'px';
	  	scrollsecondDiv.style.left='0px'
	  	scrollsecondDiv.style.top= scrollheight + 'px';
	  	scrollsecondDiv.innerHTML=scrolltxtArray[1];

		parentDiv.appendChild(scrollsecondDiv);
		scrollbottomDiv = scrollsecondDiv;
		scrollinterval = setTimeout("scroll(false)",scrollpause);
	}
}

function scroll(change, speed)
{
	if( change == true )
	{
		if( parseInt(scrollfirstDiv.style.top) == 0 )
		{
			scrolltopDiv = scrollfirstDiv; scrollbottomDiv = scrollsecondDiv;
		}
		else
		{
			scrolltopDiv = scrollsecondDiv; scrollbottomDiv = scrollfirstDiv;
		}
	}
	
	//if( top is not yet in view, scroll it
	if (parseInt(scrollbottomDiv.style.top) > 0 )
	{ 	
		scrolltopDiv.style.top=(parseInt(scrolltopDiv.style.top)-scrollstep) +'px';
		scrollbottomDiv.style.top=(parseInt(scrollbottomDiv.style.top)-scrollstep)+'px';
		scrollinterval = setTimeout("scroll(false)",scrollincrement);
	}
	else
	{	//top is in view
		scrollcurrentScrollIndex ++;
		if( scrollcurrentScrollIndex >= scrolltxtArray.length )
			scrollcurrentScrollIndex = 0; 
		scrollheight=Math.max(scrollbottomDiv.offsetHeight, scrollrefHeight);
		scrolltopDiv.style.top=parseInt(scrollheight)+'px';
		scrolltopDiv.innerHTML=scrolltxtArray[scrollcurrentScrollIndex];
		scrolltopDiv.style.height=scrollrefHeight+'px';	// set min height if content is too small
		scrollinterval = setTimeout("scroll(true)",scrollpause);
	}
}

function strtrim() 
{
//Match spaces at beginning and end of text and replace
//with null strings
    return this.replace(/^\s+/,'').replace(/\s+$/,'');
}
String.prototype.trim = strtrim;

String.leftPad = function (val, size, ch)
{
    var result = new String(val);
    if (ch == null) {
        ch = " ";
    }
    while (result.length < size) {
        result = ch + result;
    }
    return result;
}
String.rightPad = function (val, size, ch)
{
    var result = new String(val);
    if (ch == null) {
        ch = " ";
    }
    while (result.length < size) {
        result = result + ch;
    }
    return result;
}

function capFirst(value) {
    var a = value.split(/\s+/g); // split the sentence into an array of words
    var firstLetter;
    for (i = 0 ; i < a.length ; i ++ ) 
    {
        firstLetter = a[i].substring(0, 1).toUpperCase();
        a[i] = firstLetter + a[i].substring(1); // re-assign it back to the array and move on
    }
    return a.join(' '); // join it back together
}

function capFirstExt(value)
{
    var a = value.split(/\s+/g); // split the sentence into an array of words
    var firstLetter;
    for (i = 0 ; i < a.length ; i ++ ) 
    {
        firstLetter = a[i].substring(0, 1).toUpperCase();
        a[i] = firstLetter + a[i].substring(1); // re-assign it back to the array and move on
    }
    value =  a.join(' '); // join it back together
    
    a = value.split('\''); // split the sentence into an array of words
    for (i = 0 ; i < a.length ; i ++ ) 
    {
        firstLetter = a[i].substring(0, 1).toUpperCase();
        a[i] = firstLetter + a[i].substring(1); // re-assign it back to the array and move on
    }
    value =  a.join('\''); // join it back together
    
    a = value.split('\-'); // split the sentence into an array of words
    for (i = 0 ; i < a.length ; i ++ ) 
    {
        firstLetter = a[i].substring(0, 1).toUpperCase();
        a[i] = firstLetter + a[i].substring(1); // re-assign it back to the array and move on
    }
    value =  a.join('\-'); // join it back together

    a = value.split('mc'); // split the sentence into an array of words
    for (i = 0 ; i < a.length ; i ++ ) 
    {
        firstLetter = a[i].substring(0, 1).toUpperCase();
        a[i] = firstLetter + a[i].substring(1); // re-assign it back to the array and move on
    }
    value =  a.join('Mc'); // join it back together
    
    a = value.split('Mc'); // split the sentence into an array of words
    for (i = 0 ; i < a.length ; i ++ ) 
    {
        firstLetter = a[i].substring(0, 1).toUpperCase();
        a[i] = firstLetter + a[i].substring(1); // re-assign it back to the array and move on
    }
    value =  a.join('Mc'); // join it back together
    
    return value;
}

var emailCheckPatt = /^[ ]*[\-\_\&\!\#\$\%\'\*\+\/\=\?\^\`\{\|\}\~A-Za-z0-9]+(\.[\-\_\&\!\#\$\%\'\*\+\/\=\?\^\`\{\|\}\~A-Za-z0-9]+)*@[\-\_\&\!\#\$\%\'\*\+\/\=\?\^\`\{\|\}\~A-Za-z0-9]+(\.[\-\_\&\!\#\$\%\'\*\+\/\=\?\^\`\{\|\}\~A-Za-z0-9]+)*\.([\-\_\&\!\#\$\%\'\*\+\/\=\?\^\`\{\|\}\~A-Za-z0-9]){2,4}[ ]*$/i;
function checkEmailAddress(value, isMultiple)
{
  if(value.length == 0)
     return null;

 	var allAddresses = new Array(1);
 	allAddresses[0] = value;
	if( isMultiple && isMultiple == true && ( value.indexOf(',') != -1 || value.indexOf(';') != -1) )
  		allAddresses = value.split(/[,;]/g);

 	for(i=0; i< allAddresses.length; i++)
 	{ 	
 		allAddresses[i] = (allAddresses[i]!=null ? allAddresses[i].trim() : '');
 		if(allAddresses[i].length > 0 && emailCheckPatt.test(allAddresses[i])==false)
 			return allAddresses[i];
 	}
  
	return null;
}

function verifyEmailAddress(element, isMultiple) 
{
	if( element.value.trim().length > 0 && element.value.trim() != ',')
	{
		badEmail = checkEmailAddress(element.value, isMultiple);
		if( badEmail != null) 
		{
			alert(badEmailMsg+'\n'+ badEmail); 
			var r = element.createTextRange();
			r.findText(badEmail);
			r.select();
			element.focus(); 
			return false;
		}
	}
	else
		element.value='';
	return true;
}

function hover(elttag) 
{ 
	var srcElt = window.event.srcElement; 
	if( !elttag) elttag = 'TD'; 
	else elttag = elttag.toUpperCase();
	while(srcElt.tagName != elttag ) srcElt = srcElt.parentElement; 
	var cname = srcElt.className; 
	if( (idx = cname.indexOf('hover')) != -1 ) srcElt.className = cname.substring(0, idx); 
	else srcElt.className = cname + 'hover'; 
	window.event.cancelBubble=true; 
	window.event.returnValue=false; 
	return false;
}
function MM_swapImgRestore() { var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}
function MM_preloadImages() { var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image(); d.MM_p[j++].src=a[i];}}}
function MM_findObj(n, d) { var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x;}
function MM_swapImage() {var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}

var popupblockerMsg="Pour pouvoir utiliser la recherche Centris confortablement, vous devez desactiver le 'blocage des fenetres intempestives' dans votre configuration d'Internet Explorer, ou ajouter ce site dans la liste de sites non bloques.\n\nIn order to use Centris Search comfortably, you must disable the 'popup blocker' function of your Internet Explorer browser, or add the current site to the list of unblocked sites.";

function launch(url, child_window_name, height, width, attribute) 
{ var remote = null;
  if( height > 0 && width > 0 )
  {
	  var lg = (screen.width-width)/2;   
	  var ht = (screen.height-height)/2;   
	  remote = open( url, child_window_name, "height=" + height + ",width=" + width + ", left="+lg+",top="+ht+"," + attribute);    
  }
  else
  	  remote = open( url, child_window_name, attribute);    
  	  
try{
  if(typeof(remote) != 'undefined' && remote != null )remote.focus();
  else 
  {
  	hideWaiting();
  	alert(popupblockerMsg); 
	if(window.opener && !window.opener.closed ) 
		window.close();
  }}
catch(e){} 
  return remote; 
} 
 

function submitSelf(form) 
{     
try{
    if( window.event )  
        window.event.cancelBubble = true; 
    form.target = '_self'; 
    if(document.body) {
	    if( typeof(pleaseWait) == 'undefined' )
	    	pleaseWait = 'Please wait / Veuillez patienter';
	    showWaiting(document.body, pleaseWait);
    }
    try{form.submit()}catch(err){};  
    }
    catch(ex) {alert('SubmitSelf('+form.action+') Error when submitting form:'+ ex.message);}
    return false; 
}  


function submitInSubFrame(form, subFrame)
{ 
    if( window.event )  
        window.event.cancelBubble = true;  
    form.target=subFrame.name;
    form.submit();
    return false;
}
 

var provinces = new Array(2); provinces['CA'] = new Array(13); provinces['CA'][0] = 'AB'; provinces['CA'][1] = 'BC'; provinces['CA'][2] = 'MB'; provinces['CA'][3] = 'NB'; provinces['CA'][4] = 'NL'; provinces['CA'][5] = 'NT'; provinces['CA'][6] = 'NS'; provinces['CA'][7] = 'NU'; provinces['CA'][8] = 'ON'; provinces['CA'][9] = 'PE'; provinces['CA'][10] = 'QC'; provinces['CA'][11] = 'SK'; provinces['CA'][12] = 'YT';  
provinces['US'] = new Array(51); provinces['US'][0] = 'AL'; provinces['US'][1] = 'AK'; provinces['US'][2] = 'AZ'; provinces['US'][3] = 'AR'; provinces['US'][4] = 'CA'; provinces['US'][5] = 'CO'; provinces['US'][6] = 'CT'; provinces['US'][7] = 'DE'; provinces['US'][8] = 'DC'; provinces['US'][9] = 'FL'; provinces['US'][10] = 'GA'; provinces['US'][11] = 'HI'; provinces['US'][12] = 'ID'; provinces['US'][13] = 'IL'; provinces['US'][14] = 'IN'; provinces['US'][15] = 'IA'; provinces['US'][16] = 'KS'; provinces['US'][17] = 'KY'; provinces['US'][18] = 'LA'; provinces['US'][19] = 'ME'; provinces['US'][20] = 'MD'; provinces['US'][21] = 'MA'; provinces['US'][22] = 'MI'; provinces['US'][23] = 'MN'; provinces['US'][24] = 'MS'; provinces['US'][25] = 'MO'; provinces['US'][26] = 'MT'; provinces['US'][27] = 'NE'; provinces['US'][28] = 'NV'; provinces['US'][29] = 'NH'; provinces['US'][30] = 'NJ'; 
provinces['US'][31] = 'NM'; provinces['US'][32] = 'NY'; provinces['US'][33] = 'NC'; provinces['US'][34] = 'ND'; provinces['US'][35] = 'OH'; provinces['US'][36] = 'OK'; provinces['US'][37] = 'OR'; provinces['US'][38] = 'PA'; provinces['US'][39] = 'RI'; provinces['US'][40] = 'SC'; provinces['US'][41] = 'SD'; provinces['US'][42] = 'TN'; provinces['US'][43] = 'TX'; provinces['US'][44] = 'UT'; provinces['US'][45] = 'VT'; provinces['US'][46] = 'VA'; provinces['US'][47] = 'WA'; provinces['US'][48] = 'WV'; provinces['US'][49] = 'WI'; provinces['US'][50] = 'WY';  
var countries = new Array(2); countries[countries.length]='CA'; countries[countries.length]='US';

function formatPhone(tf)
{
  var num = tf.value.trim();
  if(isNaN(num))
  	return;
  
  if(num.length == 7)
  { 
        var st = num.substring(0,3);
        _return=st+"-";
        var end = num.substring(3,7);
        _return+=end;
        tf.value = _return;
  } 
  else if(num.length == 10)
  { 
        var ini = num.substring(0,3);
        _return="("+ini+") ";
        var st = num.substring(3,6);
        _return+=st+"-";
        var end = num.substring(6,10);
        _return+=end;
        tf.value = _return;
  }
  else if(num.length == 11)
  { 
    var pre = num.substring(0,1);
        _return=pre;
        var ini = num.substring(1,4);
        _return+="("+ini+") ";
        var st = num.substring(4,7);
        _return+=st+"-";
        var end = num.substring(7,11);
        _return+=end;
        tf.value = _return;
  }
}

function formatZip(tf)
{
    var zip = tf.value.trim().toUpperCase();
  
  if(zip.length == 6)
  {
        var st = zip.substring(0,3);
        _return=st+" ";
        var end = zip.substring(3,6);
        _return+=end;
        tf.value = _return;
  }
  else //if(zip.length == 7)
  { 
        tf.value = zip;
  } 
}  
function setFieldsEvents(){
	var inputs= document.getElementsByTagName('INPUT');
	var i;
	var elem;    
	for(i=0; i < inputs.length; i++)
	{
	       elem = inputs.item(i);
	       if( elem.type == "text"){
               //Vefication importante, puisque certain champs on comme valeur textfield_i (Section Suite)            
	           if(elem.className.length <= 0 ){
                   elem.className="textfield";           
	               if(elem.onfocus == null)
	                     elem.onfocus=function() {this.className='textfield_selected'};                              
	               if(elem.onblur == null)
	                   elem.onblur=function() {this.className='textfield'};   
               }                
	       }
	}
}

var hideWaitingTimeout;
function showWaiting(parentElt,msgWaiting,isTimeout)
{
var wDiv ;
if(!document.getElementById('pleaseWait') || document.getElementById('pleaseWait') == null)
	wDiv = document.createElement('DIV');
else
{
	wDiv = document.getElementById('pleaseWait');
	if(wDiv.style.display == 'block')
	 	return;
}
wDiv.id='pleaseWait' 
wDiv.style.position='absolute';
wDiv.style.left='0px';
wDiv.style.top='0px';
wDiv.style.zIndex='10';
wDiv.style.display='block';
wDiv.style.width='100%';
wDiv.style.height='100%';
wDiv.innerHTML = '<table style="cursor:wait" width="100%" height="100%" cellpadding="0" cellspacing="0" onclick="window.event.cancelBubble=true; '+
'return false;"><tr><td valign="middle" align="center"><table id="pleaseWaitTable" style="background-color:#E3EFF9;color:#003366; border:1px solid #003366" '+
'cellpadding="10" cellspacing="0" width="350"><tr>'+
'<td height="100%" valign="middle" align="center" style="padding-top:20px">' +
msgWaiting + '</td></tr><tr><td valign="middle" align="center" style="padding-bottom:20px">'+
'<img border="0" src="/centris/images/indicator_blue.gif"/></td></tr></table></td></tr></table>';

if(!document.getElementById('pleaseWait') || document.getElementById('pleaseWait') == null)
	parentElt.appendChild(wDiv);

hideShowCovered(document.getElementById('pleaseWaitTable'));
if(typeof(hideWaitingTimeout)!='undefined')
	clearTimeout(hideWaitingTimeout);
if( isTimeout )
	hideWaitingTimeout = setTimeout('hideWaiting()', 10000);
}
function hideWaiting()
{
var wDiv ;
if(!document.getElementById('pleaseWait') || document.getElementById('pleaseWait') == null)
	{ return;}
wDiv = document.getElementById('pleaseWait');
wDiv.style.display='none';
hideShowCovered(document.getElementById('pleaseWaitTable'));
}

function getAbsolutePos(el) 
{  
  var SL = 0, ST = 0;  
//  var is_div = /^div$/i.test(el.tagName);  
  if (el.scrollLeft)
  	SL = el.scrollLeft; 
  if ( el.scrollTop) 
  	ST = el.scrollTop;  
  var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
  if (el.offsetParent) 
  {  
  	var tmp = getAbsolutePos(el.offsetParent); 
  	r.x += tmp.x;  
  	r.y += tmp.y; 
  } 
  return r; 
};


function hideShowAll(srcMenu) { 
    var self = this; 
    function getVisib(obj){   
        var value = obj.style.visibility; 
        if (!value) {
            if (obj.currentStyle) { 
                value = obj.currentStyle.visibility;}
           else value = ''; }
        return value;
    };
    var tags = new Array("applet",  "select"); 
    var el = srcMenu; 
    for (var k = tags.length; k > 0; ) {
        var ar = document.getElementsByTagName(tags[--k]); 
        var cc = null;
        for (var i = ar.length; i > 0;) { 
            cc = ar[--i];
            if (srcMenu.style.visibility=='hidden') {
                if (!cc.__msh_save_visibility) {
                    cc.__msh_save_visibility = getVisib(cc);}
                cc.style.visibility = cc.__msh_save_visibility;
            } 
            else {
                if (!cc.__msh_save_visibility) {
                    cc.__msh_save_visibility = getVisib(cc);}
                cc.style.visibility = "hidden"; 
            } 
        } 
    } 
};
function hideShowCovered(srcMenu) { 
    var self = this; 
    function getVisib(obj){   
        var value = obj.style.visibility; 
        if (!value) {
            if (obj.currentStyle) { 
                value = obj.currentStyle.visibility;}
           else value = ''; }
        return value;
    };
    var tags = new Array('applet',  'select'); 
    var el = srcMenu; 
    var p = getAbsolutePos(srcMenu); 
    var EX1 = p.x;
    var EX2 = el.offsetWidth + EX1; 
    var EY1 = p.y; 
    var EY2 = el.offsetHeight + EY1; 
    for (var k = tags.length; k > 0; ) {
        var ar = document.getElementsByTagName(tags[--k]); 
        var cc = null;
        for (var i = ar.length; i > 0;) { 
            cc = ar[--i];
            p = getAbsolutePos(cc); 
            var CX1 = p.x; 
            var CX2 = cc.offsetWidth + CX1;
            var CY1 = p.y; 
            var CY2 = cc.offsetHeight + CY1;
            if (srcMenu.style.visibility=='hidden' || (EX1 == EX2 && EY1 == EY2)  || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
                if (!cc.__msh_save_visibility) {
                    cc.__msh_save_visibility = getVisib(cc);}
                cc.style.visibility = cc.__msh_save_visibility;
            } 
            else {
                if (!cc.__msh_save_visibility) {
                    cc.__msh_save_visibility = getVisib(cc);}
                cc.style.visibility='hidden'; 
            } 
        } 
    } 
};

function addToFavorite(url, description) 
{
if(window.external)	window.external.AddFavorite(url, description);
}

function createCookie(name,value,days,path) 
{
	var expires = "";
	if (days) 
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+escape(value)+expires+ "; path="+(path!=null?path:"/");
}

function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split('; ');
	for (var i=0; i < ca.length; i++)
	  {
	    var aCrumb = ca[i].split("=");
	    if (name == aCrumb[0]) 
	      return unescape(aCrumb[1]);
	  }

	return null;
}
function eraseCookie(name) 
{
	createCookie(name,"",-1,null);
}

var gmap;
//Google maps script must be included before utils.js
//To set before call:
//var gmapParentName
//var gmapLinkName
//var gmapLinkUrl
//var gmapAddress
//var gmapMarkerTitle	#Optional, address will be taken instead
function loadMap() {
try {
  if (GBrowserIsCompatible()) 
  {
  	if (!(gmapParentName && gmapLinkName && gmapLinkUrl && gmapAddress))
  	{
  		alert("gmapParentName or gmapLinkName or gmapLinkUrl or gmapAddress not set.");
  		return;
  	}
  	else if (!document.getElementById(gmapParentName))
  	{
  		alert("Element '"+gmapParentName+"' does not exist.");
  		return;
  	}
  	else if (!document.getElementById(gmapLinkName))
  	{
  		alert("Link '"+gmapLinkName+"' does not exist.");
  		return;
  	}
  
    gmap = new GMap2(document.getElementById(gmapParentName), {size:new GSize(275,200),mapTypes:[G_NORMAL_MAP]});
    gmap.addControl(new GSmallZoomControl());
    //gmap.addControl(new GScaleControl());
    
    var icon = new GIcon();
    icon.image = "/prospects/images/icomap.png";
    icon.iconSize = new GSize(24, 30);
    icon.iconAnchor = new GPoint(11, 30);
    icon.infoWindowAnchor = new GPoint(12, -5);
    
    var geocoder = new GClientGeocoder();
   	geocoder.getLatLng(gmapAddress,
			function(point) 
			{ 
				if (!point) 
				{ 
					document.getElementById(gmapLinkName).onclick=null;
					document.getElementById(gmapLinkName).href=gmapLinkUrl;
					document.getElementById(gmapLinkName).target='_blank';
				} 
				else 
				{ 
					gmap.setCenter(point, 15);
					var opt = {title:(gmapMarkerTitle?gmapMarkerTitle:gmapAddress),clickable:false,icon:icon};
					var marker = new GMarker(point, opt); 
					gmap.addOverlay(marker);        
				} 
			}  );
  }
}
catch(gExc) { 
  	document.getElementById(gmapLinkName).onclick=null;
	document.getElementById(gmapLinkName).href=gmapLinkUrl;
	document.getElementById(gmapLinkName).target='_blank';
}
}
