preload = function() {
	preload_image_object = new Image();

	// set image url
	image_url = new Array();
	image_url[0] = "xxx.jpg";
	image_url[1] = "xxx.jpg";
	image_url[2] = "xxx.jpg";

	var i = 0;
	for(i=0; i<=30; i++)
	 preload_image_object.src = image_url[i];
}

toggle = function( room , index ) {
	var pic = new Image();
	pic.src = '../img/photo/'+room+'_'+index+'.jpg';

	if ( !isImageOk(pic.src) ) {
		document.getElementById('bigImage').style.display = 'block';
		document.getElementById('bigImage').src = pic.src;
	} else {
		document.getElementById('bigImage').style.display = 'none';
	}
}

function isImageOk(img) {
    // During the onload event, IE correctly identifies any images
    // that weren't downloaded as not complete. Others should too.
    // Gecko-based browsers act like NS4 in that they report this
    // incorrectly: they always return true.
    if (!img.complete) {
        return false;
    }

    // However, they do have two very useful properties: naturalWidth
    // and naturalHeight. These give the true size of the image. If
    // it failed to load, either of these should be zero.
    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
}

/**********************************************
       DETECTING CLIENT'S BROWSER NAME
**********************************************/
var detect = navigator.userAgent.toLowerCase();
var os_ = navigator.platform.toLowerCase();
var browser,thestring;

if (checkIt('safari')) browser = "Safari"
else browser = "not Safari"

if ( os_ == 'macppc' ) os = "Mac"
else os = "not Mac"

if ( os_ == 'macppc' && checkIt('firefox')) os = "FF/Mac"

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

window.onload = preload;
