/*
 * These functions are for doing button rollovers. See the header.tag file
 * for example of how to use. Must define the image objects in the specific
 * file and the img tag needs to have the mouse event functions set to point
 * to these functions.
 */

function buttondown(buttonid, idnum) {
	if (idnum == undefined || idnum == null) {
		idnum = "";
	}
	if (document.images) {
		var iButton = document.getElementById(buttonid + idnum);
		if (iButton) {
			iButton.src = eval( buttonid + "down.src" );
		}
	}
}

function buttonup(buttonid, idnum) {
	if (idnum == undefined || idnum == null) {
		idnum = "";
	}
	if (document.images) {
		var iButton = document.getElementById(buttonid + idnum);
		if (iButton) {
			iButton.src = eval( buttonid + "up.src" );
		}
	}
}

function popup(url, name, attributes) {
    _popup(url, name, attributes,true);
}

function _popup(url, name, attributes, resize) {
    if (url.indexOf('?') != -1) {
        url += '&_popup=true';
    } else {
        url += '?_popup=true';
    }
    if (resize == true) {
        url += '&_resize=true';
    }
    p=window.open(url, name , attributes);
    if (p.opener == null) {
        p.opener = window;
    }
    if (window.focus) {
        p.focus();
    }
}

if (document.images){
	sortbuttonup      	 	= new Image();
	sortbuttonup.src		= "images/buttons/btn_sort.gif";
	sortbuttondown     		= new Image();
	sortbuttondown.src 		= "images/buttons/btn_sort_mouseover.gif";
	pagerrightup      	 	= new Image();
	pagerrightup.src		= "images/buttons/btn_right.gif";
	pagerrightdown     		= new Image();
	pagerrightdown.src 		= "images/buttons/btn_right_mouseover.gif";
	pagerleftup       		= new Image();
	pagerleftup.src  		= "images/buttons/btn_left.gif";
	pagerleftdown     		= new Image();
	pagerleftdown.src 		= "images/buttons/btn_left_mouseover.gif";
}

function updateAnySelector() {
    document.merlotForm.elements['anyKeyWords'].value = true;
    document.merlotForm.elements['allKeyWords'].value = false;
    document.merlotForm.elements['exactPhraseKeyWords'].value = false;
}

function updateAllSelector() {
    document.merlotForm.elements['anyKeyWords'].value = false;
    document.merlotForm.elements['allKeyWords'].value = true;
    document.merlotForm.elements['exactPhraseKeyWords'].value = false;
}

function updateExactSelector() {
    document.merlotForm.elements['anyKeyWords'].value = false;
    document.merlotForm.elements['allKeyWords'].value = false;
    document.merlotForm.elements['exactPhraseKeyWords'].value = true;
}

function cat(id, parentId, name) {
   this.id = id;
   this.parentId = parentId;
   this.name = name;
}

function populate(parent_cat_id, field) {
	var j=1;
	document.merlotForm.elements[field].options.length = 0;
	if (parent_cat_id == "") {
		document.merlotForm.elements[field].options[0]= new Option(cats[2].name, cats[2].id);
	} else if (parent_cat_id < 0) {
		document.merlotForm.elements[field].options[0]= new Option(cats[0].name, cats[0].id);
	} else {
		document.merlotForm.elements[field].options[0]= new Option(cats[1].name, cats[1].id);
	}
	if (parent_cat_id >= 0) {
		for (i=3; i<=cats.length-1; i++) {
			if (cats[i].parentId == parent_cat_id) {
				document.merlotForm.elements[field].options[j]= new Option(cats[i].name, cats[i].id);
				j++;
			}
		}
		if (document.merlotForm.elements[field].options.length == 1) {
			document.merlotForm.elements[field].options[0]= new Option(cats[0].name, cats[0].id);
		}
	}
	if (document.merlotForm.elements[field].options[0].value == -3) {
		document.merlotForm.elements[field].disabled = true;
	} else {
		document.merlotForm.elements[field].disabled = false;
	}
}

function populateSub(field, subfield) {
	var selectedValue;
	selectedValue = document.merlotForm.elements[field].options[document.merlotForm.elements[field].selectedIndex].value;
	if (subfield != null) {
		populate(selectedValue, subfield);
		if (document.merlotForm.elements[subfield].onchange != null) {
			document.merlotForm.elements[subfield].onchange();
		}
	}
	if (selectedValue > 0 && (subfield == null || document.merlotForm.elements[subfield].options[document.merlotForm.elements[subfield].selectedIndex].value < 0)) {
		document.merlotForm.elements['category'].value = selectedValue;
	}
}

function setCategory(value) {
	var j=0;
	var i=0;
	var z=0;
	var parentId = null;
	var catStack = new Array();
	var fieldName;

	if (value > 0) {
		for (i=0; i<=cats.length-1; i++) {
			if(cats[i].id == value) {
				catStack.push(cats[i]);
				parentId = cats[i].parentId;
				break;
			}
		}
	}
	for (j=0; j<cats.length && parentId != null; j++) {
		if(cats[j].id == parentId) {
			catStack.push(cats[j]);
			parentId = cats[j].parentId;
			j=0;
		}
	}
	j=1;
	for (i=catStack.length-1; i>=0; i--) {
		fieldName = 'cat'+j;
		populate(catStack[i].parentId, fieldName);
		var box = document.merlotForm.elements[fieldName];
		for (z = 0; z < box.options.length; z++) {
			if (box.options[z].value == catStack[i].id) {
				box.selectedIndex = z;
				break;
			}
		}
		j++;
	}
	if (catStack.length > 0) {
		fieldName = 'cat'+catStack.length;
		if (document.merlotForm.elements[fieldName].onchange != null) {
			document.merlotForm.elements[fieldName].onchange();
		}
	}
}

var Today = new Date();
var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var MonthNames = new Array('ינואר','פברואר','מרץ','אפריל','מאי','יוני','יולי','אוגוסט','ספטמבר','אוקטובר','נובמבר','דצמבר');
var curYear = Today.getFullYear();
var curMonth = Today.getMonth() + 1;
var curDay = Today.getDate();
var time = Today.getTime();
var startYear = 1997;

function setupDatePulldowns(field, inputDate, format, tabindexstart, idprefix, labelprefix){
	dateFieldFormat = format;
	monthFieldName = "month"+ field;
	dayFieldName = "day"+ field;
	yearFieldName = "year"+ field;
	currentFieldName = "current"+ field;
	if (inputDate==""){
		selectedMonth = curMonth;
		selectedDay = curDay;
		selectedYear = curYear;
	}else{
		selectedMonth = inputDate.substring(5,7);
		selectedDay = inputDate.substring(8,10);
		selectedYear = inputDate.substring(0,4);
	}
	monthLabel = "";
	if (idprefix != undefined && labelprefix != undefined) {
		monthLabel = "<label for=\"" + idprefix + "month\"><span style=\"display:none\">" + labelprefix + " Month</span></label>";
	}
	monthField = "<select name='" + monthFieldName + "' onChange=\"update('" + field + "');\"";
	if (tabindexstart != undefined && tabindexstart > 0) {
		monthField += " tabindex=\"" + tabindexstart + "\"";
		++tabindexstart;
	}
	if (idprefix != undefined) {
		monthField += " id=\"" + idprefix + "month\"";
	}
	monthField += "></select>";
	dayLabel = "";
	if (idprefix != undefined && labelprefix != undefined) {
		dayLabel = "<label for=\"" + idprefix + "day\"><span style=\"display:none\">" + labelprefix + " Day</span></label>";
	}
	dayField = "<select name='" + dayFieldName + "' onChange=\"update('" + field + "');\"";
	if (tabindexstart != undefined && tabindexstart > 0) {
		dayField += " tabindex=\"" + tabindexstart + "\"";
		++tabindexstart;
	}
	if (idprefix != undefined) {
		dayField += " id=\"" + idprefix + "day\"";
	}
	dayField += "></select>";
	yearLabel = "";
	if (idprefix != undefined && labelprefix != undefined) {
		yearLabel = "<label for=\"" + idprefix + "year\"><span style=\"display:none\">" + labelprefix + " Year</span></label>";
	}
	yearField = "<select name='" + yearFieldName + "' onChange=\"update('" + field + "');\""
	if (tabindexstart != undefined && tabindexstart > 0) {
		yearField += " tabindex=\"" + tabindexstart + "\"";
		++tabindexstart;
	}
	if (idprefix != undefined) {
		yearField += " id=\"" + idprefix + "year\"";
	}
	yearField += "></select>";
	dateFieldFormat = dateFieldFormat.replace("{M}",monthField);
	dateFieldFormat = dateFieldFormat.replace("{D}",dayField);
	dateFieldFormat = dateFieldFormat.replace("{Y}",yearField);
	document.writeln(dateFieldFormat + "<input type='hidden' name='" + field + "'>");

	for (i=0;i<=11;i++){
		document.merlotForm.elements[monthFieldName].options[i] = new Option(MonthNames[i],i+1);
	}
	if (selectedMonth>0){
		document.merlotForm.elements[monthFieldName].selectedIndex = selectedMonth-1;
	}else{
		document.merlotForm.elements[monthFieldName].selectedIndex = 0;
	}
	if (selectedMonth==2){
		if(selectedYear%4 == 0){
			pdEndDate = 29;
		}else{
			pdEndDate = 28;
		}
	}else{
		pdEndDate = MonthDays[document.merlotForm.elements[monthFieldName].selectedIndex];
	}
	for (i=0; i<= pdEndDate-1; i++){
		document.merlotForm.elements[dayFieldName].options[i] = new Option(i+1,i+1);
	}
	document.merlotForm.elements[dayFieldName].selectedIndex = selectedDay-1;
	for (i=0;i<=curYear-startYear;i++){
		document.merlotForm.elements[yearFieldName].options[i] = new Option(curYear-i,curYear-i);
	}
	document.merlotForm.elements[yearFieldName].selectedIndex = curYear-selectedYear;

	hiddenDate = "";
	hiddenDate = hiddenDate + document.merlotForm.elements[yearFieldName].options[document.merlotForm.elements[yearFieldName].selectedIndex].value;
	hiddenDate = hiddenDate + "-";
	monthIndex= document.merlotForm.elements[monthFieldName].selectedIndex + 1;
	hiddenDate = hiddenDate + monthIndex;
	hiddenDate = hiddenDate + "-";
	hiddenDate = hiddenDate + document.merlotForm.elements[dayFieldName].options[document.merlotForm.elements[dayFieldName].selectedIndex].value;
	document.merlotForm.elements[field].value= hiddenDate;
}

function update(fieldName){
	monthFieldName = "month"+ fieldName;
	dayFieldName = "day"+ fieldName;
	yearFieldName = "year"+ fieldName;
	selectedMonth = document.merlotForm.elements[monthFieldName].selectedIndex + 1;
	selectedYear = document.merlotForm.elements[yearFieldName].options[document.merlotForm.elements[yearFieldName].selectedIndex].value;
	
	selectedDay = document.merlotForm.elements[dayFieldName].selectedIndex;
	for (i=0;i<= document.merlotForm.elements[dayFieldName].length;i++){
		document.merlotForm.elements[dayFieldName].options[i] = null;
	}
	if (selectedMonth==2){
		if(selectedYear%4 == 0){
			pdEndDate = 29;
		}else{
			pdEndDate = 28;
		}
	}else{
		pdEndDate = MonthDays[document.merlotForm.elements[monthFieldName].selectedIndex];
	}
	if (selectedDay > MonthDays[document.merlotForm.elements[monthFieldName].selectedIndex]){
		selectedDay = MonthDays[document.merlotForm.elements[monthFieldName].selectedIndex];
	}
	for (i=0; i<= pdEndDate-1; i++){
		document.merlotForm.elements[dayFieldName].options[i] = new Option(i+1,i+1);
	}
	if (selectedDay > document.merlotForm.elements[dayFieldName].length -1){
		selectedDay = document.merlotForm.elements[dayFieldName].length -1;
	}
	document.merlotForm.elements[dayFieldName].selectedIndex = selectedDay;
	hiddenDate = "";
	hiddenDate = hiddenDate + document.merlotForm.elements[yearFieldName].options[document.merlotForm.elements[yearFieldName].selectedIndex].value;
	hiddenDate = hiddenDate + "-";
	monthIndex= document.merlotForm.elements[monthFieldName].selectedIndex + 1;
	hiddenDate = hiddenDate + monthIndex;
	hiddenDate = hiddenDate + "-";
	hiddenDate = hiddenDate + document.merlotForm.elements[dayFieldName].options[document.merlotForm.elements[dayFieldName].selectedIndex].value;
	document.merlotForm.elements[fieldName].value= hiddenDate;
	setRange();
}

function blankDates(){
	document.merlotForm.createdSince.value="";
	document.merlotForm.createdBefore.value="";
	document.merlotForm.monthcreatedSinceHolder.disabled=true;
	document.merlotForm.daycreatedSinceHolder.disabled=true;
	document.merlotForm.yearcreatedSinceHolder.disabled=true;
	document.merlotForm.monthcreatedBeforeHolder.disabled=true;
	document.merlotForm.daycreatedBeforeHolder.disabled=true;
	document.merlotForm.yearcreatedBeforeHolder.disabled=true;
	document.merlotForm.days.disabled=true;
}

function setDays(){
	days = document.merlotForm.days.value;
	aheadDate = new Date(Today.getTime() - days*24*60*60*1000);
	var aheadYear = aheadDate.getFullYear();
	var aheadMonth = aheadDate.getMonth() + 1;
	var aheadDay = aheadDate.getDate();
	document.merlotForm.createdSince.value=aheadYear + "-" + aheadMonth + "-" + aheadDay;
	document.merlotForm.createdBefore.value="";
	document.merlotForm.monthcreatedSinceHolder.disabled=true;
	document.merlotForm.daycreatedSinceHolder.disabled=true;
	document.merlotForm.yearcreatedSinceHolder.disabled=true;
	document.merlotForm.monthcreatedBeforeHolder.disabled=true;
	document.merlotForm.daycreatedBeforeHolder.disabled=true;
	document.merlotForm.yearcreatedBeforeHolder.disabled=true;
	document.merlotForm.days.disabled=false;
}

function setRange(){
	document.merlotForm.createdSince.value=
	document.merlotForm.createdSinceHolder.value;
	document.merlotForm.createdBefore.value=
	document.merlotForm.createdBeforeHolder.value;
	document.merlotForm.monthcreatedSinceHolder.disabled=false;
	document.merlotForm.daycreatedSinceHolder.disabled=false;
	document.merlotForm.yearcreatedSinceHolder.disabled=false;
	document.merlotForm.monthcreatedBeforeHolder.disabled=false;
	document.merlotForm.daycreatedBeforeHolder.disabled=false;
	document.merlotForm.yearcreatedBeforeHolder.disabled=false;
	document.merlotForm.days.disabled=true;
}

//WZToolTip
/* This notice must be untouched at all times.
wz_tooltip.js    v. 3.38
The latest version is available at
http://www.walterzorn.com
or http://www.devira.com
or http://www.walterzorn.de
Copyright (c) 2002-2005 Walter Zorn. All rights reserved.
Created 1. 12. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
Last modified: 9. 12. 2005
Cross-browser tooltips working even in Opera 5 and 6,
as well as in NN 4, Gecko-Browsers, IE4+, Opera 7+ and Konqueror.
No onmouseouts required.
Appearance of tooltips can be individually configured
via commands within the onmouseovers.
LICENSE: LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For more details on the GNU Lesser General Public License,
see http://www.gnu.org/copyleft/lesser.html
*/

////////////////  GLOBAL TOOPTIP CONFIGURATION  /////////////////////
var ttAbove       = false;        // tooltip above mousepointer? Alternative: true
var ttBgColor     = "#ECECEC";
var ttBgImg       = "";           // path to background image;
var ttBorderColor = "#663333";
var ttBorderWidth = 1;
var ttDelay       = 500;          // time span until tooltip shows up [milliseconds]
var ttFontColor   = "#663333";
var ttFontFace    = "arial,helvetica,sans-serif";
var ttFontSize    = "11px";
var ttFontWeight  = "normal";     // alternative: "bold";
var ttLeft        = false;        // tooltip on the left of the mouse? Alternative: true
var ttOffsetX     = 12;           // horizontal offset of left-top corner from mousepointer
var ttOffsetY     = 15;           // vertical offset                   "
var ttOpacity     = 100;          // opacity of tooltip in percent (must be integer between 0 and 100)
var ttPadding     = 3;            // spacing between border and content
var ttShadowColor = "";
var ttShadowWidth = 0;
var ttStatic      = false;        // tooltip NOT move with the mouse? Alternative: true
var ttSticky      = false;        // do NOT hide tooltip on mouseout? Alternative: true
var ttTemp        = 0;            // time span after which the tooltip disappears; 0 (zero) means "infinite timespan"
var ttTextAlign   = "right";
var ttTitleColor  = "#ffffff";    // color of caption text
var ttWidth       = 200;
////////////////////  END OF TOOLTIP CONFIG  ////////////////////////

//////////////  TAGS WITH TOOLTIP FUNCTIONALITY  ////////////////////
// List may be extended or shortened:
var tt_tags = new Array("a","area","b","big","caption","center","code","dd","div","dl","dt","em","h1","h2","h3","h4","h5","h6","i","img","input","li","map","ol","p","pre","s", "select", "small","span","strike","strong","sub","sup","table","td","th","tr","tt","u","var","ul","layer");
/////////////////////////////////////////////////////////////////////

///////// DON'T CHANGE ANYTHING BELOW THIS LINE /////////////////////
var tt_obj = null,         // current tooltip
tt_ifrm = null,            // iframe to cover windowed controls in IE
tt_objW = 0, tt_objH = 0,  // width and height of tt_obj
tt_objX = 0, tt_objY = 0,
tt_offX = 0, tt_offY = 0,
xlim = 0, ylim = 0,        // right and bottom borders of visible client area
tt_sup = false,            // true if T_ABOVE cmd
tt_sticky = false,         // tt_obj sticky?
tt_wait = false,
tt_act = false,            // tooltip visibility flag
tt_sub = false,            // true while tooltip below mousepointer
tt_u = "undefined",
tt_mf = null,              // stores previous mousemove evthandler
// Opera: disable href when hovering <a>
tt_tag = null;             // stores hovered dom node, href and previous statusbar txt

var tt_db = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body? document.body : null,
tt_n = navigator.userAgent.toLowerCase(),
tt_nv = navigator.appVersion;
// Browser flags
var tt_op = !!(window.opera && document.getElementById),
tt_op6 = tt_op && !document.defaultView,
tt_op7 = tt_op && !tt_op6,
tt_ie = tt_n.indexOf("msie") != -1 && document.all && tt_db && !tt_op,
tt_ie6 = tt_ie && parseFloat(tt_nv.substring(tt_nv.indexOf("MSIE")+5)) >= 5.5,
tt_n4 = (document.layers && typeof document.classes != tt_u),
tt_n6 = (!tt_op && document.defaultView && typeof document.defaultView.getComputedStyle != tt_u),
tt_w3c = !tt_ie && !tt_n6 && !tt_op && document.getElementById;
function tt_Int(t_x){
	var t_y;
	return isNaN(t_y = parseInt(t_x))? 0 : t_y;
}
function wzReplace(t_x, t_y){
	var t_ret = "",
	t_str = this,
	t_xI;
	while((t_xI = t_str.indexOf(t_x)) != -1){
		t_ret += t_str.substring(0, t_xI) + t_y;
		t_str = t_str.substring(t_xI + t_x.length);
	}
	return t_ret+t_str;
}
String.prototype.wzReplace = wzReplace;
function tt_N4Tags(tagtyp, t_d, t_y){
	t_d = t_d || document;
	t_y = t_y || new Array();
	var t_x = (tagtyp=="a")? t_d.links : t_d.layers;
	for(var z = t_x.length; z--;) t_y[t_y.length] = t_x[z];
	for(z = t_d.layers.length; z--;) t_y = tt_N4Tags(tagtyp, t_d.layers[z].document, t_y);
	return t_y;
}
function tt_Htm(tt, t_id, txt){
	var t_bgc = (typeof tt.T_BGCOLOR != tt_u)? tt.T_BGCOLOR : ttBgColor,
	t_bgimg   = (typeof tt.T_BGIMG != tt_u)? tt.T_BGIMG : ttBgImg,
	t_bc      = (typeof tt.T_BORDERCOLOR != tt_u)? tt.T_BORDERCOLOR : ttBorderColor,
	t_bw      = (typeof tt.T_BORDERWIDTH != tt_u)? tt.T_BORDERWIDTH : ttBorderWidth,
	t_ff      = (typeof tt.T_FONTFACE != tt_u)? tt.T_FONTFACE : ttFontFace,
	t_fc      = (typeof tt.T_FONTCOLOR != tt_u)? tt.T_FONTCOLOR : ttFontColor,
	t_fsz     = (typeof tt.T_FONTSIZE != tt_u)? tt.T_FONTSIZE : ttFontSize,
	t_fwght   = (typeof tt.T_FONTWEIGHT != tt_u)? tt.T_FONTWEIGHT : ttFontWeight,
	t_opa     = (typeof tt.T_OPACITY != tt_u)? tt.T_OPACITY : ttOpacity,
	t_padd    = (typeof tt.T_PADDING != tt_u)? tt.T_PADDING : ttPadding,
	t_shc     = (typeof tt.T_SHADOWCOLOR != tt_u)? tt.T_SHADOWCOLOR : (ttShadowColor || 0),
	t_shw     = (typeof tt.T_SHADOWWIDTH != tt_u)? tt.T_SHADOWWIDTH : (ttShadowWidth || 0),
	t_algn    = (typeof tt.T_TEXTALIGN != tt_u)? tt.T_TEXTALIGN : ttTextAlign,
	t_tit     = (typeof tt.T_TITLE != tt_u)? tt.T_TITLE : "",
	t_titc    = (typeof tt.T_TITLECOLOR != tt_u)? tt.T_TITLECOLOR : ttTitleColor,
	t_w       = (typeof tt.T_WIDTH != tt_u)? tt.T_WIDTH  : ttWidth;
	if(t_shc || t_shw){
		t_shc = t_shc || "#cccccc";
		t_shw = t_shw || 5;
	}
	if(tt_n4 && (t_fsz == "10px" || t_fsz == "11px")) t_fsz = "12px";
	var t_optx = (tt_n4? '' : tt_n6? ('-moz-opacity:'+(t_opa/100.0)) : tt_ie? ('filter:Alpha(opacity='+t_opa+')') : ('opacity:'+(t_opa/100.0))) + ';';
	var t_y = '<div id="'+t_id+'" style="position:absolute;z-index:1010;';
	t_y += 'right:0px;top:0px;width:'+(t_w+t_shw)+'px;visibility:'+(tt_n4? 'hide' : 'hidden')+';'+t_optx+'">' +
		'<table border="0" cellpadding="0" cellspacing="0"'+(t_bc? (' bgcolor="'+t_bc+'" style="background:'+t_bc+';"') : '')+' width="'+t_w+'">';
	if(t_tit){
		t_y += '<tr><td style="padding-left:3px;padding-right:3px;" align="'+t_algn+'"><font color="'+t_titc+'" face="'+t_ff+'" ' +
			'style="color:'+t_titc+';font-family:'+t_ff+';font-size:'+t_fsz+';"><b>' +
			(tt_n4? '&nbsp;' : '')+t_tit+'</b></font></td></tr>';
	}
	t_y += '<tr><td><table border="0" cellpadding="'+t_padd+'" cellspacing="'+t_bw+'" width="100%">' +
		 '<tr><td'+(t_bgc? (' bgcolor="'+t_bgc+'"') : '')+(t_bgimg? ' background="'+t_bgimg+'"' : '')+' style="text-align:'+t_algn+';';
	if(tt_n6) t_y += 'padding:'+t_padd+'px;';
	t_y += '" align="'+t_algn+'"><font color="'+t_fc+'" face="'+t_ff+'"' +
		' style="color:'+t_fc+';font-family:'+t_ff+';font-size:'+t_fsz+';font-weight:'+t_fwght+';">';
	if(t_fwght == 'bold') t_y += '<b>';
	t_y += txt;
	if(t_fwght == 'bold') t_y += '</b>';
	t_y += '</font></td></tr></table></td></tr></table>';
	if(t_shw){
		var t_spct = Math.round(t_shw*1.3);
		if(tt_n4){
			t_y += '<layer bgcolor="'+t_shc+'" right="'+t_w+'" top="'+t_spct+'" width="'+t_shw+'" height="0"></layer>' +
				'<layer bgcolor="'+t_shc+'" right="'+t_spct+'" align="bottom" width="'+(t_w-t_spct)+'" height="'+t_shw+'"></layer>';
		}else{
			t_optx = tt_n6? '-moz-opacity:0.85;' : tt_ie? 'filter:Alpha(opacity=85);' : 'opacity:0.85;';
			t_y += '<div id="'+t_id+'R" style="position:absolute;background:'+t_shc+';right:'+t_w+'px;top:'+t_spct+'px;width:'+t_shw+'px;height:1px;overflow:hidden;'+t_optx+'"></div>' +
				'<div style="position:relative;background:'+t_shc+';right:'+t_spct+'px;top:0px;width:'+(t_w-t_spct)+'px;height:'+t_shw+'px;overflow:hidden;'+t_optx+'"></div>';
		}
	}
	return(t_y+'</div>' +
		(tt_ie6 ? '<iframe id="TTiEiFrM" src="javascript:false" scrolling="no" frameborder="0" style="filter:Alpha(opacity=0);position:absolute;top:0px;right:0px;display:none;"></iframe>' : ''));
}

function tt_EvX(t_e){
	var t_y = tt_Int(t_e.pageX || t_e.clientX || 0) +
		tt_Int(tt_ie? tt_db.scrollLeft : 0) +
		tt_offX;
	if(t_y > xlim){
		t_y = xlim;
	}
	var t_scr = tt_Int(window.pageXOffset || (tt_db? tt_db.scrollLeft : 0) || 0);
	if(t_y < t_scr){
		t_y = t_scr;
	}
	return t_y;
}

function tt_EvY(t_e){
	var t_y = tt_Int(t_e.pageY || t_e.clientY || 0) +
		tt_Int(tt_ie? tt_db.scrollTop : 0);
	if(tt_sup){
		t_y -= (tt_objH + tt_offY - 15);
	}else if(t_y > ylim || !tt_sub && t_y > ylim-24){
		t_y -= (tt_objH + 5);
		tt_sub = false;
	}else{
		t_y += tt_offY;
		tt_sub = true;
	}
	return t_y;
}

function tt_ReleasMov(){
	if(document.onmousemove == tt_Move){
		if(!tt_mf && document.releaseEvents){
			document.releaseEvents(Event.MOUSEMOVE);
		}
		document.onmousemove = tt_mf;
	}
}

function tt_ShowIfrm(t_x){
	if(!tt_obj || !tt_ifrm){
		return;
	}
	if(t_x){
		tt_ifrm.style.width = tt_objW+'px';
		tt_ifrm.style.height = tt_objH+'px';
		tt_ifrm.style.display = "block";
	}else{
		tt_ifrm.style.display = "none";
	}
}

function tt_GetDiv(t_id){
	return(
		tt_n4? (document.layers[t_id] || null)
		: tt_ie? (document.all[t_id] || null)
		: (document.getElementById(t_id) || null)
	);
}

function tt_GetDivW(){
	return tt_Int(
		tt_n4? tt_obj.clip.width
		: (tt_obj.style.pixelWidth || tt_obj.offsetWidth)
	);
}

function tt_GetDivH(){
	return tt_Int(
		tt_n4? tt_obj.clip.height
		: (tt_obj.style.pixelHeight || tt_obj.offsetHeight)
	);
}

// Compat with DragDrop Lib: Ensure that z-index of tooltip is lifted beyond toplevel dragdrop element
function tt_SetDivZ(){
	var t_i = tt_obj.style || tt_obj;
	if(t_i){
		if(window.dd && dd.z){
			t_i.zIndex = Math.max(dd.z+1, t_i.zIndex);
		}
		if(tt_ifrm){
			tt_ifrm.style.zIndex = t_i.zIndex-1;
		}
	}
}

function tt_SetDivPos(t_x, t_y){
	var t_i = tt_obj.style || tt_obj;
	var t_px = (tt_op6 || tt_n4)? '' : 'px';
	if (t_x > 0){
		t_i.left = (tt_objX = t_x) + t_px;
		t_i.right = '0px';
	}else{
		t_i.right = '0px';
	}
	t_i.top = (tt_objY = t_y) + t_px;
	if(tt_ifrm){
		tt_ifrm.style.left = t_i.left;
		tt_ifrm.style.top = t_i.top;
	}
}

function tt_ShowDiv(t_x){
	tt_ShowIfrm(t_x);
	if(tt_n4){
		tt_obj.visibility = t_x? 'show' : 'hide';
	}else{
		tt_obj.style.visibility = t_x? 'visible' : 'hidden';
	}
	tt_act = t_x;
}

function tt_OpDeHref(t_e){
	var t_tag;
	if(t_e){
		t_tag = t_e.target;
		while(t_tag){
			if(t_tag.hasAttribute("href")){
					tt_tag = t_tag
					tt_tag.t_href = tt_tag.getAttribute("href");
					tt_tag.removeAttribute("href");
					tt_tag.style.cursor = "hand";
					tt_tag.onmousedown = tt_OpReHref;
					tt_tag.stats = window.status;
					window.status = tt_tag.t_href;
					break;
			}
			t_tag = t_tag.parentElement;
		}
	}
}

function tt_OpReHref(){
	if(tt_tag){
		tt_tag.setAttribute("href", tt_tag.t_href);
		window.status = tt_tag.stats;
		tt_tag = null;
	}
}

function tt_Show(t_e, t_id, t_sup, t_delay, t_fix, t_left, t_offx, t_offy, t_static, t_sticky, t_temp){
	if(tt_obj){
		tt_Hide();
	}
	tt_mf = document.onmousemove || null;
	if(window.dd && (window.DRAG && tt_mf == DRAG || window.RESIZE && tt_mf == RESIZE)){
		return;
	}
	var t_sh, t_h;
	tt_obj = tt_GetDiv(t_id);
	if(tt_obj){
		t_e = t_e || window.event;
		tt_sub = !(tt_sup = t_sup);
		tt_sticky = t_sticky;
		tt_objW = tt_GetDivW();
		tt_objH = tt_GetDivH();
		tt_offX = t_left? -(tt_objW+t_offx) : t_offx;
		tt_offY = t_offy;
		if(tt_op7){
			tt_OpDeHref(t_e);
		}
		if(tt_n4){
			if(tt_obj.document.layers.length){
				t_sh = tt_obj.document.layers[0];
				t_sh.clip.height = tt_objH - Math.round(t_sh.clip.width*1.3);
			}
		}else{
			t_sh = tt_GetDiv(t_id+'R');
			if(t_sh){
				t_h = tt_objH - tt_Int(t_sh.style.pixelTop || t_sh.style.top || 0);
				if(typeof t_sh.style.pixelHeight != tt_u){
					t_sh.style.pixelHeight = t_h;
				}else{
					t_sh.style.height = t_h+'px';
				}
			}
		}
		xlim = tt_Int((tt_db && tt_db.clientWidth)? tt_db.clientWidth : window.innerWidth) +
			tt_Int(window.pageXOffset || (tt_db? tt_db.scrollLeft : 0) || 0) -
			tt_objW -
			(tt_n4? 21 : 0);
		ylim = tt_Int(window.innerHeight || tt_db.clientHeight) +
			tt_Int(window.pageYOffset || (tt_db? tt_db.scrollTop : 0) || 0) -
			tt_objH - tt_offY;
		tt_SetDivZ();
		if(t_fix){
			tt_SetDivPos(tt_Int((t_fix = t_fix.split(','))[0]), tt_Int(t_fix[1]));
		}else{
			tt_SetDivPos(tt_EvX(t_e), tt_EvY(t_e));
		}
		var t_txt = 'tt_ShowDiv(\'true\');';
		if(t_sticky){
			t_txt += '{'+
				'tt_ReleasMov();'+
				'window.tt_upFunc = document.onmouseup || null;'+
				'if(document.captureEvents) document.captureEvents(Event.MOUSEUP);'+
				'document.onmouseup = new Function("window.setTimeout(\'tt_Hide();\', 10);");'+
				'}';
		}else if(t_static){
			t_txt += 'tt_ReleasMov();';
		}
		if(t_temp > 0){
			t_txt += 'window.tt_rtm = window.setTimeout(\'tt_sticky = false; tt_Hide();\','+t_temp+');';
		}
		window.tt_rdl = window.setTimeout(t_txt, t_delay);
		if(!t_fix){
			if(document.captureEvents){
				document.captureEvents(Event.MOUSEMOVE);
			}
			document.onmousemove = tt_Move;
		}
	}
}

var tt_area = false;

function tt_Move(t_ev){
	if(!tt_obj){
		return;
	}
	if(tt_n6 || tt_w3c){
		if(tt_wait){
			return;
		}
		tt_wait = true;
		setTimeout('tt_wait = false;', 5);
	}
	var t_e = t_ev || window.event;
	tt_SetDivPos(tt_EvX(t_e), tt_EvY(t_e));
	if(tt_op6){
		if(tt_area && t_e.target.tagName != 'AREA'){
			tt_Hide();
		}else if(t_e.target.tagName == 'AREA'){
			tt_area = true;
		}
	}
}

function tt_Hide(){
	if(window.tt_obj){
		if(window.tt_rdl){
			window.clearTimeout(tt_rdl);
		}
		if(!tt_sticky || !tt_act){
			if(window.tt_rtm){
				window.clearTimeout(tt_rtm);
			}
			tt_ShowDiv(false);
			tt_SetDivPos(-tt_objW, -tt_objH);
			tt_obj = null;
			if(typeof window.tt_upFunc != tt_u){
				document.onmouseup = window.tt_upFunc;
			}
		}
		tt_sticky = false;
		if(tt_op6 && tt_area){
			tt_area = false;
		}
		tt_ReleasMov();
		if(tt_op7) tt_OpReHref();
	}
}

function tt_Init(){
    if(!(tt_op || tt_n4 || tt_n6 || tt_ie || tt_w3c)){
		return;
	}
	var htm = tt_n4? '<div style="position:absolute;"></div>' : '',
	tags,
	t_tj,
	over,
	esc = 'return escape(';
	var i = tt_tags.length;
	while(i--){
		tags = tt_ie? (document.all.tags(tt_tags[i]) || 1)
			: document.getElementsByTagName? (document.getElementsByTagName(tt_tags[i]) || 1)
			: (!tt_n4 && tt_tags[i]=="a")? document.links
			: 1;
		if(tt_n4 && (tt_tags[i] == "a" || tt_tags[i] == "layer")){
			tags = tt_N4Tags(tt_tags[i]);
		}
		var j = tags.length;
		while(j--){
			if(typeof (t_tj = tags[j]).onmouseover == "function" && t_tj.onmouseover.toString().indexOf(esc) != -1 && !tt_n6 || tt_n6 && (over = t_tj.getAttribute("onmouseover")) && over.indexOf(esc) != -1){
				if(over){
					t_tj.onmouseover = new Function(over);
				}
				var txt = unescape(t_tj.onmouseover());
				htm += tt_Htm(
					t_tj,
					"tOoLtIp"+i+""+j,
					txt.wzReplace("& ","&")
				);
				t_tj.onmouseover = new Function('e',
					'tt_Show(e,'+
					'"tOoLtIp' +i+''+j+ '",'+
					((typeof t_tj.T_ABOVE != tt_u)? t_tj.T_ABOVE : ttAbove)+','+
					((typeof t_tj.T_DELAY != tt_u)? t_tj.T_DELAY : ttDelay)+','+
					((typeof t_tj.T_FIX != tt_u)? '"'+t_tj.T_FIX+'"' : '""')+','+
					((typeof t_tj.T_LEFT != tt_u)? t_tj.T_LEFT : ttLeft)+','+
					((typeof t_tj.T_OFFSETX != tt_u)? t_tj.T_OFFSETX : ttOffsetX)+','+
					((typeof t_tj.T_OFFSETY != tt_u)? t_tj.T_OFFSETY : ttOffsetY)+','+
					((typeof t_tj.T_STATIC != tt_u)? t_tj.T_STATIC : ttStatic)+','+
					((typeof t_tj.T_STICKY != tt_u)? t_tj.T_STICKY : ttSticky)+','+
					((typeof t_tj.T_TEMP != tt_u)? t_tj.T_TEMP : ttTemp)+
					');'
				);
				t_tj.onmouseout = tt_Hide;
				if(t_tj.alt){
					t_tj.alt = "";
				}
				if(t_tj.title){
					t_tj.title = "";
				}
			}
		}
	}
	document.write(htm);
	if(document.getElementById) tt_ifrm = document.getElementById("TTiEiFrM");
}
//WZToolTip

function setInvisible(objName){
    document.getElementById(objName).style.visibility="hidden";
}

function setVisible(objName){
    document.getElementById(objName).style.visibility="visible";
}

function OpenNew(element, title){
	window.open(element, title);
	return false;
}

function showOther(mySelect, targetId){
	var selected = mySelect.options[mySelect.selectedIndex].value;
	if (selected == 'Other'){
		target = document.getElementById(targetId);
		if (target.style.display == "none"){
			target.style.display = "";
		}
	} else {
		target = document.getElementById(targetId);
		if (target.style.display != "none"){
			target.style.display = "none";
		}
	}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("&"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all)
		x=d.all[n];

	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
	for( i=0; !x && d.layers && i<d.layers.length; i++)
		x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById)
		x=d.getElementById(n);

	return x;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth;
			document.MM_pgH=innerHeight;
			onresize=MM_reloadPage;
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
		location.reload();
}
MM_reloadPage(true);

function MM_showHideLayer(layerName,soh) {
	var v;
	obj=MM_findObj(layerName);
	if (soh == 'show'){
		v='show';
	}else{
		v='hide';
	}
	if (obj.style) {
		obj=obj.style;
		v=(v=='show')?'':(v='hide')?'none':v;
	}
	obj.display=v;
}

function HideAllLayers(){
	MM_showHideLayer('Layer1','hide');
	MM_showHideLayer('Layer2','hide');
	MM_showHideLayer('Layer3','hide');
	MM_showHideLayer('Layer4','hide');
	MM_showHideLayer('Layer5','hide');
	MM_showHideLayer('Layer6','hide');
	MM_showHideLayer('Layer7','hide');
	MM_showHideLayer('Layer8','hide');
	MM_showHideLayer('Layer9','hide');
}

/* function to handle when user select catetory */
function categoryHandler(a) {
	document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_institution").innerHTML;
	document.merlotForm.elements['affCategory'].value = a.options[a.selectedIndex].value;
	document.merlotForm.elements['affType'].value = '';
	document.merlotForm.elements['affCountry'].value = '';
	document.merlotForm.elements['affState'].value = '';
	document.merlotForm.elements['aff'].value = '';
	document.merlotForm.elements['edType'].selectedIndex = 0;
	document.merlotForm.elements['highEdType'].selectedIndex = 0;
	document.merlotForm.elements['govType'].selectedIndex = 0;
	document.merlotForm.elements['nonProfitType'].selectedIndex = 0;
	document.merlotForm.elements['country'].selectedIndex = 0;
	document.merlotForm.elements['state'].selectedIndex = 0;
	document.merlotForm.elements['prov'].selectedIndex = 0;
	document.merlotForm.elements['affiliation'].selectedIndex = 0;
	affiliationType='';
	country='';
	state='';
	
	if (a.options[a.selectedIndex].value =='Education'){
		affiliationCategory='Education';
		HideAllLayers();
		MM_showHideLayer('Layer1','show');
	} else if (a.options[a.selectedIndex].value =='Corporation'){
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_company").innerHTML;
		affiliationCategory='Corporation';
		affiliationType='Other';
		document.merlotForm.elements['affType'].value = 'Other';
		HideAllLayers();
		MM_showHideLayer('Layer5','show');
	} else if (a.options[a.selectedIndex].value =='Government'){
		affiliationCategory='Government';
		HideAllLayers();
		MM_showHideLayer('Layer3','show');
	} else if (a.options[a.selectedIndex].value =='Non-Profit'){
		affiliationCategory='Non-Profit';
		HideAllLayers();
		MM_showHideLayer('Layer4','show');
	} else if (a.options[a.selectedIndex].value =='Other'){
		affiliationCategory='Other';
		affiliationType='Other';
		document.merlotForm.elements['affType'].value = 'Other';
		HideAllLayers();
		MM_showHideLayer('Layer5','show');
	} else if (a.options[a.selectedIndex].value =='Any') {
		document.getElementById('aff_hint').innerHTML = '';
		affiliationCategory='Any';
		affiliationType='Any';
		document.merlotForm.elements['affType'].value = 'Any';
		HideAllLayers();
		MM_showHideLayer('Layer5','show');
	} else {  // select...
		HideAllLayers();
	}
}

/* function to handle when user select  education type - primary, middle, ... higher education */
function edTypeHandler(a) {
	document.merlotForm.elements['affType'].value = a.options[a.selectedIndex].value;
	document.merlotForm.elements['affCountry'].value = '';
	document.merlotForm.elements['affState'].value = '';
	document.merlotForm.elements['aff'].value = '';
	document.merlotForm.elements['highEdType'].selectedIndex = 0;
	document.merlotForm.elements['govType'].selectedIndex = 0;
	document.merlotForm.elements['nonProfitType'].selectedIndex = 0;
	document.merlotForm.elements['country'].selectedIndex = 0;
	document.merlotForm.elements['state'].selectedIndex = 0;
	document.merlotForm.elements['prov'].selectedIndex = 0;
	document.merlotForm.elements['affiliation'].selectedIndex = 0;
	country='';
	state='';

	if (a.options[a.selectedIndex].value =='Primary/Grade School'){
		affiliationType='Primary/Grade School';
		HideAllLayers();
		MM_showHideLayer('Layer1','show');
		MM_showHideLayer('Layer5','show');
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_primary").innerHTML;
	} else if (a.options[a.selectedIndex].value =='Middle School'){
		affiliationType='Middle School';
		HideAllLayers();
		MM_showHideLayer('Layer1','show');
		MM_showHideLayer('Layer5','show');
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_middle").innerHTML;
	} else if (a.options[a.selectedIndex].value =='High School'){
		affiliationType='High School';
		HideAllLayers();
		MM_showHideLayer('Layer1','show');
		MM_showHideLayer('Layer5','show');
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_high").innerHTML;
	} else if (a.options[a.selectedIndex].value =='Higher Education'){
		affiliationType='Higher Education';
		HideAllLayers();
		MM_showHideLayer('Layer1','show');
		MM_showHideLayer('Layer2','show');
	} else if (a.options[a.selectedIndex].value =='Any'){
		document.getElementById('aff_hint').innerHTML = '';
		affiliationType='Any';
		HideAllLayers();
		MM_showHideLayer('Layer1','show');
		MM_showHideLayer('Layer5','show');
	} else {
		HideAllLayers();
		MM_showHideLayer('Layer1','show');
	}
}


function highEdTypeHandler(a) {
	document.merlotForm.elements['affType'].value = a.options[a.selectedIndex].value;
	document.merlotForm.elements['affCountry'].value = '';
	document.merlotForm.elements['affState'].value = '';
	document.merlotForm.elements['aff'].value = '';
	document.merlotForm.elements['govType'].selectedIndex = 0;
	document.merlotForm.elements['nonProfitType'].selectedIndex = 0;
	document.merlotForm.elements['country'].selectedIndex = 0;
	document.merlotForm.elements['state'].selectedIndex = 0;
	document.merlotForm.elements['prov'].selectedIndex = 0;
	document.merlotForm.elements['affiliation'].selectedIndex = 0;
	country='';
	state='';
	var show_flag='show';

	if (a.options[a.selectedIndex].value =='Community/Technical College') {
		affiliationType='Community/Technical College';
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_community_college").innerHTML;
	} else if (a.options[a.selectedIndex].value =='Technical College') {
		affiliationType='Technical College';
	} else if (a.options[a.selectedIndex].value =='4 Year/4 Year + Grad') {
		affiliationType='4 Year/4 Year + Grad';
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_4year_college").innerHTML;
	} else if (a.options[a.selectedIndex].value =='4 Year + Graduate Programs') {
		affiliationType='4 Year + Graduate Programs';
	} else if (a.options[a.selectedIndex].value =='Any') {
		document.getElementById('aff_hint').innerHTML = '';
		affiliationType='Higher Education';
		document.merlotForm.elements['affType'].value = 'Higher Education';
	} else {
		show_flag='hide';
	}
	
	HideAllLayers();
	MM_showHideLayer('Layer1','show');
	MM_showHideLayer('Layer2','show');
	MM_showHideLayer('Layer5',show_flag);
}

function govTypeHandler(a) {
	document.merlotForm.elements['affType'].value = a.options[a.selectedIndex].value;
	document.merlotForm.elements['affCountry'].value = '';
	document.merlotForm.elements['affState'].value = '';
	document.merlotForm.elements['aff'].value = '';
	document.merlotForm.elements['highEdType'].selectedIndex = 0;
	document.merlotForm.elements['nonProfitType'].selectedIndex = 0;
	document.merlotForm.elements['country'].selectedIndex = 0;
	document.merlotForm.elements['state'].selectedIndex = 0;
	document.merlotForm.elements['prov'].selectedIndex = 0;
	document.merlotForm.elements['affiliation'].selectedIndex = 0;
	country='';
	state='';
	var show_flag='show';

	if (a.options[a.selectedIndex].value =='Federal') {
		affiliationType='Federal';
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_federal").innerHTML;
	} else if (a.options[a.selectedIndex].value =='State') {
		affiliationType='State';
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_state").innerHTML;
	} else if (a.options[a.selectedIndex].value =='Other') {
		affiliationType='Other';
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_gov").innerHTML;
	} else if (a.options[a.selectedIndex].value =='Any') {
		document.getElementById('aff_hint').innerHTML = '';
		affiliationType='Any';
	} else {
		show_flag='hide';
	}

	HideAllLayers();
	MM_showHideLayer('Layer3','show');
	MM_showHideLayer('Layer5',show_flag);
}

function nonProfitTypeHandler(a) {
	document.merlotForm.elements['affType'].value = a.options[a.selectedIndex].value;
	document.merlotForm.elements['affCountry'].value = '';
	document.merlotForm.elements['affState'].value = '';
	document.merlotForm.elements['aff'].value = '';
	document.merlotForm.elements['edType'].selectedIndex = 0;
	document.merlotForm.elements['highEdType'].selectedIndex = 0;
	document.merlotForm.elements['govType'].selectedIndex = 0;
	document.merlotForm.elements['country'].selectedIndex = 0;
	document.merlotForm.elements['state'].selectedIndex = 0;
	document.merlotForm.elements['prov'].selectedIndex = 0;
	document.merlotForm.elements['affiliation'].selectedIndex = 0;
	country='';
	state='';
	var show_flag='show';

	if (a.options[a.selectedIndex].value =='Private') {
		affiliationType='Private';
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_non_profit").innerHTML;
	} else if (a.options[a.selectedIndex].value =='Public') {
		affiliationType='Public';
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_non_profit").innerHTML;
	} else if (a.options[a.selectedIndex].value =='Other') {
		affiliationType='Other';
		document.getElementById('aff_hint').innerHTML = document.getElementById("msg_full_name_non_profit").innerHTML;
	} else if (a.options[a.selectedIndex].value =='Any') {
		document.getElementById('aff_hint').innerHTML = '';
		affiliationType='Any';
	} else {
		show_flag='hide';
	}
	
	HideAllLayers();
	MM_showHideLayer('Layer4','show');
	MM_showHideLayer('Layer5',show_flag);
}

function countryHandler(a) {
	document.merlotForm.elements['affCountry'].value = a.options[a.selectedIndex].value;
	document.merlotForm.elements['affState'].value = '';
	document.merlotForm.elements['aff'].value = '';
	document.merlotForm.elements['state'].selectedIndex = 0;
	document.merlotForm.elements['prov'].selectedIndex = 0;
	document.merlotForm.elements['affiliation'].selectedIndex = 0;
	document.merlotForm.elements['affiliation'].options.length = 0;
	state='';
	
	MM_showHideLayer('Layer6','hide');
	MM_showHideLayer('Layer7','hide');
	if (a.options[a.selectedIndex].value =='United States'){
		MM_showHideLayer('Layer6','show');
		MM_showHideLayer('Layer8','hide');
		MM_showHideLayer('Layer9','hide');
		country='United States';
	} else if (a.options[a.selectedIndex].value =='Canada'){
		MM_showHideLayer('Layer7','show');
		MM_showHideLayer('Layer8','hide');
		MM_showHideLayer('Layer9','hide');
		country='Canada';
	} else if (a.options[a.selectedIndex].value =='Israel'){
		country = a.options[a.selectedIndex].value;
		state='Other';
		document.merlotForm.elements['affState'].value='Other';
		findAffs();
	} else if (a.options[a.selectedIndex].value =='Any'){
		document.getElementById('aff_hint').innerHTML = '';
		country = a.options[a.selectedIndex].value;
		state='Any';
		document.merlotForm.elements['affState'].value='Any';
		MM_showHideLayer('Layer8','show');
		MM_showHideLayer('Layer9','hide');
		findAffs();
	} else {
	// turn off the hint if we are in the advanced member search
		if (a.options[a.selectedIndex].value !='') {
			MM_showHideLayer('Layer8','hide');
			MM_showHideLayer('Layer9','show');
		} else {
			MM_showHideLayer('Layer8','hide');
			MM_showHideLayer('Layer9','hide');
		}
		document.merlotForm.elements['affState'].value='Other'
	}
}

function stateHandler(a) {
	document.merlotForm.elements['affState'].value = a.options[a.selectedIndex].value;
	document.merlotForm.elements['prov'].selectedIndex = 0;
	document.merlotForm.elements['affiliation'].selectedIndex = 0;
	document.merlotForm.elements['aff'].value = '';
	state=a.options[a.selectedIndex].value;
	findAffs();
}

function canadaProvinceHandler(a) {
	document.merlotForm.elements['affState'].value = a.options[a.selectedIndex].value;
	document.merlotForm.elements['state'].selectedIndex = 0;
	document.merlotForm.elements['affiliation'].selectedIndex = 0;
	document.merlotForm.elements['aff'].value = '';
	state=a.options[a.selectedIndex].value;
	findAffs();
}

function affiliationHandler(a) {
	if (a.options[a.selectedIndex].value =='')
		MM_showHideLayer('Layer9','show');
	else {
		document.merlotForm.elements['aff'].value = a.options[a.selectedIndex].text;
		MM_showHideLayer('Layer9','hide');
	}
}

affiliationCategory='';
affiliationType='';
country='';
state='';
buttonClicked='';
numOfAffiliations = 0;

function findAffs() {
	document.merlotForm.elements['affiliation'].options.length =0;
	var j=1;
	document.merlotForm.elements['affiliation'].options[0]= new Option('בחירה...', '');

	for (var i=0; i<=affs.length-1; i++) {
		if ((affiliationType == 'Any' ||
			(affiliationType == 'Higher Education' && (affs[i].affiliationType == '4 Year/4 Year + Grad' || affs[i].affiliationType == 'Community/Technical College'))
			|| affs[i].affiliationType == affiliationType) &&
			(affiliationCategory == 'Any' || affs[i].affiliationCategory == affiliationCategory) &&
			(country == 'Any' || affs[i].country == country) &&
			(state == 'Any' || affs[i].state == state)) {
			if (affs[i].display == 'true') {
				document.merlotForm.elements['affiliation'].options[j]= new Option(affs[i].name, affs[i].id);
				j++;
			}
		}
	}

// turn off the hint if we are in the advanced member search
	document.merlotForm.elements['affiliation'].options[j]= new Option('אחר', '');
	if(j==1) {
		MM_showHideLayer('Layer8','hide');
		MM_showHideLayer('Layer9','show');
	}
	else {
		MM_showHideLayer('Layer8','show');
		MM_showHideLayer('Layer9','hide');
	}
}


function checkForAdd(){
	if (buttonClicked == 'add') {
		if (document.merlotForm.elements['affCategory'].value ==''){
			alert("חובה לבחור קטגוריית השתייכות.");
			return false;
		}
		if (document.merlotForm.elements['affType'].value ==''){
			alert("חובה לבחור סוג מוסד.");
			return false;
		}
		if (document.merlotForm.elements['affCountry'].value ==''){
			alert("חובה לבחור מדינה.");
			return false;
		}
		if (document.merlotForm.elements['affState'].value ==''){
			alert("חובה לבחור State או Province.");
			return false;
		}
		if (document.merlotForm.elements['affiliation'].options.length <=2 ||
			document.merlotForm.elements['affiliation'].options[document.merlotForm.elements['affiliation'].selectedIndex].value == '') {
			if (document.merlotForm.elements['aff'].value ==''){
				alert("חובה להזין שם ארגון.");
				return false;
			}
		} else {
			if (document.merlotForm.elements['affiliation'].selectedIndex == 0){
				alert("חובה לבחור מוסד");
				return false;
			}
		}
		return true;
	}
	if (buttonClicked == 'next'){
		if (numOfAffiliations == 0){
			alert("חובה להזין השתייכות");
			return false;
		} else {
			return true;
		}
	}
	return false;
}

function checkForAddAbst(field, message){
	if (document.merlotForm.elements[field].value ==''){
		alert(message);
		return false;
	}
	return true;
}

function deleteItem(formName, itemName, item) {
	var deleteItemName = "_delete" + itemName;
	if (confirmDelete(itemName)) {
		MyForm = document.forms[formName];
		MyForm.elements[deleteItemName].value = item;
		MyForm.submit();
	}
}

function confirmDelete(obj) {
	var msg = "? האם את/ה בטוח/ה שברצונך למחוק פריט זה";
	ans = confirm(msg);
	if (ans) {
		return true;
	} else {
		return false;
	}
}

function validateLoginForm(form){
	var username = form.username;
	var password = form.password;
	if (username.value == '') {
		alert("נא להזין שם משתמש");
		username.focus(); 
		return false;
	}
	if (password.value == '') {
		alert("נא להזין סיסמה");
		password.focus(); 
		return false;
	}
	return true;
}

function checkURLForProtocol(urlFieldId) {
	var urlField = document.getElementById(urlFieldId);
	if ((urlField.value.length > 0) && (urlField.value.indexOf("://") < 0)){
		urlField.value = "http://" + urlField.value;
	}
}

function testURL(form, inputURL){
	var test=document.forms[form].elements[inputURL].value;
	errorMsg = "השדה ריק";

	if (test==""){
		alert (errorMsg);
	}else{
		if (test.indexOf("://") < 0){
		   test= "http://" + test;
		   document.forms[form].elements[inputURL].value = test;
		}
		newwin = window.open(test, 'newwin', '');
	}
}

var popupBGColor = "#D9EBFB";
var popupTextColor = "#000000";
var popupSelectedBGColor = "#CCCCCC";
var popupSelectedTextColor = "#000000";

var matches = null;
var closeTimeout = null;

function findMatches(needle, maxMatches) {
	if (needle == undefined){
		return null;
	}
	if (needle.length == 0){
		return null;
	}
	var llen = languages.length;
	needle = needle.toLowerCase();
	if (maxMatches == undefined){
		maxMatches = 20;
	}
	var matches = new Array();
	var startMatches = new Array();
	var stopMatches = false;
	for (var i=0; i < llen; ++i) {
		var ind = languages[i].toLowerCase().indexOf(needle);
		if (ind >= 0){
			if (ind == 0){
				if (startMatches.push(i) >= maxMatches) {
					break;
				}
			}
			if (!stopMatches) {
				if (matches.push(i) >= maxMatches) {
					stopMatches = true;
				}
			}
		}
	}
	if (matches.length == 0){
		return null;
	} else if (startMatches.length > 0){
		var aMatch = null;
		var mOn = 0;
		var origStartLength = startMatches.length;
		do {
			do {
				if (mOn >= matches.length) {
					break; // inner do loop
				}
				aMatch = matches[mOn++];
				for (var j=origStartLength-1; j >= 0; --j) {
					if (aMatch == startMatches[j]) {
						aMatch = -1;
						break; // for loop
					}
				}
			} while (aMatch < 0);
			if (mOn >= matches.length){
				break; // outer do loop
			}
		} while (startMatches.push(aMatch) < maxMatches);
		return startMatches;
	} else {
		return matches;
	}
}

var pItemSelected = -1;
var numPItems = 0;
function popupCompletions(tf, e) {
	var textValue = tf.value;
	if (e) {
		var keycode = e.keyCode;
		//alert("keycode = " + keycode);
		if (keycode == 38) {
			// Up arrow
			var newLink = pItemSelected - 1;
			if (newLink < 0) {
				newLink = numPItems - 1;
			}
			changeSelected(pItemSelected, newLink);
			e.preventDefault();
			return false;
		} else if (keycode == 40) {
			// Down arrow
			var newLink = pItemSelected + 1;
			if (newLink >= numPItems) {
				newLink = 0;
			}
			changeSelected(pItemSelected, newLink);
			e.preventDefault();
			return false;
		} else if (keycode == 13) {
			if (pItemSelected >= 0 && pItemSelected < numPItems) {
				matchChosen(matches[pItemSelected]);
			}
			e.preventDefault();
			return false;
		}
	}
	matches = findMatches(textValue, 20);
	var popup = document.getElementById("completionspopup");
	if (matches == null) {
		popup.style.visibility = "hidden";
	} else {
		popup.style.visibility = "visible";
		var mlist = "";
		for (var i=0; i < matches.length; ++i) {
			if (i > 0) mlist += "<br/>";
			mlist += "<a href=\"javascript:matchChosen(" + matches[i] +
					 ")\" class=\"completelink\" onfocus=\"" +
					 "popupLinkFocused()\" id=\"languagelink" + i +
					 "\" style=\"color:" + popupTextColor + "\">" +
					 languages[matches[i]] + "</a>";
		}
		var popuptext = document.getElementById("completionstext");
		popuptext.innerHTML = mlist;
		numPItems = matches.length;
	}
	return true;
}

function changeSelected(fromLink, toLink) {
	if (fromLink >= 0 && fromLink < numPItems) {
		var ll = document.getElementById("languagelink" + fromLink);
		if (ll != null) {
			ll.style.backgroundColor = popupBGColor;
			ll.style.color = popupTextColor;
			ll.style.fontWeight = "normal";
			ll.style.textDecoration = "none";
		} else {
			alert("fromLink null");
		}
	}
	if (toLink >= 0 && toLink < numPItems) {
		var ll = document.getElementById("languagelink" + toLink);
		if (ll != null) {
			ll.style.backgroundColor = popupSelectedBGColor;
			ll.style.color = popupSelectedTextColor;
			ll.style.fontWeight = "bold";
			ll.style.textDecoration = "underline";
		} else {
			alert("toLink null");
		}
		pItemSelected = toLink;
	}
}

function findPos(elt) {
	var curleft = 0;
	var curtop  = 0;

	if (elt.offsetParent){
		do {
			curleft += elt.offsetLeft;
			curtop  += elt.offsetTop;
		} while (elt = elt.offsetParent);
	}
	return { left: curleft, top:  curtop};
}

function initPopup() {
	var langTF = document.getElementById("languagetextfield");
	var popupdiv = document.getElementById("completionspopup");
	var langtfpos = findPos(langTF);
	var mytop = langtfpos.top + langTF.offsetHeight;
	popupdiv.style.top = mytop + "px";
	popupdiv.style.left = langtfpos.left + "px";
	popupdiv.style.visibility = "hidden";
	popupdiv.style.color = popupTextColor;
	popupdiv.style.backgroundColor = popupBGColor;
	document.merlotForm.cat1.focus();
}

function textFieldBlurred(tf) {
	closeTimeout = setTimeout("closePopUp()", 100);
}

function closePopUp() {
	if (pItemSelected >= 0 && pItemSelected < numPItems) {
		matchChosen(matches[pItemSelected]);
	} else if (matches != null && numPItems > 0) {
		matchChosen(matches[0]);
	} else {
		var popupdiv = document.getElementById("completionspopup");
		popupdiv.style.visibility = "hidden";
	}
}

function popupLinkFocused() {
	if (closeTimeout != null) {
		clearTimeout(closeTimeout);
	}
}

function matchChosen(matchNum) {
	if (matchNum >= 0 && matchNum < languages.length) {
		var lang = languages[matchNum];
		var langTF = document.getElementById("languagetextfield");
		if (lang != null && langTF != null) {
			popupLinkFocused();
			langTF.value = lang;
			var hfield = document.getElementById("languagecode");
			hfield.value = languageCodes[matchNum];
			var comppop = document.getElementById('completionspopup');
			comppop.style.visibility='hidden';
		}
	}
}

function CheckAuthor(){
	if ((document.merlotForm.firstName.value != "") || (document.merlotForm.lastName.value != "") ||
		(document.merlotForm.email.value != "") || (document.merlotForm.organization.value != "")){
		return true;
	}
	return false;
}

function checkAuthorFields(){
	if (CheckAuthor()) {
		return confirm("הזנת פרטי מחבר אך לא לחצת על הוספה. האם ברצונך להמשיך למסך הבא מבלי להוסיף את פרטי המחבר ?");
	} else {
		return true;
	}
}

function showOtherVisiblity(mySelect, targetId) {
	var selected = mySelect.options[mySelect.selectedIndex].text;
	if (selected == 'Other'){
		if (document.getElementById) {
			target = document.getElementById(targetId);
			if (target.style.visibility == "hidden"){
				target.style.visibility = "visible";
			}
		}
	} else {
		if (document.getElementById) {
			target = document.getElementById(targetId);
			if (target.style.visibility == "visible"){
				target.style.visibility = "hidden";
			}
		}
	}
}