﻿/* **** CUSTOM MAPPING CODE **** */
Map_PointIconSet.prototype.SetType = function(strPointType)
{
    if(strPointType.indexOf('GROUP') > -1)
    {
        this.iconImage = '/images/mapping/Default_ClusterPin.gif';
        this.iconImageShadow = ''; //'/images/mapping/Default_ClusterPin_Shadow.gif';
        //this.pushpinWidth = 35;
        //this.pushpinHeight = 40;
        this.pushpinWidth = 21;
        this.pushpinHeight = 21;
        this.tooltipClassName = 'Map_Green_ToolTip';
        this.isGrouping = true;
        this.pushPinOrientation = 'Center';
    }
    else if(strPointType.indexOf('PROPERTY_IDX') > -1)
    {
        this.iconImage = '/images/mapping/Blue_Pin.gif';
        this.iconImageShadow = '/images/mapping/Blue_Pin_Shadow.gif';
        this.pushpinWidth = 15;
        this.pushpinHeight = 20;
        this.tooltipClassName = 'Map_Blue_ToolTip';
        this.isGrouping = false;
        this.pushPinOrientation = 'BottomMiddle';
    }
    else if(strPointType.indexOf('PROPERTY_EMERALD') > -1)
    {
        this.iconImage = '/images/mapping/Yellow_Pin.gif';
        this.iconImageShadow = '/images/mapping/Yellow_Pin_Shadow.gif';
        this.pushpinWidth = 15;
        this.pushpinHeight = 20;
        this.tooltipClassName = 'Map_Yellow_ToolTip';
        this.isGrouping = false;
        this.pushPinOrientation = 'BottomMiddle';
    }
    else if(strPointType.indexOf('PROPERTY_OPENHOUSE') > -1)
    {
        this.iconImage = '/images/mapping/Red_Pin.gif';
        this.iconImageShadow = '/images/mapping/Red_Pin_Shadow.gif';
        this.pushpinWidth = 15;
        this.pushpinHeight = 20;
        this.tooltipClassName = 'Map_Red_ToolTip';
        this.isGrouping = false;
        this.pushPinOrientation = 'BottomMiddle';
    }
    else if(strPointType.indexOf('PROPERTY_GREENRIDGE') > -1)
    {
        this.iconImage = '/images/mapping/Default_Pin.gif';
        this.iconImageShadow = '/images/mapping/Default_Pin_Shadow.gif';
        this.pushpinWidth = 15;
        this.pushpinHeight = 20;
        this.tooltipClassName = 'Map_Green_ToolTip';
        this.isGrouping = false;
        this.pushPinOrientation = 'BottomMiddle';
    }
    else //DEFAULT
    {
        this.iconImage = '/images/mapping/Default_Pin.gif';
        this.iconImageShadow = '/images/mapping/Default_Pin_Shadow.gif';
        this.pushpinWidth = 15;
        this.pushpinHeight = 20;
        this.tooltipClassName = 'Map_Green_ToolTip';
        this.isGrouping = false;
        this.pushPinOrientation = 'BottomMiddle';
    }
};





/* This function is used in the /_include/mapping/MapDetail_PropertyRequestInfo.asp */
function submitMapRequestInfo()
{
    
    var frm = document.getElementById("frmMapRequestInfo");
	var msg = '';
	
	if (!validateTextBox(frm.FIRSTNAME) || !validateTextBox(frm.LASTNAME)){msg=msg+'First and Last Name\n';}
	if (!validateEmail(frm.mailfrom)){msg=msg+'Valid E-Mail Address\n';}
	if (!validateTextBox(frm.COMMENTS)){msg=msg+'Comments\n';}
	
	if (msg != '')
	{
        msg = 'Error: The following field(s) are required.\n\n' + msg + '\n';
		alert(msg);
		return false;
	}
	else
	{
	    
	    
	    ///Submit the form
		var strParameters = '';
        var elem = frm.elements;
        var strVal='';
        for(var i = 0; i < elem.length; i++){
            if(elem[i].name.length != 0){
                strVal = elem[i].value;
                strVal = strVal.replace(/[%]/g, '%25');
                strVal = strVal.replace(/[?]/g, '%3F');
                strVal = strVal.replace(/[&]/g, '%26');
                if(strParameters.length > 0){
                    strParameters += '&';
                }
                strParameters += elem[i].name + '=' + strVal;
            }
        }
        var url = frm.action;
        var myRequest = GetXmlHttp();
	    myRequest.onreadystatechange = function(){if (myRequest.readyState == 4){if (myRequest.status == 200){document.getElementById('Map_Detail_IFrame').innerHTML = myRequest.responseText;}else{alert('There was a problem with the request.');}}};
        myRequest.open('POST', url, true);
        myRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        myRequest.setRequestHeader("Content-length", strParameters.length);
        myRequest.send(strParameters);
	    return false;
	}
}

/* ***************************************** */
/* **** NO NEED TO EDIT BELOW THIS LINE **** */

var SlideShow_IntervalID = 0;
var SlideShow_MaxPic = 0;
var SlideShow_Count = 1;

function NextSlideShow()
{
    SlideShow_Count++;
    if(SlideShow_Count > SlideShow_MaxPic){SlideShow_Count = 1;}
    LoadSlideShow();
}

function PrevSlideShow()
{
    SlideShow_Count--;
    if(SlideShow_Count==0){SlideShow_Count = SlideShow_MaxPic;}
    LoadSlideShow();
}

function LoadSlideShow()
{
    if(document.all)
    {
        document.getElementById('p').style.filter='blendTrans(duration=2)';
        document.getElementById('p').style.filter='blendTrans(duration=crossFadeDuration)';
        document.getElementById('p').filters.blendTrans.Apply();
    }
    eval("document.getElementById('p').src=p" + SlideShow_Count + ".src;");
    if(document.all)
    {
        document.getElementById('p').filters.blendTrans.Play();
    }
}

function StopSlideShow()
{
    document.getElementById("slidebutton").value='Stop';
    clearInterval(SlideShow_IntervalID);
    SetPlayPauseButtonImage();
}

function PlayPauseSlideShow()
{
    if(document.getElementById("slidebutton").value=='Play')
    {
        StopSlideShow();
    }
    else
    {
        document.getElementById("slidebutton").value = 'Play';
        startPix();
    }
    SetPlayPauseButtonImage();
}

function SetPlayPauseButtonImage()
{
    if(document.getElementById("slidebutton").value=='Play')
    {
        document.getElementById('photoPlayMiniButton').src = '/images/photoPauseMini.gif';
    }
    else
    {
        document.getElementById('photoPlayMiniButton').src = '/images/photoPlayMini.gif';
    }
}

function startPix()
{
    var rotate_delay=4000;/*delay in milliseconds (3000 = 3 secs)*/
    if(SlideShow_IntervalID != 0)
    {
        clearInterval(SlideShow_IntervalID);
    }
    SlideShow_IntervalID = setInterval("slideshow()", rotate_delay);
}

function slideshow()
{
    try
    {
        if(document.getElementById("slidebutton").value=="Play")
        {
            NextSlideShow();
        }
    }
    catch(e)
    {
        if(SlideShow_IntervalID != 0)
        {
            clearInterval(SlideShow_IntervalID);
        }
    }
}
