var THEME = 'purple';

window.onerror = null;

theMonths = new Array();
theMonths[1] = 'ינואר';
theMonths[2] = 'פברואר';
theMonths[3] = 'מרץ';
theMonths[4] = 'אפריל';
theMonths[5] = 'מאי';
theMonths[6] = 'יוני';
theMonths[7] = 'יולי';
theMonths[8] = 'אוגוסט';
theMonths[9] = 'ספטמבר';
theMonths[10] = 'אוקטובר';
theMonths[11] = 'נובמבר';
theMonths[12] = 'דצמבר';

function openPhotoPreviewWin(photoCaption, photoFile) {
	prvWin = window.open('imgPrv.asp?c=' + photoCaption + '&f=' + photoFile, 'CMpreview', 'left=100,top=100,width=150,height=70,location=no,resizable=no,toolbar=no,status=no')
}

function navigateToSelectVal(elmSelect) {
	newUrl = elmSelect.options[elmSelect.selectedIndex].value;
	if (newUrl != '') location.href = newUrl;
}

function showSubscribe() {
	subWin = window.open('subscribe.html', 'Subscribe', 'left=300,top=300,width=300,height=200,location=no,resizable=no,toolbar=no,status=no')
	if (subWin != null) subWin.focus();
}

function showTalkback(title, url) {
	subWin = window.open('talkback.html?title=' + escape(title) + '&url=' + escape(url), 'Talkback', 'left=100,top=100,width=500,height=420,location=no,resizable=no,toolbar=no,status=no');
	if (subWin != null) subWin.focus();
}

function showRssMsg() {
	subWin = window.open('rsspopup.html', 'RSS', 'left=200,top=200,width=400,height=200,location=no,resizable=no,toolbar=no,status=no')
	if (subWin != null) subWin.focus();
}

function displayTalkbackLink(title, url) {
	document.write('<div style="font-size: 10px; float: left;">');
	document.write('<a href="javascript:showTalkback(\'' + title + '\',\'' + url + '\')" onMouseOver="window.status=\'שלח תגובה\';return true;" onMouseOut="window.status=\'\';return true;">שלח תגובה</a>');
	document.write('</div>');
}

function addToArray(arrName, newItem) {
	eval('tst = (typeof(' + arrName + ') == "undefined")');
	if (tst) {
		nl = 0;
		eval(arrName + ' = new Array');
	}
	eval('nl = ' + arrName + '.length');
	eval(arrName + '[' + nl + '] = newItem');
}

function itemExistsInArray(arrName, itemValue) {
	eval('tst = (typeof(' + arrName + ') == "undefined")');
	if (tst) return -1; // array does not exist	
	eval('len = ' + arrName + '.length');
	for (var i = 0; i < len; i++) {
		eval('tst = (' + arrName + '[' + i + '] == itemValue)');
		if (tst) return i;
	}
	return -1;
}

function convertHebMonth(hebFormat) {
	theYear = hebFormat.substr(hebFormat.indexOf(' ') + 1);
	theMonth = hebFormat.substr(0, hebFormat.indexOf(' '));
	theMonth = itemExistsInArray('theMonths', theMonth);
	if (String(theMonth).length == 1) theMonth = '0' + theMonth;
	rc = theYear + theMonth;
	return rc;
}

function convertShortMonth(shortFormat) {
	theYear = shortFormat.substr(0, 4);
	theMonth = shortFormat.substr(4);
	theMonth = theMonths[Number(theMonth)];
	rc = theMonth + ' ' + theYear;
	return rc;
}

function getMax(arrNums) {
	var tmpMax = arrNums[0];
	for (var i = 1; i < arrNums.length; i++) {
		if (arrNums[i] > tmpMax) tmpMax = arrNums[i];
	}
	return tmpMax;
}
