﻿var CookesArr="";
var szInfoArr = new Array();
var szTitlePage=" vTop - מתכונים מצולמים "
var GLOBAL_REC ="0";
var GLOBAL_CAT ="0";

var TmpArr = new Array();
var CategoryTmpArr = new Array();
var CategoryDirectTmpArr = new Array();
var RandomTmpArr = new Array();

var bShareVisible=false;


function RandomRecipe(){
    var RandomTmpArrFull = new Array();

    CategoryIran("Random");
    RandomTmpArrFull = RandomTmpArr;
    // alert(RandomTmpArrFull);
    CategoryYemeni("Random");
    RandomTmpArrFull = RandomTmpArr;
    // alert(RandomTmpArrFull);
     
    //alert(RandomTmpArrFull[3]);
    for (var i=0;i<RandomTmpArrFull.length;i++) {
            alert(RandomTmpArrFull[i]);
    }

}

function Search(szKeyWord){
    if (szKeyWord){
        szSearchMe = szKeyWord
    }
    else{
        szSearchMe = document.getElementById("txtSearch").value;
        if (szSearchMe==""){
            return;
        }
    }    
    var SearchArr = new Array();
    var SearchArrTmp = new Array();
    var FoundItems = new Array();
    var ItemSplit = new Array();
    var ItemSplit2 = new Array();
    var iPos = 0;
    var szSearchResultGUI="";

    SearchArr = CategoryIran("",true);
    SearchArr=SearchArr.concat(CategoryYemeni("",true));
    SearchArr=SearchArr.concat(CategoryMorocco("",true));
    SearchArr=SearchArr.concat(CategoryJapan("",true));
    SearchArr=SearchArr.concat(CategoryItaly("",true));
    SearchArr=SearchArr.concat(CategoryIndia("",true));
    SearchArr=SearchArr.concat(CategoryLibya("",true));
    SearchArr=SearchArr.concat(CategorySouthAmerica("",true));
    SearchArr=SearchArr.concat(CategoryMainCourse("",true));
    SearchArr=SearchArr.concat(CategoryFirstCourseAndSalad("",true));
    SearchArr=SearchArr.concat(CategoryAddition("",true));
    SearchArr=SearchArr.concat(CategoryBazzek("",true));
    SearchArr=SearchArr.concat(CategorySweet("",true));
    SearchArr=SearchArr.concat(Passover("",true));
    SearchArr=SearchArr.concat(CategoryGrill("",true));
    SearchArr=SearchArr.concat(CategoryPoland("",true));
    SearchArr=SearchArr.concat(CategoryPurim("",true));

    //reset the global var
    GLOBAL_REC ="0";
    GLOBAL_CAT ="0";
    
    for (var i=0;i<SearchArr.length;i++) {
        //SearchArrTmp=SearchArr[i].split("|");
        iPos = SearchArr[i].indexOf(szSearchMe);
        if (iPos != -1) {
            //alert(SearchArr[i]);
            FoundItems.push(i);
        }
    }
//alert(document.getElementById("txtSearch").value);
//onmouseover=\"this.className='SearchResultOver'\"
    clearBoard();
    
     if (!szKeyWord){
 	    document.getElementById('oTitle').innerHTML = "חיפוש באתר";
    }
    else{
        document.getElementById('oTitle').innerHTML = szKeyWord;
    }
    
    document.getElementById('oNotes').innerHTML = "נמצאו: " +FoundItems.length +"  מתכונים ";

    for (var i=0;i<FoundItems.length;i=i+2) {
        ItemSplit = SearchArr[FoundItems[i]].split("|");

        
        if (typeof SearchArr[FoundItems[i+1]] == "undefined"){
            ItemSplit2[0]="img/dot.gif";
            ItemSplit2[1]=" ";
            ItemSplit2[2]="FakeClick";

         }
         else{
            ItemSplit2 = SearchArr[FoundItems[i+1]].split("|");
         }   
        
        
            szSearchResultGUI +="    <table class=\"SearchResult\" cellpadding='2' cellspacing='0' border='0'>";
            
            
            szSearchResultGUI +="        <tr>";
            szSearchResultGUI +="            <td width=\"120px\" onclick=\""+ItemSplit[2] +"()\" style=\"cursor:hand;text-align:right;padding-left:20px\"   >"+ ItemSplit[1] +"</td>";
            szSearchResultGUI +="            <td width=\"120px\" ><img onclick=\""+ItemSplit[2] +"()\" style=\"cursor:hand;width:120px;height:90px;\"  src=\"" + ItemSplit[0] +"\"></td>";

            szSearchResultGUI +="            <td width=\"120px\" onclick=\""+ItemSplit2[2] +"()\" style=\"cursor:hand;\"   >"+ ItemSplit2[1] +"</td>";
            szSearchResultGUI +="            <td width=\"120px\" ><img onclick=\""+ItemSplit2[2] +"()\" style=\"cursor:hand;width:120px;height:90px;\"  src=\"" + ItemSplit2[0] +"\"></td>";
            szSearchResultGUI +="        </tr>";
            
            szSearchResultGUI +="        <tr>";
            szSearchResultGUI +="            <td colspan=\"4\" class=\"Separate\" ></td>";
            szSearchResultGUI +="        </tr>";
            szSearchResultGUI +="    </table>";
            document.getElementById('Search').innerHTML = szSearchResultGUI;
        
    }
//alert(document.getElementById("Search").innerHTML);

}

function FakeClick(){

}
function UserPress(e){
/**/
  // IE
  if(window.event){
  keynum = e.keyCode;
  }
  // Netscape/Firefox/Opera
  else if(e.which){
  keynum = e.which;
  }
  //keychar = String.fromCharCode(keynum);
  
  if(keynum==13){
    //Press ENTER
    Search();
  }
}

/***************************************************************************************************************************************************************
****************************************************************************************************************************************************************
****************************************************************************************************************************************************************
****************************************************************************************************************************************************************
****************************************************************************************************************************************************************
****************************************************************************************************************************************************************
* ShowCategory  - ShowCategory
****************************************************************************************************************************************************************
****************************************************************************************************************************************************************/
function ShowCategory(DirectRecipe,CategoryTmpArr,szTitle){

if(DirectRecipe!=""){
    GLOBAL_REC = DirectRecipe; // display the direct link without conflict
}

    if (DirectRecipe!=""){
        if (DirectRecipe=="Random"){
                for (var i=0;i<CategoryTmpArr.length;i++) {
                            //alert(DirectRecipe+"###"+CategoryTmpArr[i]+"###"+i);
                            //alert(CategoryTmpArr[i].indexOf(DirectRecipe+".jpg"));
					        
					            CategoryDirectTmpArr=CategoryTmpArr[i].split("|"); 
					            //alert(CategoryDirectTmpArr[2] +"<<<");
					            RandomTmpArr[i] = CategoryDirectTmpArr[2];
                                
			        }
			        //alert(RandomTmpArr);
			        return RandomTmpArr;
        }
        
        else{
                //for (var i=CategoryTmpArr.length-1; i>0 ;i--) {
                //alert(i);
                for (var i=0;i<CategoryTmpArr.length;i++) {
                            //alert(DirectRecipe+"###"+CategoryTmpArr[i]+"###"+i);
                            //alert(CategoryTmpArr[i].indexOf(DirectRecipe+".jpg"));
					        if(CategoryTmpArr[i].indexOf(DirectRecipe+".jpg")>0){
					            CategoryDirectTmpArr=CategoryTmpArr[i].split("|"); 
					            var szRecipe =CategoryDirectTmpArr[2];
					            //alert(szRecipe);
	                            eval(szRecipe+"()");
	                            //alert(szRecipe);
                                return;
					        }
			     }
		}
    }
    
   var DynamicRow = parseInt((CategoryTmpArr.length / 3)+1)

	CreateCategoryTable(DynamicRow,3);
	FillCategoryImg(DynamicRow,3,CategoryTmpArr);
	document.getElementById('oNotes').innerHTML = "";
	document.getElementById('oTitle').innerHTML = szTitle;
	document.title = szTitlePage + szTitle;
}

    function updateFBMetaInfo (_currentURL, _type, _title, _description, _imageURL)    {
        metatags = document.getElementsByTagName("meta");
        for (i = 0; i < metatags.length; i++)    {
            var property = metatags[i].getAttribute("property");
            var content = metatags[i].getAttribute("content");
//            if (property == "og:type" && _type)    {
//                  metatags[i].setAttribute("content", _type);
//            }
            if (property == "og:title" && _title)    {
                  metatags[i].setAttribute("content", _title);
            }
//            if (property == "og:image" && _imageURL)    {
//                  metatags[i].setAttribute("content", _imageURL);
//            }
//            if (property == "og:url" && _currentURL)    {
//                  metatags[i].setAttribute("content", _currentURL);
//            }
//            if (property == "og:description" && _description)    {
//                  metatags[i].setAttribute("content", _description);
//            }
        }
    }


/*****************************************************
******************************************************
* RecipeImages  - Dynamic Recipe Images
******************************************************
******************************************************/
function RecipeImages(CategoryFolder,RecipeFolder,TmpArrString,NumberOfPic,Title,szAuther,bShowRecipeIcon,szheight,nLevel){
	TmpArr = new Array();

	var szPathPic = "img/"+CategoryFolder+"/"+RecipeFolder+"/";
	var nNextPic=0;
	
	if (szheight==""){
	    szheight ='700';
	}
	
	if (!nLevel){
	    img_level="bar_level0.png";
	}
	else{
        img_level="bar_level"+nLevel+".png";
	}
	
/*	*/
	for(i=0;i<NumberOfPic;i++){
		if (i==5){
			//TmpArr[i]="ad|www";
			//i++
		}
		if (typeof TmpArrString[i]=="undefined"){
			TmpArrString[i]="";
		}		
		
		nNextPic = i+1;
		TmpArr[i]=szPathPic +nNextPic+".jpg|"+TmpArrString[i];
	}
	
 	var col =NumberOfPic/3;
 	CreateTable(col,3);
	FillImg(col,3,TmpArr);

	//Auther
	document.getElementById('oNotes').innerHTML = szAuther ;
	/**/
	document.getElementById('oNotes').innerHTML +="<BR>" ;
	document.getElementById('oNotes').innerHTML +=" : קישור ישיר למתכון" ;
	document.getElementById('oNotes').innerHTML +="<BR>" ;
	//document.getElementById('oNotes').innerHTML +="<input type=text size=40 value="+GetDirectLink()+">";
	document.getElementById('oNotes').innerHTML +="<a href="+GetDirectLink()+">"+GetDirectLink()+"</a>";
	
	var szRecipeLink = GetDirectLink();
	//URL-encoding 
    szRecipeLink = escape(szRecipeLink);
    szRecipeLink = szRecipeLink.replace(':','%3A');
    szRecipeLink = szRecipeLink.replace('//','%2F%2F');
    var sBarCodeLink = "http://qrcode.kaywa.com/img.php?s=2&d=" + szRecipeLink;
	// BarCode
	document.getElementById('oBarCode').innerHTML ="<img style=\"cursor:hand;\" alt=\" קוד לסריקה באמצעות הטלפון -לחץ להסבר \" onclick=\"window.open('http://qr.vtop.co.il','window','');\" src="+sBarCodeLink+"   />";  //http://qrcode.kaywa.com/img.php?s=2&d=http%3A%2F%2Ffood.vtop.co.il%3FCat%3D30%26Rec%3D4
	
	// BarCode text
	//document.getElementById('oBarCodeText').innerHTML ="QR קוד <br> לסריקה באמצעות  <br> הטלפון";
	
	//oFaceBook
	
//    var szFB = "<div id='fb-root'></div>";
//    szFB += "<script>(function(d, s, id) {";
//    szFB += "var js, fjs = d.getElementsByTagName(s)[0];";
//    szFB += "if (d.getElementById(id)) {return;}";
//    szFB += "js = d.createElement(s); js.id = id;";
//    szFB += "js.src = '//connect.facebook.net/en_US/all.js#xfbml=1';";
//    szFB += "fjs.parentNode.insertBefore(js, fjs);";
//    szFB += "}(document, 'script', 'facebook-jssdk'));</script>";
//    szFB += "<div class='fb-like'  data-href='http://food.vtop.co.il' ";
//    szFB += ""; //data-send='false'
//    szFB += "data-width='450' data-show-faces='true'></div>";
    
    var szURL = szRecipeLink;
   //$('meta[name=og:title]').attr('og:title', Title);
   //$('meta[name=description]').attr('description', new_description);  
    //updateFBMetaInfo("","",Title+" - מתכונים מצולמים ","","");
//    var szFB ="<meta property='og:title' content='"+Title+"- מתכונים מצולמים  '/>";
//    szFB +="<meta property='og:url' content='"+szURL+"'/>";    
//    szFB +="<meta property='og:image' content='http://food.vtop.co.il/img/fb.jpg'/>";
    //szFB +="<meta property='og:type' content='Products and Entertainment'/>";    
    //szFB +="<meta property='og:site_name' content='מתכונים מצולמים - food.vtop.co.il'/>";
    //szFB +="<meta property='fb:admins' content='100002470993741'/>";

    var szFB = "<iframe src='http://www.facebook.com/plugins/like.php?href="+szURL+"'&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=80' scrolling='no' frameborder='0' style='border:none; overflow:hidden;  height:30px;' allowTransparency='true'; text-align=left;></iframe>";
	
	document.getElementById('oFaceBook').innerHTML =szFB;
	
	// BarCode explain
	document.getElementById('oBarCodeExplain').innerHTML =" קוד ליצירת<br> לינק לעמוד<br> מתכון זה <a href=\"http://qr.vtop.co.il\" onclick=\"window.open(this.href,'window','') ;return false;\">הסבר</a> ";
	
	// Icons
	document.getElementById('oTitleBar').innerHTML ="";
	
   	//back Icon
	document.getElementById('oTitleBar').innerHTML +="<img alt=\"חזרה\" style=\"cursor:hand;\" onmouseover=\"this.style.backgroundImage='url(img/bar_back.png)';\" onmouseout=\"this.style.backgroundImage='url(img/bar_back.png)';\" onclick=\""+CategoryFolder +"()\" src=\"img/bar_back.png\"/>"+"<img src=\"img/dot.gif\" width=\"1px\"/>";

    var szRecipeExists ="מתכון";
    //RecipeIcon
	if(bShowRecipeIcon){
	    document.getElementById('oTitleBar').innerHTML +="<img alt=\"מתכון\" style=\"cursor:hand;\" onmouseover=\"this.style.backgroundImage='url(img/bar_recipe.png)';\" onmouseout=\"this.style.backgroundImage='url(img/bar_recipe.png)';\" onclick=\"window.location.href='#iframereplacePage'\"  src=\"img/bar_recipe.png\" />" +"<img src=\"img/dot.gif\" width=\"1px\"/>";
	    var sUrlRecipe ="img/"+CategoryFolder+"/"+RecipeFolder+ "/recipe.htm" ; 
        replacePage(sUrlRecipe,szheight,'oRecipe',false);
    }
    else{
        	    document.getElementById('oTitleBar').innerHTML +="<img alt=\" מתכון בקרוב\" style=\"cursor:hand;\"  src=\"img/bar_recipe.png\" />" +"<img src=\"img/dot.gif\" width=\"1px\"/>";
                szRecipeExists ="מתכון<br>בקרוב";
    }

  	//? Icon
	//document.getElementById('oTitleBar').innerHTML +="<img alt=\" שאלה לשולח המתכון\" style=\"cursor:hand;\" onmouseover=\"this.style.backgroundImage='url(img/bar_ask.png)';\" onmouseout=\"this.style.backgroundImage='url(img/bar_ask.png)';\" src=\"img/bar_ask.png\"/>"+"<img src=\"img/dot.gif\" width=\"1px\"/>";

  	//print Icon
	document.getElementById('oTitleBar').innerHTML +="<img alt=\" הדפס מתכון\" style=\"cursor:hand;\" onmouseover=\"this.style.backgroundImage='url(img/bar_print.png)';\" onmouseout=\"this.style.backgroundImage='url(img/bar_print.png)';\"  onclick='parent.iframereplacePage.focus();window.print()' src=\"img/bar_print.png\"/>"+"<img src=\"img/dot.gif\" width=\"1px\"/>";

  	//level Icon
	document.getElementById('oTitleBar').innerHTML +="<img id=\"idLevelImg\" style=\"cursor:hand; height:25px;\"   onmouseout=\"closeLevelHelp();\" onmouseover=\"LevelHelp();\" src=\"img/"+img_level+"\"/>"+"<img src=\"img/dot.gif\" width=\"1px\" />";
    
    //refresh Icon
    document.getElementById('oTitleBar').innerHTML +="<img alt=\"רענן עמוד\" style=\"cursor:hand;\" onmouseover=\"this.style.backgroundImage='url(img/bar_refresh.jpg)';\" onmouseout=\"this.style.backgroundImage='url(img/bar_refresh.jpg)';\" onclick=\""+RecipeFolder +"()\" src=\"img/bar_refresh.jpg\"/>"+"<img src=\"img/dot.gif\" width=\"1px\"/>";


    var szDOT = "<img src=\"img/dot.gif\" width=\"10px\" />";
    var szMenuGUI="";
    //
    szMenuGUI +="    <table  style=\"cursor:hand; height:25px;border-color:#008000\" bgcolor=\"#FFFFFF\"   cellpadding='0' cellspacing='3' border='0'>";
    szMenuGUI +="        <tr style=\"font-size:8px;text-align:center;\">";
    szMenuGUI +="            <td onclick=\""+CategoryFolder +"()\" ><img src='img/bar_back.png' /></td>";
    szMenuGUI +="            <td onclick=\"window.location.href='#iframereplacePage'\"><img src='img/bar_recipe.png' /></td>";
    szMenuGUI +="            <td onclick='parent.iframereplacePage.focus();window.print()'><img src='img/bar_print.png' /></td>";
    szMenuGUI +="            <td onmouseout=\"closeLevelHelp();\" onmouseover=\"LevelHelp();\"><img src='img/"+img_level+"\' style=\"height:25px;\" /></td>";
    szMenuGUI +="            <td onclick=\""+RecipeFolder +"()\"><img src='img/bar_refresh.jpg' /></td>";
    szMenuGUI +="        </tr>";
    szMenuGUI +="        <tr style=\"font-size:10px;text-align:center;font-family:Tahoma;color:#008000;\">";
    szMenuGUI +="            <td onclick=\""+CategoryFolder +"()\">חזרה</td><td onclick=\"window.location.href='#iframereplacePage'\">"+szRecipeExists+"</td><td onclick='parent.iframereplacePage.focus();window.print()'>הדפס<br>מתכון</td><td onmouseout=\"closeLevelHelp();\" onmouseover=\"LevelHelp();\">רמת<br>קושי</td><td onclick=\""+RecipeFolder +"()\">רענן<br>עמוד</td>";
    szMenuGUI +="        </tr>";    
    szMenuGUI +="    </table>";


    document.getElementById('oTitleBar').innerHTML = szMenuGUI;
    //document.getElementById('oFloatingMenu').innerHTML = szMenuGUI;
    
    
    // Caption
    document.getElementById('oTitle').innerHTML = Title;
    document.title = szTitlePage + Title;

    
    //UP
	document.getElementById('goUP').innerHTML = "<img alt=\" חזור למעלה\" style=\"cursor:hand;\" onclick=\"window.location.href='#up'\"  src=\"img/goUP.png\" />" + "<img src=\"img/dot.gif\" width=\"30px\"/>";
 
    //Bottom refresh
    var szRefreshGUI="";
    //
    szRefreshGUI +="    <table class=\"RefreshTable\" onclick=\""+RecipeFolder +"()\" style=\"cursor:hand;\" bgcolor=\"#EEEED8\"   cellpadding='0' cellspacing='2' border='0'>";
    szRefreshGUI +="        <tr>";
    szRefreshGUI +="            <td>במידה וחלק מהתמונות לא נטענו באתר</td>";
    szRefreshGUI +="        </tr>";
    szRefreshGUI +="        <tr>";
    szRefreshGUI +="            <td>לחץ כאן לטעינה חוזרת</td>";
    szRefreshGUI +="        </tr>";
    szRefreshGUI +="        <tr>";
    szRefreshGUI +="            <td><img  src=\"img/bar_refresh.jpg\"/></td>";
    szRefreshGUI +="        </tr>";
    szRefreshGUI +="    </table>";    
    document.getElementById('oRefresh').innerHTML =szRefreshGUI; 
 
    // more recipes...
    // get the all category
	var szCatArr = eval(CategoryFolder+"('',true)");
	var nExcludeRecipesID = new Array();
	
	//alert(szCatArr.length +"||" +szCatArr)
	 // Exclude the current recipe   
     for (b=0; b < szCatArr.length; b++){
        //alert(szCatArr[b].indexOf(trim(Title)) +"|%|" +  Title   +"|%|" + szCatArr[b])
        if (szCatArr[b].indexOf(trim(Title))>0){
            //alert(b +"###"+szCatArr[b])
            //szCatArr.splice(b,1) 
            nExcludeRecipesID.push(b+1);
        }    
     }
     
try{
  
	 // Exclude recipe בקרוב 
	 var szSoon="בקרוב";  
	 //alert(szCatArr.length +"||" +szCatArr);
     for (b=szCatArr.length-1 ; b>0;  b--){
        //alert(szCatArr[b].indexOf(Title))
        //alert(szCatArr[b] +","+ szCatArr[b].indexOf(szSoon));
        if (szCatArr[b].indexOf(szSoon) >0){
            //alert(b+"|"+szCatArr[b])
            //szCatArr.splice(b,1) 
            nExcludeRecipesID.push(b+1);
        }    
     }
     //alert(nExcludeRecipesID);
     //alert(szCatArr.length +"||" +szCatArr);



    // get random numbers
    var nRecipesID = new Array()
    //alert("TmpArrString.length," + szCatArr.length);
    var nLottery = 4; // default number of recipe

    if(szCatArr.length<=4){
        nLottery = szCatArr.length-1; // if 4 is over we take the max category length
    }
    //alert("nLottery  " +nLottery);
    nRecipesID = generate_numbers(nLottery,szCatArr.length,nExcludeRecipesID); // generate numbers
    //alert(nRecipesID);
    var szMoreRecipesGUI="";
    szMoreRecipesGUI +="    <table class=\"MoreRecipes\" cellpadding='10' cellspacing='10' border='0'>";
    szMoreRecipesGUI +="        <tr>";
    szMoreRecipesGUI +="            <td class=\"MoreRecipesCaption\" colspan=\"4\"> מתכונים נוספים שיכולים לעניין אותך";
    szMoreRecipesGUI +="            <a onclick=\""+CategoryFolder +"(); window.location.href='#';\">בקטגוריה זו </a>";
    szMoreRecipesGUI +="         </td>";
    szMoreRecipesGUI +="        </tr>";
    szMoreRecipesGUI +="        <tr>";

//"<a href="+GetDirectLink()+">"+GetDirectLink()+"</a>";

    for (y=1; y < nRecipesID.length; y++){
        //alert(nRecipesID[y]);
        //alert(szCatArr.length);
        var szRecipeRandomItem = szCatArr[nRecipesID[y]-1]; // get the full item for text
        //alert(szRecipeRandomItem);
        var szRecipeRandomItemText = new Array();
        szRecipeRandomItemText = szRecipeRandomItem.split("|");
        szMoreRecipesGUI +="<td style=\"width:120px;vertical-align:text-top;\" onclick=\"" +CategoryFolder +"('"+nRecipesID[y]+"'); window.location.href='#up'; \" ><img  width=\"120\" height=\"90\" src=\"img/" +CategoryFolder + "/" + nRecipesID[y] + ".jpg\"/>";
        szMoreRecipesGUI +=szRecipeRandomItemText[1]; + "</td>"; // write the text
    }

    szMoreRecipesGUI +="   </tr>";
    szMoreRecipesGUI +="</table>"; 
    document.getElementById('oMoreRecipes').innerHTML =szMoreRecipesGUI; 
}
catch(e){alert(e)}  

}

		//*********************************************************************************************************
		//	
		// trim
		//
		//*********************************************************************************************************	
        // Removes leading whitespaces
        function LTrim( value ) {
	        var re = /\s*((\S+\s*)*)/;
	        return value.replace(re, "$1");
        }
        // Removes ending whitespaces
        function RTrim( value ) {
	        var re = /((\s*\S+)*)\s*/;
	        return value.replace(re, "$1");
        }
        // Removes leading and ending whitespaces
        function trim( value ) {
	        return LTrim(RTrim(value));
        }
		//*********************************************************************************************************
		//	
		// generate_numbers
		//
		//******************************************************************************************************    
		function generate_numbers(numbersneeded, maxnumber,exclude)
		{
            var nNum = new Array()
			// get random numbers making sure that each is unique
			duplicates = 1
			do
			{
				nums = get_numbers(numbersneeded,maxnumber)
				duplicates = check_numbers (nums,numbersneeded)
				if(duplicates==0){
				    // no duplicates, we check Exclude list
				    duplicates = exclude_numbers (nums,exclude)
				}
			}
			while (duplicates == 1)
			// display the numbers 
			for ( i = 1; i < numbersneeded+1; i++)
			{
				//doc.write(nums[i])
				nNum[i] = (nums[i]);
//				if (i < numbersneeded)
//				{
//					doc.write(", ")
//				}
			}
			return nNum;
//			doc.write("<\/center>")		
		}
		//*********************************************************************************************************
		//	
		// exclude_numbers
		//
		//*********************************************************************************************************
 
		function exclude_numbers (numbers, exclude )
		{
//		alert(numbers);
//		alert(numbers.length);
//		alert(exclude.length);
			// note that it is assumed that the numbers in the list (array) are in numerical order
			dupnum = 0;
			for ( i=0; i < exclude.length; i++ )
			{
			    for ( j=1; j < numbers.length; j++ ){
			    //alert("if:" + exclude[i] + "==" + numbers[j])
			        if ( exclude[i] == numbers[j] )
				    {
					    dupnum = 1;
					    return dupnum;
				    }
			    }
			}
			return dupnum;
		}		
		//*********************************************************************************************************
		//	
		// function to see if there are any duplicates in a list (array) of numbers
		//
		//*********************************************************************************************************
 
		function check_numbers ( numbers, numofnumbers )
		{
			// note that it is assumed that the numbers in the list (array) are in numerical order
			dupnum = 0
			for ( i=1; i < numofnumbers; i++ )
			{
				if ( numbers[i] == numbers[i+1] )
				{
					dupnum = 1
				}
			}
			return dupnum
		}		
		//*********************************************************************************************************
		//	
		// get_numbers
		//
		//*********************************************************************************************************
		function get_numbers ( numbersneeded , maxnumber )
		{
 
			// function to generate a list of random numbers
			var rnum = new Array()
			for ( i = 1; i < numbersneeded+1; i++)
			{
				rnum[i] = random_number(maxnumber)
			}
			// sort the numbers into numerical order
			sort_numbers ( rnum , numbersneeded )
			return rnum		
		}
		//*********************************************************************************************************
		//	
		// function to create a random number between 1 and upperlimit
		//
		//*********************************************************************************************************
	
		function random_number ( upperlimit )
		{	
			
			randnum = Math.round ( Math.random() * upperlimit )
			if (randnum == 0)
			{
				randnum = 1
			}
			return randnum
		}		
		//*********************************************************************************************************
		//	
		// function to sort an array of numbers into numerical order
		//
		//*********************************************************************************************************		
 
		function sort_numbers ( numbers, numofnumbers )
		{
			// function that takes an array of numbers and sorts them into numerical order
			for ( j=1; j < numofnumbers+1; j++)
			{
				for ( i=1; i < numofnumbers; i++)
				{
					if ( numbers[i] > numbers[i+1] )
					{
						temp = numbers[i+1]
						numbers[i+1] = numbers[i]
						numbers[i] = temp
					}
				}
			}
		}
		


		
//var cursorX =0;
//var cursorY =0;

//function getCursorPosition(eventObject) {
//	     cursorX =eventObject.offsetX;
//	     cursorY =eventObject.offsetY;

//}onMouseMove=\"getCursorPosition(event)\"
function GetDirectLink(){

var szLink ="";

if (GLOBAL_REC=="0" || GLOBAL_CAT=="0"){
    szLink = "http://food.vtop.co.il";
}
else{
    szLink = "http://food.vtop.co.il?Cat="+GLOBAL_CAT+"&Rec="+GLOBAL_REC;
}
return szLink;
}
function LevelHelp(){


   //var oidLevelImg = document.getElementById("idLevelImg");
	//alert(oidLevelImg.style.left);
	
var szLevelGUI="";
//
szLevelGUI +="    <table class=\"HelpLevel\" onclick=\"closeLevelHelp();\" style=\"position:absolute; top:160px; left:210px;\" bgcolor=\"#EEEED8\"   cellpadding='0' cellspacing='0' border='2'>";
szLevelGUI +="        <tr>";
szLevelGUI +="            <td>קשה</td><td>מורכב</td><td>מאתגר</td><td>קל</td><td>קל מאוד</td><td>לא הוגדר</td><td>רמת קושי</td>";
szLevelGUI +="        </tr>";
szLevelGUI +="        <tr>";
szLevelGUI +="            <td><img src='img/bar_level5.png' /></td>";
szLevelGUI +="            <td><img src='img/bar_level4.png' /></td>";
szLevelGUI +="            <td><img src='img/bar_level3.png' /></td>";
szLevelGUI +="            <td><img src='img/bar_level2.png' /></td>";
szLevelGUI +="            <td><img src='img/bar_level1.png' /></td>";
szLevelGUI +="            <td><img src='img/bar_level0.png' /></td>";
szLevelGUI +="            <td>תמונה</td>";
szLevelGUI +="        </tr>";
szLevelGUI +="    </table>";


    document.getElementById('oLevelHelp').innerHTML = szLevelGUI;

//alert(szLevelGUI);
//DivSetVisible('oLevelHelp',true);
oLevelHelp.style.visibility="visible";
}

function closeLevelHelp(){
	oLevelHelp.style.visibility="hidden";
}
/*****************************************************
******************************************************
* CreateCategoryTable
******************************************************
******************************************************/
function CreateCategoryTable(nRows, nCols) {

	clearBoard();
 
    	//back Icon
	document.getElementById('oTitleBar').innerHTML ="<img alt=\"חזרה\" style=\"cursor:hand;\"  onclick=\"window.navigate('http://food.vtop.co.il');\" src=\"img/bar_back.png\"/>"+"<img src=\"img/dot.gif\" width=\"1px\"/>";


   var oDiv = document.getElementById("oDiv");
	oDiv.align="center";

	var oTable = document.createElement("TABLE")
	oTable.setAttribute("cellPadding","0px");
	//oTable.setAttribute("cellSpacing","0");
	oTable.setAttribute("id","tbl");
	oTable.border="0";
	oTable.bgColor="#FFFFFF"; //"#CACACA"; //"#6D7071";//"#3b77b2";
	//oTable.style.fontStyle="italic";
	oTable.style.fontFamily="tahoma";
	oTable.style.fontWeight="bolder";
 	oTable.style.fontSize="12px";
  	oTable.style.color="#008000";
	
	var oTBody = document.createElement("TBODY")
	var oTR,oTD 
	oTable.appendChild(oTBody);

		var JJ;

	
		for (var i=0;i<nRows;i++) {

			oTRCaption = document.createElement("TR");
			oTRCaption.setAttribute('align','right');
			oTRCaption.setAttribute('valign','middle');
			oTRCaption.setAttribute('style','padding-top:0px');
			oTRCaption.setAttribute('id','trCaption'+i);
			//oTRCaption.bgColor="#6D7071";
			oTR = document.createElement("TR");
			oTR.setAttribute('id','trCam'+i);
			oTR.setAttribute('align','center');

			oTRDown = document.createElement("TR");
			oTRDown.setAttribute('align','center');
			oTRDown.setAttribute('id','trDown'+i);

			for (var j=0;j<nCols;j++) {
   		   JJ =nCols-j-1; //arrange the index from right to left
				oTDCaption = document.createElement("TD");
				oTDCaption.setAttribute('id','td_Caption'+i+JJ);
				//oTDCaption.onclick= function() { document.getElementById(this.id).parentNode.removeChild(document.getElementById(this.id));  document.getElementById(this.id.replace('td_Caption','td_Cam')).parentNode.removeChild(document.getElementById(this.id.replace('td_Caption','td_Cam'))) ;return false};
				//oTDCaption.onclick= function() { document.getElementById(this.id).innerHTML="";  document.getElementById(this.id.replace('td_Caption','td_Cam')).innerHTML="" ;return false};

				//oTDCaption.setAttribute('style','background-color:#454738;');
				//oTDCaption.setAttribute('aline', 'right');
				//oTDCaption.innerHTML = i+"-"+j;
				oTRCaption.appendChild(oTDCaption);

				oTD = document.createElement("TD");
				oTD.setAttribute('id','td_Cam'+i+JJ);
				oTD.style.height="180px";
				oTD.style.width="240px";
				//oTD.innerHTML = "&nbsp;";
				oTR.appendChild(oTD);
				
				oTDDown = document.createElement("TD");
				oTDDown.setAttribute('id','td_Down'+i+JJ);
				//oTDDown.innerHTML = "";
				oTRDown.appendChild(oTDDown);			}

					
			oTBody.appendChild(oTRCaption);
			oTBody.appendChild(oTR);
			oTBody.appendChild(oTRDown);
		}
	 oDiv.style.paddingTop="0px";
    oDiv.appendChild(oTable);
    //oTable.border=1
    //alert(document.getElementById("oDiv").innerHTML);
}
function FillCategoryImg__OLD__(nRows, nCols,imgArr) {
		var z=0;
		var length=0;
		var oImg="";
		var indImgArr = 0;
		var bigImg=""
		var CatImgArr = new Array();
		var ooTDDown ="";
		
		for (var i=0;i<nRows;i++) {
			for (var j=0;j<nCols;j++) {
				var ooTD = document.getElementById('td_Cam'+i+j);
				//var ooTDCaption = document.getElementById('td_Caption'+i+j);
				ooTDDown = document.getElementById('td_Down'+i+j);
				//ooTD.innerHTML = i+";"+j;
				//ooTD.innerHTML =imgArr[z];
				if(typeof imgArr[z] != "undefined"){

					szInfoArr = imgArr[z].split("|");
					length = szInfoArr.length;
					//ooTD.appendChild(NewPlayer(szInfoArr[0]));
					
							oImg = document.createElement("img");
							oImg.setAttribute("id",indImgArr);
							indImgArr++;
							//oImg.setAttribute("id","img_"+i+j);
							//oImg.setAttribute("src","img/progress_green_gray.gif"); //loading...
			

							//oImg.setAttribute("src",szInfoArr[0]);
							oImg.style.cursor="hand";
							oImg.style.height="180px";
							oImg.style.width="240px";
							//oImg.style.height="31px";
							//oImg.style.width="31px";
							//ooTD.align="right";
							//oImg.style.padding="15px";
							oImg.style.backgroundColor="#cccccc";

							//ooTD.onclick= function() {alert('3.2'); return false};//"magnifyImg(this.src)"
							//ooTD.onclick= function() {magnifyImg(szInfoArr[0]); return false};
							oImg.onclick= function() {  
								CatImgArr=imgArr[this.id].split("|"); 
								ClickCategory(CatImgArr[0],CatImgArr[1],CatImgArr[2],this.id) ;
								return false
								};
							
							//ooTD.style.height="100px";
							//ooTD.style.paddingTop="50";
							//ooTD.style.backgroundColor="blue";
							ooTD.style.filter ="progid:DXImageTransform.Microsoft.Shadow(color='#FF6600', Direction=225, Strength=8)";

							
							
							// load image after the green progress 
							var imgID = indImgArr-1 ;
							//alert('waitImg("'+oImg+'","'+szInfoArr[0]+'")');
							
							///setTimeout('waitImg("'+imgID+'","'+szInfoArr[0]+'")',1000);
							oImg.setAttribute("src",szInfoArr[0]); //loading...
							
                            ooTD.appendChild(oImg);
                            
					//ooTDCaption.innerHTML = szInfoArr[1];
					ooTDDown.innerHTML = szInfoArr[1];
					//ooTD.appendChild(NewPlayer(imgArr[i]))
					z++;
				}
			}
		}

}

function FillCategoryImg(nRows, nCols,imgArr) {
		//normal order
		var indImgArr = 0;
		var z=0;
        //order from the last
		var z=imgArr.length-1;
		var indImgArr = imgArr.length-1;
		
		var oImg="";
		var bigImg=""
		var CatImgArr = new Array();
		var ooTDDown ="";
		
		var guiImg="";
		
		for (var i=0;i<nRows;i++) {
			for (var j=0;j<nCols;j++) {
				var ooTD = document.getElementById('td_Cam'+i+j);
                ooTD.style.filter ="progid:DXImageTransform.Microsoft.Shadow(color='#FF6600', Direction=225, Strength=8)";

				
				
				if(typeof imgArr[z] != "undefined"){

					    szInfoArr = imgArr[z].split("|"); //result szInfoArr[0]=image,szInfoArr[1]=down text,szInfoArr[2]=
					    CatImgArr=imgArr[indImgArr].split("|");
						guiImg = " <img id="+indImgArr+"   height='180px' width='240px' style=\"cursor:hand;background-color:#FFF1CC; \"  src='"+szInfoArr[0]+"' onclick=\"ClickCategory('"+CatImgArr[0]+"','"+CatImgArr[1]+"','"+CatImgArr[2]+"','"+indImgArr+"'); \" />"
                        ooTD.innerHTML = guiImg;
						
						//alert(guiImg);
						//indImgArr++;
						//z++;
						indImgArr--;
					    z--;
					    
					    //Down Caption
					    ooTDDown = document.getElementById('td_Down'+i+j);
				        ooTDDown.innerHTML = szInfoArr[1];
				}
			}
		}

}

function waitImg(id,src){
//alert(id);
var imgID =document.getElementById(id);
imgID.setAttribute("src",src);

setTimeout('ForceImgLoader("'+id+'","'+src+'")',3000);
//imgID.setAttribute("src","img/progress_green_static.jpg");
//imgID.style.height="180px";
//imgID.style.width="240px";
//setTimeout('IncreaseImg("'+id+'")',1000);
//setTimeout('IncreaseImg("'+id+'","'+src+'")',1000);
}

function ForceImgLoader(id,src){
//alert(id);
var imgID =document.getElementById(id);
imgID.setAttribute("src",src);


}
function IncreaseImg(id,src){
var imgID =document.getElementById(id);
//alert(imgID);

imgID.style.height="180px";
imgID.style.width="240px";
imgID.setAttribute("src",src);
}

function replacePage(szPage,szheight,oElement,bClearBoard){
	
	    if (bClearBoard)
		    clearBoard();
		
		var oDiv = document.getElementById(oElement)
		var oIframe = document.createElement("iframe")
		
		oIframe.setAttribute("id","iframereplacePage");
		oIframe.setAttribute("height",szheight);
		oIframe.setAttribute("width","100%");
		//oIframe.setAttribute("scrolling", "no"); 
		oIframe.setAttribute("frameBorder", "0"); 
		oIframe.setAttribute("src",szPage);
		oDiv.appendChild(oIframe);
		oDiv.align="center";
}
function ClickCategory(imgSrc,szText,catFolder,id){

    var nEnd = imgSrc.length;
    var nStart = imgSrc.lastIndexOf('/');
    GLOBAL_REC = imgSrc.substring(nStart+1,nEnd-4);
    //alert(szRec);

	//alert(imgSrc);
	//alert(id);
	//alert(szText);
	//alert(catFolder);
	//alert("setTimeout('"+catFolder+"()"+"',500);");

	var szEval = "setTimeout('"+catFolder+"("+GLOBAL_REC+")"+"',1);";
	eval(szEval);
    window.location.href='#up'; //jump up
//	Memola();

}

function FillImg(nRows, nCols,imgArr) {
		var z=0;
		var length=0;
		var oImg="";
		var indImgArr = 0;
		var bigImg=""
		var bigImgArr = new Array();
		var ooTDDown ="";

		for (var i=0;i<nRows;i++) {
			for (var j=0;j<nCols;j++) {
			//alert('td_Cam'+i+j);
				var ooTD = document.getElementById('td_Cam'+i+j);
				var ooTDCaption = document.getElementById('td_Caption'+i+j);
				ooTDDown = document.getElementById('td_Down'+i+j);
				//ooTD.innerHTML = i+"-"+j;
				//ooTD.innerHTML =imgArr[z];
				if(typeof imgArr[z] != "undefined"){

					szInfoArr = imgArr[z].split("|");
					length = szInfoArr.length;
					//ooTD.appendChild(NewPlayer(szInfoArr[0]));
					
							oImg = document.createElement("img");
							oImg.setAttribute("id",indImgArr);
							indImgArr++;
							//oImg.setAttribute("id","img_"+i+j);
							oImg.setAttribute("src","img/progress_green_gray.gif"); //loading...

							//oImg.setAttribute("src",szInfoArr[0]);
							oImg.style.cursor="hand";
							//oImg.style.height="31px";
							//oImg.style.width="31px";
							oImg.style.height="180px";
							oImg.style.width="240px";
							//ooTD.align="right";
							//oImg.style.padding="15px";
							//oImg.style.backgroundColor="#000000";

							//ooTD.onclick= function() {alert('3.2'); return false};//"magnifyImg(this.src)"
							//ooTD.onclick= function() {magnifyImg(szInfoArr[0]); return false};
							oImg.onclick= function() {  
								bigImgArr=imgArr[this.id].split("|");
							   magnifyImg(bigImgArr[0],this.id) ;
							   return false
							   };
							
							//ooTD.style.height="100px";
							//ooTD.style.paddingTop="50";
							//ooTD.style.backgroundColor="blue";
							ooTD.style.filter ="progid:DXImageTransform.Microsoft.Shadow(color='#008000', Direction=225, Strength=8)";
							
		ooTD.appendChild(oImg)
							// load image after the green progress 
							var imgID = indImgArr-1 ;
							//alert('waitImg("'+oImg+'","'+szInfoArr[0]+'")');
							setTimeout('waitImg("'+imgID+'","'+szInfoArr[0]+'")',1000);
		
					//ooTDCaption.innerHTML = szInfoArr[1];
		ooTDDown.innerHTML = szInfoArr[1];
					//ooTD.appendChild(NewPlayer(imgArr[i]))
					z++;
				}
			}
		}

}

function magnifyImg(imgSrc,id){

	var nWidth = 400;
	var nHeight = 300;
	var nLeft = (screen.width-nWidth)/3;
	var guiLarge="";
	//alert(nLeft);
	//var nTop = (screen.height-nHeight)/2;

   	
			//Top	
  		   var object = document.getElementById(id);
    		var nTop = object.offsetTop;
		    while (object.tagName != 'BODY' && object.offsetParent){
    			object = object.offsetParent;
		    	nTop += object.offsetTop;
    		}

	//oMagnifyImg.innerHTML="<table bgcolor=\"#000000\" height=\"450\" width=\"450\" cellpadding=\"10\" cellspacing=\"10\" border=\"1\"  ><tr><td><img onclick=\"closeMagnifyImg();\" src=\""+imgSrc+"\" height="+nHeight+" width="+nWidth+" style=\"position:absolute; top:"+nTop+"px; left:"+nLeft+"px;\" /></td></tr></table>";
	guiLarge = "<table  style=\"position:absolute; top:"+nTop+"px; left:"+nLeft+"px;\" bgcolor=\"#6D7071\" height=\"300\" width=\"400\" cellpadding=\"4\" cellspacing=\"4\" border=\"2\"";
	guiLarge = guiLarge +"onclick=\"closeMagnifyImg();\"  >";
	guiLarge = guiLarge +"<tr><td>";
	guiLarge = guiLarge +"<img height=\"100%\" width=\"100%\" src=\""+imgSrc+"\" ";
	guiLarge = guiLarge +"";
	guiLarge = guiLarge +"</td></tr></table>";
	oMagnifyImg.innerHTML=guiLarge;
	oMagnifyImg.style.visibility="visible";
//alert(document.body.innerHTML);
//alert(document.getElementById("oMagnifyImg").innerHTML);

}

function closeMagnifyImg(){
	oMagnifyImg.style.visibility="hidden";
}


function clearBoard(){
	if(document.getElementById("eMessageArea")){
		removeElement("eMessageArea");
	}
	if(document.getElementById("iframereplacePage")){
		removeElement("iframereplacePage");
	}
	if(document.getElementById("iframeFun")){
		document.getElementById("iframeFun").innerHTML = "";
		removeElement("iframeFun");
	}
	if(document.getElementById("iframeReport")){
		removeElement("iframeReport");
	}	
	if(document.getElementById("tbl")){
		//window.document.execCommand('Stop');
		removeElement("tbl");
		//document.getElementById("oDiv").innerHTML = "";
		
	}
	if(document.getElementById("img_intro")){
		removeElement("img_intro");
	}
	if(document.getElementById("oCustom")){
		document.getElementById("oCustom").innerHTML = "";
		removeElement("oCustom");
	}
	/**/
	if(document.getElementById("DivBookInside")){
		document.getElementById("DivBookInside").innerHTML = "";
	}
	if(document.getElementById("oDivA")){
		document.getElementById("oDivA").innerHTML = "";
	}
	if(document.getElementById("oDivB")){
		document.getElementById("oDivB").innerHTML = "";
	}
	if(document.getElementById("oDivC")){
		document.getElementById("oDivC").innerHTML = "";
	}
	if(document.getElementById("oDivD")){
		document.getElementById("oDivD").innerHTML = "";
	}
	if(document.getElementById("oDivE")){
		document.getElementById("oDivE").innerHTML = "";
	}
	if(document.getElementById("oDivF")){
		document.getElementById("oDivF").innerHTML = "";
	}
	if(document.getElementById("Search")){
		document.getElementById("Search").innerHTML = "";
	}

	
	if(document.getElementById("Caption_oDivA")){
		removeElement("Caption_oDivA");
	}	
	if(document.getElementById("Caption_oDivB")){
		removeElement("Caption_oDivB");
	}	
	if(document.getElementById("Caption_oDivC")){
		removeElement("Caption_oDivC");
	}	
	if(document.getElementById("Caption_oDivD")){
		removeElement("Caption_oDivD");
	}	
	if(document.getElementById("Caption_oDivE")){
		removeElement("Caption_oDivE");
	}	
	if(document.getElementById("Caption_oDivF")){
		removeElement("Caption_oDivF");
	}

		
	    ClearConstElement();
}

function ClearConstElement(){


	document.getElementById('oNotes').innerHTML = "";
	document.getElementById('oBarCode').innerHTML = "";
	//document.getElementById('oBarCodeText').innerHTML = "";
	document.getElementById('oFaceBook').innerHTML = "";
	document.getElementById('oBarCodeExplain').innerHTML = "";
	document.getElementById('oMoreRecipes').innerHTML = "";
	
	//document.getElementById('oMagnifyImg').innerHTML = "";
	document.getElementById('oIntroTxt').innerHTML = "";
	document.getElementById('oTitle').innerHTML = "";
	document.getElementById('oTitleBar').innerHTML = "";
	document.getElementById('oRecipe').innerHTML = "";
	document.getElementById('goUP').innerHTML = "";
	document.getElementById('oRefresh').innerHTML = "";
}
function PleaseWait(func) { 

	clearBoard();
		
		var oDiv = document.getElementById("oDiv");
		var oImg = document.createElement("img");
		oImg.setAttribute("id","img_intro");
		oImg.setAttribute("src","img/progress_green_transparent.gif");
		oDiv.align="center";

		//oDiv.style.height="100px";
		oDiv.style.paddingTop="50px";
		//oDiv.style.backgroundColor="blue";
		oDiv.appendChild(oImg);

	var szEval = "setTimeout('"+func+"',1500);";
	eval(szEval);

}
function removeElement(elm) {
var theElm=document.getElementById(elm);
//alert(elm +"  "+theElm);
	if (theElm){
		theElm.parentNode.removeChild(theElm);
	}
}

/*
function Home(){

		clearBoard();
		var oDiv = document.getElementById("oDiv")
		var oImg = document.createElement("img")
		oImg.setAttribute("id","img_intro");
		oImg.setAttribute("src","img/traffic_camera.jpg");
		oDiv.appendChild(oImg);
		oDiv.align="center";

	

}
*/
function CreateTable(nRows, nCols) {

	clearBoard();
 
   var oDiv = document.getElementById("oDiv");
	oDiv.align="center";

	var oTable = document.createElement("TABLE")
	oTable.setAttribute("cellPadding","0px");
	//oTable.setAttribute("cellSpacing","0");
	oTable.setAttribute("id","tbl");
	oTable.border="0";
	oTable.bgColor="#FFFFFF"; //"#CACACA"; //"#6D7071";//"#3b77b2";
	//oTable.style.fontStyle="italic";
	oTable.style.fontFamily="tahoma";
	oTable.style.fontWeight="bolder";
 	oTable.style.fontSize="12px";
  	oTable.style.color="#008000";
	
	var oTBody = document.createElement("TBODY")
	var oTR,oTD 
	oTable.appendChild(oTBody);

		var JJ;
	
		for (var i=0;i<nRows;i++) {
			oTRCaption = document.createElement("TR");
			oTRCaption.setAttribute('align','right');
			oTRCaption.setAttribute('valign','middle');
			oTRCaption.setAttribute('style','padding-top:0px');
			oTRCaption.setAttribute('id','trCaption'+i);
			//oTRCaption.bgColor="#6D7071";
			oTR = document.createElement("TR");
			oTR.setAttribute('id','trCam'+i);
			oTR.setAttribute('align','center');

			oTRDown = document.createElement("TR");
			oTRDown.setAttribute('align','right');
			oTRDown.setAttribute('id','trDown'+i);

			for (var j=0;j<nCols;j++) {
			 JJ =nCols-j-1; //arrange the index from right to left
//document.getElementById(this.id).innerHTML="";
				oTDCaption = document.createElement("TD");
				oTDCaption.setAttribute('id','td_Caption'+i+JJ);
				//oTDCaption.onclick= function() { document.getElementById(this.id).parentNode.removeChild(document.getElementById(this.id));  document.getElementById(this.id.replace('td_Caption','td_Cam')).parentNode.removeChild(document.getElementById(this.id.replace('td_Caption','td_Cam'))) ;return false};
				//oTDCaption.onclick= function() { document.getElementById(this.id).innerHTML="";  document.getElementById(this.id.replace('td_Caption','td_Cam')).innerHTML="" ;return false};

				//oTDCaption.setAttribute('style','background-color:#454738;');
				//oTDCaption.setAttribute('aline', 'right');
				//oTDCaption.innerHTML = i+"-"+j;
				oTRCaption.appendChild(oTDCaption);

				oTD = document.createElement("TD");
				oTD.setAttribute('id','td_Cam'+i+JJ);
				oTD.style.height="180px";
				oTD.style.width="240px";
				//oTD.innerHTML = "&nbsp;";
				oTR.appendChild(oTD);
				
				oTDDown = document.createElement("TD");
				oTRDown.setAttribute('align','center');
				oTDDown.setAttribute('id','td_Down'+i+JJ);
				//oTDDown.innerHTML = "";
				oTRDown.appendChild(oTDDown);			}

					
			oTBody.appendChild(oTRCaption);
			oTBody.appendChild(oTR);
			oTBody.appendChild(oTRDown);
		}
	 oDiv.style.paddingTop="0px";
    oDiv.appendChild(oTable);
    //oTable.border=1
    //alert(document.getElementById("oDiv").innerHTML);

}



function ClearCustom(){
	if(document.getElementById("oCustom")){
		removeElement("oCustom");
	}
	CookesArr="";

}

// block the right click
/*	

document.ondragstart = Disable; // the whole document 
document.onselectstart = Disable; // the whole document 
document.oncontextmenu=Disable;  // the whole document
window.status = "http://food.vtop.co.il";

function Disable() {
  return event.returnValue=false;
}
*/

function controlPanelLoading(id,txt){
var psik =",";
	document.getElementById(id).innerHTML="<img src=\"img/dot.gif\" width=\"18px\"/><img src=\"img/progress_small.gif\" /><img src=\"img/dot.gif\" width=\"18px\"/>";
//alert('restoreControlPanelTxt("'+id+psik+txt+'")');width=\"35px\"
	setTimeout('restoreControlPanelTxt('+id+psik+txt+')',1000);
}

function restoreControlPanelTxt(id,txt) {
/*
switch case (id){
	case ('idCP_save'):
		txt="idCP_save";
	break;
	case ('idCP_save'):
		txt="idCP_save";
	break;
	default:
	break;
	}
*/
	if (id.id == 'idCP_save'){
	txt = "שמור מצלמות";
	}
	if (id.id == 'idCP_myCam'){
	txt = "המצלמות שלי";
	}
   if (id.id == 'idCP_home'){
	txt = "סגור מצלמות";
	}
	id.innerHTML=txt;
}

function Save(){
	if (CookesArr == ""){
			Home();
			document.getElementById('oIntroTxt').innerHTML = "<img src=\"img/dbldown.gif\">  לא נבחרו מצלמות לשמירה. יש לבחור מצלמות להתאמה אישית על ידי פתיחת החץ הכחול*<img src=\"img/dot.gif\" width=\"25px\">";
	}
	else{
		setCookie(CookesArr);
	}
}

function Restore(){
	
	clearBoard();
	
	var length=0;
	var tmpArr = new Array();
	var szList = getCookie();
	if (szList){
			tmpArr = szList.split("#");
			
			for (var i=0;i<tmpArr.length;i++) {
					tmpArr[i] = typoURL(tmpArr[i]);
			}
			for(i=1;i<tmpArr.length;i++){
				AddSingleCam(tmpArr[i]);
			}
	}
	else{
				Home();
				document.getElementById('oIntroTxt').innerHTML = " .לא נמצאו מצלמות להצגה*<img src=\"img/dot.gif\" width=\"25px\">";
	}
}

function subMenu (seeNum){

//alert(document.body.innerHTML);
	if (seeNum.style.display=="none"){
		seeNum.style.display=""
			//show map
			if(seeNum.id=="ooMap"){
				showMap();
			}
	}
	else{
		 seeNum.style.display="none"
		 //close map
		 	if(seeNum.id=="ooMap"){
				document.getElementById('td_map').innerHTML="";
			}
	}
}
function SendUsRecipe(){
	
		clearBoard();
		
		var oDiv = document.getElementById("oDiv")
		var oIframe = document.createElement("iframe")
		
		oIframe.setAttribute("id","eMessageArea");
		oIframe.setAttribute("height","500");
		oIframe.setAttribute("width","100%");
		oIframe.setAttribute("frameBorder", "0"); 
		oIframe.setAttribute("src","img/sendus.pdf");
		oDiv.appendChild(oIframe);
}

function ContactUS(){
	
		clearBoard();
		
		var oDiv = document.getElementById("oDiv")
		var oIframe = document.createElement("iframe")
		
		oIframe.setAttribute("id","eMessageArea");
		oIframe.setAttribute("height","500");
		oIframe.setAttribute("width","100%");
		oIframe.setAttribute("frameBorder", "0"); 
		oIframe.setAttribute("src","msg/message.php");
		oDiv.appendChild(oIframe);
}

function DistributionList(){
	
		clearBoard();
		
		var oDiv = document.getElementById("oDiv")
		var oIframe = document.createElement("iframe")
		
		oIframe.setAttribute("id","eMessageArea");
		oIframe.setAttribute("height","500");
		oIframe.setAttribute("width","100%");
		oIframe.setAttribute("frameBorder", "0"); 
		oIframe.setAttribute("src","distribution/message.php");
		oDiv.appendChild(oIframe);
}
function ShareWithFriend(){
	//removeElement("eEditorFriend");
					
		if(document.getElementById("eEditorFriend")){
				if (bShareVisible)
					bShareVisible=false;
				else
					bShareVisible=true;

 				DivSetVisible('ShareTarget',bShareVisible)
		}
		
		else{
				var oDiv = document.getElementById("ShareTarget")
				var oIframe = document.createElement("iframe")
				
				oIframe.setAttribute("id","eEditorFriend");
				oIframe.setAttribute("height","180");
				oIframe.setAttribute("width","100%");
				oIframe.setAttribute("frameBorder", "0"); 
				oIframe.setAttribute("src","share/message.php");
				oDiv.appendChild(oIframe);
				
				DivSetVisible('ShareTarget',true)
				bShareVisible=true;
		}
		

}
function RecipePage(CategoryFolder,RecipeFolder){
	var nWidth = 520;
	var nHeight = 540;
	var nLeft = (screen.width-nWidth)/2;
	var nTop = (screen.height-nHeight)/2;
	var sFeatures = "toolbar=1,location=0,directories=0,status=0,scrollbars=1,resizable=0";
	var sSize = "width="+nWidth+",height="+nHeight+",top="+nTop+",left="+nLeft;
	//var sUrl = "http://moked.iba.org.il/index.asp?classto=mokedTraffic" ; menubar=1,
	
	var sUrl ="img/"+CategoryFolder+"/"+RecipeFolder+ "/recipe.htm" ; 
	var sPopupTitle = "dlg" ; 



	//DivSetVisible('oProgress',true)
	//window.showModalDialog('http://moked.iba.org.il/index.asp?classto=mokedTraffic', '123', 'dialogWidth:520px;dialogHeight:400px;center:1;help:0;status:0;edge:raised;');
	//popUp(sUrl,sPopupTitle,sFeatures+','+sSize);
	//DivSetVisible('oProgress',false)
	
	/*
		clearBoard();
		
		try{
		var oDiv = document.getElementById("oDiv")
		var oIframe = document.createElement("iframe")
		
		oIframe.setAttribute("id","iframeReport");
		oIframe.setAttribute("height","400");
		oIframe.setAttribute("width","520");
		oIframe.setAttribute("frameBorder", "0"); 
		oIframe.setAttribute("src",sUrl);
		oDiv.appendChild(oIframe);
		}
		catch(e){alert(e)}
	*/	

}

function popUp(URL,WinName,FeaturesSize){
//alert(URL);
pop = open(URL,WinName,FeaturesSize);
pop.focus();

}
  function DivSetVisible(oDiv,state)
  {
  //alert(oDiv);
  
  var DivRef = document.getElementById(oDiv)
  //alert(DivRef);
  //alert(state);
  if(state)
	DivRef.style.display = "";
  else
	DivRef.style.display = "none";
  }
 

function isIE(){
	var bRet = false
	re = /Internet Explorer/i; 
	bRet = navigator.appName.search(re);
	if(bRet>0)
		return true;
	else
		return false;
}
function showFun(szSWF){

		clearBoard();
		
		var oIframe = document.createElement("iframe")
		oIframe.setAttribute("id","iframeFun");
		oIframe.setAttribute("height","495");
		oIframe.setAttribute("width","80%");
		oIframe.setAttribute("frameBorder", "0"); 
		oIframe.setAttribute("scrolling", "no"); 
		//oIframe.setAttribute("src","fun/"+szSWF); //"http://food.vtop.co.il/ifun.htm?swf="+szSWF);
		oIframe.setAttribute("src","ifun.htm?swf="+szSWF); 
		oDiv.appendChild(oIframe);
		oDiv.align="center";
}
function closeFun(){
		guiFun="";
		drawFun(guiFun);
}

