var playState = "playing";
var slideShowTimer = 0;
var slideShowCounter = -1;
var blendDuration = 2;
var desiredWidth = 440;
var desiredHeight = 340;

var holderWidth = 440;
var holderHeight = 340;
        var locations = new Array();
        var slideShowSpeed = 1000;
        var crossFadeDuration = 1;
        var slideArray = new Array();

function toggleSlideShow(){
	if (playState == "paused")
    {
		clearTimeout(slideShowTimer);
		slideShowTimer = setTimeout('runSlideShow()', 1);
	}
    else
    {
		
		playState = "paused";
		clearTimeout(slideShowTimer);
	}
}
   



function loadThese()
        {
        
fill_location('PROVINCE', 1, 0);            loadMoreField();
            startSlidesProp();
        }
        
        function loadMoreField()
        {
            if (document.edit && document.edit.list_room_details)
            {
                var roomFieldArray = new Array();
                var fieldArray;
                var interest_object;
                var field = document.edit.room_details_list;

                for (var i=0; i < roomFieldArray.length; i++)
                {
                    fieldArray = roomFieldArray[i].split('|');
                    field_object = new Option(fieldArray[0]);
                    field[i] = field_object;
                    field[i].value = roomFieldArray[i];
                }
            }
        }




var isWindowsIE = false;

var emailList = "";

if(navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Win") != -1 && navigator.userAgent.indexOf("Opera") == -1)
{
	if(document.all)
	{
		isWindowsIE = true;
    }
}


function fill_location(type, id, select)
{
    if (document.edit)
    {
        //alert(locations.length);
        var cList = document.edit.list_country;
        var pList = document.edit.list_province;
        var tList = document.edit.list_city;
        var aList = document.edit.list_area;

        if (type == 'PROVINCE')
        {
            //alert (pList.length);

            // Clear the drop list that already exist, so that new values could be loaded.

            while (pList.length > 1)
            {
                 pList[pList.length - 1] = null;
            }
            while (tList.length > 1)
            {
                 tList[tList.length - 1] = null;
            }
            while (aList.length > 1)
            {
                 aList[aList.length - 1] = null;
            }
        }
        else if (type == 'CITY')
        {
            // Clear the drop list that already exist, so that new values could be loaded.
            while (tList.length > 1)
            {
                 tList[tList.length - 1] = null;
            }
            while (aList.length > 1)
            {
                 aList[aList.length - 1] = null;
            }
        }
        else if (type == 'AREA')
        {
            // Clear the drop list that already exist, so that new values could be loaded.
            while (aList.length > 1)
            {
                 aList[aList.length - 1] = null;
            }
        }


        var index = 1;
        var id_array;



        for (i = 0; i < locations.length; i++)
        {
            if (id && !isInteger(id))
            {
                id_array = id.split(':');
                id = id_array[0];
            }

        }
    }
}



function runSlideShow()
{
	slideShowCounter++;
	if (slideShowCounter > (slideArray.length-1))
		slideShowCounter=0;

	if(slideArray[slideShowCounter] && slideArray[slideShowCounter].image && slideArray[slideShowCounter].image.complete)
    {
		switchImage(null);
	}

	clearTimeout(slideShowTimer);
	slideShowTimer = setTimeout('runSlideShow()', slideShowSpeed);
}


function showBig(sB)
{
	switchImage(sB);
}

function switchImage(directLink)
{
	var slideShow = document.getElementById("PropSlideShow");

	if(document.images.PropSlideShow.filters)
	{
		 document.images.PropSlideShow.style.filter="blendTrans(duration="+ blendDuration+")";
		 document.images.PropSlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		 document.images.PropSlideShow.filters.blendTrans.Apply();
	}

	if(directLink != null)
	{
		playState = "playing";
		toggleSlideShow();
		slideShowCounter = directLink;
	}

	if (!( document.images.PropSlideShow.style && document.images.PropSlideShow.style.MozOpacity == "")) {

		var slideShowLast = document.getElementById("SlideShowLast");
		slideShowLast.width = slideArray[slideShowCounter].image.width;
		slideShowLast.height = slideArray[slideShowCounter].image.height;
		slideShowLast.src = slideArray[slideShowCounter].image.src;
		slideShowLast.style.top = Math.round((holderHeight - slideShowLast.height) / 2);
		slideShowLast.style.left = Math.round((holderWidth - slideShowLast.width) / 2);

		slideShow.src = "images/clear.gif";
	}

	showSnipe();
	if(document.getElementById("photoCaption"))
		if (slideArray[slideShowCounter].url == "") {
			document.getElementById("photoCaption").innerHTML = slideArray[slideShowCounter].caption;
		} else {
			document.getElementById("photoCaption").innerHTML = slideArray[slideShowCounter].caption + "... <a href='" + slideArray[slideShowCounter].url + "'>More Details</a>";
		}
	if(document.getElementById("slideShowTitle"))
		document.getElementById("slideShowTitle").innerHTML = slideArray[slideShowCounter].title;

	if(document.images.PropSlideShow.filters)
	{
		document.images.PropSlideShow.filters.blendTrans.Play();

		mozDissTimer = setTimeout('finishIESlide()', blendDuration * 1000);
	} else if (document.images.PropSlideShow.style && document.images.PropSlideShow.style.MozOpacity == "") {
		startMozDissolve();
	}

	hideBigImage();

}



function showBigImage()
{
	var centerSlideShowX = 0;
	var centerSlideShowY = 0;

	var bigImageHolder = document.getElementById("bigImageHolder");
	var slideShow = document.getElementById("PropSlideShow");
	var slideShowHolder = document.getElementById("slideShowHolder");

	document.getElementById("bigImage").src = slideArray[slideShowCounter].bigImage;
	bigImageHolder.style.position = "absolute";

	document.getElementById("bigImage").onmouseover = function()
	{
		onHover(this);
	}
	document.getElementById("bigImage").onmouseout = function()
	{
		offHover(this);
		hideBigImage();
	}

	var centerSlideShowX = (slideShowHolder.offsetWidth) / 2;
	var centerSlideShowY = (slideShowHolder.offsetHeight) / 2;

	if(document.all)
	{
		var browseWidth = document.body.clientWidth;
		var browseHeight = document.body.clientHeight;
	}
	else
	{
		var browseWidth = window.outerWidth;
		var browseHeight = window.outerHeight;
	}
	var onBottom = Math.abs(browseHeight - (get_true_top(slideShowHolder) - ((slideShowHolder.offsetHeight) / 2)));
	var onTop = browseHeight - onBottom;

	var onRight = browseWidth - (get_true_left(slideShowHolder) - ((slideShowHolder.offsetWidth) / 2));
	var onLeft = browseWidth - onRight;

	document.getElementById("bigImage").onload = function()
	{
		if(document.all)
			bigImageHolder.style.display = "block";

		if(onTop > onBottom)
			bigImageHolder.style.top = centerSlideShowY - document.getElementById("bigImage").offsetHeight;
		else
			bigImageHolder.style.top = centerSlideShowY;

		if(onLeft > onRight)
			bigImageHolder.style.left = centerSlideShowX - document.getElementById("bigImage").offsetWidth;
		else
			bigImageHolder.style.left = centerSlideShowX;

		//bigImageHolder.style.border = "solid thin black";
		bigImageHolder.style.visibility = "visible";
		bigImageHolder.style.zIndex = 99;
	}
}



var thumbView = 'left';

function beginDelayed()
{
	clearTimeout(slideShowTimer);
	slideShowTimer = setTimeout('runSlideShow()', 600);
}

function startSlidesProp()
{
	beginDelayed();
	fixAspectRatios();
}


function clickThrough(cT) {
	clearTimeout(slideShowTimer);

	if (cT.name == "forward") {
		if (slideShowCounter >= (slideArray.length-1))
			slideShowCounter=0;
		else
			slideShowCounter++;
	}
	else if(cT.name == "back")
	{
		if (slideShowCounter == 0)
			slideShowCounter=slideArray.length-1;
		else
			slideShowCounter--;
	}
	switchImage(null);

	if (playState == "playing") {
		slideShowTimer = setTimeout('runSlideShow()', slideShowSpeed);
	}
}

