function showhidemenu(n)
{
	var uls = $('mainulitem');
	var lis = uls.getElementsByTagName('ul');
	lis = $A(lis);
	//alert('start');
	lis.each(function(li)
					  {
						//new Effect.BlindUp(li); 
						$(li).style.display = 'none';
						//alert('inloop');
					  })
	
	//alert('afterloop');
	$('ulitem'+n).style.display = 'block';
	//new Effect.BlindDown('ulitem'+n);
	//alert('end');
	//return false;
}


function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}

function bookmarksite(title, url){
	if (document.all)
	window.external.AddFavorite(url, title);
	else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
}

function showhide(layer) {
	if (document.getElementById(layer).style.display=='block')
		document.getElementById(layer).style.display = 'none';
	else
		document.getElementById(layer).style.display = 'block';
}

function viewlaer(layer)
{
	$('item1').style.visibility = 'hidden';
	$('item2').style.visibility = 'hidden';
	$(layer).style.visibility = 'visible';
}

function hidelayer(layer)
{
	$(layer).style.visibility = 'hidden';
}
function checkEmail() {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email1').value))
		return true;
	else
		alert("Invalid E-mail Address! Please re-enter.")
	return false;
}

function checkContact() {
	var msg = '';
	if (document.getElementById('cname').value=='')
		msg = msg + "חובה להזין שם\n";
	if (document.getElementById('ccontent').value=='')
		msg = msg + "חובה להזין את תוכן הפניה\n";
	if (document.getElementById('cemail').value=='')
		msg = msg + "חובה להזין כתובת דואר אלקטרוני\n";
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('cemail').value)) 
		msg = msg;
	else
		msg = msg + "כתובת הדואר האלקטרוני לא תקינה";
		
	if (msg=='') return true;
	alert(msg);
	return false;
}

function opendialog(file,p,w,h)
{
	var op = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+w+',height='+h+'';
	var fl = 'http://www.fat-fish.co.il/includes/dialogs/'+file+'.php?'+p;
	window.open(fl,"dialog",op);
}

function externals()
{
	/*
	var a = document.body.getElementsByTagName("a");
	var r;
	for (r in a)
	{
		if (a[r].getAttribute("rel")=="external")
			a[r].setAttribute("target","_blank");
	}
	*/
}
var font_size = 12;

function increaseTextSize()
{
	if (font_size < 17)
	{
		font_size+=2;
		document.getElementsByTagName('body')[0].style.fontSize = font_size + 'px';
	}
}
function reduceTextSize()
{
	if (font_size > 9)
	{
		font_size-=2;
		document.getElementsByTagName('body')[0].style.fontSize = font_size + 'px';
	}
}




var Scroller = function(frameId,contentId,direction,tempo,w,h)
{
	// default parameters
	var thisObj 		= this;
	this.nXlocation 	= 0;
	this.nYlocation 	= 0;
	this.nFrameHeight 	= h;
	this.nFrameWidth	= w;
	this.nTempo			= tempo;
	this.strDirection	= direction;
	this.scrollerStat	= true;
	this.objFrame		= document.getElementById(contentId);
	
	// frame parameter
	f = document.getElementById(frameId);
	f.style.height 	= h+'px';
	f.style.width 	= w+'px';

	this.MoveScroller = function()
	{
		switch(this.strDirection)
		{
			case 'u':	// moving up
				this.nXlocation--;
				this.objFrame.style.top=this.nXlocation+"px";
				break;
			case 'd':	// moving sown
				this.nXlocation++;
				this.objFrame.style.top=this.nXlocation+"px";
				break;
			case 'r':	// moving right
				this.nYlocation++;
				this.objFrame.style.left=this.nYlocation+"px";
				break;
			case 'l':	// moving left
				this.nYlocation--;
				this.objFrame.style.left=this.nYlocation+"px";
				break;
		}
	}

	this.CheckScroller = function()
	{
		switch(this.strDirection)
		{
			case 'u':
				if ((0-this.nXlocation) > this.objFrame.offsetHeight)
				this.nXlocation = this.nFrameHeight;
				break;
			case 'd':
				if (this.nXlocation > this.nFrameHeight)
				this.nXlocation = -this.objFrame.offsetHeight;
				break;
			case 'r':
				if (this.nYlocation > this.nFrameWidth)
				this.nYlocation = -this.objFrame.offsetWidth;
				break;
			case 'l':
				if ((0-this.nYlocation) > this.objFrame.offsetWidth)
				this.nYlocation = this.nFrameWidth;
				break;
		}	
	}
	
	this.RunScroll = function()
	{
		if (this.scrollerStat)
		{
			this.MoveScroller();
			this.CheckScroller();
		}
	}
	
	this.StartScroll = function()
	{
		setInterval(function() { thisObj.RunScroll(); },thisObj.nTempo);
	}
	
	this.Hlat 	= function() { this.scrollerStat = false; }
	this.Resume = function() { this.scrollerStat = true; }
	
}


function CheckRegisterForm()
{
	var msg = '';
	
	if ($('fname').value=='')		msg += "יש להזין שם פרטי\n";
	if ($('lname').value=='') 		msg += "יש להזין שם משפחה\n";
	if ($('street').value=='')	 	msg += "יש להזין רחוב\n";
	if ($('house').value=='') 		msg += "יש להזין מספר בית\n";
	if ($('city').value=='') 		msg += "יש להזין ישוב\n";
	if ($('idnumber').value=='')	msg += "יש להזין מספר תעודת זהות\n";
	if ($('birthday').value=='') 	msg += "יש להזין תאריך לידה\n";
		
	if (msg == '') return true;
	alert(msg);
	return false;
}

function CheckRegisterFormNet()
{
	var msg = '';
	
	if ($('fname').value=='')		msg += "יש להזין שם פרטי\n";
	if ($('lname').value=='') 		msg += "יש להזין שם משפחה\n";
	if ($('birthday').value=='') 	msg += "יש להזין תאריך לידה\n";
	if ($('email').value=='') 		msg += "יש להזין כתובת דואר אלקטרוני, כתובת זו משמשת לכניסה למערכת\n";
	
	if ($('password').value=='') 	msg += "יש לבחור סיסמה\n";
	if ($('password').value!=$('cpassword').value) 	msg += "סיסמה ואישור סיסמה צריכים להיות זהים\n";

	if (msg == '') return true;
	alert(msg);
	return false;
}





// flash //
function show_flash(flash_source, flash_width, flash_height, flash_vars)
{
	document.write('<NONSCRIPT><EMBED SRC="'+flash_source+'" swLiveConnect=FALSE WIDTH='+flash_width+' HEIGHT='+flash_height+' QUALITY=AUTOLOW MENU=false PLAY=true FLASHVARS="'+flash_vars+'" WMODE=transparent TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></NONSCRIPT>')
}

function show_flash_object(flash_source, flash_width, flash_height, flash_vars)
{
	document.write('<NONSCRIPT><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=3,0,0,0" ID=ECHOECHO WIDTH='+flash_width+' HEIGHT='+flash_height+'>')
	document.write('<PARAM NAME=movie VALUE="'+flash_source+'">')
	document.write('<PARAM NAME=quality VALUE=AUTOLOW>')
	document.write('<PARAM NAME=play VALUE=true>')
	document.write('<PARAM NAME=wmode VALUE=transparent>')
	document.write('<PARAM NAME=menu VALUE=false>')
	document.write('<EMBED SRC="'+flash_source+'" swLiveConnect=FALSE WIDTH='+flash_width+' HEIGHT='+flash_height+' QUALITY=AUTOLOW MENU=false PLAY=true FLASHVARS="'+flash_vars+'" WMODE=transparent TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>')
	document.write('</OBJECT></NONSCRIPT>')
}

function setdivhtml(id, html)
{
	$(id).innerHTML = html;
}

