
function doBlockButtons(bid,options){
	
	$("#block-"+bid).data('p' 	, options.p );
	$("#block-"+bid).data('all' , options.all );
	
	$("#block-"+bid+" #next"+bid).click(function(){
		
		$("#loading" + bid).css("display","block");
			
		var p 	= $("#block-"+bid).data('p') +1;
		var all = $("#block-"+bid).data('all');
		
		if( p > all ){
			p = 1;
		}
		$("#block-"+bid).data('p' , p );
		
		$.ajax({
			type: "GET",
			url: "/block/index/ajax/bid/" + bid + "/p/"+p,
			dataType: "html",
			success: function(html){
	    		$("#replace" + bid).html(html);
	    		$("#loading" + bid).css("display","none");
			},
	   		error: function(msg){
	   			$("#loading" + bid).css("display","none");
	   			alert("error");
	   			
	   		}
		});

		$(this).blur();
		
	});
	

	$("#block-" + bid + " #prev" + bid ).click(function(){
	
		$("#loading" + bid).css("display","block");
		
		var p 	= $("#block-"+bid).data('p') - 1;
		var all = $("#block-"+bid).data('all');
		
		if( p < 1 ){
			p = all;
		}
		
		$("#block-"+bid).data('p' , p);
		
		$.ajax({
			type: "GET",
		  	url: "/block/index/ajax/bid/" + bid + "/p/"+p,
		  	dataType: "html",
		  	success: function(html){
		    	$("#replace" + bid).html( html);
		    	$("#loading" + bid).css("display","none");
			},
			error: function(msg){
				$("#loading" + bid).css("display","none");
		   		alert("error");
		   		
		   	}
		});
		
		$(this).blur();
		
	});
}
//
//function doButtons(){
//	$(".block-buttons").each(function(i){
//		var id = $(this).attr('id');
//		id = id.replace("block-" , "");
//		id = parseInt(id);
//			
//		$("#block-" + id + " #next" + id ).click(function(){
//			
//			$("#loading" + id).css("display","block");
//			
//			var p = blockParams[id]['currentPage'] + 1;
//			if( p > blockParams[id]['all'] ){
//				p = 1;
//			}
//			
//			blockParams[id]['currentPage'] = p;
//			
//			$.ajax({
//				type: "GET",
//				url: "/" + blockParams[id]['module'] +  "/" + blockParams[id]['controller'] + "/ajax/bid/" + id + "/p/"+p,
//				dataType: "html",
//				success: function(html){
//		    		$("#replace" + id).html(html);
//		    		$("#loading" + id).css("display","none");
//				},
//		   		error: function(msg){
//		   			alert("error");
//		   		}
//	
//			});
//	
//			$(this).blur();
//		
//		
//		});
//		
//		
//		
//		$("#block-" + id + " #prev" + id ).click(function(){
//		
//			$("#loading" + id).css("display","block");
//			
//			var p = blockParams[id]['currentPage'] - 1;
//			if( p < 1 ){
//				p = blockParams[id]['all'];
//			}
//			
//			
//			blockParams[id]['currentPage'] = p;
//			
//			$.ajax({
//				type: "GET",
//			  	url: "/" + blockParams[id]['module'] +  "/" + blockParams[id]['controller'] + "/ajax/bid/" + id + "/p/"+p,
//			  	dataType: "html",
//			  	success: function(html){
//			    	$("#replace"  +id ).html( html);
//			    	$("#loading" + id).css("display","none");
//				},
//				error: function(msg){
//			   		alert("error");
//			   	}
//		
//			});
//			
//			$(this).blur();
//			
//		});
//		
//	});
//}
//
//
//function doButtons2(){
//	$(".block-buttons").each(function(i){
//		var id = $(this).attr('id');
//		id = id.replace("block-" , "");
//		id = parseInt(id);
//			
//		$("#block-" + id + " #next" + id ).click(function(){
//			
//			$("#loading" + id).css("display","block");
//			
//			var p = blockParams[id]['currentPage'] + 1;
//			if( p > blockParams[id]['all'] ){
//				p = 1;
//			}
//			
//			blockParams[id]['currentPage'] = p;
//			
//			$.ajax({
//				type: "GET",
//				url: "/blocks/index/ajax/bid/" + id + "/p/"+p,
//				dataType: "html",
//				success: function(html){
//		    		$("#replace" + id).html(html);
//		    		$("#loading" + id).css("display","none");
//				},
//		   		error: function(msg){
//		   			alert("error");
//		   		}
//	
//			});
//	
//			$(this).blur();
//		
//		
//		});
//		
//		
//		
//		$("#block-" + id + " #prev" + id ).click(function(){
//		
//			$("#loading" + id).css("display","block");
//			
//			var p = blockParams[id]['currentPage'] - 1;
//			if( p < 1 ){
//				p = blockParams[id]['all'];
//			}
//			
//			
//			blockParams[id]['currentPage'] = p;
//			
//			$.ajax({
//				type: "GET",
//			  	url: "/blocks/index/ajax/bid/" + id + "/p/"+p,
//			  	dataType: "html",
//			  	success: function(html){
//			    	$("#replace"  +id ).html( html);
//			    	$("#loading" + id).css("display","none");
//				},
//				error: function(msg){
//			   		alert("error");
//			   	}
//		
//			});
//			
//			$(this).blur();
//			
//		});
//		
//	});
//}

$(function(){

	$(".block-round").prepend(
		'<div class="top-corners"><div class="top-corner-right"></div><div class="top-corner-left"></div></div>'
		).append(
		'<div class="bottom-corners"><div class="bottom-corner-right" ></div><div class="bottom-corner-left"></div></div>'
		);
		
});


$(document).ready(function(){
	
	var heightTotal = $("#block-72").height();
	var heightMinus = $("#block-73").height() + $("#block-55").height() + 36;
	
	$("#block-74 > .block-mid").height(heightTotal - heightMinus);
	
	
	$(".addToFavorite").click(function(){
		//console.log('im here');
		if(document.all) { 
			window.external.AddFavorite("http://www.hapisga.co.il","\"מדריך הפסגה\""); 
		} else { 
			alert(".CTRL+D כדי לשמור את הדף במועדפים, יש ללחוץ במקלדת על"); 
		} 
		return false;
		
	
	})
	
	$("#send-to-freind").click(function(){
	
	
		window.open('/index/recommend','שלח המלצה לחבר', 'width=460,height=380,toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');
		return false;
	})
	
	$("#block-71 > .block-mid > .add > a").attr('id' , 'addSaying');
	
	$("#addSaying").click(function(){
	
	
		window.open('/saying/index/new','הוסף משפט משלך!', 'width=460,height=380,toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');
		return false;
	})
});

	




var playerAlreadyActivated = false;
function playVideo(filename,height,width)
{
	//console.log(filename);
	
	//if(playerAlreadyActivated) return true;
	playerAlreadyActivated = true;
	startImg = document.getElementById("vidStartImg");
	
	if (startImg)
	startImg.style.display="none";

	videoBox = document.getElementById("vidBox");
	if (videoBox){
	videoBox.innerHTML = "<div align='center' id='playerDiv'>" +
	"<object classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' id='player' width="+width+" height="+height+" >" +
	"    <param name='url' value='http://www.hapisga.co.il/videos/" + filename +"' />" +
	"    <param name='src' value='http://www.hapisga.co.il/videos/" + filename + "' /> " +
	"    <param name='ShowControls' value='1'>" +
	"      <param name='playCount' value='10'>" +
	"     <param name='ShowPositionControls' value='1'>" +
	"     <param name='ShowAudioControls' value='1'>" +
	"    <param name='ShowTracker' value='1'>" +
	"     <param name='ShowDisplay' value='0'>" +
	"     <param name='AutoSize' value='1'>" +
	"    <param name='ShowGotoBar' value='0'>" +
	"    <param name='ShowCaptioning' value='0'>" +
	"    <param name='AutoStart' value='1'>" +
	"    <param name='AnimationAtStart' value='0'>" +
	"    <param name='TransparentAtStart' value='0'>" +
	"    <param name='AllowScan' value='1'>" +
	"    <param name='EnableContextMenu' value='0'>" +
	"    <param name='ClickToPlay' value='0'>" +
	"    <param name='InvokeURLs' value='0'>" +
	"    <param name='DefaultFrame' value='1'>" +
	"    <param name='Autorewind' value='0'>" +
	"  <param name='Volume' value='100000'>" +
	"  <!--[if !IE]>-->" +
	"  <object type='video/x-ms-wmv' data='http://www.hapisga.co.il/videos/" + filename +"'  width="+width+" height="+height+">" +
	"    <param name='src' value='http://www.hapisga.co.il/videos/" + filename + "' />" +
	" <param name='ShowControls' value='1'>" +
	"      <param name='playCount' value='10'>" +
	"      <param name='ShowPositionControls' value='1'>" +
	"      <param name='ShowAudioControls' value='1'>" +
	"      <param name='ShowTracker' value='1'>" +
	"      <param name='ShowDisplay' value='0'>" +
	"      <param name='ShowStatusBar' value='1'>" +
	"      <param name='AutoSize' value='1'>" +
	"      <param name='ShowGotoBar' value='0'>" +
	"      <param name='ShowCaptioning' value='0'>" +
	"      <param name='AutoStart' value='1'>" +
	"      <param name='AnimationAtStart' value='0'>" +
	"      <param name='TransparentAtStart' value='0'>" +
	"      <param name='AllowScan' value='1'>" +
	"      <param name='EnableContextMenu' value='0'>" +
	"      <param name='ClickToPlay' value='0'>" +
	"      <param name='InvokeURLs' value='0'>" +
	"     <param name='DefaultFrame' value='datawindow'>" +
	"     <param name='Autorewind' value='0'>" +
	"<param name='Volume' value='100000'>" +
	"  </object>" +
	"  <!--<![endif]-->" +
	"</object>" +
	"     " +
	"      </div>";
	}

}

