var Limonata = {};

Limonata.Cookie = {};

Limonata.Cookie.write =
	function(name, value)
	{
		var date = new Date();		
		date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));

		document.cookie = name + '=' + value + '; expires=' + date.toGMTString() + '; path=/';
	};


Limonata.Form = {};

Limonata.Form.post =
	function(id)
	{
		var form = document.getElementById(id);
		
		form.submit();
	};

Limonata.Font = {};

Limonata.Font.size = 11;

Limonata.Font.set =
	function(sign)
	{
		var mainb = document.getElementById('mainb');
		var mains = document.getElementById('mains');
		var mainf = document.getElementById('mainf');

		switch (sign)
		{
			case '0':
				Limonata.Font.size = 11;
				break;
			case '+':
				if (Limonata.Font.size >= 18)
					return;
				
				Limonata.Font.size++;				
				break;	
			case '-':
				if (Limonata.Font.size <= 11)
					return;
				
				Limonata.Font.size--;
				break;
			default:
				Limonata.Font.size = sign;
				break;
		}
		
		mainb.style.fontSize
			= mains.style.fontSize
			= mainf.style.fontSize
			= (Limonata.Font.size / 10) + 'em';
		
		Limonata.Cookie.write('limonata.font', Limonata.Font.size);
	};

Limonata.Style = {};

Limonata.Style.set =
	function(title)
	{
		var links = document.getElementsByTagName('link');
		
		for (var i = 0; i < links.length; i++)
		{
			if (links[i].attributes['rel'].value.indexOf('stylesheet') > -1)
			{
				if (links[i].attributes['rel'].value.indexOf('alternate') > -1)
				{
					links[i].disabled = true;
				}
				
				if
					(
						links[i].attributes['title'] &&
						links[i].attributes['title'].value == title
					)
				{
					links[i].disabled = false;
					
					Limonata.Cookie.write('limonata.style', i);
				}
			}
		}
		
		if (title == 'Mavi')
			Limonata.Cookie.write('limonata.style', 0);
	};

Limonata.Class = {};

Limonata.Class.has =
	function(id, name)
	{
		var obj = document.getElementById(id);
		
		var objAttributeClass = obj.className;
		
		if (objAttributeClass == null || objAttributeClass == '')
		{
			return false;
		}
		
		var objAttributes = objAttributeClass.split(' ');
		
		for (var i = 0; i < objAttributes.length; i++)
		{
			if (objAttributes[i] == name)
				return true;
		}
		
		return false;
	};
	
Limonata.Class.toogle =
	function(id, name)
	{
		if (Limonata.Class.has(id, name))
		{
			Limonata.Class.remove(id, name);
		}
		else
		{
			Limonata.Class.add(id, name);
		}
	};
	
Limonata.Class.add =
	function(id, name)
	{
		var classList;
		
		var obj = document.getElementById(id);
		
		var objAttributeClass = obj.className;
	
		if (objAttributeClass != null && objAttributeClass != '')
		{
			classList = objAttributeClass.split(' ');
		}
		else
		{
			classList = new Array();
		}
		
		classList.push(name);
		
		obj.className = classList.join(' ');
	};
	
Limonata.Class.remove =
	function(id, name)
	{
		var classList = new Array();
	
		var obj = document.getElementById(id);
		
		var objAttributeClass = obj.className;

		if (objAttributeClass != null && objAttributeClass != '')
		{
			var objAttributes = objAttributeClass.split(' ');
			
			for (var i = 0; i < objAttributes.length; i++)
			{
				if (objAttributes[i] == name)
					continue;
				
				classList.push(objAttributes[i]);
			}
		}
		
		obj.className = classList.join(' ');
	};

Limonata.Share = {};

Limonata.Share.url =
	function(service)
	{
		var title = encodeURIComponent(window.document.title);
		var url = encodeURIComponent(window.location.href);
	
		switch(service)
		{
			case 'facebook':
				var sURL = 'http://www.facebook.com/sharer.php?u=' + url + '&title=' + title;
				break;
			case 'twitter':
				var sURL = 'http://twitter.com/home?status=' + title + ' ' + url;
				break;
			case 'google':
				var sURL = 'http://www.google.com/bookmarks/mark?op=edit&bkmk=' + url + '&title=' + title;
				break;
			case 'myspace':
				var sURL = 'http://www.myspace.com/Modules/PostTo/Pages/?l=2&u=' + url + '&t=' + title + '&c=' + title;
				break;
		}
		
		window.open(sURL, '_blank', 'width=800,height=600,titlebar=no,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=1');
	};

Limonata.Search = {};

Limonata.Search.toogle =
	function()
	{
		Limonata.Class.toogle('search-tsd', 'none');
		Limonata.Class.toogle('search-google', 'none');
	};
	
Limonata.Suggest = {};

Limonata.Suggest.popup =
	function()
	{
		window.open('/siteyi-oner', '_blank', 'width=500,height=300,titlebar=no,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=1');
	};