function Fade_In_Func(Div_Name,Frame_Num)
{
	document.getElementById(Div_Name).style.display='block';
    Fade_In_Out = new OpacityTween(document.getElementById(Div_Name),Tween.EaseOut, 0, 100, Frame_Num);
    Fade_In_Out.start();
}
function Fade_Out_Func(Div_Name)
{

	var Fade_Out = new OpacityTween(document.getElementById(Div_Name),Tween.EaseIn, 100, 0, 0.4);
	var Fade_Lis = new Object();
	Fade_Lis.onMotionFinished = function()
	{
		document.getElementById(Div_Name).style.display='none';
	    document.getElementById(Div_Name).style.filter.opacity=0;
	};
	Fade_Out.addListener(Fade_Lis);
	Fade_Out.start();
}
function Fade_Img(Cur_Div)
{
	    Fade_Out = new OpacityTween(Cur_Div,Tween.EaseIn, 100, 0, 0.5);
        Fade_Out.start();
	    Fade_Out.onMotionFinished = function()
		{
  		    Fade_In = new OpacityTween(Cur_Div,Tween.EaseOut, 0, 100, 0.5);
	        Fade_In.start();
		    Fade_Out2 = new OpacityTween(document.getElementById('Sal_Btn_Div'),Tween.EaseIn, 100, 0, 0.5);
    	    Fade_Out2.start();
		    Fade_Out2.onMotionFinished = function()
			{

	  		    Fade_In2 = new OpacityTween(document.getElementById('Sal_Btn_Div'),Tween.EaseOut, 0, 100, 0.5);
		        Fade_In2.start();

			}
		}
}
function Switch_Divs(Hide_Div,Show_Div,Url_Address)
{
	document.getElementById(Hide_Div).style.display='none';
	document.getElementById(Show_Div).style.display='block';
	if(Url_Address!=undefined && Url_Address.length>10)
		window.frames.IFrame_Video.location.href =Url_Address;

}

function Update_Sum(how_much,Form_Name,Total_Price)
{
//   Form_Name.Price_Order.value=(parseInt(Total_Price)+parseInt(how_much));
	var Old=parseInt(Form_Name.Price_Order.value);
	if(how_much==0 && Add_Mes==true)
		how_much=-50;
   	Form_Name.Price_Order.value=(Old+(parseInt(how_much)) );

}
function Change_Display(Which_Div,Other_Div)
{
	for (i=1; i<=2; i++)
	{
		document.getElementById(Which_Div+'_Div_'+i).style.display='block';
		document.getElementById(Other_Div+'_Div_'+i).style.display='none';
	}

}
function Toggle_Display(Div_Name)
{
	if(Div_Name.style.display=='block')
	{
		document.getElementById('Iframe_In').src=document.getElementById('Iframe_In').src;
		Div_Name.style.display='none';
	}
	else
	{		Div_Name.style.display='block';

	}
}
function nl2br (str, is_xhtml)
{
 var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '' : '<br>';

    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
}
//         GALLERY FUNCTIONS --------------------------
function swapImage(swapImg)
{
   document.getElementById('imageBIG').style.display="block";
 //  document.getElementById('Text_Title').style.display="none";
   document.images['Image_Name'].src=swapImg;
}
function swapImage_Gallery(swapImg,Name_Image)
{
        document.images['Image_Name'].src='../Gallery/'+swapImg;
        document.images['Image_Name'].alt=Name_Image;
        document.getElementById('Text_Img').value=Name_Image;
}
function Show_Next_Prev(RowStart,Genral_QueryString)
{
        ajaxFunction();
        ajaxRequest.onreadystatechange = function()
        {
                if(ajaxRequest.readyState == 4)
                {
                        var ajaxDisplay = document.getElementById('content_Div');
                        ajaxDisplay.innerHTML = ajaxRequest.responseText;
                }
        }
        var queryString = "?RowStart=" + RowStart+ "&"+Genral_QueryString;
        ajaxRequest.open("GET", "Gallery_Inc.php" + queryString, true);
        ajaxRequest.send(null);
}
function Check_Enter(Word_Search)
{
    if (( window.event.keyCode == 13) && (Word_Search.length>0) )
    {
                //Search_Item(Word_Search);
                Submit_It();
    }
  };

function Validate_Search_Item(Form_Name)
{
 if(Form_Name.Word_Search.value.length<3 || Form_Name.Word_Search.value=='לחיפוש דף תוכן')
   {
     alert("נא להקליד לפחות 3 אותיות לחיפוש");
     Form_Name.Word_Search.focus();
     return false;
   }
	Form_Name.action='Search_Results.php';
   return true;
 };
function Submit_It()
{
 if(document.Search_Item.onsubmit())
 {
		document.Search_Item.action='Search_Results.php';

  document.Search_Item.submit();
 }
}
function Submit_It2(Form_Name)
{
 if(Form_Name.onsubmit())
 {
  Form_Name.submit();
 }
}
//         VALIDATION FUNCTIONS --------------------------
function Is_Telephone(Field_F,Field_Name,Heb,Lengh_F,Key_Up)
{
   if (((Field_F.value / Field_F.value) != 1) && (Field_F.value != 0))
   {
       if(Heb==true)
                   alert("בבקשה להקיש ספרות בלבד בשדה ה "+Field_Name);
       else
               alert("please type digits only in the "+Field_Name+" field");
       Field_F.select();
       return false;
   }
   var Str_Phone=Field_F.value.substring(0,2);
   if(Str_Phone==02 || Str_Phone==03 || Str_Phone==04 || Str_Phone==06 || Str_Phone==08 || Str_Phone==09)
   	Lengh_F=9;
   else
   {	   var Str_Phone2=Field_F.value.substring(0,3);
   		if (Str_Phone2=='077' || Str_Phone2=='074' || Str_Phone2=='072' || Str_Phone2=='078')
   		{
		   	Lengh_F=10;
		}
		else
	   {	       alert("נא להקיש טלפון נכון לדוגמא 036785412");
	       Field_F.select();
	       return false;
	   }
   }
   if(Field_F.value.length!=Lengh_F && Key_Up==false)
   {
       if(Heb==true)
                   alert("בבקשה להקיש מספר ספרות מדוייק בשדה ה "+Field_Name);
       else
               alert("please type the right sum of Digits in the "+Field_Name+" field");
       Field_F.select();
       return false;
   }
   return true;
}
function Is_Cell(Field_F,Field_Name,Heb,Lengh_F,Key_Up)
{
   if (((Field_F.value / Field_F.value) != 1) && (Field_F.value != 0))
   {
       if(Heb==true)
                   alert("בבקשה להקיש ספרות בלבד בשדה ה "+Field_Name);
       else
               alert("please type digits only in the "+Field_Name+" field");
       Field_F.select();
       return false;
   }
   var Str_Phone2=Field_F.value.substring(0,3);
  		if (Str_Phone2=='050' || Str_Phone2=='052' || Str_Phone2=='054' || Str_Phone2=='057')
  		{
		   	Lengh_F=10;
		}
		else
	   {
	       alert("נא להקיש טלפון נכון לדוגמא 052658741");
	       Field_F.select();
	       return false;
	   }
   if(Field_F.value.length!=Lengh_F && Key_Up==false)
   {
       if(Heb==true)
                   alert("בבקשה להקיש מספר ספרות מדוייק בשדה ה "+Field_Name);
       else
               alert("please type the right sum of Digits in the "+Field_Name+" field");
       Field_F.select();
       return false;
   }
   return true;
}
function Has_Value_Correct_Arr(Field_F)
{
	var Cur_Form=document.Contact;
	if(Cur_Form.Exist!=undefined)
	{
	    if(Cur_Form.Exist.value=='yes' && Field_F.value!='' )
	    {
	    	return true;
	    }
	}
	for(i=0; i<Name_Ar.length; i++)
	{
	  	if(Field_F.value==Name_Ar[i] || Field_F.value=='')
	  	{
	     	alert("בבקשה להכניס את ה"+Field_F.value);
	    	Field_F.focus();//מחזיר את הסמן לשדה הטקסט החסר
	     	return false;
		}
	}
   return true;
}
function Has_Value_Correct_Arr_Form(Field_F)
{
	var Cur_Form=document.Contact;
	for(i=0; i<Name_Ar.length; i++)
	{
	  	if(Field_F.value==Name_Ar[i] || Field_F.value=='')
	  	{
	     	alert("בבקשה להכניס את ה"+Field_F.value);
//	    	Field_F.focus();//מחזיר את הסמן לשדה הטקסט החסר
	     	return false;
		}
	}
   return true;
}
function Is_Number(Field_F,Field_Name,Heb,Lengh_F,Key_Up)
{
   if(Key_Up==false)
   {
           if(! (Has_Value(Field_F,Field_Name,Heb)) )
           return false;
   }
   if (((Field_F.value / Field_F.value) != 1) && (Field_F.value != 0))
   {
       if(Heb==true)
                   alert("בבקשה להקיש ספרות בלבד בשדה ה "+Field_Name);
       else
               alert("please type digits only in the "+Field_Name+" field");
       Field_F.select();
       return false;
   }
   if(Field_F.value.length<Lengh_F && Key_Up==false)
   {
       if(Heb==true)
                   alert("בבקשה להקיש מספר ספרות מדוייק בשדה ה "+Field_Name);
       else
               alert("please type the right sum of Digits in the "+Field_Name+" field");
       Field_F.select();
       return false;
   }
   return true;
}
function Has_Value(Field_F,Field_Name)
{
   if (Field_F.value=="")
   {
     alert("בבקשה להכניס את "+Field_Name);
     Field_F.focus();//מחזיר את הסמן לשדה הטקסט החסר
     return false;
   }
   return true;
}
function Is_Correct_Email(Field_F)
{
 if(! (Has_Value(Field_F,"הדואר האלקטרוני")) )   return false;
 if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(Field_F.value)))
  {
     alert("הכנס כתובת דואר אלקטרוני נכונה \n   info@catit.co.il  - לדוגמא ");
         Field_F.focus();
     Field_F.select();
     return false;
   }
  return true;
}
function Checked_RedioBottons(Feild)
{
  for (i=Feild.length-1; i > -1 ; i--)
  {
   if (Feild[i].checked)
       return true;
  }
  return false;
}

