// [ghfs-dev]/includes/tools.js
// Javascript tools collection

winpops = null

function popupImage(img)
{
    if (winpops && !winpops.closed)
    {
        winpops.close();
    }
    var url = 'http://www.greenhomesforsale.com' + img;
    winpops = window.open(url, "", "scrollbars=yes,resizable=yes,width=440,height=470");
}

function rotateImage(img)
{
    if (winpops && !winpops.closed)
    {
        winpops.close();
    }
    var curr = Thumbs[img];
    var url = './' + curr;

        winpops = window.open("", "", "scrollbars=yes,resizable=yes,width=440,height=470");
        winpops.document.write("<html><head><link href=\"styles/standard.css\" rel=\"stylesheet\" type=\"text/css\"><SCRIPT language=javascript>\nThumbs = new Array()\n")
        for(i = 0; i < Thumbs.length; i++)
    winpops.document.write("Thumbs["+i+"] = \""+ Thumbs[i] + "\"\n");
        winpops.document.write("imgCtC = Thumbs.length-1\nthatPic = "+img+"\nfunction rotate()\n{\nif (thatPic == imgCtC)\n{\nthatPic = 0\n}\nelse\n{\nthatPic++\n}\ndocument.C.src= Thumbs[thatPic]\n} \nfunction back()\n{\nif (thatPic == 0)\n{\nthatPic = imgCtC\n}\nelse\n{\nthatPic--\n}\ndocument.C.src=\'http://greenhomesforsale.com\' + Thumbs[thatPic]\n}\n</SCRIPT></head><body>\n<div style=\"height: 410; border-bottom: solid 1px #3a8e87\" align=\"center\"><img src="+url+" name=\"C\"></div><BR>\n<table width=100% cellspacing=0 cellpadding=0><tr><td width=100><a href=javascript:back()><B>Back</B></a></td>\n<td width=200 align=\"center\"><a href=javascript:close()>Close Window</a></td>\n<td width=100 align=\"right\"><a href=javascript:rotate()><B>Next</B></a></td></tr></table>\n</body>\n</html>");
}

function deletePhotos()
{
    var del = document.getElementById("current");
    var the = 'these';
    var photo = 'photos';
    var j   = 0;
    var k   = '';
    nums = new Array();
    nums[1] = 'one';
    nums[2] = 'two';
    nums[3] = 'three';
    nums[4] = 'four';
    nums[5] = 'five';
    nums[6] = 'six';
    nums[7] = 'seven';
    nums[8] = 'eight';

    // loop through all elements
    for (i=0; i<del.length; i++)
    {
        // Look for our checkboxes only
        if (del.elements[i].name.indexOf("delete[]") !=-1)
        {
            // If any are checked then confirm alert, otherwise nothing happens
            if(del.elements[i].checked)
            {
                j++;
                //return confirm ('Are you sure you want to delete your selection(s)?')
            }
        }
    } 

    if (j == 0)
    {
        alert('No photos selected for deletion');
        return false;
    }
    if (j == 1)
    {
        the = 'this'; 
        photo = 'photo';
    }
    if (j > 0 && j < 9)
    {
        k = nums[j];
    }
    else
    {
        k = j;
    } 

    var is_confirmed = confirm('Are you sure you want to delete ' + the + 
                               ' ' + k + ' ' + photo + '?\n');
    return is_confirmed; 
}

