
// simulate "click" event for Anchor Element in Mozilla
/*
HTMLAnchorElement.prototype.click = function() {
   var evt = this.ownerDocument.createEvent('MouseEvents');
   evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
   this.dispatchEvent(evt);
}

HTMLAnchorElement.prototype.mouseover = function() {
   var evt = this.ownerDocument.createEvent('MouseEvents');
   evt.initMouseEvent('mouseover', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
   this.dispatchEvent(evt);
}
*/

function hideStatus(obj_name) {
	clearTimeout(this.timeout);
	//Effect.Appear(obj_name);
	setTimeout("Effect.Fade('"+obj_name+"')", 3000);
}

function deselect(selObj) {
	for (var i = 0; i < selObj.length; i++)
		selObj.options[i].selected = false;	
}




/***********************************************************************************/
var timerID = null
var timerRunning = false

var myCounter = 0

function setClock(itemName) {
	timerID = setTimeout("setClock('"+itemName+"')", 100)
	
	timerRunning = true
	myCounter++;
	
	if (myCounter==10) { // now content starts after 2 seconds mouse over
		xajax_loadPageContent(itemName);
		stopClock()
	}
}

function stopClock() {
	if (timerRunning) clearTimeout(timerID)
	myCounter = 0
	timerRunning = false
}

function update() {
	stopClock()
	setClock()
}

/********************************************/

var globalID = null;

// for image and description pages
function refresh(page) {
			/*if ($('rollOverPage').style.display!='none') { 
				Effect.BlindUp($('rollOverPage'), {duration:.3}); 
				Effect.BlindDown($('basicPage'), {queue: 'end', duration:.3})
			};*/
	
			if ($('rollOverPage').style.display=='none') {
				$('basicPage').style.display = 'none';
				$('rollOverPage').style.display = '';
			}; 
			
			$('page_image_container').innerHTML = '<img style="cursor:pointer" onclick="xajax_loadChapter(\''+page+'\', \'image\', 1)" src="img/menu_rollover/'+page+'.jpg" width="243" height="243" border="0"><br>';
			$('current_url').innerHTML = '';
}

// static page
function refresh2(page) {
			
			if ($('rollOverPage').style.display=='none') {
				Effect.BlindUp($('basicPage'), {duration:.3});
				Effect.BlindDown($('rollOverPage'), {queue:'end', duration:.3})
			}; 
			
			$('page_image_container').innerHTML = '<img style="cursor:pointer" onclick="xajax_loadPageContent(\''+page+'\')" src="img/menu_rollover/'+page+'.jpg" width="243" height="243" border="0"><br>';
			$('current_url').innerHTML = '';
}

// no content
function refresh3(page) {
			
			if ($('rollOverPage').style.display=='none') {
				Effect.BlindUp($('basicPage'), {duration:.3});
				Effect.BlindDown($('rollOverPage'), {queue:'end', duration:.3})
			}; 
			
			$('page_image_container').innerHTML = '<img  src="img/menu_rollover/'+page+'.jpg" width="243" height="243" border="0"><br>';
			$('current_url').innerHTML = '';
}

// gallery
function refresh4(page) {
            
            if ($('rollOverPage').style.display=='none') {
                Effect.BlindUp($('basicPage'), {duration:.3});
                Effect.BlindDown($('rollOverPage'), {queue:'end', duration:.3})
            }; 
            
            $('page_image_container').innerHTML = '<img style="cursor:pointer" onclick="xajax_loadGallery(\''+page+'\')" src="img/menu_rollover/'+page+'.jpg" width="243" height="243" border="0"><br>';
            $('current_url').innerHTML = '';
}

function path() {
    var url=location.href.replace(/\\/g,'/');
	return url.substring(0,url.lastIndexOf('/'));
}

function send_request(pageName) {
	return false;
}

function replaceImage(page_id, item_id, src) {
	//newImage = new Image();
	//newImage.src='img/works/'+src;
	//if (!newImage.complete) Effect.Fade($('opened_image'), {duration:.3});
	//$('basicPage').innerHTML = '<table width="820px" cellpadding="0" cellspacing="0" border="0"><tr><td height="390" width="100%" align="center" valign="top"><img src="img/loading_status.gif" border="0"><br></td></tr><table>';
	if ($('opened_image').src!=path()+"/img/works/"+src) {
		$('opened_image').src = "img/loading_status.gif";
		$('l_title').innerHTML = '&nbsp;';
		$('p_title').innerHTML = '&nbsp;';
		preloading('img/works/'+src);
		xajax_fillTitleAndImage(page_id, item_id, src);
	};
	
}   


var currentImageIndex = 0
var widthOfEachImage = 0
var totalImages = 0
var imagesPerPage = 0





