﻿function MM_findObj(n, d) { 
 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { 
 var i,p,v,obj,args=MM_showHideLayers.arguments;
 for (i=0; i<(args.length-2); i+=3) 
 if ((obj=MM_findObj(args[i]))!=null) { 
 v=args[i+2];
 if (obj.style) { 
 obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
 }
 obj.visibility=v; 
 }
}

 function promptMove(photoid) {
 $('movephotoidx').value = photoid;
 $('movephotoid').value = photoid;
 MM_showHideLayers('Move','','show');
 }
 
 function movePhoto(photoidx,photoid,albumid) {
     if (albumid < 0) {
         alert("Sorry, could not move photo");
         new Effect.Shake('photo'+photoidx);
         return;
     }
     var opt = {
         method: 'post',
         postBody: 'photoid='+photoid+'&t=m&albumid='+albumid,
         onSuccess: function(t) {
         new Effect.Fold('photo'+photoidx);
     },
         onFailure: function(t) {
         new Effect.Shake('photo'+photoidx);
         alert("Sorry, could not move photo");
     }
 }
      new Ajax.Request('/controls/doPhoto.aspx', opt);
 }

 function deletePhoto(photoid) {
     if (confirm('Are you sure you want to delete this photo?')) {
         var opt = {
             method: 'post',
             postBody: 'photoid=' + photoid + '&t=d',
             onSuccess: function(t) {
                 new Effect.Shrink('photo' + photoid);
             },
             onFailure: function(t) {
                 new Effect.Shake('photo' + photoid);
                 alert("Sorry, could not delete photo");
             }
         }
         new Ajax.Request('/controls/doPhoto.aspx', opt);
     }
     //document.aspnetForm.submit();
 }

 function mp(photoid, id) {
     if (confirm('confirm this?')) {
         var opt = {
             method: 'post',
             postBody: 'photoid=' + photoid + '&t=dm&id' + id,
             onSuccess: function(t) {
                 new Effect.Shrink('photo' + photoid);
             },
             onFailure: function(t) {
                 new Effect.Shake('photo' + photoid);
                 alert("Sorry, could not process");
             }
         }
         new Ajax.Request('/controls/doPhoto.aspx', opt);
     }
 }

 function deleteAlbum(albumid) {
    if (confirm('Are you sure you want to delete this album?'))
    {
            var opt = {
                     method: 'post',
                     postBody: 'albumid='+albumid+'&t=a',
                     onSuccess: function(t) {
                   },
                     onFailure: function(t) {
                     alert("Sorry, could not delete photo");
                    }
         }
          new Ajax.Request('/controls/doPhoto.aspx', opt);
     }
          document.aspnetForm.submit();
}
 function defaultPhoto(photoid) {
    if (confirm('Are you sure you want to set this photo as default for your profile?'))
    {
            var opt = {
                     method: 'post',
                     postBody: 'photoid='+photoid+'&t=f',
                     onSuccess: function(t) {
                     new Effect.Pulsate('photo'+photoid);
                     //refreshAd();
                   },
                     onFailure: function(t) {
                     new Effect.Shake('photo'+photoid);
                     alert("Sorry, could not delete photo");
                    }
         }
          new Ajax.Request('/controls/doPhoto.aspx', opt);
     }
}

 function deleteComment(commentid) {
    if (confirm('Are you sure you want to delete this comment?'))
    {
            var opt = {
                     method: 'post',
                     postBody: 'cid='+commentid+'&t=c',
                     onSuccess: function(t) {
                     new Effect.Shrink('comment'+commentid);
                   },
                     onFailure: function(t) {
                     new Effect.Shake('comment'+commentid);
                     alert("Sorry, could not delete comment");
                    }
         }
          new Ajax.Request('/controls/doPhoto.aspx', opt);
          //document.aspnetForm.submit();
     }
}
function refreshAd() {
      var currentTime = new Date(); 
      var r=Math.floor(Math.random()*3)
      if (r == 0) 
            yad.location = "/scripts/ad.aspx?s=" + currentTime.getTime(); 
      else if (r == 1)
          yad.location = "/scripts/ads.aspx?s=" + currentTime.getTime(); 
      else
          yad.location = "/scripts/camad.aspx?s=" + currentTime.getTime(); 
}

function report(tid,sid,stid) {
     var opt = {
         method: 'post',
         postBody: 'tid='+tid+'&sid='+sid+'&stid='+stid,
         onSuccess: function(t) {
         new Effect.Fold('photo'+tid);
     },
         onFailure: function(t) {
         new Effect.Shake('photo'+photoidx);
         alert("Sorry, could not report");
     }
 }
      new Ajax.Request('/controls/doPhoto.aspx', opt);
      //document.aspnetForm.submit();
 } 
 
 function online() {
     var currentTime = new Date();
     var opt = {
         method: 'post',
         postBody: 'id=' + myid + '&r=' + room,
         onSuccess: function(t) {
             if (t.responseText != "") {
                 var m = t.responseText.split("|");
                 if (document.getElementById('ctl00_popupWin') != null) {
                     document.getElementById('ctl00_popupWintitleEl').innerText = 'Youve got a new message!';
                     document.getElementById('ctl00_popupWinaCnt').innerHTML = m[0];
                     document.getElementById('ctl00_popupWinaCnt').href = '/messages/ja' + m[1] + '125.htm';
                     self.focus();
                     ctl00_popupWinespopup_winLoad();
                 }
             }
             if (room == 1) {
                 refreshAd();
             }
             var to = setTimeout("online()", 30000);
         },
         onFailure: function(t) {
             //alert("Sorry, could not report");
         }
     }
      new Ajax.Request('/controls/doOnline.aspx?s=' + currentTime.getTime(), opt);
 } 
 
 function startonline() {
     //if (myid > 0 && myid != 21972)
     //   var to = setTimeout("online()",30000);
 }
