function showHide(val)
{
	if (document.getElementById(val).style.display == "none")
	{
		document.getElementById(val).style.display = "";
	}
	else
	{
		document.getElementById(val).style.display = "none";
	}
}

function ShowHideTrip(t_id, t_activityTextFirst)
{
	var element = document.getElementById("sub"+t_id);
	element.style.display = element.style.display == "none" ? "" : "none";
	if (element.style.display == "")
	{
	    // Get the trip details
	    document.getElementById("frame"+t_id).src = "TripDetails.aspx?tripId=" + t_id + "&activityTextFirst=" + t_activityTextFirst ;

		//blankFrame2.location.href='handle_views.asp?id='+t_id
	}
	//return true;
}


function ShowHideThanks(val)
{
	if (document.getElementById("thanks" + val).style.display == "none")
	{
		document.getElementById("thanks" + val).style.display = "";
	}
	else
	{
		document.getElementById("thanks" + val).style.display = "none";
	}
}

function ShowHideMedia(val)
{
	if (document.getElementById("media" + val).style.display == "none")
	{
		document.getElementById("media" + val).style.display = "";
	}
	else
	{
		document.getElementById("media" + val).style.display = "none";
	}
}

function ShowHideNewsletter()
{
	if (document.getElementById("trNewsletter").style.display == "none")
	{
		document.getElementById("trNewsletter").style.display = "";
	}
	else
	{
		document.getElementById("trNewsletter").style.display = "none";
	}
}

function srOver(id)
{
	for (i=1; i<=8; i++)
	{
		if (document.getElementById("td" + id + "_" + i))
		{
		    document.getElementById("td" + id + "_" + i).style.backgroundColor = "#6E6E6E";
		}
	}
}


function srOut(id, index)
{
	var color;
	
	if (index % 2 == 0)
	{
		color = "#F3F3F3";
	}
	else
	{
		color = "#E5E5E5";
	}
	
	for (i=1; i<=9; i++)
	{
		if (document.getElementById("td" + id + "_" + i))
		{
		    document.getElementById("td" + id + "_" + i).style.backgroundColor = color;
		}
	}
}


function switchPics()
{
	
	document.getElementById("video").src = "";
	
	document.getElementById("bigPic").style.display = "";
	document.getElementById("video").style.display = "none";
	
	if (curPic > pics.length - 1)
	{
		curPic = 1;
	}
	
	for (j=0; j<=2; j++)
	{
		if (curPic + j <= pics.length - 1)
		{
			if (document.getElementById("pic"+j))
			{
			    document.getElementById("pic"+j).src = pics[curPic + j].src;
			}
		}
		else
		{
		    if (document.getElementById("pic"+j))
		    {
			    document.getElementById("pic"+j).src = "images/none.gif";
			}
		}
	}
	
	curPic = curPic + 3;
	
}


function loadDeatils(id)
{
	if (pics.length > 4)
	{
		document.getElementById("morePics").style.display = "";
	}
	
//	if (pics.length >= 1)
//	{
//		document.getElementById("bigPic").src = pics[1].src;
//	}
//	else
//	{
//		document.getElementById("bigPic").src = "images/none.gif";
//	}

	if (isVideo == true)
	{
	    document.getElementById("moreVideo").style.display = "";
		switchVideo(id);
	}
	else
	{
		switchPics();
	}
}


function enlarge(id)
{
	document.getElementById("video").src = "";
	
	document.getElementById("bigPic").style.display = "";
	document.getElementById("video").style.display = "none";
	
	if (curPic-3 <= 0)
	{
		curPic = curPic + 3;
	}
	
	document.getElementById("bigPic").src = pics_big[curPic-3+id].src;
}


function switchVideo(id)
{
	document.getElementById("video").height = 176;
	document.getElementById("video").src = "Video.aspx?tripId=" + id;
	
	document.getElementById("video").style.display = "";
	document.getElementById("bigPic").style.display = "none";
}

function openContactBuisTrip(buisId, tripId)
{
    window.open ("ContactBuisWin.aspx?buisId="+buisId+"&tripId="+ tripId , "contactBuisWin_"+buisId, "width=400px, height=420px, left=250px")
}

function openContactBuis(buisId)
{
    window.open ("ContactBuisWin.aspx?buisId="+ buisId , "contactBuisWin_"+buisId, "width=400px, height=420px, left=250px")
}

function openExplain()
{
	window.open ("images/explain.jpg" , "explain", "width=700px, height=400px, left=160px")
}

function openSendFriend(tripId)
{
    window.open ("SendFriendWin.aspx?tripId="+ tripId , "SendFriendWin_"+tripId, "width=400px, height=400px, left=250px")
}

function openContactGroupWin()
{
    window.open ("ContactGroupWin.aspx" , "ContactGroupWin", "width=400px, height=500px, left=250px")
}

function enableDisableFile(clientId)
{
	if (document.getElementById(clientId).disabled == false)
	{
		document.getElementById(clientId).disabled = true;
	}
	else
	{
		document.getElementById(clientId).disabled = false;
	}
}


function prov_switchPic(innerHtmlCode)
{
	try
	{
		document.getElementById("imgBigPic").style.display = "inline";
		document.getElementById("iframeVideo").style.display = "none";
		document.getElementById("imgBigPic").src = pics_big[1].src;
		document.getElementById("iframeVideo").src = "";
		document.getElementById("ctl00_ContentPlaceHolder1_picScroller_contentScrollerMain").innerHTML = innerHtmlCode;
		scrollInit();
	}
	catch (ex) { }
	
	if (pics.length <= 2)
	{
		document.getElementById("movePrevNext").style.display = "none";
	}
}

function prov_switchVideo(innerHtmlCode)
{
	try
	{
		if (videos[1])
		{
			document.getElementById("iframeVideo").src = videos[1];
		}
		else
		{
			document.getElementById("iframeVideo").src = "";
		}
		document.getElementById("iframeVideo").style.display = "inline";
		document.getElementById("imgBigPic").style.display = "none";
		document.getElementById("ctl00_ContentPlaceHolder1_picScroller_contentScrollerMain").innerHTML = innerHtmlCode;
		scrollInit();
	}
	catch (ex) { }
	
	if (videos.length <= 2)
	{
		document.getElementById("movePrevNext").style.display = "none";
	}
}


function prov_showVideo(id)
{
	curVideo = id;
	document.getElementById("iframeVideo").src = videos[id];
}

function addRemoveFavorites(id)
{
	if (document.getElementById("plus" + id).src.indexOf('plus') > 0)
	{
		if (displayFirstClickMsg)
		{
			document.getElementById("firstClickMsg").style.display = "";
			displayFirstClickMsg = false;
		}
		
	    document.getElementById("plus" + id).src = "images/v.gif";
	    blankFrame.location.href = "/AddRemoveFav.aspx?action=add&id=" + id;
	}
	else
	{
	    document.getElementById("plus" + id).src = "images/plus.gif";
	    blankFrame.location.href = "/AddRemoveFav.aspx?action=remove&id=" + id;
	}
}

function addRemoveFavoritesNoPlus(id)
{
	if (displayFirstClickMsg)
	{
		document.getElementById("firstClickMsg").style.display = "";
		displayFirstClickMsg = false;
	}
		
    blankFrame.location.href = "/AddRemoveFav.aspx?action=add&id=" + id;

    //blankFrame.location.href = "/AddRemoveFav.aspx?action=remove&id=" + id;
}

function clearFavorites(id)
{
	blankFrame.location.href = "/AddRemoveFav.aspx?action=clear";
	location.href = "/SearchResults.aspx?fav=yes";
}

function prov_enlargePic(id)
{
	curPic = id;
	document.getElementById("imgBigPic").src = pics_big[curPic].src;
}

function prov_movePrev()
{
	if (document.getElementById("iframeVideo").style.display == "inline")
	{
		//video mode
		
		if (curVideo > 1)
		{
			curVideo = curVideo - 1;
		}
		else
		{
			curVideo = videos.length - 1;
		}
		
		document.getElementById("iframeVideo").src = videos[curVideo];
	}
	else
	{	
		//pictures mode
		
		if (curPic > 1)
		{
			curPic = curPic - 1;
		}
		else
		{
			curPic = pics.length - 1;
		}
		
		document.getElementById("imgBigPic").src = pics_big[curPic].src;
	}
}

function prov_moveNext()
{
	if (document.getElementById("iframeVideo").style.display == "inline")
	{
		//video mode
		
		if (curVideo < videos.length - 1)
		{
			curVideo = curVideo + 1;
		}
		else
		{
			curVideo = 1;
		}
		
		document.getElementById("iframeVideo").src = videos[curVideo];
	}
	else
	{	
		//pictures mode
	
		if (curPic < pics.length - 1)
		{
			curPic = curPic + 1;
		}
		else
		{
			curPic = 1;
		}
		
		document.getElementById("imgBigPic").src = pics_big[curPic].src;
	}
}


function setMainWidth()
{
	var i;
	var padding = ((screen.width - 770) / 2) - 11;
	
	for (i=1; i<=6; i++)
	{
		try
		{
			document.getElementById("mainTd" + i).style.paddingLeft = padding + "px";
			document.getElementById("mainTd" + i).style.paddingRight = padding + "px";
		}
		catch (ex) { }
	}
	
	document.getElementById("mainTd2").style.paddingLeft = 0 + "px";
	
	try {
		document.getElementById("mainTd6").style.paddingRight = 0 + "px";
		document.getElementById("mainTd6").style.paddingLeft = ((screen.width - 770) / 2) - 11 + 33 + "px";
	} catch (ex) { }
}


function showTooltip(bname)
{
	document.getElementById("tooltip").innerText = "## " + bname + " ## לחץ לקבלת פרטים נוספים";
	document.getElementById("tooltip").position
}

function addToFavorites(val)
{
	if (document.all)
	{
		window.external.AddFavorite('http://www.groupi.co.il', 'Groupi - ' + val);
	}
}

function setHomePage(obj)
{
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage('http://www.groupi.co.il');
}

function closeFirstClickMsg()
{
	document.getElementById('firstClickMsg').style.display = 'none';
}

function savePakage(actText)
{
	document.getElementById('searchedItem').innerText = actText;
	document.getElementById('savePakageMsg').style.display = '';
}

function closeSavePakageMsg()
{
	document.getElementById('savePakageMsg').style.display = 'none';
}

function firstClickMsgPos()
{
	document.getElementById('savePakageMsg').style.left = (screen.availWidth - 250) / 2 + "px";
	document.getElementById('savePakageMsg').style.top = (screen.availHeight - 150) / 2 + "px";
	
	document.getElementById('firstClickMsg').style.left = (screen.availWidth - 250) / 2 + "px";
	document.getElementById('firstClickMsg').style.top = (screen.availHeight - 150) / 2 + "px";
}



function isMail(val)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(val);
}
