// ----------------------------------------------------------------------
// Northeast Ohio Backpacking Club
// Aaron Tsur
// ----------------------------------------------------------------------


// ----------------------------------------------------------------------
// Like Dislike Functions
// ----------------------------------------------------------------------

		function imageBtnLike(uid,type)
		{		
		    try
		    {
				var rtnCnt = bpcV1.AjaxCode.like_Click(uid,type).value;
				setLikeValues(uid, rtnCnt);
			}
			catch( err)
			{
				//alert(err);
			}
		};

		function imageBtnLikeNot(uid,type)
		{		
		    try
		    {
   			   if( confirm("Are you sure you want to vote Dislike?\n\nNote: Please post a message why you are disliking this, it would be very helpful.\n"))
			   {
					var rtnCnt = bpcV1.AjaxCode.likeNot_Click(uid,type).value;
					setLikeValues(uid, rtnCnt);
				}
			}
			catch( err)
			{
				//alert(err);
			}
		};

		function imageBtnLikeRemove(uid,type)
		{		
		    try
		    {
   			   if( confirm("Are you sure you want to remove your Vote?"))
			   {
			  	  var rtnCnt = bpcV1.AjaxCode.likeRemove_Click(uid,type).value;
				  setLikeValues(uid, rtnCnt);
			   }
			}
			catch( err)
			{
				//alert(err);
			}
		};


		function setLikeValues(uid, rtnCnt)
		{
			try
			{
				var fldNameD = "display_" + uid + "_D";
				var fldNameL = "display_" + uid + "_L";

				var dObjD = document.getElementById(fldNameD);
				var dObjL = document.getElementById(fldNameL);

				if(document.all)
				{
					dObjD.innerText = "Dislike: " + rtnCnt.Dn;
					dObjL.innerText = "Like: " + rtnCnt.Ln;
				}
				else
				{
					dObjD.textContent = "Dislike: " + rtnCnt.Dn;
					dObjL.textContent = "Like: " + rtnCnt.Ln;
				}
			}
			catch( err)
			{
				//alert(err);
			}
		}

           //function LikeView(did,type)
           //{
           //   var now = new Date();
           //   open ("viewLikeInfo.aspx?did=" + did + "&t=" + type + "&" + now.getTime(),
           //         "Like",
           //         "left=" + (screen.width-750)/2 + ",top=" + (screen.height-500)/2 + ",height=500,width=750,scrollbars=Yes,toolbar=No,titlebar=No,resizable=No,status=No");
           //};   

			function mOverLike(o,sFlag)
			{
				if( sFlag == 1)
				{
					o.style.cursor="hand";
					o.style.borderLeftColor="black";
					o.style.borderTopColor="black";
					o.style.borderBottomColor="lightgrey";
					o.style.borderRightColor="lightgrey";
				}
				else
				{
					o.style.cursor="pointer";
					o.style.borderLeftColor="lightgrey";
					o.style.borderTopColor="lightgrey";
					o.style.borderBottomColor="black";
					o.style.borderRightColor="black";
				}
			}

			function mOverImage(o,sFlag)
			{
				if( sFlag == 1)
				{
					o.style.cursor="hand";
					o.style.borderLeftColor="red";
					o.style.borderTopColor="red";
					o.style.borderBottomColor="orange";
					o.style.borderRightColor="orange";
				}
				else
				{
					o.style.cursor="pointer";
					o.style.borderLeftColor="orange";
					o.style.borderTopColor="orange";
					o.style.borderBottomColor="red";
					o.style.borderRightColor="red";
				}
			}

// ----------------------------------------------------------------------
// Help Functions
// ----------------------------------------------------------------------

		   function openremoteQWindow(helpId)
			{
				//open ("help/remoteHelp.aspx?hid=" + helpId,
				//		"Explain",
				//		"left=" + (screen.width-450)/2 + ",top=" + (screen.height-300)/2 + ",height=300,width=450,scrollbars=Yes,toolbar=No,titlebar=No,resizable=No,status=No");
				//RefreshFlag = 0;
					            
	            Shadowbox.open(
	            {
		           title:   "Explain",
		           player:  "iframe",
		           content: url="help/remoteHelp.aspx?hid=" + helpId,
		           height:  300,
                   width:   450
	            }, {listenOverlay:false});

                return false;
				
				
				
				
			};   

// ----------------------------------------------------------------------
// about member popup **** replaced with jquery popup *******
// ----------------------------------------------------------------------

           //function MemberView(mid)
           //{
           // open ("viewMemberInfo.aspx?mid=" + mid,
           //       "Member",
           //       "left=" + (screen.width-750)/2 + ",top=" + (screen.height-500)/2 + ",height=500,width=750,scrollbars=Yes,toolbar=No,titlebar=No,resizable=No,status=No");
           //};   

// ----------------------------------------------------------------------
// string functions
// ----------------------------------------------------------------------

		// Removes leading and trailing spaces from the passed string. Also removes
		// consecutive spaces and replaces it with one space. If something besides
		// a string is passed in (null, custom object, etc.) then return the input.
		function trim(inputString) 
		{
			if (typeof inputString != "string") 
			{ 
				return inputString; 
			}
			
			var retValue = inputString;
			
			var ch = retValue.substring(0, 1);
			while (ch == " ") 
			{ 
				retValue = retValue.substring(1, retValue.length);
				ch = retValue.substring(0, 1);
			}
			
			ch = retValue.substring(retValue.length-1, retValue.length);
			while (ch == " ") 
			{
				retValue = retValue.substring(0, retValue.length-1);
				ch = retValue.substring(retValue.length-1, retValue.length);
			}
			
			while (retValue.indexOf("  ") != -1) 
			{
				retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
			}
			
			return retValue;
		}

		function Left(str, n)
		{
 			if (n <= 0)
 				return "";
			else if (n > String(str).length)
				return str;
			else
				return String(str).substring(0,n);
		}
   
		function Right(str, n)
		{
			if (n <= 0)
				return "";
			else if (n > String(str).length)
				return str;
			else 
			{
				var iLen = String(str).length;
				return String(str).substring(iLen, iLen - n);
			}
		}

// ----------------------------------------------------------------------
// Sidebar functions
// ----------------------------------------------------------------------

	function PagePrinter()
	{
	    var tdObj = document.getElementById('tdSideBar');
	    var StateVal = document.getElementById('HSsideBarVal');

		tdObj.style.display = "none";
		tdObj.style.visibility = "hidden";
		//SHsidebar();
		//alert("well?");
		window.print();
		//alert("well?");
		//SHsidebar();
		if( StateVal.value == 1)
		{
			tdObj.style.display = "block";
			tdObj.style.visibility = "visible";
		}
	}

	function SHsidebar()
	{
	    var imgObj = document.getElementById('imgHSsideBar');
	    var tdObj = document.getElementById('tdSideBar');
	    var StateVal = document.getElementById('HSsideBarVal');
	
		if( StateVal.value == 1) // hide
		{
			imgObj.src = "images/showsidebar.gif";
			imgObj.title = "Click to Show Sidebar";
			tdObj.style.display = "none";
			tdObj.style.visibility = "hidden";
			try
			{
			StateVal.value = 0;
			}
			catch(e)
			{
			};
		}
		else // show
		{
			imgObj.src = "images/hidesidebar.gif";
			imgObj.title="Click to Hide Sidebar";
			tdObj.style.display = "";
			tdObj.style.visibility = "visible";
			try
			{
			StateVal.value = 1;
			}
			catch(e)
			{
			};
		}
	}	

	function SHsidebarInit()
	{
	    var StateVal = document.getElementById('HSsideBarVal');
	
		if( StateVal.value == "")
		{
			StateVal.value = 0;
		}
		else
		{
			if( StateVal.value == 1)
			{
				StateVal.value = 0;
			}
			else
			{
				StateVal.value = 1;
			}
		}
	
		SHsidebar();
	}

// ----------------------------------------------------------------------
// Misc
// ----------------------------------------------------------------------

  	function goHome()
	{
		top.location.replace("home.aspx");
	}


// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------

