
function resetFrm(frm){
        for( i=0;i<frm.elements.length;i++){
		setFieldValue(frm.elements[i],"");
	}
}
function setFieldValue(destinationField,value){
	destinationField.value = value;
}
function addFieldValue(destinationField,value){
	destinationField.value += value;
}
function setFieldValueOnValidValue(validValue,destinationField,value){
	if( validValue == value ){
		destinationField.value = value;
	}
}
function setObjectVisibility(destinationObject,state){
	var status;
	if( state == 0 || state == '0' || state == 'no' ){
		status = 'hidden';
	}else if( state == 1 || state == '1' || state == 'yes' ){
		status = 'visible';
	}else{
		status = state;
	}
	destinationObject.style.visibility = status;
}
function setObjectVisibilityOnValidValues(validValues,value,destinationObject,state){
	for( i=0;i<validValues.length;i++){
		if( validValues[i] == value ){
			setObjectVisibility(destinationObject,state);
		}
	}
}
function setObjectDisplay(destinationObject,state){
	var status;
	if( state == 0 || state == '0' || state == 'no' ){
		status = 'none';
	}else if( state == 1 || state == '1' || state == 'yes' ){
		status = '';
	}else{
		status = state;
	}
	destinationObject.style.display = status;
}
function setObjectDisplayOnValidValues(validValues,value,destinationObject,state){
	for( i=0;i<validValues.length;i++){
		if( validValues[i] == value ){
			setObjectDisplay(destinationObject,state);
		}
	}
}
  function about(url) {
   newWindow = window.open(url,"about","menubar=no,status=no,scrollbars=yes,resizable=yes,width=600,height=620");
    }

function lametayelbanner(url){
	 newWindow = window.open(url,"lametayel","location=yes,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes, width=760,height=320,top=200,left=50" );
}
function aigbanner(url){
	 newWindow = window.open(url,"aig","location=no,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no, width=800,height=450,top=100,left=50" );
}
function caspibanner(url){
	 newWindow = window.open(url,"caspi","location=yes,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes, width=760,height=320,top=200,left=50" );
}
function easyshuttlebanner(url){
	 newWindow = window.open(url,"easyshuttle","location=yes,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes, width=800,height=450,top=100,left=50" );
}
function friendrec(url){
	 newWindow = window.open(url,"friendrec","location=no,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no, width=550,height=210,top=100,left=50" );
}
function amana(url){
	 newWindow = window.open(url,"amana","location=no,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no, width=730,height=550,top=5,left=50" );
}
function radiobanner(url){
	 newWindow = window.open(url,"lametayel","location=yes,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes, width=760,height=320,top=200,left=50" );
}
function pelebanner_1(url){
	 newWindow = window.open(url,"lametayel","location=yes,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes, width=760,height=320,top=200,left=50" );
}
function pelebanner_2(url){
	 newWindow = window.open(url,"lametayel","location=yes,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes, width=760,height=320,top=200,left=50" );
}

function openBunner(url){
	 newWindow = window.open(url,"elal","location=yes,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes, width=734,height=450,top=100,left=50" );
}
function doOnSubmitIframe(frm){
	if(frm.target=="target"){
		frm.target="";
	}
	if(frm.target=="_blank"){
		window.open("","target","dependent=no,hotkeys=no,status=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,titlebar=yes,toolbar=yes,height=600,width=1000");
		frm.target="target";
	}
}

function openRating(agentId)
{
 newWindow = window.open("/travelist/inc/ratingDetails.jsp?agentId="+agentId,"Rating",
 "location=no,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no, width=500,height=550,top=5,left=50" );
}

function checkBrowser(){
	var Browser = new Object(); 
	var ua = navigator.userAgent.toLowerCase(); 
	Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined'); 
	Browser.isIE = window.ActiveXObject ? true : false; 
	Browser.isFirefox = (ua.indexOf("firefox")!=-1); 
	Browser.isSafari = (ua.indexOf("Browser.isSafari")!=-1); 
	Browser.isOpera = (typeof window.opera != 'undefined'); 
	Browser.isChrome = (ua.indexOf("chrome")!=-1); 
	return Browser;
}

function findPosX(obj) {
	var browser = checkBrowser();
	var curleft = 0;
	if (browser.isMozilla || browser.isFirefox) {
		if (obj.offsetParent)
			while (1) {
				curleft += obj.offsetLeft;
				if (!obj.offsetParent)
					break;
				obj = obj.offsetParent;
			}
		else if (obj.x)
			curleft += obj.x;
	} else {
		curleft = obj.offsetLeft;
	}
	return curleft;
}

  function findPosY(obj) {
	var browser = checkBrowser();
	var curtop = 0;
	if (browser.isMozilla || browser.isFirefox) {
		if (obj.offsetParent)
			while (1) {
				curtop += obj.offsetTop;
				if (!obj.offsetParent)
					break;
				obj = obj.offsetParent;
			}
		else if (obj.y)
			curtop += obj.y;
	} else {
		curtop = obj.offsetTop;
	}
	return curtop;
}



if(typeof CalendarView !="undefined"){
	var monthToolButtonAttributes={
		className:"rich-calendar-tool-btn-month",
		onmouseover:"this.className='rich-calendar-tool-btn-month rich-calendar-tool-btn-month-hover'",
		onmouseout:"this.className='rich-calendar-tool-btn-month'",
		onmousedown:"this.className='rich-calendar-tool-btn-month rich-calendar-tool-btn-month-hover rich-calendar-tool-btn-press'",
		onmouseup:"this.className='rich-calendar-tool-btn-month rich-calendar-tool-btn-month-hover'"
	};		
	CalendarView.nextMonthControl=CalendarView.getControl(">",monthToolButtonAttributes,"nextMonth");
	CalendarView.previousMonthControl=CalendarView.getControl("<",monthToolButtonAttributes,"prevMonth");

	var ttPrefix = '<span';
	var ttPrefixInner = ttPrefix+' class=\"rich-calendar-cell-tooltip\">';
	var ttPrefixCnt = ttPrefix+' class=\"rich-calendar-cell-tooltip-cnt\">';
	var ttSuffix = '</span>';
	
	
	
	function showToolTip(obj, toolTip){
		obj.innerHTML = obj.innerHTML +ttPrefixCnt+ ttPrefixInner + toolTip + ttSuffix+ttSuffix ;
	}
	
	function hideToolTip(obj){
		var index = obj.innerHTML.toLowerCase().indexOf(ttPrefix.toLowerCase(),0);
		if(index>=0){
			obj.innerHTML = obj.innerHTML.substr(0,index);
		}
	}
	
	Object.extend(CalendarContext.prototype,
				{nextMonthControl:CalendarView.nextMonthControl,
				previousMonthControl:CalendarView.previousMonthControl});
	Object.extend(Calendar.prototype, {
		eventCellOnMouseOver : function(e, obj) {
			var daydata = this.days[parseInt(obj.id
					.substr(this.DATE_ELEMENT_ID.length), 10)];
			if (this.invokeEvent("datemouseover", obj, e, daydata.date)
					&& daydata.enabled) {
				if (daydata._month == 0 && obj.id != this.selectedDateCellId
						&& obj.id != this.todayCellId) {
					Element.addClassName(obj, 'rich-calendar-hover');
				}
				
				if (daydata._month == 0 
						&& obj.id != this.todayCellId) {
					var toolTip=daydata.toolTip;
					if(toolTip!=null){
						showToolTip(obj,toolTip);
					}
				}		
			}
		}
	})
	Object.extend(Calendar.prototype, {
		eventCellOnMouseOut: function (e, obj) {
		var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
		if (this.invokeEvent("datemouseout", obj, e, daydata.date) && daydata.enabled)
		{
			if (daydata._month==0 && obj.id!=this.selectedDateCellId && obj.id!=this.todayCellId) Element.removeClassName(obj,'rich-calendar-hover');
		}
		hideToolTip(obj);
		}
	})
}	

function check_email(element){
	var msg = ".הכתובת שהוקלדה שגויה, אנא נסה שנית";
	return check_email(element,msg);
}

function check_email(element,msg){
	var valid = false;
	try{
	var Email= element.value.replace(/^\s+|\s+$/, ''); 
		if ((Email=="")||(Email==null)
			||(Email.indexOf("@") == -1)||(Email.indexOf(".") == -1)){
			alert(msg);
		}else{
			valid = true;
		}
	}catch(e){}
	return valid;
}
