
 
/////////////////// פונקציה שמוודאת דוא"ל
function fValidEmail(strEmail)
{
	return  /^[\w\-]+@[a-z0-9\-]+\.(?:[a-z0-9]+\.)*[a-z]{2,4}$/i.test(strEmail);
}

function fIsNumeric(strNum)
{
	return /^\d+$/.test(strNum);
}

///////////////האם הקלט הוא מספר עשרוני?
function fIsFloat(strNum)
{
	return /^\d+\.\d+$/.test(strNum);
}

/////////	// האם הקלט מורכב מאותיות ומספרים בלבד? )ישמש לבדיקת שמות המשתמש)
function fIsAlphanumeric(str)
{

	return /^[\da-zA-Zא-ת]+$/i.test(str);
}
///////////////  // בדיקת תקינות של קובץ
function fIsValidFileName(str)
{

	  return /(?:[^\\]*\\)*([a-z\d\-\_]+)\.(gif|jpg|png)/.test(str);
}

//////////////מסירה רווחים משני צידי הקלט
	
function Trim(str)
{
	return str.replace(/^\s*(\S(?:.|\n)+\S)\s*$/,"$1");
}
 
	
///////////////////////פותחת חלון של תזכורת סיסמא

function fucForgetPass()
{
    window.open('/ic/flash/login/forgetPass.asp','forgetPass','location=no,status=no,left=280,top=200,scrollbar=no,width=350,height=200');
}

///////////////////// בודק תזכורת סיסמא
function checkForgetPass(strEmail1)
{
	a=true;
	if(!fValidEmail(strEmail1))
	{
		alert("אנא הכנס דואר אלקטרוני");
		forgetPassform.email.focus();
		a=false;
		return false;
	}
    else
    {
	  	(a)? forgetPassform.submit():"";
   	}
}

 
///////////////////// בודק לוגאין
function checkLogIn(userLogIn, userPass, vlogInForm)
{
	 
	a=true
	if(!fValidEmail(userLogIn.value))
	{
		alert("הכנס שם משתמש תקין");
		userLogIn.focus();
		a=false;
		return false;
	}
	
	if(!fIsAlphanumeric(userPass.value))
	{
		alert("הכנס סיסמא תקינה");
		userPass.focus();
		a=false;
		return false;
	}
	(a)? document.getElementById(vlogInForm).submit():"";
}
	
////////// מחזירה ארור לפקד

function inputEror(strText, erorText)
{
	alert(erorText);
	strText.value="";
	strText.focus();
	a=false;
	return false;
}// inputEror()
	 
function show(section) 
{
    for (var i = 0; i < sections.length; i++) 
    {
        if (sections[i] == section) 
        {
            document.getElementById(sections[i]).style.display = 'block';
        } else 
        {
            document.getElementById(sections[i]).style.display = 'none';
        }//if
    }//for
}//show

/////////////////////////////////////////////////////////////////
function showAll(section) 
{
    for (var i = 0; i < sections.length; i++) 
    {
       document.getElementById(sections[i]).style.display = 'block';
    }//for
}//showAll

//////////////////////////////////////
 function closeAll(section) 
 {
    for (var i = 0; i < sections.length; i++) 
    {
       document.getElementById(sections[i]).style.display = 'none';
    }//for
}//closeAll

//////////////////////////////////////

function add2F(isChecked, appID)
{
    //alert(document.getElementById("apparment"+appID) )
	//var strAppID=new String()
	var strAppID=document.cookie.toString ()
	if (strAppID.indexOf("appID=")==0){
		 strAppID=strAppID.substring (strAppID.indexOf("appID=")+6, strAppID.indexOf(";"));
	}
	else
	{
	    strAppID="";
	}
	if (isChecked)
	{
		strAppID="appID=~"+appID+"~,"+strAppID;
		document.cookie =strAppID;
		changeColor("apparment"+appID,"#F6F7F9");
	}
	else
	{
     	strAppID="appID="+ strAppID.replace( "/,~"+appID+"~/\g" ,"");
 		document.cookie =strAppID;
 		changeColor("apparment"+appID,"#fff");
 	}//if
	 
}//add2F

function changeColor(secID, color)
{
	document.getElementById(secID).style.backgroundColor=color;
}//changeColor

/////////////////////////////////////////////////////////


function checkAll(isChecked)
{
	var addToSec=document.getElementsByName("addToSec");
	if (isChecked)
	{
		for (i=0;i<addToSec.length;i++)
		{
			addToSec.item(i).checked=isChecked;
			var appID=document.getElementById(addToSec.item(i).id).parentElement.parentElement.parentElement.id;
			appID=appID.replace("apparment","");
			isChecked=isChecked;
			add2F(isChecked, appID);
		}//for
	 }
	else
	{
    	for (i=0;i<addToSec.length;i++)
    	{
			addToSec.item(i).checked=isChecked;
			var appID=document.getElementById(addToSec.item(i).id).parentElement.parentElement.parentElement.id;
			appID=appID.replace("apparment","");
			isChecked=isChecked;
			add2F(isChecked, appID);
		}//for
	    document.cookie="appID=;expires = new Date()-1; ";
	}//else
}//checkAll

function	showBox()
{
    strAppID=new String();
    var strAppID=document.cookie.toString ();
	if (strAppID.indexOf("appID=")==0)
	{
		strAppID=strAppID.substring (strAppID.indexOf("appID=")+6, strAppID.indexOf(";"));
		re = /~/g;
		strAppID=   strAppID.replace(re,'');
	    alert( strAppID.replace(re,''));
	}
	else
	{
	    strAppID="";
	}
	window.open("showBox.asp", "box", "width=330, height=500, status=yes, scroll=yes"); 
}
////////////////////////////////////////////////////////////
///הפונקציה מראה את המודעות הנבחרות לפי עוגיה.
//
/////////////////////////////
function	showF()
{ 
    var strAppID=document.cookie.toString ()
	if (strAppID.indexOf("appID=")==0)
	{
	    strAppID=strAppID.substring (strAppID.indexOf("appID=")+6, strAppID.indexOf(";"));
	    re = /~/g;
	    strAppID=strAppID.replace(re,'');
	    window.open("showBox.asp", "box", "width=390, height=500, status=yes, scrollbars=yes")	;
	}
	else
	{
	    strAppID="";
	    alert( "לא בחרת כלום");
	}
}

////////////////////////////////////////////////////
// מראה את הצקבוקס כשר ואת האיזור לפי הקטגוריה
////////////////////////////////////////////////////

function isKosher(catID)
{
//alert(catID)
	/*check Foot 155 */
	if ((catID==151)||(catID==150))
	{
	    document.getElementById("kosher").style.visibility="";
	}
	else
    {
	    document.getElementById("kosher").style.visibility="hidden";
	}
	if ((catID==154)||(catID==153)||(catID==164))
	{
	    document.getElementById("area").style.visibility="hidden";
	}
	else
    {
	    document.getElementById("area").style.visibility="";
 	}
}


////////////////////////////////////////////////////
// פונקציה מראה את הקופון
////////////////////////////////////////////////////

function showCupon(showCuponID)
{
    window.open("/drYang/flash/templete/showCupon.asp?articlID="+showCuponID ,"showCupon1","top=50,left=50,width=450, height=300");
}

 
////////////////////////////////////////////////////
// הפונקציה שואבת את תוצאות החיפוש
////////////////////////////////////////////////////

function GetXmlResponse(DataToSend, URL, bText, thisID,tableID)
{
	URL	="/drYang/flash/templete/pages/"+ URL +".asp";
	btnID=document.getElementById("btnID"+thisID);
	divID =document.getElementById("moreDetails"+thisID);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",URL + '?rand='+ Math.random() ,false);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send( DataToSend);
	//return(bText?xmlhttp.responseText:xmlhttp.responseXML);
//	alert(xmlhttp.responseText)
	divID.innerHTML =xmlhttp.responseText;
	btnNew='<button class="'+btnID.className +'Over" id="'+ btnID.id+'" onclick=show_Hide("' +thisID+'","'+ btnID.className +'")> </button>';
	//alert(btnNew)	
	show_Hide(thisID,btnID.className);
	btnID.outerHTML=btnNew;
	document.location.hash=tableID;
}
	
 

function GetXmlcomments(DataToSend, URL, bText, thisID,tableID)
{
	URL	="/drYang/flash/templete/pages/"+ URL +".asp";
	btnID=document.getElementById("btnCommentsID"+thisID);  
	divID =document.getElementById("comments"+thisID);
 //alert(thisID)
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",URL + '?rand='+ Math.random() ,false);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send( DataToSend);
	//return(bText?xmlhttp.responseText:xmlhttp.responseXML);
//	alert(xmlhttp.responseText)
	divID.innerHTML =xmlhttp.responseText;
	btnNew='<button class="'+btnID.className +'Over" id="'+ btnID.id+'" onclick=show_HideComments("' +thisID+'","'+ btnID.className +'")> </button>';
	//alert(btnNew)	
	show_HideComments(thisID,btnID.className);	
	btnID.outerHTML=btnNew;
	document.location.hash=tableID;
	}
////////////////////////////////////////////////////
// הפונקציה מעלימה ומסתירה את תוצאות התגובות
////////////////////////////////////////////////////
function show_HideComments(thisID,className)
{
   divID =document.getElementById("comments"+thisID);
   btnID=document.getElementById("btnCommentsID"+thisID);
  //  alert(className)
  //alert(divID.style.display )
   divID.style.display= (divID.style.display=="none") ? "block" : "none";
   btnID.className= (divID.style.display=="none") ? className : className+"Over";
}
/////////////////////////////////
////////////////////////////////////////////////////
// הפונקציה מעלימה ומסתירה את תוצאות החיפוש
////////////////////////////////////////////////////
function show_Hide(thisID,className)
{
   divID =document.getElementById(thisID);
   divID.style.display=(divID.style.display=="none") ? "block" : "none"; 
}
/////////////////////////////////
 
 
