﻿(function($) {
	$(function() { //on DOM ready
		$('.scroller li').each(function() {
			if (listimg = $(this).find('img')) {
				imgw = listimg.attr("width");
				imgh = listimg.attr("height");
				if (imgh > 100) { imgh = 100; }
				wcount = Math.floor(596 / imgw);
				rpadding = Math.floor((596 % imgw) / wcount);
				tpadding = Math.floor((100 - imgh) / 2);
				$(this).css("width", imgw + "px");
				$(this).css("padding-right", rpadding + "px");
				$(this).css("padding-top", tpadding + "px");
			}
		});
		$(".scroller").simplyScroll({
						speed: 15
		});
});
})(jQuery);


       $(document).ready(function () {

           $('a.clueTipTitle').cluetip({ splitTitle: '|', activation: 'click', cluetipClass: 'rounded', dropShadow: false, positionBy: 'mouse', arrows: true, showTitle: true });       
       
           $("a.clueTipTitle").each(function () {
               $(this).attr('title', '');
           });

       });


       function closeLayer(reload) {
           $.fn.colorbox.close();
       }

       function showLayer(url, width, height, element) {
           $.fn.colorbox({ href: url, innerWidth: width, innerHeight: height, iframe: true, overlayClose: true, title: function () { return $(element).attr("title"); } }); return false;
       }

       function CallPageMethod(pageUrl, methodName, onSuccess, onFail) {
           var args = '';
           var l = arguments.length;
           if (l > 3) {
               for (var i = 4; i < l - 1; i += 2) {
                   if (args.length != 0) args += ',';
                   args += '"' + arguments[i] + '":"' + arguments[i + 1] + '"';
               }
           }
           $.ajax({
               type: "POST",
               url: pageUrl + "/" + methodName,
               data: "{" + args + "}",
               contentType: "application/json; charset=utf-8",
               dataType: "json",
               success: onSuccess,
               fail: onFail
           });
       }

       function log(string) {
           if (window.console && window.console.firebug) {
               console.log(string);
           }
       }



       var CurrentUrl;
       var CurrentPhotoNo;
       var CurrentAlbumNo;
       var CurrentUID;
       var CurrentTitle;
       var CurrentShareType;
       var wsUrl = "/MyOutdoorJournal/wsSocialMedia.aspx";

       function loadSharedUrl(arrID) {
           CurrentAlbumNo = arrID[0];
           CurrentPhotoNo = arrID[1];
           CurrentUID = arrID[2];
           CurrentTitle = arrID[3];
           CurrentShareType = arrID[4];
           CurrentUrl = currentDomain + "/PhotoAlbum/PhotoView.aspx?PhotoNo=" + CurrentPhotoNo + "&AlbumNo=" + CurrentAlbumNo + "&UID=" + CurrentUID + "&lang=" + (CurrentLanguage == "en-US" ? "en" : "es");
           log("CurrentUrl=" + CurrentUrl);

           SetShareUrlInSession();

           sharethis.properties.url = CurrentUrl;
           sharethis.properties.title = CurrentTitle;
       }



       function AddToFavorites() {
           if (isLoggedIn == "1") {
               CallPageMethod(wsUrl, "SaveToMyFavorites", null, null,
                "photoNo", CurrentPhotoNo,
                "uID", currentLoginUserID);
           }
           else {
               location.href = "/Signup/login.aspx?referrer=" + CurrentUrl;
           }
       }

       function loadEmailToFriend2() {
           var url = "/EmailToFriends/SendToFriend2.aspx?Cache=" + Math.floor(Math.random() * 1001) + "&lang=" + (CurrentLanguage == "en-US" ? "en" : "es");
           showLayer(url, 500, 500);
       }

       function ReportPhoto() {
           CallPageMethod(wsUrl, "IsPhotoReported", onSuccess_PR, null,
           "photoNo", CurrentPhotoNo);
       }

       function onSuccess_PR(response) {
           var items = jQuery.parseJSON(response.d);
           var alreadyReported = (items == "1");
           log("items.length=" + items.length);

           if (alreadyReported) {
               alert(reportAcknowledgeMessage);
           }
           else {
               if (confirm(reportWarningMessage)) {
                   CallPageMethod(wsUrl, "ReportPhoto", null, null,
                        "photoNo", CurrentPhotoNo,
                         "uID", CurrentUID);
                   alert(reportAcknowledgeMessage);
               }
           }
       }

       function SetShareUrlInSession() {
           CallPageMethod(wsUrl, "SetShareUrlInSession", null, null,
                         "url", CurrentUrl, "sharetype", CurrentShareType);
       }


       $(document).ready(function () {


           setTimeout(function () {

               var getHeight = $('#hdgcContentWrap').outerHeight(true) + 20;              
               $("#gcBackground").css("height", getHeight);

           }, 150);



       });
    
