var currContentId;
var cnt = 0;
var maxZ = 100;
var theLetters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*&#$@%';
var currLetters = new Array();
imgPreLoad = new Image();
imgPreLoad.src = 'images/folder-dark.gif';

function menuSquaresOver(linkElm, toolTipText, statusLineText) {
	showToolTip(linkElm, toolTipText);
	window.status = statusLineText;
}

function menuSquaresOut() {
	hideToolTip();
	window.status='';return true;
}

function showToolTip(linkElm, toolTipText) {
	toolTipElm = getElm('toolTip');
	toolTipElm.style.position = 'absolute';
	toolTipElm.style.left = '28';
	toolTipElm.style.top = getPosition(linkElm)[1];
	getElm('toolTipTxt').innerHTML = toolTipText;
	toolTipElm.style.visibility = 'visible';
	toolTipElm.style.display = 'inline';
}

function hideToolTip() {
	getElm('toolTip').style.visibility = 'hidden';
	getElm('toolTip').style.display = 'none';
}

function rollOverMenuSquares(objPic, direction) {
	if (direction == 'in') {
		objPic.src = imgPreLoad.src;
		getElm('preview').innerText = objPic.alt;
		return true;
	} else {
		objPic.src = 'images/folder.gif';
		getElm('preview').innerText = '';
		return true;
	}	
}

function openStoryWin(storyFile) {
	storyWin = window.open('stories/' + storyFile, 'StoryPreview', 'left=100,top=50,width=600,height=500,location=no,resizable=no,toolbar=no,status=no,scrollbars=yes')
	storyWin.focus();
}

function openPhotoPreviewWin(photoCaption, photoFile) {
	prvWin = window.open('/me-etc/imgPrv.html?' + photoCaption + '&' + photoFile, 'preview', 'left=100,top=100,width=150,height=70,location=no,resizable=no,toolbar=no,status=no')
}

function showContent(id) {
	//getElm('aboutDiv').innerHTML = '';
	//hide('aboutDiv');
	//getElm('CvDiv').innerHTML = '';
	//hide('CvDiv');
	currContentId = id;
	var divHeight = 250 //default for small screens
	if (screen.height > 700) divHeight = 350;
	enlargeFm(500, divHeight);
	getElm('fm').style.background = '#cacaca';
	getElm('fm').style.zIndex = 250;
}

function enlargeFm(maxW, maxH) {
	getElm('fmc').innerHTML = '';
	getElm('fm').style.display = 'inline';
	getElm('fm').style.width = '1';
	getElm('fm').style.height = '1';
	resizeDiv('fm', maxW, maxH, 40, 'afterEnlargeFm()');
}

function afterEnlargeFm() {
	getElm('fmc').innerHTML = getElm('fmc' + currContentId).innerHTML;
}

function hideFm(afterCmd, nextUrl) {
	if (typeof(afterCmd) == 'undefined') afterCmd = '';
	if (typeof(nextUrl) != 'undefined') {
		afterCmd = 'location.href="' + nextUrl + '"';
	} else {
		afterCmd = 'tmx=setTimeout("' + afterCmd + '",300)';
	}
	if (getElm('fmc').innerHTML != '') {
		getElm('fmc').innerHTML = '';
		fade('getElm("fm").style.background', '#e8e8e8', '#cccccc', 'getElm("fm").style.display="none";' + afterCmd);
	} else {
		eval(afterCmd);
	}
}

var aboutDivId = '';
var aboutInnerDivId = '';
function showAbout(divId, innerDivId, maxHeight) {
	if (aboutDivId != '') return;
	aboutDivId = divId;
	aboutInnerDivId = innerDivId;
	AboutDivElm = getElm(divId);
	AboutDivElm.style.zIndex = ++maxZ;
	AboutDivElm.style.width = '600px';
	AboutDivElm.style.height = '0px';
	fade('getElm("' + divId + '").style.background', '#c8c8c8', '#e8e8e8');
	resizeDiv(divId, 600, maxHeight, 20, 'afterShowAbout()');
	AboutDivElm.style.visibility = 'visible';
	AboutDivElm.style.display = 'inline';
}

function afterShowAbout() {
	if (getElm(aboutDivId).innerHTML == '') {
		getElm(aboutDivId).innerHTML = getElm(aboutInnerDivId).innerHTML;
	}
	aboutDivId = '';
	aboutInnerDivId = '';
}

function displayHebAbout() {
	fade('getElm("aboutDiv").style.background', '#c8c8c8', '#e8e8e8');
	getElm('aboutDiv').innerHTML = getElm('aboutDivInnerHe').innerHTML;
}

function displayEnAbout() {
	fade('getElm("aboutDiv").style.background', '#c8c8c8', '#e8e8e8');
	getElm('aboutDiv').innerHTML = getElm('aboutDivInnerEn').innerHTML;
}

function hideAbout(divId) {
	if (aboutDivId != '') return;
	aboutDivId = divId;
	AboutDivElm = getElm(divId);
	AboutDivElm.innerHTML = '';
	fade('getElm("' + divId + '").style.background', '#e8e8e8', '#b0b0b0');
	resizeDiv(divId, 600, 10, -10, 'afterHideAbout()');
}

function afterHideAbout() {
	AboutDivElm = getElm(aboutDivId);
	AboutDivElm.style.visibility = 'hidden';
	AboutDivElm.style.display = 'none';
	aboutDivId = '';
}

function writeEmailLink(strCaption) {
	if (typeof(strCaption) == 'undefined') strCaption = 'Contact';
	document.write('<a href="mailto:rgord' + 'on@ma' + 'il.co.il" xonMouseOver="window.status=\'Contact me\';return true;" xonMouseOut="window.status=\'\';return true;">' + strCaption + '</a>');
}

function beforeUnloadPage() {
	//not working due to timing!
	if (getElm('fm').style.display != 'inline') {
		hideFm();
	}
}


