﻿var Users = {
  userlinks: [
    { id:"message",
	  name: "Mesaj Göndereyim", 
	  href: "/compose.aspx?id={userid}",
	  condition:"'{myid}'!=''&&'{myid}'!='{userid}'"
	},
	{ id:"contact",
	  name: "Arkada\u015Flar\u0131ma Ekleyeyim", 
	  href: "/profile.aspx?p=6&id={userid}",
	  condition:"'{myid}'!=''&&'{myid}'!='{userid}'"
	},
    { id:"profile",
	  name: "Profiline Bakay\u0131m", 
	  href: "/showprofile.aspx?id={userid}",
	  condition: "'{myid}'!='{userid}'"
	},
    { id:"profile",
	  name: "Kendimi Göreyim", 
	  href: "/profile.aspx",
	  condition: "'{myid}'=='{userid}'"
	}
  ],
  
  getTip: function(myid, userid) {
	var wrapper = new Element('div');

	var userlinks = wrapper.appendChild(new Element('ul'));
	userlinks.insert(new Element('li', { className: 'top' }).update('<!-- round -->'));
	this.userlinks.each(function(l,i) {
	    var condition = l.condition;
	    if (condition) {
	        condition = condition.replace('{myid}', myid).replace('{userid}', userid);
	        condition = condition.replace('{myid}', myid).replace('{userid}', userid);
	        if (!eval(condition))
	            return;
	    }
	        
		var li = userlinks.appendChild(new Element('li'));
		//	  var target = (l.name == name) ? '_self' : '_self';
		var href = l.href.replace('{userid}', userid);
		var a = li.appendChild(new Element('a', { className: 'ut' + l.id, 'target': '_self', 'href': href }).update(l.name));
		if (i + 1 == this.userlinks.length) a.addClassName('last');
    }.bind(this));
	userlinks.insert(new Element('li', { className: 'bottom' }).update('<!-- round -->'));
	
	return wrapper;
  },
  
  createTip: function(ctlid, myid, userid) {
	var content = this.getTip(myid, userid);
    if (!content)
        return;
        
	new Tip(ctlid, content, Object.extend({
	  className: 'ut',
	  effect: 'appear',
	  hook: { tip: 'topLeft', target: 'topRight' },
	  hideOn: false,
	  offset: { x: 5, y: 0 },
	  hideAfter: 0.5
	  })
	);
  },
  
  Preview: function(name, url) 
  {
    if (Lightview)
    {
        Lightview.show({
	      href: url,
	      rel: 'image',
	      title: name,
	      options: {
	        menubar:true,
	        autosize: true,
	        topclose: true
          }
	    });
	    
	    return false;
    }
    
    return true;
  }
}