//<!--
function popup_window( url, id, width, height )
    {
      popup = window.open( url, id, 'toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=no,width=' + width + ',height=' + height + '' );
      popup.focus();
    }

function OpenInNewWin(s_url,n,m)
{
	var s_defaults;

	s_defaults = "directories=no,fullscreen=no,location=no,menubar=no,titlebar=no" +
				 ",toolbar=no,resizable=no,top=0,left=0,width=" + n + ", height=" + m;

	window.open(s_url,  "", s_defaults);
}

function OpenInNewStandardWin(s_url,n,m)
{
	var s_defaults;

	s_defaults = "directories=yes,fullscreen=no,location=yes,menubar=yes,titlebar=yes" +
				 ",toolbar=yes,resizable=yes,top=0,left=0,width=" + n + ", height=" + m;

	window.open(s_url,  "", s_defaults);
}


function MM_preloadImages() 
{ //v3.0
	var d=document; 
	if(d.images)
	{ 
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
		for(i=0; i<a.length; i++)
		{
			if (a[i].indexOf("#")!=0)
			{ 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

// function call example
// MM_swapImage('Image2','','images/products_f2.jpg',1)

function MM_swapImage() 
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null)
	{
		document.MM_sr[j++]=x;
		if(!x.oSrc) 
			x.oSrc=x.src; 
		x.src=a[i+2];
	}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; 
  
  document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) 
		eval(args[i]+".location='"+args[i+1]+"'");
}

function ChangeLinkClass(o_lnk, b_val, s_class, b_with_img)
{
	if(o_lnk==null)
		return;
		
	o_lnk.className=s_class + (b_val==0 ? "_OFF" : "_ON");
		
	if (b_with_img==1)
	{
		var o_img = o_lnk.firstChild;
		if (o_img.tagName.toUpperCase() == 'IMG')
		{
			s_src = o_img.src;
			if (s_src.length > 0)
			{
				s_extention = s_src.slice(-4);
				o_img.src = s_src.slice(0,s_src.length-5) + ((b_val==0)? "n" : "o") + s_extention;
			}
		}
	}
}

//**************************************************************************
//function returnes the value of entered item, from the received QueryString
//the function is in use by msl_yediot_edit and msl_yediot_ricouz
function GetItemFromQueryString(s_search_query, s_item)
{
	if (s_search_query.indexOf(s_item) != -1)
		return s_search_query.split(s_item+"=")[1].split("&")[0];
	else
		return null;
}


// ----------------------------------------------------------------------

function SetStatus(sStr)
{
	window.status=sStr;
}

var sPeldec="Peldec Decision Systems Ltd.";
window.status=sPeldec;

top.sStatus = new Array(10);
top.sStatus[0]='About Peldec Decision Systems Ltd.';
top.sStatus[1]='Information on Peldec\'s products.';
top.sStatus[2]='Information on Peldec\'s professional services.';
top.sStatus[3]='Peldec\'s customers and partners.';
top.sStatus[4]='News about Peldec\'s activities.';
top.sStatus[5]='Contact information for Peldec.';

// ----------------------------------------------------------------------

function IsNumber(num)
{
	var chrnum=""+num;// char value
	var test="0123456789.-";//making a test string
	var pointCun=0;
	if(chrnum!="")
	{
		if (chrnum.indexOf("-") > 0)
			return false;
			
		for(k=0;k<chrnum.length;k++) //this loop goes over the string 
		{    
			if(chrnum.charAt(k)=='.')
			{
	  			pointCun++;
	  			if (pointCun > 1)//max 1 '.'
				     return false;
			}
			tmpchr=chrnum.charAt(k);        //and look for chars other than numbers
			if(test.indexOf(tmpchr)<0)
			     return false;
		}
	}
	else
		return false;
	return true;
}


function IsDateValid(strDate)
{
      var IsValid=false,ChkDate,d = new Date(),HowManyYears=new Number (60*60*1000*24*365);
      ChkDate= Date.parse(strDate)/HowManyYears;
      //alert("ChkDate="+ChkDate);
      if(!(isNaN(ChkDate)||(ChkDate==0)||(ChkDate<-71)||(ChkDate>1030)))//isNaN for  explorer and 0 for netscape
           IsValid=true; 
      return(IsValid);
}


function Trim(strValue) 
{
     var ichar, icount;
     //var strValue = this;
     ichar = strValue.length - 1;
     icount = -1;
     while (strValue.charAt(ichar)==' ' && ichar > icount)
         --ichar;
     if (ichar!=(strValue.length-1))
         strValue = strValue.slice(0,ichar+1);
     ichar = 0;
     icount = strValue.length - 1;
     while (strValue.charAt(ichar)==' ' && ichar < icount)
         ++ichar;
     if (ichar!=0)
         strValue = strValue.slice(ichar,strValue.length);
     return strValue;
}


function CheckEmail(str)
{
	var pointCun=0 , AtCount=0;
	var test="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_@&'/~+{}*=?^";// a test string
	
	if ( (str.indexOf('@')>0) && str.indexOf('.')>0 && str.charAt(str.length-1) != '.' )
	{
		for(i=0 ; i < str.length; i++) //this loop goes over the string 
		{
			if(str.charAt(i)=='@')
			{
				AtCount++;
				if (AtCount > 1)//max 1 '@'
				     return false;
			}
			
			//and look for ileagal chars
			if(test.indexOf(str.charAt(i))<0)
				return false;
		}
		return true;
	}
	return false;
}

function EscapeXml(sStr)
{

/*
<!ENTITY lt     "&#38;#60;"> 
<!ENTITY gt     "&#62;"> 
<!ENTITY amp    "&#38;#38;"> 
<!ENTITY apos   "&#39;"> 
<!ENTITY quot   "&#34;"> 
*/

	sStr = sStr.replace("<", "&#38;#60;");
	sStr = sStr.replace(">", "&#62;");
	sStr = sStr.replace("&", "&#38;#38;");
	sStr = sStr.replace("'", "&#39;");
	sStr = sStr.replace('"', "&#34;");
	
	return sStr;
}

//-->
