﻿//var baseURL ="http://food.vtop.co.il/docs/";
var baseURL ="./books/";
function Books(){
	//if(document.getElementById("oDiv")){
	// alert(document.getElementsByTagName('table').item(6).innerHTML);
	//  }

	bclearBoard();

    	BooksA();
    	BooksB();
    	BooksC();
    	BooksD();
    	BooksE();
    	BooksF();
    	//oTitle
    	document.getElementById('oTitle').innerHTML = "ספרי מתכונים";
    	//oNotes
   	document.getElementById('oNotes').innerHTML = ".מתכונים אלו נאספו ממקורות שונים ,אשר התקבלו במהלך השנים במיילים   ";
}

function BooksA(){
	var TmpString = new Array();
	TmpString[0]=baseURL+"amim1.doc|מתכונים מרוקאיים ";
	TmpString[1]=baseURL+"amim2.doc|מתכונים בוכריים  ";
	TmpString[2]=baseURL+"amim3.doc|מתכונים עירקיים ";
	TmpString[3]=baseURL+"amim4.doc|מתכונים תימניים ";
    	TmpString[4]=baseURL+"amim5.doc|מתכונים תוניסאיים ";
    	TmpString[5]=baseURL+"amim6.doc|מתכונים תאילנדיים ";
    	TmpString[6]=baseURL+"amim7.doc|מתכונים פוריאניים ";
    	TmpString[7]=baseURL+"amim8.pdf|ארוחה איטלקית ";
    	TmpString[8]=baseURL+"amim9.doc|ספר הסושי ";
        TmpString[9]=baseURL+"amim10.doc|מתכונים טורקיים ";
        TmpString[10]=baseURL+"amim11.doc|מתכונים בולגריים ";
        TmpString[11]=baseURL+"amim12.doc|מתכוני טריפולי ";

        
	
	BookImages("book.jpg","img",TmpString,TmpString.length,"ספרי מתכוני עמים ","",false,"","oDivA");
}

function BooksB(){
	var TmpString = new Array();
	TmpString[0]=baseURL+"hagim1.doc|מתכונים לטו בשבט ";
	TmpString[1]=baseURL+"hagim2.doc|מתכונים לפורים 1  ";
	TmpString[2]=baseURL+"hagim3.doc|מתכונים לפורים 2";
	TmpString[3]=baseURL+"hagim4.doc|מתכונים לפסח 1";
	TmpString[4]=baseURL+"hagim5.doc|מתכונים לפסח 2";
	TmpString[5]=baseURL+"hagim6.doc|מתכונים לפסח 3";
	TmpString[6]=baseURL+"hagim7.doc|מתכונים לשבועות 1";
	TmpString[7]=baseURL+"hagim8.doc|מתכונים לשבועות 2";
	TmpString[8]=baseURL+"hagim9.doc|מתכונים לטו בשבט 2";
	TmpString[9]=baseURL+"hagim10.doc|מתכונים לטו בשבט 3";
	
	
	BookImages("book.jpg","img",TmpString,TmpString.length,"ספרי מתכוני חגים ","",false,"","oDivB");
}

function BooksC(){
	var TmpString = new Array();
	TmpString[0]=baseURL+"salat1.ppt|ספר הסלטים של קיצי ";
	TmpString[1]=baseURL+"salat2.doc|ספר הסלטים 2  ";
	TmpString[2]=baseURL+"salat3.doc|ספר הסלטים 3 ";
	
	
	BookImages("book.jpg","img",TmpString,TmpString.length,"ספרי מתכוני סלטים ","",false,"","oDivC");
}

function BooksD(){
	var TmpString = new Array();
	TmpString[0]=baseURL+"shonim1.doc|ספר הבישול של  אמא ";
	TmpString[1]=baseURL+"shonim2.doc|ספר בישול של אהרוני  ";
	TmpString[2]=baseURL+"shonim3.doc|ספר המנגל";
	TmpString[3]=baseURL+"shonim4.doc|ספר מתכוני חורף";
	TmpString[4]=baseURL+"shonim5.doc|לחמים ולחמניות";
	TmpString[5]=baseURL+"shonim6.zip|ספר גולשי וואלה";
	TmpString[6]=baseURL+"shonim7.doc|בשר ועוף";
	TmpString[7]=baseURL+"shonim8.doc|ספר מתכונים למתחילים";
	TmpString[8]=baseURL+"shonim9.doc|מנות עיקריות";
	TmpString[9]=baseURL+"shonim10.doc|הספר של לשקמי וצ'ומפי";
	TmpString[10]=baseURL+"shonim11.pdf|מתכונים כיד המלך";
	TmpString[11]=baseURL+"shonim12.doc|כל מתכוני החמין";
	TmpString[12]=baseURL+"shonim13.doc|מתכונים לסיר איטי";
	TmpString[13]=baseURL+"shonim14.doc|ספר הלימון";
        TmpString[14]=baseURL+"shonim15.doc|מתכונים לקפה";
        TmpString[15]=baseURL+"shonim16.doc|השף חיים כהן";
        TmpString[16]=baseURL+"shonim17.doc|השף קובי מזרחי";
        TmpString[17]=baseURL+"shonim18.doc|מתכוני דגים";
        TmpString[18]=baseURL+"shonim19.doc|המתכונים של רות אוליבר";
        TmpString[19]=baseURL+"shonim20.doc|השף יניב גור-אריה";


	BookImages("book.jpg","img",TmpString,TmpString.length,"ספרי מתכונים שונים ","",false,"","oDivD");
}

function BooksE(){
	var TmpString = new Array();
	TmpString[0]=baseURL+"matok1.doc|עוגות גבינה 1 ";
	TmpString[1]=baseURL+"matok2.doc|עוגות גבינה 2  ";
	TmpString[2]=baseURL+"matok3.doc|עוגות גבינה 3";
	TmpString[3]=baseURL+"matok4.doc|ספר העוגות המלא";
	TmpString[4]=baseURL+"matok5.doc|עוגות עם פיצוחים";
	TmpString[5]=baseURL+"matok6.doc|עוגות ועוגיות";
	TmpString[6]=baseURL+"matok7.doc|עוגיות";
	TmpString[7]=baseURL+"matok8.doc|מתכוני שוקולד";
	TmpString[8]=baseURL+"matok9.doc|מתכוני שוקולד לבן";
	TmpString[9]=baseURL+"matok10.zip|ספר השוקולד";
	TmpString[10]=baseURL+"matok11.doc|מתוקים קינוחים גלידות";
	TmpString[11]=baseURL+"matok12.doc|מתכוני גלידה";
	TmpString[12]=baseURL+"matok13.doc|הספר של יד מרדכי - דבש";
        TmpString[13]=baseURL+"matok14.doc|גלידות סורבה ופרפה";
	
	BookImages("book.jpg","img",TmpString,TmpString.length,"ספרי מתכוני מתוקים ","",false,"","oDivE");
}

function BooksF(){
	var TmpString = new Array();
	TmpString[0]=baseURL+"briut1.doc|ספר מתכוני דיאטה ";
	TmpString[1]=baseURL+"briut2.doc|מתכונים דלי פחמימות ";
	TmpString[2]=baseURL+"briut3.doc|מתכונים למתוקים בריאים";
	TmpString[3]=baseURL+"briut4.doc|מתכונים דיאטתיים";
        TmpString[4]=baseURL+"briut5.doc|עוגות וקינוחים דלי שומן";
	
	
	BookImages("book.jpg","img",TmpString,TmpString.length,"ספרי מתכוני בריאות ","",false,"","oDivF");
}

/*****************************************************
******************************************************
* BookImages  - Dynamic  Images
******************************************************
******************************************************/

function BookImages(ImageCategory,SubFolder,TmpArrString,NumberOfPic,Title,szAuther,bShowRecipeIcon,szheight,szDiv){
	TmpArr = new Array();
	TmpArrString_Split = new Array();

	var szPathPic = "";
	
	if (szheight==""){
	//    szheight ='700';
	}

	for(i=0;i<NumberOfPic;i++){

		//split TmpArrString
		TmpArrString_Split = TmpArrString[i].split("|");
		if (typeof TmpArrString_Split[1]=="undefined"){
			TmpArrString_Split[1]="";
		}		
		
		//get extension
		szExt = TmpArrString_Split[0].substr(TmpArrString_Split[0].length -3,TmpArrString_Split[0].length)

        switch (szExt){
            case "doc":
                 szPathPic = SubFolder+"/bword.gif";
                 break;
            case "pdf":
                 szPathPic = SubFolder+"/bpdf.gif";
                 break;
            case "ppt":
                 szPathPic = SubFolder+"/bpowerpoint.gif";
                  break;
           case "zip":
                 szPathPic = SubFolder+"/bzip.gif";
                 break;
            default: 
                szPathPic = SubFolder+"/"+ImageCategory;
                break;
         }
		    
		
		//pic Path  | url | text |
		TmpArr[i]=szPathPic+ "|"+TmpArrString_Split[1]+"|"+TmpArrString_Split[0];
		//alert(TmpArr[i]);
	}
/*	 */ 
	
	var col =NumberOfPic/4;

    //ads
    vDivSetVisible('oVideoAds',true);
    
    
	bCreateTable(col,4,szDiv);
	bFillImg(col,4,TmpArr,szDiv);
	
	//insert category for book
	var oDiv = document.getElementById(szDiv);
	//oDiv.align="right";
    //oDiv.style.paddingRight="30px";
	var oDivCaption = document.createElement("Div")
	oDivCaption.className="BookCategory";
	oDivCaption.setAttribute("id","Caption_"+szDiv);
	var parentDiv = oDiv.parentNode;
    // insert the new element into the DOM before oDiv
    parentDiv.insertBefore(oDivCaption, oDiv);
	oDivCaption.innerHTML = Title;
	
	//Auther
	document.getElementById('oNotes').innerHTML = szAuther;
	// Icons
	document.getElementById('oTitleBar').innerHTML ="";
   	//back Icon
	document.getElementById('oTitleBar').innerHTML +="<img alt=\"חזרה\" style=\"cursor:hand;\"  onclick=\"Books()\" src=\"img/bar_back.png\"/>"+"<img src=\"img/dot.gif\" width=\"1px\"/>";
    //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\"/>";

  
}
  function vDivSetVisible(oDiv,state)
  {
  var DivRef = document.getElementById(oDiv)
  if(state)
	DivRef.style.display = "";
  else
	DivRef.style.display = "none";
  }


function waitImg(id,src){
//alert(id);
var imgID =document.getElementById(id);
imgID.setAttribute("src",src);


//imgID.setAttribute("src","img/progress_green_static.jpg");
//imgID.style.height="180px";
//imgID.style.width="133px";
//setTimeout('IncreaseImg("'+id+'")',1000);
//setTimeout('IncreaseImg("'+id+'","'+src+'")',1000);
}





function bFillImg(nRows, nCols,imgArr,szDiv) {
		var z=0;
		var length=0;
		var oImg="";
		var indImgArr = 0;
		var bigImg=""
		var urlImgArr = 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+szDiv);
				var ooTDCaption = document.getElementById('td_Caption'+i+j+szDiv);
				ooTDDown = document.getElementById('td_Down'+i+j+szDiv);
				//ooTD.innerHTML = i+"-"+j;
				//ooTD.innerHTML =imgArr[z];
				if(typeof imgArr[z] != "undefined"){

					szInfoArr = imgArr[z].split("|");
					//alert(szInfoArr[2]);

					length = szInfoArr.length;
					//ooTD.appendChild(NewPlayer(szInfoArr[0]));
					
							oImg = document.createElement("img");
							oImg.setAttribute("id",indImgArr+szDiv);
							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="40px";
							oImg.style.width="40px";
							
							//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() {
							    var idImage = this.id.replace(szDiv, "");    
								urlImgArr=imgArr[idImage].split("|");
                                //alert(imgArr[this.id]);
							   bpopUp(urlImgArr[2],this.id) ; //+szDiv
							   return false
							   };
							
							//ooTD.style.height="100px";
							//ooTD.style.paddingTop="50";
							//ooTD.style.backgroundColor="blue";
		                    ooTD.appendChild(oImg)

							// load image after the green progress 
							var imgID = indImgArr-1 ;
							//alert('waitImg("'+oImg+'","'+szInfoArr[0]+'")');
							setTimeout('waitImg("'+imgID+szDiv+'","'+szInfoArr[0]+'")',1);
		
					//ooTDCaption.innerHTML = szInfoArr[1];
		ooTDDown.innerHTML = szInfoArr[1];
					//ooTD.appendChild(NewPlayer(imgArr[i]))
					z++;
				}
			}
		}

}


function bpopUp(urlSrc,id){
/*alert(id +"#"+urlSrc);
var oImg = document.getElementById(id);
oImg.innerHTML= "<a href="+urlSrc+"></a>";
*/

	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=1";
	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 =urlSrc ; 
	var sPopupTitle = "" ; 
	
//	OpenInsidePage(sUrl);
//alert(sUrl);
//window.navigate(sUrl);
//pop = window.showModalDialog(sUrl,sPopupTitle,"");
pop = open(sUrl,sPopupTitle,"");
pop.focus();

}

function OpenInsidePage(file){
	
	
		//bclearBoard(true);
		
		var oDiv = document.getElementById("DivBookInside")
		//alert(oDiv);
		var oIframe = document.createElement("iframe")
		
		oIframe.setAttribute("id","eBookArea");
		oIframe.setAttribute("height","1000");
		oIframe.setAttribute("width","100%");
		oIframe.setAttribute("frameBorder", "0"); 
		oIframe.setAttribute("src",file);
		oDiv.appendChild(oIframe);
		//alert(oDiv.innerHTML);
		window.location.href='#up';
}


function bclearBoard(){
	if(document.getElementById("eMessageArea")){
		bremoveElement("eMessageArea");
	}
	if(document.getElementById("iframereplacePage")){
		bremoveElement("iframereplacePage");
	}
	if(document.getElementById("iframeFun")){
		document.getElementById("iframeFun").innerHTML = "";
		bremoveElement("iframeFun");
	}
	if(document.getElementById("iframeReport")){
		bremoveElement("iframeReport");
	}	
	if(document.getElementById("tbl")){
		//window.document.execCommand('Stop');
		bremoveElement("tbl");
		//document.getElementById("oDiv").innerHTML = "";
		
	}
	if(document.getElementById("img_intro")){
		bremoveElement("img_intro");
	}
	if(document.getElementById("oCustom")){
		document.getElementById("oCustom").innerHTML = "";
		bremoveElement("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 = "";
	}
	//alert(document.getElementById("Caption_oDivA");
	
	if(document.getElementById("Caption_oDivA")){
		bremoveElement("Caption_oDivA");
	}	
	if(document.getElementById("Caption_oDivB")){
		bremoveElement("Caption_oDivB");
	}	
	if(document.getElementById("Caption_oDivC")){
		bremoveElement("Caption_oDivC");
	}	
	if(document.getElementById("Caption_oDivD")){
		bremoveElement("Caption_oDivD");
	}	
	if(document.getElementById("Caption_oDivE")){
		bremoveElement("Caption_oDivE");
	}	
	if(document.getElementById("Caption_oDivF")){
		bremoveElement("Caption_oDivF");
	}
		
	    bClearConstElement();
}

function bClearConstElement(){

	document.getElementById('oNotes').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 bremoveElement(elm) {
var theElm=document.getElementById(elm);
//alert(elm +"  "+theElm);
	if (theElm){
		theElm.parentNode.removeChild(theElm);
	}
}


function bCreateTable(nRows, nCols,szDiv) {
//alert(szDiv);
//	bclearBoard();

	//var oDiv = document.getElementById("oDiv");
	var oDiv = document.getElementById(szDiv);

	oDiv.align="center";
    oDiv.style.paddingRight="30px";
    
	var oTable = document.createElement("TABLE")
	//oTable.setAttribute("cellPadding","0px");
	//oTable.setAttribute("cellSpacing","0");
	oTable.setAttribute("id","tbl"+szDiv);
	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','center');
			oTRCaption.setAttribute('valign','middle');
			oTRCaption.setAttribute('style','padding-top:0px');
			oTRCaption.setAttribute('id','trCaption'+i+szDiv);
			//oTRCaption.bgColor="#6D7071";
			oTR = document.createElement("TR");
			oTR.setAttribute('id','trCam'+i+szDiv);
			oTR.setAttribute('align','center');

			oTRDown = document.createElement("TR");
			oTRDown.setAttribute('align','center');
			oTRDown.setAttribute('id','trDown'+i+szDiv);

			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+szDiv);
				//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', 'center');
				
				//oTDCaption.innerHTML = i+"-"+j;
				oTRCaption.appendChild(oTDCaption);
                //IMAGE
				oTD = document.createElement("TD");
				oTD.setAttribute('aline','center');
				oTD.setAttribute('id','td_Cam'+i+JJ+szDiv);
				//oTD.setAttribute("padding-bottom","44px");
				//oTD.setAttribute("style", "padding-right: 200px;"); 
				oTD.style.paddingRight ="60px"; 
				oTD.style.paddingLeft ="60px"; 
				oTD.style.paddingBottom ="10px"; 
				//oTD.style.height="40px";
				//oTD.style.width="40px";
                //oTD.style.backgroundColor="#FF0000";

				//oTD.innerHTML = "&nbsp;";
				oTR.appendChild(oTD);
				
				//DOWN TEXT
				oTDDown = document.createElement("TD");
				oTRDown.setAttribute('align','center');
				//oTRDown.setAttribute("cellPadding","1px");
				oTDDown.setAttribute('id','td_Down'+i+JJ+szDiv);
				//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);

}















  





