	
// T2777
function checkEmailList(mailList,msg) {
	mailList = mailList + ";";
	var tmp = mailList.split(";");
	if (mailList!=";") {
		for (var i=0;i<tmp.length;i++) {
			if (tmp[i]!="") {	
				if(checkEmail(TrimString(tmp[i]))!= 1 && (TrimString(tmp[i]))!="") {
					alert(msg+" ("+TrimString(tmp[i])+")");
				return false;
				}
			}
		}	
	} else {
		alert(msg);
		return false;
	}
}

function checkEmailListInternal(mailList,msg) {
	mailList = mailList + ";";
	var tmp = mailList.split(";");
	if (mailList!=";") {
		for (var i=0;i<tmp.length;i++) {
			if (tmp[i]!="") {	
				if(checkEmail(TrimString(tmp[i])) != 1 && (TrimString(tmp[i]))!="") {
					rc_alert(msg+" ("+TrimString(tmp[i])+")");
				return false;
				}
			}
		}	
	} else {
		rc_alert(msg);
		return false;
	}
}
/////////////////
function TrimString(sString) {
	var oRegTrim = new RegExp('^([ ]*)');
	sString = sString.replace(oRegTrim,'');
	var oRegTrim = new RegExp('([ ]*)$');
	sString = sString.replace(oRegTrim,'');
	return(sString);
}
function OpenPopUpWindow(sUrl) {
	var oLength = this.OpenPopUpWindow.arguments ;
	var sWindowName = 'BankLeumiNewWindow';
	var sAttributes = 'toolbar=no,location=no,status=no,resizable=no,scrollbars=no,menubar=no';
	if (oLength.length > 1) sWindowName = oLength[1];
	if (oLength.length > 2) {
		if (oLength.length > 3) {
			if (oLength[3] == true) sAttributes = oLength[2];
				else sAttributes += ',' + oLength[2];
		} else sAttributes += ',' + oLength[2];
	}
	if (oLength.length > 4) {
		sAttributes = oLength[2] ;
		if(oLength[4]==0) var oWin = window.open(sUrl,'_self',sAttributes);
		else var oWin = window.open(sUrl,sWindowName,sAttributes);
	} else {
		var oWin = window.open(sUrl,sWindowName,sAttributes);
	}
	return(oWin);
}


function OpenPopUpWindowHelp(sUrl, attr) {
	var sWindowName = 'Help';
	var sAttributes = attr;
	var oWin = window.open(sUrl,'HelpPage','resizable=no,width=400,height=300,scrollbars=no,top=250,left=350'); 
	return(oWin);
}

function GotoURL(ExternalUrl,IsNewWindow,Width,Height,IsToolbarDisplayed,isScrollbars,isStatus,isResizable,isAddressBar,isMenuBar) {
		if(IsNewWindow==1) {
			var sWinName = "" ;
			var overWrite = true ;
			var sAttributes = "width="+Width+",height="+Height ;
			if(IsToolbarDisplayed) sAttributes += ",location=yes,toolbar=yes" ;
			else sAttributes += ",location=no,toolbar=no" ;
			if(isScrollbars)  sAttributes += ",scrollbars=yes" ;
			else sAttributes += ",scrollbars=no" ;
			
			if(isAddressBar)  sAttributes += ",location=yes" ;
			else sAttributes += ",location=no" ;
			
			if(isMenuBar)  sAttributes += ",menubar=yes" ;
			else sAttributes += ",menubar=no" ;
			
			if(isStatus)  sAttributes += ",status=yes" ;
			else sAttributes += ",status=no" ;
			if(isResizable)  sAttributes += ",resizable=yes" ;
			else sAttributes += ",resizable=no" ;
			OpenPopUpWindow(ExternalUrl,sWinName,sAttributes,overWrite) ;
		} else window.location = ExternalUrl;
}
function PopUpColorDialog() {
	var sColor = "";
	if (this.PopUpColorDialog.arguments.length > 0) {
		sColor = this.PopUpColorDialog.arguments[0];
		var oRegTrim = new RegExp('^([#]*)');
		sColor = sColor.replace(oRegTrim,'');
	}
	if (this.PopUpColorDialog.arguments.length > 1) {
		if (this.PopUpColorDialog.arguments[1] == true) var sUrl = '/Int/Api/CmaAppChooseColor/1,4098,,00.html';
			else var sUrl = '/Int/Api/CmaAppChooseDBColor/1,4099,,00.html';
	} else var sUrl = '/Int/Api/CmaAppChooseDBColor/1,4099,,00.html';
	sUrl = sUrl + '?Color=' + sColor;
	if (this.PopUpColorDialog.arguments.length > 2) {
		if (this.PopUpColorDialog.arguments[2] == true) sUrl = sUrl + '&SiteID=AllSites';
	}
	return (window.showModalDialog (sUrl,'','dialogHeight:410px;dialogWidth:528px;center:yes;help:no;resizable:no;status:no;scroll:no;'));
}
/****************************************************************************************************************
The function open a loading bar where the process's progress is shown as percentage. The loading itself is
done from the specified CURL .
****************************************************************************************************************/
//T2536 (C4292), Lior Carmel, 23.05.2004 
function openLoading(){  
	var oWidth = 350; 
	var oHeight = 140;
	var oTop = (screen.availHeight - oHeight) / 2;
	var oLeft = (screen.availWidth - oWidth) / 2;
	var params = '?langAlign=&langDir=';
	var sUrl = '/Leumi/Int/Api/GeneralTemplates/IntApiGen_LoadingWin/1,6491,,00.html';
	//if(this.openLoading.arguments.length > 0) {
		//sUrl = '';
		//oHeight = 30;
		//params += '&iSiteID='+window.iSiteID ;
	//}
	var att = 'top='+oTop+',left='+oLeft+',width='+oWidth+',height='+oHeight+',toolbars=0,status=0,resizable=0';
	sUrl += params;
	loadWindow = window.open(sUrl,'lWin',att);
}

/* Print Script */

function goToPrint(id,proc,tType){
	var dom = document.getElementById ? 1: 0;
	var nIE4 = ( document.all && !dom ) ? 1 : 0;
	document.printForm.eltContID.value=id;
	document.printForm.proc_name.value=proc;
	document.printForm.eltTypeID.value=tType;
	if(!nIE4) window.open('','wStr','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes,menubar=yes');
	document.printForm.target = 'wStr';
	document.printForm.submit();
}

function openPopUp(url,width,height,more_atts){
	if(arguments[1] == '') width = 400;
	if(arguments[2] == '') height = 520;
	if(arguments[3] == null || arguments[3] == '' || arguments[3] == 'undefined') more_atts = 'toolbar=no, resizable=1,scrollbars=1';
	var atts = 'width='+width+', height='+height+','+more_atts;
	window.open(url,'the_popup_win',atts);	
}

function addTalk(url) {
	var newURL = url;
	var attWin='width=450,height=450';
	var handle = window.open(newURL,'',attWin);
}

//2813 Ron & Nir, 20/6/04
//SetCookie(name(string),value(string),expires(date|'NEVER'),path(string),domain(string),secure(bool))
function SetCookie (name, value) { 
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = (argc > 2) ? argv[2] : null; 
	if ( expires=="NEVER" || expires=="never" ) expires=new Date(2014,12,28);
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
	document.cookie = name + "=" + escape (value) + 
					 ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
					 ((path == null) ? "" : ("; path=" + path)) + 
					 ((domain == null) ? "" : ("; domain=" + domain)) + 
					 ((secure == true) ? "; secure" : ""); 
} 
//SetCookie(cookie-name(string),chip-name(string),chip-value(string),expires(date|'NEVER'),path(string),domain(string),secure(bool))
function SetChipsCookie(cookie_name,chip_name,value) {
	var argv = SetChipsCookie.arguments; 
	var argc = SetChipsCookie.arguments.length; 
	var expires = (argc > 3) ? argv[3] : null; 
	if ( expires=="NEVER" || expires=="never" ) expires=new Date(2099,12,28);
	var path = (argc > 4) ? argv[4] : null; 
	var domain = (argc > 5) ? argv[5] : null; 
	var secure = (argc > 6) ? argv[6] : false; 

	var pattern = escape(chip_name) + "="
	var cookie_value = GetCookie(cookie_name)
	if ( cookie_value == null ) {
		var chips = new Array()
		chips.push(escape(chip_name)+"="+escape(value))
	} else if (GetCookie(cookie_name,chip_name) == null ) {
		var chips = cookie_value.split('&')
		chips.push(escape(chip_name)+"="+escape(value))
	} else {
		var chips = cookie_value.split('&')
		for ( var i=0; i < chips.length; i++ ) {
			if ( chips[i].indexOf(pattern) == 0 ) 
				chips[i]=escape(chip_name)+"="+escape(value)
		}
	}

	cookie_value=chips.join('&')
	document.cookie = cookie_name + "=" +cookie_value + 
					 ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
					 ((path == null) ? "" : ("; path=" + path)) + 
					 ((domain == null) ? "" : ("; domain=" + domain)) + 
					 ((secure == true) ? "; secure" : ""); 
	
}
function GetCookie(name,chip_name) {
	var cookies= "; " + document.cookie + ";";
	var pattern= "; " + name + "=";
	
	var start = cookies.lastIndexOf(pattern);
	if ( start < 0 ) return null;
	start += pattern.length;
	cookie_value=cookies.substr(start,cookies.indexOf(";",start)-start)
	if ( chip_name == null ) return (unescape(cookie_value)) 
	
	//if we got here then the we want only a chip from the cookie
	var chips = "&" + cookie_value + "&"
	pattern = "&" + escape(chip_name) + "="
	start = chips.lastIndexOf(pattern);
	if ( start < 0 ) return null;
	start += pattern.length;
	chip_value=chips.substr(start,chips.indexOf("&",start)-start);
	return (unescape(chip_value));
}

///
function PasswordValidation(PasswordValue){
	//password definition:
	//only english letters and digits (and _)
	//min 6 and max 10 chars
	//cannot have identical 3 chars in a sequence
	var sPasswordValue = ""+PasswordValue
	var re = new RegExp("(^[0-9A-Z]{6,10})$","gi");
	if(re.test(sPasswordValue) == true){
		// count digits and chars in password
		var iLength = sPasswordValue.length
		var sStr = sPasswordValue
		var curr = ""
		var next = ""
		var counter = 1;
		for (var i=0;i< iLength;i++) { //counts 3 consecutives in password (chars or digits , no matter , if true return false from function)
			curr = sStr.charAt(i)
			next = sStr.charAt(i+1)
			counter ++;
			if(curr != next) counter = 1;
			if(counter == 3) return false;
		}
	} else {
		return false
	}
	return true
}



var SecuredCategory = new Array;

//NL T2787, 13/6/04
function GotoReportedCategory(LinkCode,CategoryID, ExternalUrl,IsNewWindow,Width,Height,IsToolbarDisplayed,isScrollbars,isStatus,isResizable,isAddressBar,isMenuBar) {
	if (ExternalUrl == null)  
		ExternalUrl = '/Leumi/Home/0,2777,' + CategoryID + ',00.html' 
	ExternalUrl = '/Premium/LeumiPremium/Ext/Comp/Registration/PremiumExtCompRegistration_LogRedirect/1,7376,,00.html?from=' + encodeURIComponent(LinkCode) + '&to=' + encodeURIComponent(ExternalUrl) +'&'
	GotoCategory(CategoryID, ExternalUrl,IsNewWindow,Width,Height,IsToolbarDisplayed,isScrollbars,isStatus,isResizable,isAddressBar,isMenuBar)
}

function GotoCategory(CategoryID, ExternalUrl,IsNewWindow,Width,Height,IsToolbarDisplayed,isScrollbars,isStatus,isResizable,isAddressBar,isMenuBar) {
	if (ExternalUrl != null) {
		if(IsNewWindow==1) {
			var sWinName = "" ;
			var overWrite = true ;
			var sAttributes = "width="+Width+",height="+Height ;
			if(IsToolbarDisplayed) sAttributes += ",location=yes,toolbar=yes" ;
			else sAttributes += ",location=no,toolbar=no" ;
			if(isScrollbars)  sAttributes += ",scrollbars=yes" ;
			else sAttributes += ",scrollbars=no" ;
			
			if(isAddressBar)  sAttributes += ",location=yes" ;
			else sAttributes += ",location=no" ;
			
			if(isMenuBar)  sAttributes += ",menubar=yes" ;
			else sAttributes += ",menubar=no" ;
			
			if(isStatus)  sAttributes += ",status=yes" ;
			else sAttributes += ",status=no" ;
			if(isResizable)  sAttributes += ",resizable=yes" ;
			else sAttributes += ",resizable=no" ;
			OpenPopUpWindow(ExternalUrl,sWinName,sAttributes,overWrite) ;
		} else window.location = ExternalUrl;
	} else {
		var Arr = new Array;
		IDParams = CategoryID.toString();
		IDParams = IDParams.split('-');
		if (SecuredCategory[IDParams[0]]) window.location = '/Leumi/Home/0,2777,' + CategoryID + ',00.html';
		else window.location = '/Leumi/Home/0,2777,' + CategoryID + ',00.html';
	}
}
//T2967
function GotoArticle(ObjectID,CategoryID,IsNewWindow,Width,Height,IsToolbarDisplayed,isScrollbars,isStatus,isResizable,isAddressBar,isMenuBar) {
	urlStr = '/Leumi/Article/0,2777,to_replace,00.html';
	url=urlStr.replace('to_replace',ObjectID)
	GotoURL(url,IsNewWindow,Width,Height,IsToolbarDisplayed,isScrollbars,isStatus,isResizable,isAddressBar,isMenuBar)
}

function GC(CategoryID, ExternalUrl,IsNewWindow,Width,Height,IsToolbarDisplayed,isScrollbars,isStatus,isResizable,isAddressBar,isMenuBar) {
	GotoCategory(CategoryID, ExternalUrl,IsNewWindow,Width,Height,IsToolbarDisplayed,isScrollbars,isStatus,isResizable,isAddressBar,isMenuBar);
}

function getClassAtt (className,attName) {
	var curCSS,curRule,i,j;var r=null;
	for (i=0;i<document.styleSheets.length;i++) {
		curCSS=document.styleSheets[i];
		for (j=0;j<curCSS.rules.length;j++) {
			curRule=curCSS.rules[j]
			if (curRule.selectorText==className) {
				try {
					eval('r=document.styleSheets['+i+'].rules['+j+'].style.'+attName);
				} catch(e) {r=null;	}
				return r;
			}
		}
	}
	return r;
}

function OpenAlertWindow(sMessage) {
	var oErrorMessage = new Object();
	oErrorMessage.Text = sMessage;
	if (this.OpenAlertWindow.arguments.length > 1) var iAlertType = 2
		else var iAlertType = 1;
	return (window.showModalDialog('/Leumi/Ext/Api/CdaApiAlertMessages/1,3394,,00.html?LanguageID=' + iCurrentLanguageID + '&winType=' + iAlertType + '&',oErrorMessage,'dialogHeight:370px;dialogWidth:280px;center:yes;help:no;resizable:no;status:no;scroll:0'));

	//var x= window.open('/Leumi/Ext/Api/CdaApiAlertMessages/1,3394,,00.html?LanguageID=' + iCurrentLanguageID + '&winType=' + iAlertType,'win','dialogHeight:300px;dialogWidth:280px;center:yes;help:no;resizable:no;status:no;scroll:0');
}
 
 
function GotoMessagesCategory() {parent.GotoReportedCategory('MESSAGES',2875)}
function GotoBenefitsCategory() {parent.GotoReportedCategory('BENEFITS',1052)}
function GotoReportsCategory() {parent.GotoReportedCategory('REPORTS',1050)}
function GotoAlertsCategory() {parent.GotoReportedCategory('ALERTS',4561)}
function GotoChequesCategory() {parent.GotoReportedCategory('CHEQUES',3337)}
function GotoBenefitsUpdateCategory() {parent.GotoReportedCategory('BENEFITS',2800)}
function GotoReportsUpdateCategory() {parent.GotoReportedCategory('REPORTS',2554)}
function GotoAlertsUpdateCategory() {parent.GotoReportedCategory('ALERTS',4565)}
function GotoChequesUpdateCategory() {parent.GotoReportedCategory('CHEQUES',1033)}
var interFrame = '';
function delIframe() {
	YnetNewsFlashesFrame.removeNode(true);
	window.clearInterval(interFrame);
}
function LoadFlashNewsIframe() {
	if (document.all.item('YnetNewsFlashesFrame')) {
		document.all.newsFlashDiv.innerHTML = document.frames.newsFlashIframe.document.body.innerHTML;
		interFrame = window.setInterval(delIframe,100);
	}
}
function openWin(my_var) {window.open(my_var,'NewsFlash','menubar=no,resizable=no,scrollbars=yes,width=449,height=300')}
function YnetOpenWin(my_var) {window.open(my_var,'Ynet','menubar=yes,resizable=yes,scrollbars=yes,width=600,height=500')}
function LoadYnetNewsFlashes() {YnetNewsFlashesFrame.innerHTML = "<iframe id='newsFlashIframe' src='https://secure.ynet.co.il/NonReg/Secure/PremiumTicker/1,,,00.html?bll_redirect_url="+document.location.protocol+"//"+document.location.host+"/Premium/LeumiPremium/Cmm/Api/CmmApiPremium_ynetFlashIframe/1,5121,,00.html&' width=0 height=0></iframe>"}


function LoadUserMessages() {
	UserMessagesFrame.innerHTML = "<iframe src='" + '/Amidim/LeumiPremium/Ext/Comp/UserMessages/CdaAppAmidimUserMessagesUpdate/1,7984,' + iCurrentCategoryID + '-' + iCurrentLanguageID + ',00.html' + "' width=0 height=0></iframe>"			
}

function PremiumInit() {	
	// Load User Messages only when we are in live mode
	// bIsPreviewJS is set in CmmAppHomePagePremiumHTML template
	if (!bIsPreviewJS){
		if (document.all.item('UserMessagesFrame')) LoadUserMessages();
	}
	//if (document.all.item('YnetNewsFlashesFrame')) LoadYnetNewsFlashes();
}

function CheckSearchText(sErrorText) {
	var bReturn = true;
	oForm = event.srcElement;
	sString = TrimString(oForm.SearchString.value);
	var oRegTrim = new RegExp('[%\_]+');
	sString = sString.replace(oRegTrim,'');
	if (sString == '') {
		OpenAlertWindow(sErrorText);
		event.returnValue = false;
		bReturn = false;
	}
	return(bReturn);
}

function txt_link(type,url,width,height,toolbar,scroll,status,resize,add,menu) {
		var urlAtts = '';
		if (typeof(bExternalArticle) == "undefined") var bExternalArticle = 0;
		if((width) && (height)){
			urlAtts =  'width=' 	 + width 					+ ','
			urlAtts += 'height=' 	 + height 					+ ','
			urlAtts += 'toolbar='	 + (toolbar==null?0:toolbar)+ ','
			urlAtts += 'scrollbars=' + (scroll==null?1:scroll) 	+ ','
			urlAtts += 'status='	 + (status==null?1:status)	+ ','
			urlAtts += 'resizable='	 + (resize==null?1:resize)	+ ','
			urlAtts += 'location='   + (add==null?0:add) 		+ ','
			urlAtts += 'menubar='	 + (menu==null?0:menu)
		}
		switch (type){
			case 'external' :
				if( urlAtts != '' ) {
					// galp- escaep fix - added "escape(..  and the unescape("
					//alert(url)
					//alert(escape(url))
					//alert(unescape(url))
					url = escape(url)
					var x = window.open(unescape(url),'newWin',urlAtts)
				} else {				
					url = escape(url)
					document.location = unescape(url);
				}
				break;
			case 'object' :
				urlStr = '/Leumi/Article/0,2777,to_replace,00.html';
				url=urlStr.replace('to_replace',url)
				if (bExternalArticle == 1) {
					window.open(url);
				} else {
					if( urlAtts != '' ) {
						var x = window.open(url,'newWin',urlAtts)
					} else {
						document.location = url;
					}
				}
				break;
			case 'category' :
			if (bExternalArticle != 1) document.body.style.cursor = 'wait';
				
					document.all.dbIframeDiv.innerHTML = '<IFRAME id=iData style=display:none src=http://www.leumi.co.il/Common/Api/TextEditor/CmmApiTextEditor_dbRequest/1,5155,,00.html></IFRAME>';
					document.all.iData.src='/Common/Api/TextEditor/CmmApiTextEditor_dbRequest/1,5155,,00.html?execProc=getCategoryLink&id='+url+'&returnObj=setDbLinkCategory&';
				 document.body.style.cursor = 'default';
				break;
			}
	}
	
	function setDbLinkCategory(url) {eval(unescape(url));}
	
	
