﻿var currplace = 0;
var currline=0;

function showwin()
{
	if(isShown)
	{
		document.getElementById('newmsg_win').style.display="none";
	}
	else
	{
		document.getElementById('newmsg_win').style.display="block";
	}
	isShown= !isShown;
}


function UpdateCount(id,obj,count)
{
	str = obj.value;
	div = document.getElementById(id);
	div.innerHTML = count - str.length;
	if ((count - str.length) < 20) div.style.color = "red";
	else  div.style.color = "";
	if ((count - str.length) < 1) obj.value = obj.value.substring(0,count) ;
}

function send()
{
	var s="";
	if (document.f.Content.value=="") s += "עליך למלא תוכן\n";
	if (document.f.sName.value=="") s+= "עליך למלא שם\n";
	if (document.f.phone.value=="") s+= "עליך למלא טלפון\n";

	if (s!="") {alert(s);return false;}
}


function getCurrBoxType()
{
	var isZugLine = (currline%2)==0?true:false;
	var isZugPlace = (currplace%2)==0?true:false;
	var boxtype;
	if(isZugLine)
	{
		if (isZugPlace)
			{boxtype=0;}
		else
			{boxtype=1;}
	}
	else
	{
		if (isZugPlace)
			{boxtype=1;}
		else
			{boxtype=0;}
	}
	return boxtype;
}

function goNext()
{
	if(++currplace>3){currplace=0;currline++;}
}

function getNewGardenBox()
{
	if(garden_type==0)
	{return '<a href="/More/Garden.aspx/2" class="newgardenbox"><img src="'+sStaticURL+'/images/more/garden/newmadorlink.gif" /></a>';}
	else if (garden_type==1)
	{return getBox(0,'<a style="display:block;text-decoration:none;height:100%;width:100%;" href="/More/Garden.aspx">&nbsp;</a>');}
	return "";
}
function getBox(id,str)
{
return '<div class="box'+id+ '">'+str+'</div>';
}
function WriteReply(id,image,content,date)
{
	var str="";
	if(currline==1&&currplace==2)
	{
		str+= getNewGardenBox();
		goNext();
	}
	var intext="";
	var boxtype=getCurrBoxType();
	if(image>0 && garden_type==0)
	{
		intext +='<img src="/static/images/more/garden/0/newimg'+image+'.gif" />';
	}
	//אם זה הקשקשת - לחלק את התאריך לשניים
	var curryear="";
	if(garden_type==2){
	var temp = new Array();
	temp = date.split(' ');
	curryear=temp[temp.length-1];
	date ='';
	for (var i = 0; i<(temp.length-1);i++)
	{
		date+=temp[i]+' ';
	}
	date=date.substring(0,date.length-1);
	}

	intext+= '<span>'+date+'</span>';
	if(garden_type==2)
	{
		intext+='<span class="txt_year">'+curryear+'</span><br />';
	}

	intext+='<p>'+content;
		if (sLinkData != "") intext+=" (<a href=" + sLinkData.replace("New","") + "GardenManager.aspx?edit=1&id="+id+">ערוך</a>)"

	intext+= '</p>';

str+=getBox(getCurrBoxType(),intext);
	document.write(str);
	goNext();
counter++;
}
function finish_boxes()
{
	for (var i =counter; i<7;i++)
	{
	WriteReply(0,0,"","  ");
	}
}
