/**
 * refreshes the cam snap shots
 * these are <img> with 'cam_img' ids
 */

var refreshInterval = 0;
var refreshMidInterval2 = 0;

$(document).ready(function(){
	if(currentpage!="fpchat" && currentpage!="hcChat" && currentpage!="cams_iframe")
	{
		refreshInterval = setInterval("refreshImages()", 60*1000);
		setTimeout("stopRefreshImages()", 20*60*1000);
	}
	if(currentpage!="hcChat")
	{
		refreshMidInterval2 = setInterval("refreshMidImages2()", 6*1000);
		if(currentpage!="fpchat")
		{
			setTimeout("stopRefreshImages()", 20*60*1000);
		}
	}
});
/**
 * refresh latest jpg cam snapshot
 */
function refreshImages() {
    //alert('refreshImages');
    // lets create a random seed to defeat image cache
    var tmp = new Date();
    tmp = "?"+tmp.getTime();

    // jquery to refresh images
    $(".thumbnail").each(function (i) {
		this.onerror = function() {
		this.src='http://img.6-chats.com/gallery/no_picture_available.jpg';
		}
        this.src = this.src + tmp;
    });

}

/**
 * stop the refresh
 */
function stopRefreshImages() {
    //alert('stopRefreshImages');
    clearInterval( refreshInterval );
    location.reload(true);
}




/**
 * refresh latest jpg cam snapshot
 */
function refreshMidImages2() {

    var tmp = new Date();
    tmp = "?"+tmp.getTime();

	$(".thumbnail_middle").each(function (i) {
		this.onerror = function() {
		this.style.display = "None";
		}
        this.src = this.src + tmp;
		
    });
}

/**
 * stop the refresh
 */
function stopRefreshMidImages2() {
    //alert('stopRefreshImages');
    clearInterval( refreshMidInterval2 );
    location.reload(true);
}
