﻿function changeImgSrc (srcName,type) {
	var e = document.getElementById(srcName);
	if (e)	{
		if ((type =='image') && (e.src)) {
			if (e.src.indexOf('_ro')==-1) {
				e.src = e.src.replace('.gif','_ro.gif');
			} else {
				e.src = e.src.replace('_ro.gif','.gif');
			}
		} else if ((type =='td') && (e.style)) {
			if (e.style.backgroundImage.indexOf('_ro')==-1) {
				e.style.backgroundImage = e.style.backgroundImage.replace('.gif','_ro.gif');
			} else {
				e.style.backgroundImage = e.style.backgroundImage.replace('_ro.gif','.gif');
			}
		}
	}
}

function changImage(imgChange){
	if (imgChange)	{
		changeImgSrc (imgChange + 'right','image');
		changeImgSrc (imgChange + 'left','image');
		changeImgSrc (imgChange + 'center','td');
	}
}

function focusSearchLocal(){
	if ((document.all.mySubNavFrom) && (document.all.mySubNavFrom.searchField))
	{
		mySubNavFrom.searchField.focus()
		mySubNavFrom.searchField.style.borderColor = 'cccccc';
	}
}

function createAjaxObj() {
	var httprequest=false
	if (window.XMLHttpRequest){ // if Mozilla, Safari etc
		httprequest=new XMLHttpRequest()
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml');
	} else if (window.ActiveXObject) { // if IE
		try {
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				httprequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	return httprequest
}

var ajaxpack=new Object();
ajaxpack.basedomain="http://"+window.location.hostname;
ajaxpack.ajaxobj=createAjaxObj()
ajaxpack.filetype="txt"
ajaxpack.addrandomnumber=0 
ajaxpack.getAjaxRequest=function(url, parameters, callbackfunc, filetype){
ajaxpack.ajaxobj=createAjaxObj() 
if (ajaxpack.addrandomnumber==1) 
	var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
if (this.ajaxobj) {
	this.filetype=filetype
	this.ajaxobj.onreadystatechange=callbackfunc
	this.ajaxobj.open('GET', url+"?"+parameters, true)
	this.ajaxobj.send(null)
}
}

ajaxpack.postAjaxRequest=function(url, parameters, callbackfunc, filetype){
ajaxpack.ajaxobj=createAjaxObj() 
if (this.ajaxobj){
	this.filetype=filetype
	this.ajaxobj.onreadystatechange = callbackfunc;
	this.ajaxobj.open('POST', url, true);
	this.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	this.ajaxobj.setRequestHeader("Content-length", parameters.length);
	this.ajaxobj.setRequestHeader("Connection", "close");
	this.ajaxobj.send(parameters);
}
}

function writeObj(url,w,h,bgc,httpType,id) {
var str
str = ""
str = str + "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' "
str = str + "codebase='" + httpType + "://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' "	// codesbase set to the Latest Flash version
str = str + "width='"+ w +"' height='"+ h +"' id='movieflash_"+id+"' align='middle'>"
str = str + "<param name='allowScriptAccess' value='sameDomain' />"
str = str + "<param name='movie' value='"+ url +"' />"
str = str + "<param name='quality' value='high' />"
str = str + "<param name='bgcolor' value='"+ bgc +"' />"
str = str + "<param name='wmode' value='transparent' />"																	// wmode value exists as transparent requested as window
str = str + "<param name='play' value='true' />"																			// Play value. Possible values: true, false. Specifies whether the movie begins playing immediately on loading in the browser. The default value is true if this attribute is omitted.
str = str + "<param name='loop' value='true' />"																			// Loop value. Possible values: true, false. Specifies whether the movie repeats indefinitely or stops when it reaches the last frame. The default value is true if this attribute is omitted.
str = str + "<param name='scale' value='noscale' />"																		// Loop value. Possible values: true, false. Specifies whether the movie repeats indefinitely or stops when it reaches the last frame. The default value is true if this attribute is omitted.
str = str + "<param name='menu' value='true' />"																			// Menu value. Possible values: true, false:
																															//								true - displays the full menu, allowing the user a variety of options to enhance or control playback. 
																															//								false - displays a menu that contains only the Settings option and the About Flash option.
str = str + "<embed src='"+ url +"'  "																						// SRC value. Specifies the location (URL) of the movie to be loaded.
str = str + "quality='high' "
str = str + "bgcolor='"+ bgc +"' "
str = str + "width='"+ w +"' height='"+ h +"' "
str = str + "name='movieflash_" + id + "' wmode='transparent'"
str = str + "align='middle' "
str = str + "allowScriptAccess='sameDomain' "
str = str + "type='application/x-shockwave-flash' "
str = str + "pluginspage='http://www.macromedia.com/go/getflashplayer' />"
str = str + "</object>"
document.write(str)
}

function writeObj_minisite(url,w,h,bgc,httpType,id){
var str
str = ""
str = str + "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "
str = str + "codebase='" + httpType + "://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' "	// codesbase set to the Latest Flash version
str = str + "width='"+ w +"' height='"+ h +"' id='movieflash_"+id+"' align='middle'>"
str = str + "<param name='allowScriptAccess' value='sameDomain' />"
str = str + "<param name='movie' value='"+ url +"' />"
str = str + "<param name='quality' value='high' />"
str = str + "<param name='bgcolor' value='"+ bgc +"' />"
str = str + "<param name='wmode' value='window' />"																			// wmode value exists as transparent requested as window
str = str + "<param name='play' value='true' />"																			// Play value. Possible values: true, false. Specifies whether the movie begins playing immediately on loading in the browser. The default value is true if this attribute is omitted.
str = str + "<param name='loop' value='true' />"																			// Loop value. Possible values: true, false. Specifies whether the movie repeats indefinitely or stops when it reaches the last frame. The default value is true if this attribute is omitted.
str = str + "<param name='scale' value='noscale' />"																		// Loop value. Possible values: true, false. Specifies whether the movie repeats indefinitely or stops when it reaches the last frame. The default value is true if this attribute is omitted.
str = str + "<param name='menu' value='true' />"																			// Menu value. Possible values: true, false:
																															//								true - displays the full menu, allowing the user a variety of options to enhance or control playback. 
																															//								false - displays a menu that contains only the Settings option and the About Flash option.
str = str + "<embed src='"+ url +"'  "																						// SRC value. Specifies the location (URL) of the movie to be loaded.
str = str + "quality='high' "
str = str + "bgcolor='"+ bgc +"' "
str = str + "width='"+ w +"' height='"+ h +"' "
str = str + "name='movieflash_" + id + "' wmode='window'"
str = str + "align='middle' "
str = str + "allowScriptAccess='sameDomain' "
str = str + "type='application/x-shockwave-flash' "
str = str + "pluginspage='http://www.macromedia.com/go/getflashplayer' />"
str = str + "</object>"

document.write(str)
}

function init() {
if (document.getElementById('inputText1')) {
if (document.getElementById('inputText1').type == 'text' || document.getElementById('inputText1').type == 'password')
	{  
	document.getElementById('inputText1').focus();
	}
}	
} 
function TradeLink()
	{
	var h = window.screen.availHeight-30;	 
	var w = window.screen.width-10;			 
	var t = 0;								 
	var l = 0;								
	var win1=window.open("https://btol.ordernet.co.il/Opener/Opener.asp?c=125&w=" + window.screen.width + "&h=" + window.screen.availHeight, "ordernet","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbar=no,resizable=no", "replace=true");
	win1.focus();
	}
function goToGraph(value) {
	var url='/graph/0,,1007-toReplace-2,00.html';
	url=url.replace('toReplace',value);
	window.location=url;
}
function flipLevel3(objName, objCenter, op)
{
	var tmpLeft,tmpRight;
	var suff;
	var style_suff;
	suff = '.gif';
	style_suff = '';
	if (op == 'off_ro') {
		suff = '_ro.gif';
		style_suff = '_ro';
	}
	if (op == 'on')
	{
		suff = '_sel.gif';
		style_suff = '_sel';
	}
	objCenter.className = 'NavBtnLvl3' + style_suff;
	tmp = document.getElementById (objName + '_left');
	if (tmp) {
		tmp.src = '/Ext/Static/b_kartisiot_left' + suff;
	}
	tmp = document.getElementById (objName + '_right');
	if (tmp) {
		tmp.src = '/Ext/Static/b_kartisiot_right' + suff;
	}
}
function goToMnGraph(value) {
	var url = '/Graphs/ExtSecGraphs_PopupMonthlyGraph/1,,922-toReplace-2,00.html?secId=' + value +'&period=2';
	var s = window.location.toString();
	var srv, index;
	if(s.substring(0,s.indexOf(':'))=='https')
	{
		index = s.indexOf(':') + 3;
		srv = s.substring(index, s.indexOf('/',index));
		url = 'http://' + srv + url;
	}
		url = url.replace('https://','http://')
		url = url.replace('toReplace',value)
		var w = window.open(''+ url +'',null,'height=375,width=385,status=no,toolbar=no,menubar=no,location=no');
		w.focus();
}
function CreatePopUp(strURL,attWindow,WinName) 
{
if (CreatePopUp.arguments.length==1) 
{
var attWindow='directories=0, width=700, height=500, toolbar=0, status=yes, resizable=yes, scrollbars=yes';var WinName='';
}
if (CreatePopUp.arguments.length==2) 
{
var WinName=''
}
wref=window.open(strURL,WinName,attWindow);
wref.focus();
}
function TrimString(sString) {
    var oRegTrim = new RegExp('^([ ]*)');
    sString = sString.replace(oRegTrim,'');
    var oRegTrim = new RegExp('([ ]*)$');
    sString = sString.replace(oRegTrim,'');
    return(sString);
}

/////////////////////////////////////////////////////////////////////////////////////////////

function submitFormHeader(called_by){
	var string_to_check = document.getElementById('searchField').value;
	var checked_type= document.searchForm.sType[1];
	var checked_type1= document.searchForm.sType[0];
	if((checked_type.checked == true) && (isNaN(document.getElementById('searchIlanot').value)))
	{
		alert('מספר הקרן הוא ערך מספרי');
		return false;
	}
	if (string_to_check != '') {
		if (SearchCriteriaValidation(string_to_check)) {
			if (called_by==1) {
				return true;
			} else {
				document.searchFormHeader.submit();
			}
		} else {
			alert("!יש להזין תוים חוקיים לחיפוש");
			if (called_by==1) {
				return false;
			}	
		}		
	} else {
		if((checked_type.checked == true) && (document.getElementById('searchIlanot').value==''))
		alert('נא לרשום את מספר הקרן לחיפוש');
		if((checked_type1.checked == true) && (document.getElementById('searchIlanot').value==''))
		alert('נא לרשום את שם הקרן לחיפוש');
		if (called_by==1) {
			return false
		}
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////

function SearchCriteriaValidation(strToValidate){
//=============================================================================================
// Submitted by Moshe Levi on 18/07/2007
// This function recieves string variable and checks if it contains forbidden words like:
//		LIKE, UPDATE, SELECT, DELETE, INSERT in any case - UPER CASE/lower case, in other
//		word or by itself.
// This function also checks given string if for forbidden use of UNDERSCORE character:
//		If underscore used by itself only, in case of "xxx _xxx" or "xxx_ xxx" or "xxx _ xxx".
// If any of this forbidden cases been detected then this function returns FALSE, otherwise
//		it returns TRUE.
//---------------------------------------------------------------------------------------------

	var forbiddenSearchWords = "(LIKE|UPDATE|SELECT|DELETE|INSERT)";

	var the_str = strToValidate;
	the_str = the_str.toUpperCase( );
	var trimed_str = the_str.replace(/^\s+|\s+$/g,"");

	var ForbiddenRegExpr = new RegExp(forbiddenSearchWords);
	var FoundMatch1 = ForbiddenRegExpr.exec(trimed_str);
	var FoundMatch2 = trimed_str.indexOf("_ ");
	var FoundMatch3 = trimed_str.indexOf(" _");	
	if ((FoundMatch1 == null) && (FoundMatch2 == -1) && (FoundMatch3 == -1) && (trimed_str !== '_')) {
		return true
	} else {
		return false
	}
}

var fundId=''; 
function toSecurity(securityId,securityType) {
var type=securityType.split('-')[2]; 
var id=''; var re = new RegExp('replace','g');var r_url='';
switch (type) {
	case '99':
		r_url='/homex/0,,87-replace,00.html';
	break;
	case '138':
		r_url='/homex/0,,87-replace,00.html';break;
	case '79':
		r_url='/homex/0,,100-replace,00.html';break;
	case '15':
		r_url='/homex/0,,96-replace,00.html';break;
	case '47':
		r_url='/homex/0,,109-replace,00.html';break;
	case '21':
		switch (securityType.split('-')[3]) {
	case '22':	
		r_url='/homex/0,,131-replace,00.html';break;
	case '45':
		r_url='/homex/0,,861-replace,00.html';break;
	default:
		r_url='/homex/0,,120-replace,00.html';break;
	}
	break;
	default:return;} 
	if(r_url!='') { 
	r_url=r_url.replace(re,securityId); 
	if(r_url.indexOf('replace')==-1)
	document.location=r_url;
	}
}
	
function toSecurityCompany (companyId,securityId) { 
	var search_url=''; var re = new RegExp('replace','g'); var re2 = new RegExp('rep2','g');
	search_url='/homex/0,,1185-replace-rep2,00.html'; 
	search_url=search_url.replace(re,companyId); 
	search_url=search_url.replace(re2,securityId);
	document.location=search_url;
}
function toSecurityYnet (secTypeCompany,securityId) {
var type=secTypeCompany.split('-')[2]; 
var id='';
var companyId=secTypeCompany.split('~')[1]; 
var s_url=''; var re = new RegExp('replace','g'); var re2 = new RegExp('rep2','g');
switch (type) {
case '99':
	s_url='/homex/0,,1185-rep2-replace,00.html';break;
case '79':
	s_url='/homex/0,3,100-replace,00.html';break;
case '15':
	s_url='/homex/0,3,96-replace,00.html';break;
case '47':
	s_url='/homex/0,,109-replace,00.html';break;
case '21':
switch (secTypeCompany.split('-')[3]) {
case '22':	
	s_url='/homex/0,,131-replace,00.html';break;
case '45':
	s_url='/homex/0,3,861-replace,00.html';break;
default:
	s_url='/homex/0,,1185-rep2-replace,00.html';break;
}
	break;
default:
	return;
} 
if(s_url.indexOf('rep2')!=-1) {
	s_url=s_url.replace(re2,companyId);
	} 
	s_url=s_url.replace(re,securityId);
	document.location=s_url;
}
function toFunds (securityId) {  
if(!isNaN(securityId)) {  
	var param = 'id='+securityId; 	
fundId = securityId;  
	ajaxpack.getAjaxRequest('/Ext/Section/Securities/Api/ExtSecApi_CheckSecurityId', param, processGetPost, 'txt'); 
}
}
function processGetPost() {  
	var fundAddr ='http://www.cfb-funds.co.il';
	var search_url=''; var re = new RegExp('replace','g');  var myajax=ajaxpack.ajaxobj;  
	if (myajax.readyState == 4) 
{  
if (myajax.status==200 || window.location.href.indexOf('http')==-1) 
{  
var checkId= myajax.responseText;  var idParam= checkId.split('~')[1];  
if(idParam==0) { search_url = '/homex/0,,109-replace,00.html';  
search_url=search_url.replace(re,fundId); 
	document.location=search_url;  
} else {	
	search_url=fundAddr+'/homex/0,,468,00.html?fundId='+fundId; 
var x= window.open(''+search_url+'','funds','toolbar=no,location=no,status=yes,resizable=yes,scrollbars=yes,top=20,left=30,height=600,width=700'); 
} 
}  
}  
} 
var img1=new Image();
var img2=new Image();
img1.src='/Ext/Sec/AreaB/Static/I-arrow01.gif';
img2.src='/Ext/Sec/AreaB/Static/I-arrow02.gif';
function openDivLogin(divName)
{
for(i=1;i<=5;i++)
	{
		if(divName == i)
		{
		    if(document.getElementById('divLog' +i).style.display=="inline")
			{
				document.getElementById('divLog' +i).style.display="none";
				document.getElementById('tx' +i).className="txtMain";
				document.getElementById('ar'+i).src=img1.src;
			}
			else {
				document.getElementById('divLog' +i).style.display="inline";
				document.getElementById('tx' +i).className="txtMainB";
				document.getElementById('ar'+i).src=img2.src;
			}
		}
		else 
		{
		    if(document.getElementById('divLog' +i) != null)
			{
				document.getElementById('divLog' +i).style.display="none";
				document.getElementById('tx' +i).className="txtMain";
				document.getElementById('ar'+i).src=img1.src;
			}
		}
	}
}
function openDivPers(ind)
{
	
		    if(document.getElementById('divLog'+ind).style.display=="inline")
			{
				document.getElementById('divLog'+ind).style.display="none";
				document.getElementById('tx'+ind).className="txtMain";
				document.getElementById('ar'+ind).src='/Ext/Sec/AreaB/Static/I-arrow01.gif';
			}
			else {
				document.getElementById('divLog'+ind).style.display="inline";
				document.getElementById('tx'+ind).className="txtMainB";
				document.getElementById('ar'+ind).src='/Ext/Sec/AreaB/Static/I-arrow02.gif';
			}
	
}
// In order to check phone numbers.
var valid_numeric_chars = "0123456789- ()+";
// In order to check the user name. 
var valid_alfanumeric_chars_english = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"; 
// In order to check the other text fields. 
var valid_english_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var valid_hebrew_chars = "[SHOW  valid_hebrew_chars] ";
var valid_signs = "`!# ^&()-_+\"',/.:";
var valid_numeric_chars_only = "0123456789";
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function checks if a character (tmp_char) exists in the string (str).
//  if it does it returns 1 , if not : returns -1 . 
function charInString(tmp_char,str) {
  for (var i=0; i < str.length ; i++) {
    if (str.charAt(i) == tmp_char)
      return 1;
  }
    return -1;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function Checks the correctness of a input string.
//returned values:
// 1 : Correct value of the whole field.
// -1 : Incorrect value of certain chars in the string.
// -2 : Incorrect length of the string.
// -3 : First letter in the user name filed is not an english letter.
// -4 : The length of teh string is 0 . 
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkSpecificField(field,flag,mi_len,ma_len){
    var result = 0, result2 = 0,result3 = 0, result4=0;
    if(flag!=8)
    {
        if (field.length == 0 && mi_len > 0)
            return -4;
        if (field.length == 0 && mi_len == 0)
            return 1;
    }
    if(field.length !='')
    {
        if ( field.length > ma_len || field.length < mi_len )
            return -2;
    }
    switch(flag){
        case 1: //Checking the user name
            result =charInString(field.charAt(0),valid_english_chars) 
            if(result == -1 ){
                return -3;
            }
            for(var i=1; i < field.length ; i++){
                result = charInString(field.charAt(i),valid_alfanumeric_chars_english)
                if(result < 1)
                    return result;
                }
                return result;
        case 2: //
            for(var i=0; i < field.length ; i++){               
                result = charInString(field.charAt(i),valid_english_chars)
                result2 = charInString(field.charAt(i),valid_hebrew_chars)
                result3 = charInString(field.charAt(i),valid_numeric_chars)
                result4 = charInString(field.charAt(i),valid_signs)
                if(result < 0 && result2 < 0 && result3 < 0 && result4 < 0)
                    return -1;
                }
                return 1;
        case 3: 
            result = isEmail(field);    
            //alert("result "+result);
            if (result)
                return 1;
            else
                return -1;
        case 4: //phone numbers check
            for(var i=0; i < field.length ; i++){
                result = charInString(field.charAt(i),valid_numeric_chars)
                if (result < 0)
                    return result;
            }
            return result;
        case 5: // good for password(english+numeric only!)
            for(var i=1; i < field.length ; i++){
                result = charInString(field.charAt(i),valid_alfanumeric_chars_english)
                if(result < 1)
                    return result;
                }
                return result;
        case 6:
            for(var i=0; i < field.length ; i++){               
                result = charInString(field.charAt(i),valid_english_chars)
                result2 = charInString(field.charAt(i),valid_hebrew_chars)
                if(result < 0 && result2 < 0)
                    return -1;
            }
            return 1;
        case 7:
            // in order to check a numeric user name  t.z.
            for(var i=1; i < field.length ; i++){
                result = charInString(field.charAt(i),valid_numeric_chars_only)
                if(result < 1)
                    return result;
                }
        case 8:
            // in order to check t.z.
            for(var i=1; i < field.length ; i++){
                result = charInString(field.charAt(i),valid_numeric_chars_only)
                if(result < 1)
                    return result;
                }
                return result;
    }
}
///////////////////////////////////////////////////////////
function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z0-9])");
  return (!r1.test(str) && r2.test(str));
}
////////////////////////////////////////////////////////////////////////////////////////
function CheckEMailAddress ( EMailAddress ) {
	// Declare RegularExpression of E-Mail address
	var re = new RegExp("[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+[.][a-zA-Z0-9]+$",'ig'); 
	return (re.test(EMailAddress));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function checks if a char exists in a certain string. 
//If it exists - the function will return 1 
//If it doesn't exist it will return 0
function checkEmail(checkString){    
	var result = CheckEMailAddress(checkString);	
    if(result == true){
        return 1;
    }
    else {
      // DISPLAY ERROR MESSAGE
    //  alert ("Sorry, the email address younentered is not in the correctnformat.");
      return -1;
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function checks if a given value is numeric or not, returns 1 if is and 0 if not.
function isNumeric(strVar) {
	var re = new RegExp("\\D","g");
	if (strVar.match(re)){
		return 0;
	}
	return 1;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function Changes all input type=text that has no value , to have "NullData" that is being save as //	db null value
function ChangeNulls(type) {
	if (ChangeNulls.arguments.length == 0) {
		type = "text";
	}
	for(i=0; i< document.all.length; i++) {
		if (document.all(i).type == type && document.all(i).value == ""){
			document.all(i).value = "NullData";
		}
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// This function Checks if the year, month and date are valid for a certain date.
//	if only year, or year + month are supplied, only the inputed values are checked
function CheckDate(year, month, day) {
	// check that the day is not inserted without month, and month is not inserted without year
	if (((year == "") && (month != "")) || ((month == "") && (day != ""))) {
		return -1;
	}
	// Check that every input is either null or numeric
	if (year < 1900 && year != "")
		return -1
	if (!(isNumeric(year)) && (year != "") ) { 
		return -1;
	}
	if (!(isNumeric(month)) && (month != "")) { 
		return -1;
	}
	if (!(isNumeric(day)) && (day != "")) { 
		return -1;
	}
	// if all fields are inserted, check that the date is valid
	if (month == "") {
		month = 1;
	}
	if (day == "") {
		day = 1;
	}
	if ((year != "")) {
		// Check using the date object
		var newDateObj = new Date(year, (month-1), day);		
		if (isNaN(newDateObj)) {
			return -1;
		}
		if ((newDateObj.getMonth() + 1)  != month) {
			// month changed, because the day doesn't exist in the given month
			return -1;
		}
	}
	// else, passed all checks
	return 1;
}
sfHover = function() {}

function setHover(nav) {
	var ieULs = nav.getElementsByTagName('ul');
	if (navigator.appVersion.substr(22,3)!="5.0") {
		// IE script to cover <select> elements with <iframe>s
		/*for (j=0; j<ieULs.length; j++) {
			var ieMat=document.createElement('iframe');
			if(document.location.protocol == "https:")
				ieMat.src="//0";
			else if(window.opera != "undefined")
				ieMat.src="";
			else
				ieMat.src="javascript:false";
			ieMat.scrolling="no";
			ieMat.frameBorder="0";
			ieMat.style.width=ieULs[j].offsetWidth+"px";
			ieMat.style.height=ieULs[j].offsetHeight+"px";
			ieMat.style.zIndex="-1";
			ieULs[j].insertBefore(ieMat, ieULs[j].childNodes[0]);
			ieULs[j].style.zIndex="101";
		}*/
		// IE script to change class on mouseover
		var ieLIs = nav.getElementsByTagName('li');
		for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
			// Add a sfhover class to the li.
			ieLIs[i].onmouseover=function() {
				if(!/\bsfhover\b/.test(this.className))
					this.className+=" sfhover";
			}
			ieLIs[i].onmouseout=function() {
				if(!this.contains(event.toElement))
					this.className=this.className.replace(' sfhover', '');
			}
		}
	} else {
		// IE 5.0 doesn't support iframes so hide the select statements on hover and show on mouse out.
		// IE script to change class on mouseover
		var ieLIs = document.getElementById('nav').getElementsByTagName('li');
		for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
			ieLIs[i].onmouseover=function() {this.className+=" sfhover";hideSelects();}
			ieLIs[i].onmouseout=function() {this.className=this.className.replace(' sfhover', '');showSelects()}
		}
	}
}

// If IE 5.0 hide and show the select statements.
function hideSelects(){
	var oSelects=document.getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className+=" hide";
}

function showSelects(){
	var oSelects=document.getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className=oSelects[i].className.replace(" hide","");
}

// Run this only for IE.
if (window.attachEvent) window.attachEvent('onload', sfHover);
// end
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();
//***********************************************************Font Size Change functions
document.getElementsByClassName = function(clsName){
    var retVal = new Array();
    var elements = document.getElementsByTagName("*");
    for(var i = 0;i < elements.length;i++){
        if(elements[i].className.indexOf(" ") >= 0)
{            var classes = elements[i].className.split(" ");
            for(var j = 0;j < classes.length;j++){ 
             if(classes[j] == clsName)
                    retVal.push(elements[i]); 
           }
        }
        else if(elements[i].className == clsName)
            retVal.push(elements[i]); 
   }    
return retVal;
}
function getPxAttribute(el,defsize,att) {
	var value;
	/*if (document.defaultView && document.defaultView.getComputedStyle) {
		value = document.defaultView.getComputedStyle(el, null)[att];
	} else*/
	 if (el.currentStyle) {
		value = el.currentStyle[att];
	} else {
		value =  el.style[att];
  	}
	if (value.indexOf("px")!= -1){
		return parseInt(value.substring(0,value.indexOf("px")));
	} else{
		//alert(value);
		if(value.indexOf("pt")== -1){
		//alert(value);
			if(value== "1") return 11;
			if(value== "2") return 13;
			if(value== "3") return 16;
			if(value== "4") return 19;
			if(value== "5") return 24;
			if(value== "6") return 32;
			if(value== "7") return 48;
		} //else{ alert(parseInt(el.style.fontSize))}
	}
	//value = parseInt(el.style.fontSize);
	if (!isNaN(value)){
		return value;
	}
	value = parseInt(el.size);
	if (!isNaN(value)){
		return value;
	}
	return parseInt(defsize);
}

var fontZoomCounter = 0;
var classBlackList = " frame-top-left frame-left frame-btm-left ";
var zoomEnabledTags = " div span p h1 h2 h3 h4 h5 h6 td a b i strong li sub sup u abbr bdo caption cite code dd dt pre s strike ";
function changefontsize(num) {
	if( (num > 0 && fontZoomCounter < 3) || (num < 0 && fontZoomCounter > 0) ) {
		if(num > 0)
			fontZoomCounter++;
		else 
			fontZoomCounter--;

		$('.contentObjectTextArea').each(function(index, obj) {
			changeElementFontSize($(obj), num);
		});
	}
}

function changeElementFontSize(elem, num) {
	var tag = $(elem).get(0).nodeName.toLowerCase();
	// FONT tag is deprecated - disable zoom on this tag and on its child elements
	if(tag == "font")
		return;
		
	var className = $(elem).attr('class');
	// Disable zoom for blacklisted classes
	if(className != "") {
		var re = new RegExp("\\s" + className + "\\s");
		if (classBlackList.match(re))
			return;
	}
	
	// Recursive get the last element in the tree
	if($(elem).children().length > 0) {
		$(elem).children().each(function(idx, el) {
			changeElementFontSize($(el), num);
		});
	}
	// Change font size and line height
	var fontSize;
	var lineHeight;
	var reg = new RegExp("\\s" + tag + "\\s");
	if(zoomEnabledTags.match(reg)) {
		try {
			fontSize = parseInt($(elem).css('font-size'), 10);
			if(isNaN(fontSize))
				fontSize = 12;
			newFontSize = fontSize+num;
			lineHeight = parseInt($(elem).css('line-height'), 10);
			newLineHeight = lineHeight+num;
			$(elem).css({'font-size': newFontSize+'px', 'line-height': newLineHeight+'px'});
		} catch(err) {
			;
		}
	}
}

function calculateFSize(obj,defsize,change,minsize,maxsize) {
		var fontsize = getPxAttribute ( obj,defsize,"fontSize")+change;
		fontsize = Math.max(minsize,fontsize);
		fontsize = Math.min(maxsize,fontsize);
		obj.style.fontSize = fontsize + 'px';
	}
function changefontsize2(elementId,num) {

	calculateFSize(elementId,15,num,8,16);

}
function checkDates(startDate,endDate) {
		var result = 1;
		var arr1 =startDate.split('/');
		var tmp1 =arr1[0];
		var tmp2 =arr1[1];
		arr1[0]=tmp2;
		arr1[1]=tmp1;
		startDate = arr1.join('/');
		var startDateObj = new Date(startDate);
		var arr2 =endDate.split('/');
		tmp1 =arr2[0];
		tmp2 =arr2[1];
		arr2[0]=tmp2;
		arr2[1]=tmp1;
		endDate = arr2.join('/');
		var endDateObj = new Date(endDate);
		if (endDateObj - startDateObj < 0 )
				result = -1;
		return result;
	}
//**********************************TITLE ILANOT FUND*************************************************
function OpenFundForPrint1(path) {
          window.open(path,'','width=670,height=690,toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,left=110,top=100');
}

function OpenFundForPrint(url)
{
if(document.getElementById('fromDate'))
	{
		var fromDate = document.getElementById('fromDate').value;
	}
	if(document.getElementById('toDate'))
	{
		var toDate = document.getElementById('toDate').value;
	}
	var path = url+"&fromDate="+fromDate+"&toDate=" + toDate;
	var p=window.open (path,"FundPage","toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,copyhistory=yes");
	
}


function PrintPage() {
    
            path ='[CURL /IlanotFunds/Ext/Section/Comp/Keren_Page/ExtSecFunds_PrintPage]? fundId=[SHOW fundId]'

            window.open(path,'','width=670,height=690,toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,left=110,top=100');


}

function mycarousel_flashIn(carousel, item, i, state, evt)
{
    var idx = carousel.index(i, flashTitles.length);
    carousel.add(i, mycarousel_getItemHTML(flashTitles[idx - 1]));
};

function mycarousel_flashOut(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return item;
};

function carousel_Flash(carousel)
	{
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
// This function shows a designed tooltip on mouseover at "i" icon
// JQuery is required
if(typeof isJSIncluded == "undefined") {
	isJSIncluded = true;
	$(document).ready(function(){
		$('.tooltip-icon').hover(
			// mouseover
			function() {
				if($(this).attr('tooltip') == '') 
					return false;
				var div_id = '#' + $(this).attr('tooltip');
				if($.trim($(div_id + ' div').html()) == "")
					return false;
				var pos = $(this).offset();
				var left = pos.left-$(div_id).width()-2;
				var top = pos.top-$(div_id).height()-2;

				if(left-$(div_id).width() < 2) {
					left = pos.left + $(this).width() + 2;
					$(div_id + ' div').removeClass();
					$(div_id + ' div').addClass('tooltip-left');
				} else {
					$(div_id + ' div').removeClass();
					$(div_id + ' div').addClass('tooltip-right');
				}
				top += $('#container').scrollTop();
				$(div_id).css({'top' : top, 'left' : left});
				$(div_id).fadeIn(300);
			},
			// mouseout
			function() {
				if($(this).attr('tooltip') == '') 
					return false;
				var div_id = '#' + $(this).attr('tooltip');
				$(div_id).fadeOut(300);
			}
		);	
		$('.search-sec-advanced input').click(function () { 
			if(this.checked) {
				$("label[for='" + this.id + "']").removeClass('adv-search-label'); 
				$("label[for='" + this.id + "']").addClass('adv-search-label-selected');
			} else {
				$("label[for='" + this.id + "']").removeClass('adv-search-label-selected');
				$("label[for='" + this.id + "']").addClass('adv-search-label'); 
			}
		});
		
		$('.tab-right-ticker').click(function () { 
			$('.tab-right-ticker').removeClass('ticker-tab-selected'); 
			$(this).addClass('ticker-tab-selected'); 
		});
		
		$('.ticker-block').hover(
			// mouseover
			function() {
				var div_id = $(this).attr('info');
				var pos = $(this).offset();
				$('#' + div_id).css('width', $(this).width());
				var info_pos = (pos.left > ($('#ticker_body').width() / 2))? pos.left - $('#' + div_id).width() : pos.left + $(this).width();
				$('#' + div_id).css('left', info_pos);
				$('#' + div_id).css('display','block');
			},
			// mouseout
			function() {
				var div_id = $(this).attr('info');
				$('#' + div_id).css('display','none');
			}
		);

		if(typeof SelectedComboID == "undefined") {
			SelectedComboID = null;
		}
		
		$('body').click(function(event) {
			if (!$(event.target).is('.combo-left') && !$(event.target).is('.combo-text') && !$(event.target).is('.combo-right') && !$(event.target).is('.combo-text span') && SelectedComboID && $('#' + SelectedComboID).hasClass('selected')) {
				$('#' + SelectedComboID).click();
			}
		});
		
		$('.combo-left').click(function () {
			var thisID = $(this).attr('id');
			if(!$(this).hasClass('selected')) {
				if(SelectedComboID && SelectedComboID != thisID) {
					$('#' + SelectedComboID).click();
				}
				SelectedComboID = thisID;
			} else {
				SelectedComboID = null;
			}
			$(this).next('ul').slideToggle('fast');
			$(this).toggleClass('selected');
		});
		$('.combo-body li a div').click(function () {
			var comboBodyElem = $(this).closest('ul');
			var comboTitleElem = $(comboBodyElem).prev('.combo-left');
			var comboElem = $(comboBodyElem).closest('.combo');
			$(comboTitleElem).find('.combo-text').html($(this).html());
			$(comboBodyElem).slideToggle('fast');
			$(comboTitleElem).toggleClass('selected');
			$(comboBodyElem).find('li a div').removeClass('combo-option-selected');
			$(this).addClass('combo-option-selected');
			SelectedComboID = null;
			if($(comboBodyElem).hasClass('combo-type-toolbox')) {
				eval($(this).attr('value'));
			} else {
				$(comboElem).find('input[type=hidden]').val($(this).attr('value'));
			}
		});
		$('.combo-body li a div').hover(
		  function () {$(this).addClass('combo-option-hover');},
		  function () {$(this).removeClass('combo-option-hover');}
		);
		
		$('ul.tags-cloud-ul li a').click(function() {
			var tagSearchValue = ($(this).attr('title') != "")? $(this).attr('title') : $(this).text();
			$('#searchFormHeader #searchField').val(tagSearchValue);
			$('#searchFormHeader #is_from_cloud').val('1');
			headerSearchType = 0;
			submitHeaderSearchForm();
			return false;
		});
		   
	});
}

function custom_alert(objName, position, msg) {
	var obj = $('#' + objName).parents('.textbox-left');
	var pos = obj.offset();
	var left = pos.left;
	var top = pos.top;
	if(!$.browser.msie) {
		top -= $('body').scrollTop();
	}
	if($('#container').hasClass('containerSt')) {
		if($.browser.msie) {
			top += $('#container').scrollTop();
		}
	}
	$('.form-alert-div .form-alert-message').html(msg);
	msgHeight = $('.form-alert-div').height();
	msgWidth = $('.form-alert-div').width();
	fldWidth = obj.width();
	fldHeight = obj.height();
	switch(position) {
		case 1:
			top -= (msgHeight + 5);
			left += (fldWidth - msgWidth - 4);
			break;
		case 2:
			top += (fldHeight + 3);
			left += (fldWidth - msgWidth - 4);
			break;
		case 3:
			top += (fldHeight + 3);
			break;
		case 4:
			top -= (msgHeight + 5);
			break;
		default:
			top -= (msgHeight + 5);
			left += (fldWidth - msgWidth - 3);
			break;
		
	}
	
	$('.form-alert-div').css({'top' : top, 'left' : left});
	$('.form-alert-div').fadeIn(300);
	$('.form-alert-div .form-alert-close').click(
		function() {$('.form-alert-div').fadeOut(300)}
	);
	$('#' + objName).click(
		function() {$('.form-alert-div').fadeOut(300)}
	);
	$('#' + objName).keydown(
		function(event) {if(event.keyCode != 13) $('.form-alert-div').fadeOut(300);}
	);
	
}

function combobox_SetValue(combo_name, combo_value) {
	if(typeof(combo_value) != 'undefined') {
		$('#'+combo_name).val(combo_value);
		$('#ul_'+combo_name+' li a div').removeClass('combo-option-selected');
		$("#ul_'+combo_name+' li a div[value='" + combo_value + "']").addClass('combo-option-selected');
		$('#combo_text_'+combo_name).html($("#ul_"+combo_name+" li a div[value='" + combo_value + "']").html());
	} else {
		$('#'+combo_name).val($('#'+combo_name+'_default_value').html());
		$('#ul_'+combo_name+' li a div').removeClass('combo-option-selected');
		$('#combo_text_'+combo_name).html($('#'+combo_name+'_default_text').html());
	}
}

//***********************************************************************************

function divide ( numerator, denominator ) {
    var remainder = numerator % denominator;
    var quotient = ( numerator - remainder ) / denominator;
    if ( quotient >= 0 )
        quotient = Math.floor( quotient );
    else  // negative
        quotient = Math.ceil( quotient );
		
	return quotient;
}


//-------------------------------------validation----------------------------------------------------

function trim(string) {
    return string.replace(/(^\s+)|(\s+$)/g, '');
}

function CheckNumericKey(e) {
    e = e || window.event;
    var ch = e.which || e.keyCode;
    if( ch != null) {
        if( (ch >= 49 && ch <= 57)
        || ch == 0 || ch == 8
        || ch == 13 || ch == 9) return true;
    }
    return false;

}
function CheckNumericKeyWith_0(e) {
    e = e || window.event;
    var ch = e.which || e.keyCode;
    if( ch != null) {
        if( (ch >= 48 && ch <= 57)
        || ch == 0 || ch == 8
        || ch == 13 || ch == 9) return true;
    }
    return false;
}

function PrintPageAction(path) {
	window.open(path,'','width=950,height=900,toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,left=110,top=100');
}


//*******************************************curency Calculator*************************
function calculate(){
	var from=document.getElementById('from_price').value;
	var to=document.getElementById('to_price').value;
	if(document.getElementById('quantity').value=='' || document.getElementById('quantity').value=='כמות')
		document.getElementById('quantity').value=0;
	var quantity=parseInt(document.getElementById('quantity').value);
	var x = new String(quantity * from / to)
	x=x.substring(0,x.indexOf('.')+3);
	var str=quantity + ' ' +document.getElementById('from_name').value + ' = ' + x + ' ' +document.getElementById('to_name').value
	document.getElementById('calc_result').className='curency-calc-lable_res';
	document.getElementById('calc_result').innerHTML=str;
}

function display_flag(is,price,name) {
	if (is=='from') {
		document.getElementById('from_price').value=price;
		document.getElementById('from_name').value=name;
	} else {
		document.getElementById('to_price').value=price;
		document.getElementById('to_name').value=name;
	}
}
//***********************************************************************************

//***********************************************************************************

