/**
 *  XAkasha - JavaScript Functions, version 0.1
 *  (c) 2008 XAkasha
 *
 *  AutoBuilded JavaScript File with all neccessary JS Functions:
 *  @Last-Modified: 10.05.2010 09:25:18
 *
 ************************************************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] _base_utils
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

// check browser
var browser, agent, ns=0, ie=0, op=0;
browser = navigator.appName.toLowerCase();
agent = navigator.userAgent.toLowerCase();

if(GLOBAL == undefined) var GLOBAL = new Array();
GLOBAL["browser"] = "ot"; // other
if(browser.indexOf("explorer") >-1) GLOBAL["browser"] = "ie";
if(browser.indexOf("netscape") >-1) GLOBAL["browser"] = "ns";
if(agent.indexOf("opera") >-1) GLOBAL["browser"] = "op";
if(agent.indexOf("mozilla") >-1 && GLOBAL["browser"] != "ie") GLOBAL["browser"] = "mo"; // mozilla
if(agent.indexOf("mozilla") >-1 && agent.indexOf("firefox") >-1 && GLOBAL["browser"] != "ie") GLOBAL["browser"] = "ff"; // firefox


/**
 * handleErrors
 * 
 * @param: Array errors
 */
function handleErrors(errors)
{
	$A(errors).each(showMsg);
}

/**
 * showMsg
 * 
 * @param: String v
 */
function showMsg(v)
{	
	var msg = $(v);
	if(msg != null) msg.show();	
}


/**
 * handleMessages()
 *
 **/
function handleMessages() {
    try
	{
		// hide all erros messages in form
		$$('.error').each(Element.hide);
		// hide all success messages in form
		$$('.success').each(Element.hide);
	}
	catch (e){}
}

/**
 * onSendForm
 * 
 * hides all .error and .success within the $(form_id) element
 * and the .send_btn element
 *
 * @param: String id / DOM Object
 */
function onSendForm(form_id)
{
	try
	{
		// hide all erros messages in form
		$$('#' + form_id + ' .error').each(Element.hide);
		// hide all success messages in form
		$$('#' + form_id + ' .success').each(Element.hide);
		
		// hide submit button
		$($$('#' + form_id + ' .send_btn')[0]).hide();
		// show loading animation
		$($$('#' + form_id + ' .loading_btn')[0]).show()
	}
	catch (e){}
}

/**
 * onSendForm
 * 
 * shows the .send_btn
 * hides the .loading_btn
 * @param: String v
 */
function onReceiveForm(form_id)
{
	try
	{
		// show submit button
		$($$('#' + form_id + ' .send_btn')[0]).show();
		// hide loading animation
		$($$('#' + form_id + ' .loading_btn')[0]).hide();
	}
	catch (e){}
}

/**
 * getCssStyle
 * (cross-browser) gets current style value of object/element and css-rule
 * NECCESARY BECAUSE Prototype API :: getStyle dont works
 * 
 * @param: Object oElm
 * @param: String strCssRule
 * @return mixed String / Number 
 */
function getCssStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

/**
 * toggleTableRow
 * (cross-browser) toggles display of a single table row 
 * 
 * @param: String id
 */
function toggleTableRow(id,pm_id){
	
	if(pm_id != undefined){
		var url = 'php_bin/pm/update_is_read.php?id='+pm_id;
		new Ajax.Request(url, {
								method: 'post'
							  }
						);
	}
	var ua = navigator.userAgent;
	if(ua.indexOf("MSIE") >=0) {
		var now = getCssStyle($(id),'display');
		if ( now == "block") $(id).style.display='none';
		else $(id).style.display='block';
	}else{
		var now = getCssStyle($(id),'display');	
		if ( now == "table-row") $(id).style.display='none';
		else $(id).style.display='table-row';		
	}
}

/**
 * protoCheckAll
 * checks all checkboxes in form with given id = checkbox_id_basename  
 * 
 * @param: Object checkbox
 * @param: mixed String / Object form
 * @param: String checkbox_id_basename
 */
function protoCheckAll(checkbox, form, checkbox_id_basename) {
	var state = false;
	if(checkbox.checked)
		state = true;
	if(typeof form == "string")
		form = $(form);
		
	var buttons = form.getInputs('checkbox');
	for(var i = 0; i < buttons.size(); i++) {
		if(buttons[i].id && buttons[i].id.indexOf(checkbox_id_basename) == 0) {
			buttons[i].checked = state;
		}	
	}
}


/**
 * toggle
 * alias for prototype Element.toggle()
 * 
 * @param: Object or Element ID
 */
function toggle(id)
{
	$(id).toggle();
}

/**
 * show
 * alias for prototype Element.show()
 * 
 * @param: Object or Element ID or Array
 */
function show(ids)
{
	if(typeOf(ids) == "Array")
	{
		ids.each(Element.show);
		return;
	}
	$(ids).show();
};

/**
 * hide
 * alias for prototype Element.hide()
 * 
 * @param: Object or Element ID or Array
 */
function hide(ids)
{
	if(typeOf(ids) == "Array")
	{
		ids.each(Element.hide);
		return;
	}
	$(ids).hide();
};


/**
 * typeOf
 * returns the variable t`s type
 * 
 * @param: mixed
 * @return: Array or Object or String or Function
 */
typeOf = function(t)
{
	return String(t.constructor).split(" ")[1].split("()").join("");
};

/**
 * evalJs
 * evaluates all <script type='text/javascript'></script> tags in a code
 * 
 * @param: text with javascript
 */
function evalJs(t)
{
    var d = document.createElement('div');
    d.innerHTML = t;
    var c = '';
    var arr = new Array();
    arr = t.split('<script type=');
    for(var s=1; s<arr.length; ++s)
    {
    	if( arr[s].substring(1,16) == 'text/javascript' )
    	{
    		var tmp = arr[s].split("</script>")[0];
			tmp = tmp.substring(18, tmp.length);

            if (arr[s].substring(18,21) != 'src'){ //dp, 05.05.2009
                c += tmp;
            }
			
	   	}
    }
    eval(c);
    delete d;
}

/**
 * gotoURL
 * loads the given URL (always forces a full page reload)
 * 
 * @param: URL
 */
function goToUrl(url){gotoURL(url);} // alias
function gotoURL(url)
{
	if(url.indexOf('#') == -1)
	{
		window.location.href = url;
	}
	else
	{
		if(url.indexOf('?') == -1) {
			url = url.split('#').join( '?' + Math.random() * 9999 + "#" );
			window.location.href = url;
		} else {
			url = url.split('#').join( '&' + Math.random() * 9999 + "#" );
			window.location.href = url;
		}
	}
}

function gotoAnker(section,anker)
{
	document.location = 'anker';
}


/**
 * getFlashEmbed
 * gets the flash mebed object
 * 
 * @param: id
 */ 
function getFlashEmbed(movieName){
	// old code
	/*
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
	}*/
	
	// ff optimzed code
    if (navigator.appName.indexOf("Microsoft") != -1)
	{
        return window[movieName];
    }
    else
	{
	  if(document[movieName] != undefined)
	  {
	      if(document[movieName].length != undefined)
		  {
	          return document[movieName][1];
	      }
	      return document[movieName];
	  }
	  return undefined;
    }
}

// taken from lightbox js, modified argument return order
function getPageDimensions()
{	
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(windowWidth,windowHeight,pageWidth,pageHeight); 
	return arrayPageSize;
}

function showAjaxContentLoading()
{
	$('userpage_ajax_content').hide();
	$('userpage_ajax_loading').show();
}

function hideAjaxContentLoading()
{
	$('userpage_ajax_content').show();
	$('userpage_ajax_loading').hide();
}

function scrollToId(id) {
  new Effect.ScrollTo(id);
} 

function addOnWindowUnloadEventListener(callback_function)
{
	Event.observe(window, 'unload', callback_function);
}


function openPopUp(url,frame,width,height) {
	var left = (screen.width) ? (screen.width-width)/2 : 320;
	var top = (screen.height) ? (screen.height-height)/2 : 240;
	var win = open(url,frame,'toolbar=no,resizable=yes,scrollbars=yes,directories=no,menubar=no,status=yes,width='+width+',height='+height+',top='+top+',left='+left);
	win.focus();
	return win;
}


function onContent(f){//(C)webreflection.blogspot.com
var a=onContent,b=navigator.userAgent,d=document,w=window,c="onContent",e="addEventListener",o="opera",r="readyState",
s="<scr".concat("ipt defer src='//:' on",r,"change='if(this.",r,"==\"complete\"){this.parentNode.removeChild(this);",c,".",c,"()}'></scr","ipt>");
a[c]=(function(o){return function(){a[c]=function(){};for(a=arguments.callee;!a.done;a.done=1)f(o?o():o)}})(a[c]);
if(d[e])d[e]("DOMContentLoaded",a[c],false);
if(/WebKit|Khtml/i.test(b)||(w[o]&&parseInt(w[o].version())<9))(function(){/loaded|complete/.test(d[r])?a[c]():setTimeout(arguments.callee,1)})();
else if(/MSIE/i.test(b))d.write(s);
};

// Kronomy namespace for js:
var kr = (function() {
	return {
		// CORE CLASSES
		core: 		{},
			
		// GOOGLE ANALYTICS
		ga:			{},

		// AJAX HTTP CLASSES
		ajax:		{},

		// OBJECT MODELS 
		models:	{},

		// UI - Interface effects
		ui:	{},
		
		// User communities interfaces
		communities: {},
		
		// MyProfile Specific Interfaces
		myprofile:	{}
	};
	
})();

kr.isDev = function()
{
	
	try
	{
		
		var url_KrDomainName = 'kronomy.com';
		
		if (typeof document.domain == 'undefined') return false;
		if (typeof window.console == 'undefined') return false;

		if (document.domain.indexOf(url_KrDomainName) == -1) return true;

	}
	catch(e) { return false; }

	return false;
	
}

kr.log = function(message, severity)
{
	
	try 
	{
	
		if ( ! kr.isDev() ) return;
		
		if (typeof console.info == 'function' && typeof console.log == 'function') {
	
			if (typeof severity == 'undefined' || severity == '') severity = 'kr.log'; 
	
			if (typeof message == 'object') {
				console.log(message);
			} 
			else {
				var currenttime = new Date();
				
				console.info(
					currenttime.getHours() + ":" + 
					currenttime.getMinutes() + ":" + 
					currenttime.getSeconds() + " " + 
					"[" + severity + "] " + 
					message
				);
			}
	 	}
	
	} 
	catch(e) {} 
	finally { return; }
};

kr.trace = function() 
{
	
	try 
	{
	
		if (! kr.isDev() ) return;
		
		if (typeof console.trace == 'function') {
	
			console.trace();
	
		}
		
	} 
	catch(e) {} 
	finally { return; }
	
}

kr.error = function(m, url, l)
{
	
	try 
	{
	
		if (! kr.isDev() ) return;
		
		if (typeof console.error == 'function') {

			msg = m;

			if (typeof url != 'undefined') {
			    msg ='Windows.onError:\n';
			    msg += m + '; URL: ' + url;
			    if (typeof l != 'undefined') msg += '; Line: ' + l;
			} else if (typeof m == 'object')
				if (typeof m.name != 'undefined' && typeof m.message != 'undefined') { 
					msg = 'Catched: ' + m.name + ': ' + m.message;
					if (typeof m.fileName != 'undefined' && typeof m.lineNumber != 'undefined')
						msg += '; File: ' + m.fileName + '; Line: ' + m.lineNumber; 
				}
				
			severity = 'kr.error'; 

			var currenttime = new Date();
			
			console.error(
				currenttime.getHours() + ":" + 
				currenttime.getMinutes() + ":" + 
				currenttime.getSeconds() + " " + 
				"[" + severity + "] " + 
				msg
			);

		}
	}
	catch(e) { }
	finally { 
		return; 
	}
}
/* [END OF MODULE] _base_utils *****************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Tag
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: tag */
/* [END OF MODULE] Tag *************************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] _ - Test
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: event */
function testSystemMessageAccept(id)
{	
	var url = 'http://www.kronomy.com/ajax/user/testAcceptFriend.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: {"message_id":id},
							onSuccess: onTestSystemMessageAccept
						  }
					);
}

function onTestSystemMessageAccept(result)
{
	alert('ghh');
	myStuffChangeBox('my_stuff_friends');
}
/* [END OF MODULE] _ - Test ********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] _my - Stuff
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/** history functions **/

function onHistoryMyStuff(data, paging, get_params)
{
	if (paging == undefined) paging = "0";
	switch(data){
		case 'profile':
			myStuffShowBox('my_stuff_edit_profile');
			break;
		case 'account':
			myStuffShowBox('my_stuff_edit_account');
			break;	
		case 'notifications':
			myStuffShowBox('my_stuff_edit_notifications');
			break;	
		case 'feed_options':
			myStuffShowBox('my_stuff_edit_feed_options');
			break;
		case 'upload_picture':
			myStuffShowBox('my_stuff_upload_picture');
			break;
		case 'news_feed':
			sendGetNewsFeed(paging);
			break;
		case 'inbox':
			sendGetInbox(paging);
			break;
		case 'outbox':
			sendGetOutbox(paging);
			break;
		case 'new_message':
			sendGetComposeMessage();
			break;
		case 'friends':
			myStuffShowStaticBox('my_stuff_friends');
			break;
		case 'timelines':
			myStuffShowStaticBox('my_stuff_timelines');
			break;
		case 'favorites':
            if (paging != undefined || paging != "") {
                getFavoriteContent(paging);
            }
			myStuffShowStaticBox('my_stuff_favourites');
			break;
	}
}

/** history end **/

function myStuffShowBox (param) {
	$('my_stuff_news_feed').hide();
	$('my_stuff_message_box').hide();
	$('my_stuff_edit_profile').hide();
	$('my_stuff_edit_account').hide();
	$('my_stuff_edit_notifications').hide();
	$('my_stuff_edit_feed_options').hide();
	$('my_stuff_upload_picture').hide();
	$(param).show();
}

function myStuffShowStaticBox(param) {
	$('my_stuff_friends').hide();
	$('my_stuff_favourites').hide();
	$('my_stuff_timelines').hide();
	$(param).show();
}

function sendChangeAlias(form_id) {
	var url = 'http://www.kronomy.com/ajax/mystuff/changeAlias.php';
	onSendForm(form_id);
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendChangeAlias
						  }
					);
}

function getFavoriteContent(paging) {
    var url = 'http://www.kronomy.com/ajax/mystuff/getFavorites.php?page=' + paging;
	new Ajax.Request(url, {
							method: 'post',
							onSuccess: onGetFavoriteContent
						  }
					);
}

function onGetFavoriteContent(resp) {
    var result = resp.responseText.evalJSON();
    $('my_stuff_favourites_content').innerHTML = result.content;
}

function onSendChangeAlias(resp) {
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) {
		window.location.reload();
	} else {
		handleErrors(result_obj.errors);	
	}
}

/**
 * @autor dp <dimitar@kronomy.com>
 */
function deleteTimeline(timelineAlias, confirmed){
    if (confirmed !== true){
        str = $("confirm_delete_timeline").innerHTML;
        //set alias
        str = str.gsub('--alias--', timelineAlias);
		Lightbox.showBoxString(str,458,400);
    }else{
        Lightbox.hideBox();
        var url = 'http://www.kronomy.com/ajax/mystuff/deleteTimeline.php?';
        new Ajax.Request(url, {
                        method: 'post',
                        parameters: {"alias":timelineAlias},
                        onSuccess: onDeleteTimeline
                      }
                );
    }
}

/**
 * @autor dp <dimitar@kronomy.com>
 */
function onDeleteTimeline(resp){
    var obj = resp.responseText.evalJSON();
	if (obj.errors.length == 0) {
		$('li_timelines_list_'+obj.timeline_alias).hide();
		$('timeline_successfully_deleted').show();
	} else {
		handleErrors(obj.errors);	
	}
}

/**
 * @autor dp <dimitar@kronomy.com>
 */
function deleteTimelineFromFavorites(timelineAlias, confirmed){
    if (confirmed !== true){
        str = $("confirm_delete_timeline_from_favorites").innerHTML;
        //set alias
        str = str.gsub('--alias--', timelineAlias);
		Lightbox.showBoxString(str,458,400);
    }else{
        Lightbox.hideBox();
        var url = 'http://www.kronomy.com/ajax/mystuff/deleteTimelineFromFavorites.php?';
        new Ajax.Request(url, {
                        method: 'post',
                        parameters: {"alias":timelineAlias},
                        onSuccess: onDeleteTimelineFromFavorites
                      }
                );
    }
}

/**
 * @autor dp <dimitar@kronomy.com>
 */
function onDeleteTimelineFromFavorites(resp){
    var obj = resp.responseText.evalJSON();
	if (obj.errors.length == 0) {
		$('li_favorite_timelines_list_'+obj.timeline_alias).hide();
		$('std_content_favorite_count_id').innerHTML = $('std_content_favorite_count_id').innerHTML-1;
		$('timeline_successfully_deleted_from_favorites').show();
	} else {
		handleErrors(obj.errors);	
	}
}


/**
 * mystaff namespace
 * 
 * @author Peter Krebs <peter@kronomy.com>
 * @since pk-09-03-07
 * 
 */
var myStuff = {
	/**
	 * submits profile_image_upload_form to profile_image_upload_iframe
	 * and opens a LB after saving to temp
	 * 
	 */
	uploadAvatar: function() {
		if (!(obj_form = document.getElementById('profile_image_upload_form')))
		{
			alert('Error Form not found');
			return 		
		}
		
		if (!(obj_iframe = document.getElementById('profile_image_upload_iframe')))
		{
			obj_iframe = document.createElement('DIV');
			obj_iframe.style.visibility = 'hidden';
			obj_iframe.style.display 	= 'none';
			obj_iframe.id				= 'profile_image_upload_iframe';
			document.body.appendChild(obj_iframe);  
		}
		
		obj_iframe.name = 'profile_image_resize_iframe';
		
		obj_form.target = obj_iframe.name;
	    if (obj_form.encoding){
			// IE does not respect property enctype for HTML forms.
	        // Instead use property encoding.
	        obj_form.encoding = 'multipart/form-data';
		} else {
			obj_form.enctype = 'multipart/form-data';
		}
		
		obj_form.action = "ajax/mystuff/profile_avatar_image_upload.php"
		obj_form.submit();	
	},
	
	/**
	 * callback function after uploading the file
	 */
	uploadAvatarTempDone: function(aTempFile,aLang)
	{
	    
		var flashvars = {
			"picpath": aTempFile,
			"phpfile": 'ajax/mystuff/profile_image_save_resized.php',
			"w": '75',
			"h": '100',
			"lang": aLang
		};
		var params = {
			wmode : "transparent"
		};
		var attributes = {};
	
		str_content = "<div id=\"flash_resize_image\">" +
				"<p id=\"timeline\" style=\"width:606px; height:300px; background:#ccc;\">" +
				"You need to install Flash Player (Version 9) to view this site correctly. Get it <a href=\"http://get.adobe.com/de/flashplayer/\" target=\"_blank\">here</a>!" +
				"</p>" +
				"</div>";			
		Lightbox.showBoxString(str_content,350,300);
		swfobject.embedSWF("_flash/resizepic/ResizePic.swf", "flash_resize_image", "310", "260", "8.0.0","expressInstall.swf", flashvars, params, attributes);
		
	} 


}












/* [END OF MODULE] _my - Stuff *****************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] User
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: user */

/** history functions **/

function onHistoryUser(data, paging, get_params)
{
	switch(data){
		case 'friends':
			myStuffShowStaticBox('my_stuff_friends');
			break;
		case 'timelines':
			myStuffShowStaticBox('my_stuff_timelines');
			break;
		case 'favorites':
			myStuffShowStaticBox('my_stuff_favourites');
			break;
	}
}

/** history end **/

function userPageShowComposeMessage() {
	$('user_page_compose_message').toggle();
}

function sendFriendRequest(form_id) {
	var url = 'http://www.kronomy.com/ajax/user/send_friend_request.php';
	onSendForm(form_id);
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendFriendRequest
						  }
					);
}	

function onSendFriendRequest(resp) {
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) {
		Lightbox.hideBox();
		
		try{
		    $('success_friend_request_sent').show();
		}catch(e){}
	} else {
		handleErrors(result_obj.errors);	
	}
}

function acceptFriend(friend_id) {
    var url = 'http://www.kronomy.com/ajax/user/accept_friend.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: {'message_id' : friend_id}
						  }
					);
					
	$('friend_request_'+friend_id).hide();
	$('friend_successfully_added_'+friend_id).show();
	
}


/**
 * @author dp <dimitar@kronomy.com>
*/
function deleteFriend(friendId, confirmed) {

    if (confirmed !== true){
        str = $("confirm_delete_friend").innerHTML;
        //set alias
        str = str.gsub('--friendId--', friendId);
        Lightbox.showBoxString(str,458,400);
    }else{
        Lightbox.hideBox();
        var url = 'http://www.kronomy.com/ajax/user/deleteFriend.php';
        new Ajax.Request(url, {
            method: 'post',
            parameters: {"friendId":friendId},
            onSuccess: function(resp){
                var obj = resp.responseText.evalJSON();
                if (obj.errors.length == 0) {
                    $("my_friends_list_"+friendId).hide()
                    $("friend_successfully_deleted_"+friendId).show()
                    $('std_content_friends_count_id').innerHTML = $('std_content_friends_count_id').innerHTML-1;
                }else{
                    handleErrors(obj.errors);	
                }
            }
        }
    );
    }	
}


function showFriendRequestForm(alias) 
{
 Lightbox.showBoxByAJAX('ajax/user/friend_request.php?alias=' + alias,400,400); 
}

function updateProfile(form_id) 
{
	var url = 'http://www.kronomy.com/ajax/user/update_user.php';
	onSendForm(form_id);
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onUpdateProfile
						  }
					);
}

function onUpdateProfile(resp) 
{
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) {
		$('success_profile_update').show();

		$('header_user_name').innerHTML = result_obj.firstname +" "+ result_obj.lastname;
		$('about_me_name').innerHTML = result_obj.firstname +" "+ result_obj.lastname;
	} else {
		handleErrors(result_obj.errors);	
	}
}

// Change Feed Options
function sendSaveFeedOptions(form_id) 
{
	var url = 'http://www.kronomy.com/ajax/user/save_feed_options.php';
	onSendForm(form_id);
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendSaveFeedOptions
						  }
					);
}

function onSendSaveFeedOptions(resp) 
{
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) {
		$('save_feed_options_success').show();
	} else {
		handleErrors(result_obj.errors);	
	}
}

// Change Password
function sendUpdatePassword(form_id) 
{
	$('change_pw_success').hide();
	$$(".error").each(Element.hide);
	
	var url = 'http://www.kronomy.com/ajax/user/change_new_password.php';
	onSendForm(form_id);
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendUpdatePasswordSuccess
						  }
					);
}

function onSendUpdatePasswordSuccess(resp) 
{
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) {
		$('change_pw_success').show();
	} else {
		handleErrors(result_obj.errors);	
	}
}

// Change Password
function sendUpdateEmail(form_id) 
{
	$('change_email_success').hide();
	$$(".error").each(Element.hide);
	
	var url = 'http://www.kronomy.com/ajax/user/change_new_email.php';
	onSendForm(form_id);
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendUpdateEmailSuccess
						  }
					);
}

function onSendUpdateEmailSuccess(resp) 
{
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) {
		$('change_email_success').show();
	} else {
		handleErrors(result_obj.errors);	
	}
}

// Change notifocation
function updateNotification(form_id) 
{
	$('change_notification_success').hide();
	
	var url = 'http://www.kronomy.com/ajax/user/change_notification.php';
	onSendForm(form_id);
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onUpdateNotificationSuccess
						  }
					);
}

function onUpdateNotificationSuccess(resp) 
{
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) {
		$('change_notification_success').show();
	} else {
		handleErrors(result_obj.errors);	
	}
}
/* [END OF MODULE] User ************************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Category
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: category */
/* [END OF MODULE] Category ********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE]  - Flash
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/


function getFlashEmbed()
{
	return document.getElementById("timeline");
}

function setAutoMovement(enabled)
{
	try
	{
    	getFlashEmbed().setAutoMovement(enabled);
    }
	catch(e) { }
}


/**
* 
* works for player v3
*/
function changeBackgroundTo(url)
{
	try
	{
		getFlashEmbed().changeBackgroundTo(url);
    }
	catch(e) {
	}
}

function switchToTimeline(nickname){
    //dimi todo
}

/**
* 
* works for player v3
*/
function goToEvent(nickname, guid){
	try{
    	// RSS-GUID String
		getFlashEmbed().goToEvent(nickname, guid);
    }
	catch(e) {
    }
}

/**
* 
* works for player v3
*/
function addEvent(xml_string){
	try{
    	// RSS-GUID String
    	getFlashEmbed().addEvent(xml_string);
    }catch(e) {
	}
}


/**
* 
* @todo seems not to update the event in flash
*/
function updateEvent(xml_string) {
    try
	{
    	// RSS-ITEM
    	getFlashEmbed().updateEvent(xml_string);
    }
	catch(e) {
	}
}

/**
* 
* works for player v3
*/
function deleteEvent(guid) {
	try
	{
    	// RSS-GUID String
    	getFlashEmbed().deleteEvent(guid);
    }
	catch(e) {
		//dp: reload is not the best solution...???
		//document.location.reload();
	}
}

/**
* 
* works for player v3
*/
function updateEventOrder(guid_array){
	try{
    	// RSS-GUID String
    	getFlashEmbed().updateEventOrder(guid_array);
    }
	catch(e) {
	}
}

/**
* 
* works for player v3
*/
function setTopMedia(eventGuid, mediaId)
{
    try
	{
		getFlashEmbed().setTopMedia(eventGuid, mediaId);
    }
	catch(e) {
	}
}

/**
* @todo
*/
function addMedia(media, eventGuid, position)
{
    try
	{
		getFlashEmbed().addMedia(media, eventGuid, position);
    }
	catch(e) {
	}
}

/**
* @todo
*/
function updateMedia(media, eventGuid)
{
    try
	{
		getFlashEmbed().updateMedia(media, eventGuid);
    }
	catch(e) {
	}
}

/**
* 
* works for player v3
*/
function deleteMedia(mediaId, eventGuid)
{
    try
	{
		getFlashEmbed().deleteMedia(mediaId, eventGuid);
    }
	catch(e) {
	}
}


/**
* 
* works for player v3
*/
function updateMediaOrder(eventGuid, mediaIdArray){
    try{
		getFlashEmbed().updateMediaOrder(eventGuid, mediaIdArray);
    }
	catch(e){
	}
}
 
function onFlashInitialized()
{
	// <pk-09-03-23 /> () of each logic expression
    if ((GLOBAL['flash_buffer']['gotoevent'] != undefined) || (GLOBAL['flash_buffer']['gotoevent'] != ""))
   	{
       goToEvent(GLOBAL['flash_buffer']['gotoevent']);
    }
}

        
function hideMouseWheelFromBrowser(elem_id){
    //<dp-2009-09-16>
    return false;
    //</dp-2009-09-16>
    var elem = document.getElementById(elem_id);
    
    if (elem.addEventListener)
    { // W3C DOM
        elem.addEventListener('DOMMouseScroll', wheel, false);
        elem.addEventListener('mousewheel', wheel, false);
    }
    else if (elem.attachEvent) { // IE DOM
        elem.attachEvent("onmousewheel", wheel);
    }
}
            
function wheel(event)
{
    if (event.preventDefault)
        event.preventDefault();
    event.returnValue = false;
}  







/**
 * Local Fileupload
 * Flash Multiuploader
 *******/
function flash_upload_file_finished(id, type, thumb, item, preview, text){
    if (id == undefined || id == "undefined") return false;
    
	value = new Hash();
	value.set("id", id);
	value.set("type", type); 
	value.set("thumb", thumb);
	value.set("item", item);
	value.set("preview", preview);

	str = $('uploaded_media_template_container').innerHTML;
	var template = new Template(str);
	new Insertion.Bottom('uploaded_media_items', template.evaluate(value));
	
	$('uploaded_media_items_container').show();
	
}

function flash_upload_all_files_finished(){
	$('uploaded_media_items_container').show();
	$('create_local_actions').show();
}

function flash_upload_delete_all()
{
    $('uploaded_media_items').innerHTML = "";
    $('uploaded_media_items_container').hide();
	$('create_local_actions').hide();
}

// deprecated
function updatePreviewPic(xml_string, guid) {
    return false;
}
// deprecated
function reloadTunnelConfig(){
    return false;
}

/* [END OF MODULE]  - Flash ********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE]  - History
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/


 window.dhtmlHistory.create({
	toJSON: function(o) {
		return Object.toJSON(o);
	}, 
	fromJSON: function(s) {
		return s.evalJSON();
	}
});
  
Event.observe(window, 'load', function() {
	
	// globals Variable:
	if(window.GLOBAL == undefined)
		window.GLOBAL = new Array();
	
	// Init RSH JS History:
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(historyChangeListener);

	try {
		var link = document.location.href;
		var hash = link.substring(link.indexOf('#')+1);
        
		if (!historyStorage.hasKey(hash) && hash != link) {
			historyChangeListener(hash, link);
		//'create' has a default hash..
		}else if (document.location.href.indexOf('/create/') > 0 && hash == link){
            //default action in create is #upload
            historyChangeListener('upload', link);
		}
	} catch(e) {
	}
});

function historyChangeListener(newLocation, historyData) {

	try {
		if (historyData == null) historyData = document.location.href;
		// if the key is not in storage -> add
		if (!historyStorage.hasKey(newLocation)) {
			dhtmlHistory.add(newLocation, historyData);
		}
		// refer to the page
		if (historyData.indexOf('/mystuff/') > 0) {
			var withParams = checkForPagingParams(newLocation);
			onHistoryMyStuff(withParams[0], withParams[1], withParams[2]);
		}
		if (historyData.indexOf('/create/') > 0) {
			var withParams = checkForPagingParams(newLocation);
			onHistoryCreate(withParams[0], withParams[1], withParams[2]);
		}
		if (historyData.indexOf('/user/') > 0) {
			var withParams = checkForPagingParams(newLocation);
			onHistoryUser(withParams[0], withParams[1], withParams[2]);
		}
		if (historyData.indexOf('/explore/') > 0) {
			var withParams = checkForPagingParams(newLocation);
			onHistoryExplore(withParams[0], withParams[1], withParams[2]);
		}
		if (historyData.indexOf('/timeline/') > 0) {
			var withParams = checkForPagingParams(newLocation);
			onHistoryTimeline(withParams[0], withParams[1], withParams[2]);
		}
		if (historyData.indexOf('/search/') > 0) {
			var withParams = checkForPagingParams(newLocation);
			onHistorySearch(withParams[0], withParams[1], withParams[2]);
		}
		return;

		
	} catch(e) {
	}
};

function checkForPagingParams(request) {
	kr.log('Request: ' + request);
    if (request == null) return false;
	var tmp = new Array();
	var hash = (request.indexOf("?") > 0) ? request.substring(0, request.indexOf("?")) : request;
	if (hash.indexOf("|") > 0) {
		tmp[0] = hash.substring(0, hash.indexOf("|"));
		tmp[1] = hash.substring(hash.indexOf("|")+1);
		tmp[2] = (request.indexOf("?") > 0) ? request.substring(request.indexOf("?")) : "";
	} else {
		tmp[0] = hash;
		tmp[1] = "";
		tmp[2] = (request.indexOf("?") > 0) ? request.substring(request.indexOf("?")) : "";
	}
	
	// for each (var m in tmp) kr.log(' - ' + m);
	
	return tmp;
}

/* [END OF MODULE]  - History ******************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Message
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: message */
function sendNewMessage(form_id) {
	var url = 'http://www.kronomy.com/ajax/message/sendMessage.php';
	onSendForm(form_id);
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendNewMessageSuccess
						  }
					);
}

function onSendNewMessageSuccess(resp) {
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) {
		$('success_message_sent').show();
		$F('send_message').reset;
	} else {
		handleErrors(result_obj.errors);
	}
}

function deleteSelectedMessages(form_id) {
	var url = 'http://www.kronomy.com/ajax/message/deleteMessages.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onDeleteSelectedMessagesSuccess
						  }
					);
}

function onDeleteSelectedMessagesSuccess(resp) {
	var obj = resp.responseText.evalJSON();
	if (obj.type == "outbox") {
		sendGetOutbox();
	} else if (obj.type == "inbox") {
		sendGetInbox();
	}
}

function sendGetInbox(page) {
	if (page == 0) {
		page = page + 1;
	}

	var url = 'http://www.kronomy.com/ajax/message/inbox.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: {'page' : page},
							onSuccess: onSendGetInboxResponse
						  }
					);
}

function onSendGetInboxResponse(result) {
	var obj = result.responseText.evalJSON();
	$('my_stuff_message_box').innerHTML = obj.inbox;
	myStuffShowBox('my_stuff_message_box');
}

function sendGetOutbox(page) {	
	if (page == 0) {
		page = page + 1;
	}

	var url = 'http://www.kronomy.com/ajax/message/outbox.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: {'page' : page},
							onSuccess: onSendGetOutboxResponse
						  }
					);
}

function onSendGetOutboxResponse(result) {
	var obj = result.responseText.evalJSON();
	$('my_stuff_message_box').innerHTML = obj.outbox;
	myStuffShowBox('my_stuff_message_box');
}

function sendGetComposeMessage()
{	

	var url = 'http://www.kronomy.com/ajax/message/compose.php';
	new Ajax.Request(url, {
							method: 'post',
							onSuccess: onSendGetComposeMessageResponse
						  }
					);
}

function onSendGetComposeMessageResponse(result) {
	var obj = result.responseText.evalJSON();
	$('my_stuff_message_box').innerHTML = obj.compose;
	myStuffShowBox('my_stuff_message_box');
}

function sendGetAnswerMessage(message_id)
{	

	var url = 'http://www.kronomy.com/ajax/message/answer.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: {'message_id' : message_id}, 
							onSuccess: onSendGetAnswerMessageResponse
						  }
					);
}

function onSendGetAnswerMessageResponse(result) {
	var obj = result.responseText.evalJSON();

	$('my_stuff_message_box').innerHTML = obj.compose;
	$('title').value = obj.title;
	$('message').value = obj.body;
	$('title').activate();

	$('friend_receipients').options[$('friend_receipients').options.length] = new Option(obj.receiver_firstname + ' ' + obj.receiver_lastname, obj.receiver, false, true);

	myStuffShowBox('my_stuff_message_box');
}

function toggleMessage(type, id, callback) {
	if ($('message_'+type+'_'+id).className == "new_mail") {
		var url = 'http://www.kronomy.com/ajax/message/touchMessage.php';
		new Ajax.Request(url, {
								method: 'post',
								parameters: {'id' : id, 'type' : type}
							  }
						);
		$('message_'+type+'_'+id).removeClassName('new_mail');
		var new_messages = $('new_message_count').innerHTML;
		if (new_messages != 0) {
			$('new_message_count').innerHTML = (new_messages - 1);
		}
	}
	$('message_body_'+type+'_'+id).toggle();
	
}

function sendGetNewsFeed(page) {	
	if (page == 0) {
		page = page + 1;
	}

	var url = 'http://www.kronomy.com/ajax/message/newsFeed.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: {'page' : page},
							onSuccess: onSendGetNewsFeedResponse
						  }
					);
}

function onSendGetNewsFeedResponse(result) {
	var obj = result.responseText.evalJSON();
	$('my_stuff_newsfeed_content').innerHTML = obj.newsfeed;
	myStuffShowBox('my_stuff_news_feed');
}
/* [END OF MODULE] Message *********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Security
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

function sendLogin(form_id) {
    try{
        $('activation_content').hide();
        }catch(e){}
    
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/security/login.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendLoginSuccess
						  }
					);
}

function onSendLoginSuccess(response) {
	var result_obj = response.responseText.evalJSON();
	// if no errors occurrend
	if(result_obj.errors.length == 0) {
		window.location.reload();
	} else {
        try {
            handleErrors(result_obj.errors);
            if (result_obj.show_activation_send == true) {
                $('activation_email').value = result_obj.email;
                $('origin_email').value = result_obj.email;
                $('activation_content').show();
            }
        } catch (ex) {
            // do nothing
        }
	}
}

function sendActivation(form_id) {
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/security/send_activation.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendActivationSuccess
						  }
					);
}

function onSendActivationSuccess(response) {
    var obj = response.responseText.evalJSON();
    if(obj.errors.length == 0) {
		$('email_send').show();
	} else {
        handleErrors(obj.errors);
    }
}


function sendForgotPassword(form_id){
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/security/forgot_password.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendForgotPassword
						  }
					);
}

function onSendForgotPassword(response){
    var obj = response.responseText.evalJSON();
    if(obj.errors.length == 0) {
		$('forgot_password_success').show();
	} else {
        handleErrors(obj.errors);
    }
}

function showLoginForm() {
 Lightbox.showBoxByAJAX('ajax/security/login.php',300,400); 
}

function sendLogout() {
	var url = 'http://www.kronomy.com/ajax/security/logout.php';
	new Ajax.Request(url, {
							method: 'post',
							onSuccess: onSendLogoutSuccess
						  }
					);
}

function onSendLogoutSuccess(response) {
	window.location.href = "http://www.kronomy.com/explore";
}
/* [END OF MODULE] Security ********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Privacy
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: privacy */
 // hid_public
 // ext_public

function check_privacy(status){
    
	switch(status)
	{
	case '0':
		//$('ext_public').checked=false;
		break;
	case '1':
		$('ext_public').checked=false;
		$('hid_public').value = 0;
		break;
	case '-1':
		$('hid_public').checked=true;
		if($('ext_public').checked ){
			$('hid_public').value = -1;
		}
		else{
			$('hid_public').value = 0;
		}

		break;
	}
	
}
/* [END OF MODULE] Privacy *********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE]  - Create
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/** history functions **/

function onHistoryCreate(data, paging, get_params) {
	if (get_params == undefined) get_params = "";
	
	switch(data){
		case 'timeline_overview':
			sendGetMainTab(data, 'overview');
			break;
		case 'timeline':
			sendGetMainTab(data, paging, get_params);
			break;
		case 'timeline_settings':
			sendGetMainTab(data, paging, get_params);
			break;
		case 'upload':
			sendGetMainTab(data, paging);
			break;
		case 'customize':
			sendGetMainTab(data);
			break;
		case 'webcrawler':
			kr.log('webcrawler');
		    sendGetMainTab(data);
			sendGetWebCrawler(paging);
			break;
		case 'webcrawler_search':
			kr.log('webcrawler_search');
			createShowSubTab('create_web_crawler');
			kr.log($F('webcrawler_form'));
			sendWebCrawlerSearch('webcrawler_form');
			break;
		case 'local':
			sendGetMainTab(data, paging);
			break;
		case 'website':
		    sendGetMainTab(data, paging);
			break;
    	case 'website_youtube':
    	    sendGetMainTab(data, paging, get_params);
			sendGetTagSearch(paging);
    		break;	
		case 'website_picasa':
		    sendGetMainTab(data, paging, get_params);
			sendGetTagSearch(paging);
			break;
		case 'website_flickr':
		    sendGetMainTab(data, paging, get_params);
			sendGetTagSearch(paging);
			break;
		case 'website_photobucket':
		    sendGetMainTab(data, paging, get_params);
			sendGetTagSearch(paging);
			break;
		case 'customize_background':
			createSwitchCustomizeTab('background');
			break;
		case 'customize_frames':
			createSwitchCustomizeTab('frames');
			break;
		case 'customize_flow':
			createSwitchCustomizeTab('flow');
			break;
        case 'finalize':
            sendGetStep(2);
            break;
        case 'add_share':
            sendGetStep(3);
            break;
        case 'what_next':
            sendGetStep(4);
            break;
	}
}

function sendWebCrawlerSearchFromDefault() {
	createShowSubTab('create_web_crawler');
	sendWebCrawlerSearch('webcrawler_form');
}

function sendGetStep(step_nr, get_params) {
    if (GLOBAL['create_step'] == step_nr) {
        return;
    }
    GLOBAL['create_step'] = step_nr;
    handleMessages();

    var url = "http://www.kronomy.com/ajax/create/get_step.php?"+get_params+"&step_nr=" + step_nr;


    if (Prototype.Browser.IE) {
        //alert("manual: IE");
        new Ajax.Request(url, {
					method: 'post',
					asynchronous: true,
					onSuccess: onSendGetStep
				}
			);
    } else {
        new Ajax.Request(url, {
					method: 'post',
					asynchronous: false,
					onSuccess: onSendGetStep
				}
			);
    }

}

function onSendGetStep(resp) {
    
    mediaDeselectAll();


    var obj = resp.responseText.evalJSON();

    if (obj.errors.length == 0) {

        $('step').innerHTML = obj.content;
        
        //fixx me 
        try{
            
            $$('#create_step_navigation li').each(function(s, index) {
                $(s).removeClassName("txt_blue")
            });
            $('create_step_navigation_'+obj.step_nr).addClassName("txt_blue");
            //alert(obj.step_nr);
        }catch (e){}
        if (obj.step_nr == 4){
            $("create_step_navigation").hide();
        }
        //fixx me end

        } else {
        //alert("what, if there's no output-content");
        }
    }

/** history end **/

function sendGetMainTab(id, mode, get_params) {
    //sendGetStep(1, get_params);
    try{
        $("tab_content_loading").show();
    }catch(e){}

	var get = undefined;
	if (get_params != undefined && get_params != "") {
		get = get_params;
	}
	if (mode != undefined && mode != "") {
		if (get != undefined && get != "") {
            get = get + "&mode=" + mode;
        } else {
            get = "?mode=" + mode;
        }
	} else if (id == 'timeline') {
		if (get != undefined && get != "")
        {
            get = get + "&mode=default";
        }
		else
        {
            get = "?mode=" + mode;
        }
	}
	var url = "";
	if (get == undefined) {
        url = 'http://www.kronomy.com/ajax/create/switch_main_tab.php';
    } else {
        url = 'http://www.kronomy.com/ajax/create/switch_main_tab.php' + get;
    }
	handleMessages();
	new Ajax.Request(url, {
					method: 'post',
					parameters: {'a' : id},
					onSuccess: onSendGetMainTab
				}
			);
}

function scrollToEvent(event_id, scroll_container, item_container, count_ignore) {
	try {
		if (typeof count_ignore == 'undefined') count_ignore = 3;
		
		var pos = 0;
		var found = false;
		
		var event_item_id = 'event_' + event_id;
		
		kr.log(event_item_id);
		kr.log(scroll_container);
		kr.log(item_container);
		
		$(item_container).childElements().each(function(n) {
			
			kr.log(n.identify());
			kr.log(n.getWidth());
			
			if (found == false && n.identify() != event_item_id) {
				if (count_ignore-- <= 0) pos += n.getWidth();
			} else {
				found = true;
			}
		});
	
		kr.log(pos);
		kr.log(found);
		
		$(scroll_container).scrollLeft = pos;
	} catch(e) { kr.error(e) };
	
}

function onSendGetMainTab(resp) {
    mediaDeselectAll();
    try{
        $("tab_content_loading").hide();
    }catch(e){}
    
	var obj = resp.responseText.evalJSON();
	$('create_tabs').innerHTML = obj.content;

	try {
	    
		evalJs(obj.content);
		if (obj.event_id != undefined) {
			startSortingEvents(obj.event_id);
		}
	} catch (ex) {}
	try {
		startSortingTimeline();
	} catch (e) {
	}
	
	if (typeof obj.event_id != 'undefined') {
		scrollToEvent(obj.event_id, 'event_scroller', 'event_list_scroll');
	}
    
    if (typeof obj.eventAlias != 'undefined') {
    	kr.log(obj.eventAlias);
      	goToEvent(null, obj.eventAlias);  
      // goToEvent(null, obj.eventAlias);  
    }

    if (obj.hasItems) {
        $('finalize_button').show();
    }
}

function createWebSiteShowLoading() {
	try {
		$('website_content').hide();
		$('website_loading').show();
	} catch (ex) {}
}


function createShowSubTab(id) {
	try {
	    
		$('create_web_crawler').hide();
		$('create_local_upload').hide();
		$('create_website_upload').hide();
		$('create_overview').hide();
		$(id).show();
	} catch (ex) {}
}

function createSwitchCustomizeTab(id) {
	try {
		var test = $('customize_container').innerHTML;
		if (test == undefined) {
            throw new Exception;
        }
	} catch (ex) {
		sendGetMainTab('customize');
	}
    handleMessages();
	new Ajax.Request('ajax/create/switch_customize_tabs.php', {
					method: 'post',
					parameters: {'a' : id},
					onSuccess: function(resp) {
						var obj = resp.responseText.evalJSON();
						$('customize_container').innerHTML = obj.content;
					}
				}
	);
}

function sendGetWebCrawler(page) {
	setTimeout( function() {
		$('create_search_button').href = "javascript:sendWebCrawlerSearch('form_id');";
		$('form_id').action = "javascript:sendWebCrawlerSearch('form_id');";
		
		if (page == undefined) {
	        page = 0;
	    }
		if (page == 0) {
			$('create_web_crawler').show();
		} else {
			$('create_web_crawler').show();
			var url = 'http://www.kronomy.com/ajax/create/webcrawler_search.php';
	        handleMessages();
			new Ajax.Request(url, {
								method: 'post',
								parameters: {'page' : page},
								onSuccess: onWebCrawlerResponse
							  }
						);
		}
	}, 500);
}

function sendGetTagSearch(page) {
	//$('create_search_button').href = "javascript:sendWebCrawlerSearch('form_id');";
	//$('form_id').action = "javascript:sendWebCrawlerSearch('form_id');";
	setTimeout( function() {
		if (page == undefined) {
	        page = 0;
	    }
		if (page == 0) {
			// $('create_web_crawler').show();
		} else {
			// $('create_web_crawler').show();
			var url = 'http://www.kronomy.com/ajax/create/website_tag_search.php';
	        handleMessages();
			new Ajax.Request(url, {
								method: 'post',
								parameters: {'page' : page},
								onSuccess: onWebSiteTagResponse
							  }
						);
		}
	} , 500);
}

function sendWebSiteTagSearch(form_id) {
	kr.log(form_id);
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/create/website_tag_search.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onWebSiteTagResponse,
							onError: function(response) { kr.error(response); }
						  }
					);
}


function sendWebCrawlerSearch(form_id) {
    handleMessages();
    try {
        $('nothing_found').hide();
		$('webcrawler_search_box').hide();
		$('webcrawler_loading').show();
	} catch (ex) {}
	try {
		var url = 'http://www.kronomy.com/ajax/create/webcrawler_search.php';
		new Ajax.Request(url, {
								method: 'post',
								parameters: $(form_id).serialize(true),
								onSuccess: onWebCrawlerResponse
							  }
						);
	} catch (ex) {
		sendGetWebCrawler(0);
	}
}

/**
* FIXME
* dp: hier spinnt noch das blättern ab und zu. und ich erkenne noch kein muster
* inhalt ist dann einfach leer
*/
function onWebCrawlerResponse(result) {
    mediaDeselectAll();
	//createShowSubTab('create_web_crawler');
	$('create_search_button').href = "javascript:sendWebCrawlerSearch('form_id');";
	$('form_id').action = "javascript:sendWebCrawlerSearch('form_id');";
	
	kr.log(result);
	
	var obj = result.responseText.evalJSON();
	
	kr.log(obj);
	
    if (obj.wc == undefined || obj.wc == ''){
        $('nothing_found').show();
        alert("nothing_found")
    }else{
        try{
            $('create_web_crawler_show_container').show();
            $('create_web_crawler_show_container').innerHTML = obj.wc;
        }catch(e){
            alert("error innerHTML: "+ e.getMessage());
        }


    	try{
    	    $('create_web_crawler_add_media').show();
            $('webcrawler_step2_infos').show();
            $('nothing_found').hide();
    	}catch(e){}

    }
	try {
	    if (obj.tags != undefined && obj.tags != ""){
	        $('search_web').value = obj.tags;
	    }
		
	} catch (ex) {}
	try {
		$('webcrawler_loading').hide();
		$('webcrawler_search_box').show();
		
	} catch (ex) {}
}

function onWebSiteTagResponse(result) { // XXXRobert container dont exist
	kr.log('success');
	kr.log(result);
    mediaDeselectAll();
    
	// createShowSubTab('create_web_crawler');
	
	$('create_web_crawler').show();
	$('webcrawler_search_box').hide();
	
	// $('create_search_button').href = "javascript:sendWebSiteTagSearch('form_id');";
	// $('form_id').action = "javascript:sendWebSiteTagSearch('form_id');";
	var obj = result.responseText.evalJSON();
	
	kr.log('obj:');
	kr.log(obj);
	
	$('create_web_crawler_show_container').innerHTML = obj.wc;
	$('create_web_crawler_show_container').show();
	$('create_web_crawler_add_media').show();
	// $('tag_search_step2_infos').show();
	//try {
		//$('webcrawler_loading').hide();
		//$('webcrawler_search_box').show();
	//} catch (ex) {
		//kr.error(ex);
	//}
}



function sendSelectMediaFromShowContent(media_id, type, thumb, platform) {
	if (GLOBAL['web_crawler_media'] == undefined) {
		GLOBAL['web_crawler_media'] = new Hash();
	}
	var media = $('show_' + media_id);
    var value = undefined;
	if (media.className == "image image_selected") {
		media.className = "image";
		if (GLOBAL['web_crawler_media'].get(media_id) != undefined) {
			GLOBAL['web_crawler_media'].unset(media_id);
		}
	} else if (media.className == "image") {
		media.className = "image image_selected";
		value = new Hash();
		value.set("id", media_id);
		value.set("type", type);
		value.set("thumb", thumb);
		value.set("platform", platform);
		GLOBAL['web_crawler_media'].set(media_id, value);
	} else if (media.className == "video video_selected") {
		media.className = "video";
		if (GLOBAL['web_crawler_media'].get(media_id) != undefined) {
			GLOBAL['web_crawler_media'].unset(media_id);
		}
	} else if (media.className == "video") {
		media.className = "video video_selected";
		value = new Hash();
		value.set("id", media_id);
		value.set("type", type);
		value.set("thumb", thumb);
		value.set("platform", platform);
		GLOBAL['web_crawler_media'].set(media_id, value);
	}
}

function addSelectedToMediaPool() {
	
	var media= GLOBAL['web_crawler_media'];
    if (media == undefined) {
        return;
    }
	$('create_web_crawler_selected_container').show();
	$('create_web_crawler_actions').show();
	media.each(function(pair) {
			var values = pair.value;
			str = $('selected_media_template_container').innerHTML;
			var template = new Template(str);
			new Insertion.Bottom('selected_media_items', template.evaluate(values));
		}
	);
	mediaDeselectAll();
}

function addSelectedToNewEvent(album) {
	if (album == 'album') {
		Lightbox.showBoxByAJAX('ajax/create/website_add_new_event.php',458,400);
	} else {
		Lightbox.showBoxByAJAX('ajax/create/webcrawler_add_new_event.php',458,400);
	}
}


function addLocalUploadedToNewEvent() {
	Lightbox.showBoxByAJAX('ajax/create/local_upload_add_new_event.php',458,400);
}


function addNewEmptyEvent() {
    Lightbox.showBoxByAJAX('ajax/create/add_new_empty_event.php',"newbox", "newbox");
}

function showEditLB(event_id) {
    if (event_id == "default") {
        event_id = 0;
    }
    Lightbox.showBoxByAJAX('ajax/create/get_edit_event_lb.php?event_id='+event_id,"newbox", "newbox");
}

function sendEditEvent(form_id) {
	var url = 'http://www.kronomy.com/ajax/create/edit_event.php';
    handleMessages();
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onEditEvent
				  }
			);
}

function onEditEvent(resp) {
	var obj = resp.responseText.evalJSON();
	if (obj.errors.length != 0) {
        handleErrors(obj.errors);
        return;
    }
    updateEvent(obj.rss);
	Lightbox.hideBox();
	var childs;
	try {
    	childs = $('pos_'+obj.content.event_id).childElements();
    	childs.each(function(n) {
    		if (n.className == "image_frame") {
                n.title = obj.content.title;
            }
   		});
	} catch (ex) {
		$('event_'+obj.content.event_id).title = obj.content.title;
	}
    
}

function sendNewEmptyEvent(form_id) {
    var url = 'http://www.kronomy.com/ajax/create/add_new_empty_event_submit.php';
    handleMessages();
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onUploadNewEmptyEvent
				  }
			);
}

function onUploadNewEmptyEvent(resp){
    
    mediaDeselectAll();
    var obj = resp.responseText.evalJSON();
    if (obj.errors.length != 0) {
        handleErrors(obj.errors);
        return;
    }
    handleMessages();
    Lightbox.hideBox();

    //update flash
    addEvent(obj.rss);

    
    //reload events
    sendGetMainTab('timeline', obj.event_id, null);
}

function webCrawlerAddMediaToExistingEvent(event_id) {
	var selected = $('selected_media_items').childElements();
	selected.each(function(item) {
		var template = new Template("<input type='hidden' name='#{id}'/>");
		var params = {'id' : item.identify()};
		new Insertion.Bottom('webcrawler_existing_event', template.evaluate(params));
	});
	var url = 'http://www.kronomy.com/ajax/create/webcrawler_add_media_to_event.php?event_pos_id=' + event_id;
    handleMessages();
	new Ajax.Request(url, {
					method: 'post',
					parameters: $('webcrawler_existing_event').serialize(true),
					onSuccess: onUploadNewEvent
				  }
			);
	GLOBAL['web_crawler_media'] = undefined;
	$('selected_media_items').innerHTML = "";
}

function localUploadAddMediaToExistingEvent(event_id, test){

    	var uploaded = $('uploaded_media_items').childElements();
    	uploaded.each(function(item) {
    		var template = new Template("<input type='hidden' name='#{id}'/>");
    		var params = {'id' : item.identify()};
    		new Insertion.Bottom('local_existing_event', template.evaluate(params));
    	});

    	var url = 'http://www.kronomy.com/ajax/create/local_upload_add_media_to_event.php?event_pos_id=' + event_id;
        handleMessages();
    	new Ajax.Request(url, {
    					method: 'post',
    					parameters: $('local_existing_event').serialize(true),
    					onSuccess: onUploadNewEvent
    				  }
    			);

    	$('uploaded_media_items').innerHTML = "";
        
}

function sendWebCrawlerNewEvent() {
	var selected = $('selected_media_items').childElements();
	selected.each(function(item) {
		var template = new Template("<input type='hidden' name='#{id}'/>");
		var params = {'id' : item.identify()};
		new Insertion.Bottom('lb_new_event', template.evaluate(params));
	});
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/create/webcrawler_add_media_with_new_event.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $('lb_new_event').serialize(true),
					onSuccess: onUploadNewEvent
				  }
			);
	GLOBAL['web_crawler_media'] = undefined;
	$('selected_media_items').innerHTML = "";
}

function sendLocalUploadNewEvent() {

	var uploaded = $('uploaded_media_items').childElements();
	uploaded.each(function(item) {
		var template = new Template("<input type='hidden' name='#{id}'/>");
		var params = {'id' : item.identify()};
		new Insertion.Bottom('lb_new_event', template.evaluate(params));
	});
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/create/local_upload_add_media_with_new_event.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $('lb_new_event').serialize(true),
					onSuccess: onUploadNewEvent
				  }
			);
	//$('uploaded_media_items').innerHTML = "";
}

function webCrawlerShowDetails(media_id, type, thumb, platform) {
	sendSelectMediaFromShowContent(media_id, type, thumb);
	Lightbox.showBoxByAJAX('ajax/create/webcrawler_details.php?mediaid=' + media_id + '&platform=' + platform ,458,400);
}


function localUploadShowDetails(media_id, type, item) {
	//Lightbox.showBoxImage(item);
	Lightbox.showBoxByAJAX('ajax/create/localupload_details.php?mediaId=' + media_id + '&type=' + type + '&item=' + item,458,650);
}

function localShowDetails(media_id, type, thumb){
    //todo
}


function webCrawlerRemoveAll(id) {
    $('selected_media_items').innerHTML = "";
    $('create_web_crawler_actions').hide();
    $('create_web_crawler_selected_container').hide();
}

function getWebsiteContent(data, get_params) {

	if (get_params == undefined) {
        get_params = "";
    }
    try {
        $('website_content_loading').show();
    } catch (ex) {}

	var url = 'http://www.kronomy.com/ajax/create/website_load_content.php' + get_params;
	new Ajax.Request(url, {
					method: 'post',
					parameters: {'media' : data},
					onSuccess: onGetWebsiteContent
				  }
			);
}

function onGetWebsiteContent(result) {
    mediaDeselectAll();
    //alert("1: "+ result.responseText);
    //alert("1a: "+ obj.errors);

	kr.log(result);

	var obj = result.responseText.evalJSON();
	
	kr.log(obj);
	
	//alert("2: "+obj.content);
	
	if (typeof obj.content == 'undefined') {
		$('create_website_upload').hide();
		$('create_website_upload_noresults').show();	
	} else {
	    $('create_website_upload').innerHTML = obj.content;
		$('create_website_upload').show();
		$('create_website_upload_noresults').hide();	
	}
	
	foobar = $('create_website_upload').innerHTML;
    try {
        $('website_content_loading').hide();
    } catch (ex) {}
    if ((obj.errors.length != 0) && (obj.location == undefined)) {
        handleErrors(obj.errors);
        return;
    }
	if (obj.location != undefined) {
		document.location.href = obj.location;
	}

}

function sendPicasaLogin(form_id) {
    handleMessages();
	$('website_content').hide();
	$('website_loading').show();
    var url = 'http://www.kronomy.com/ajax/create/website_login_picasa.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onGetWebsiteContent
				  }
			);
}

function sendPicasaLogout() {
	var url = 'http://www.kronomy.com/ajax/create/website_logout_picasa.php';
	new Ajax.Request(url, {
					method: 'post',
					onSuccess: onSendPicasaLogout
				  }
			);
}

function onSendPicasaLogout(result) {
	getWebsiteContent('website_picasa');
}

function sendYoutubeLogout() {
	var url = 'http://www.kronomy.com/ajax/create/website_logout_youtube.php';
	new Ajax.Request(url, {
					method: 'post',
					onSuccess: onSendYoutubeLogout
				  }
			);
}

function onSendYoutubeLogout(result) {
	getWebsiteContent('website_youtube');
}

function sendYoutubeLink(form_id) {
    handleMessages();
	$('website_content').hide();
	$('website_loading').show();
	
	kr.log($(form_id).serialize(true));
	
	var url = 'http://www.kronomy.com/ajax/create/website_login_youtube_link.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onGetWebsiteContent
				  }
			);
}

function sendYoutubeLinkAddEvent(event_id, form_id) {
    handleMessages();
	$('website_content').hide();
	$('website_loading').show();
	var url = 'http://www.kronomy.com/ajax/create/website_login_youtube_link.php?add=' + event_id;
    if (event_id == "as_new") {
        new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onUploadNewEvent
				  }
			);
    } else {
        new Ajax.Request(url, {
					method: 'post',
					parameters: {'add' : 'to_existing', 'code' : form_id, 'youtube_link' : true, 'event_pos_id' : event_id},
					onSuccess: onUploadNewEvent
				  }
			);
    }
	
}

function sendYoutubeLogin(form_id) {
    handleMessages();
	$('website_content').hide();
	$('website_loading').show();
	var url = 'http://www.kronomy.com/ajax/create/website_login_youtube.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onGetWebsiteContent
				  }
			);
}

function sendFlickrLogout() {
	var url = 'http://www.kronomy.com/ajax/create/website_logout_flickr.php';
	new Ajax.Request(url, {
					method: 'post',
					onSuccess: onSendFlickrLogout
				  }
			);
}

function onSendFlickrLogout(result) {
	getWebsiteContent('website_flickr');
}

function sendFlickrLogin() {
	handleMessages();
	$('website_content').hide();
	$('website_loading').show();
	var url = 'http://www.kronomy.com/ajax/create/website_login_flickr.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: {'flickr' : 'doRedirect'},
					onSuccess: onSendFlickrLogin
				  }
			);
}

function onSendFlickrLogin(resp) {
	var obj = resp.responseText.evalJSON();
	document.location.href = obj.location;
}

function sendPhotobucketLogout() {
	var url = 'http://www.kronomy.com/ajax/create/website_logout_photobucket.php';
	new Ajax.Request(url, {
					method: 'post',
					onSuccess: onSendPhotobucketLogout
				  }
			);
}

function onSendPhotobucketLogout(result) {
	getWebsiteContent('website_photobucket');
}

function sendPhotobucketLogin() {
	handleMessages();
	$('website_content').hide();
	$('website_loading').show();
	var url = 'http://www.kronomy.com/ajax/create/website_login_photobucket.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: {'photobucket' : 'doRedirect'},
					onSuccess: onSendPhotobucketLogin
				  }
			);
}

function onSendPhotobucketLogin(resp) {
	var obj = resp.responseText.evalJSON();
	document.location.href = obj.location;
}

function websiteSelectAlbum(album_id, type, thumb, toggle) {
	if (toggle == undefined) {
        toggle = true;
    }
	if (GLOBAL['website_album'] == undefined) {
		GLOBAL['website_album'] = new Hash();
	}
	var media = $('show_' + album_id);
    var value = undefined;
	if (media.className == "image image_selected") {
		if (toggle) {
			media.className = "image";
			if (GLOBAL['website_album'].get(album_id) != undefined) {
				GLOBAL['website_album'].unset(album_id);
			}
		} else {
			value = new Hash();
			value.set('id', album_id);
			value.set('type',type);
			value.set('thumb',thumb);
			GLOBAL['website_album'].set(album_id, value);
		}
	} else if (media.className == "image") {
		media.className = "image image_selected";
        value = new Hash();
		value.set('id', album_id);
		value.set('type',type);
		value.set('thumb',thumb);
		GLOBAL['website_album'].set(album_id, value);
	} else if (media.className == "video video_selected") {
		if (toggle) {
			media.className = "video";
			if (GLOBAL['website_album'].get(album_id) != undefined) {
				GLOBAL['website_album'].unset(album_id);
			}
		} else {
			value = new Hash();
			value.set('id', album_id);
			value.set('type',type);
			value.set('thumb',thumb);
			GLOBAL['website_album'].set(album_id, value);
		}
	} else if (media.className == "video") {
		media.className = "video video_selected";
		value = new Hash();
		value.set('id', album_id);
		value.set('type',type);
		value.set('thumb',thumb);
		GLOBAL['website_album'].set(album_id, value);
	} 	else if (media.className == "album album_selected") {
		if (toggle) {
			media.className = "album";
			if (GLOBAL['website_album'].get(album_id) != undefined) {
				GLOBAL['website_album'].unset(album_id);
			}
		} else {
			value = new Hash();
			value.set('id', album_id);
			value.set('type',type);
			value.set('thumb',thumb);
			GLOBAL['website_album'].set(album_id, value);
		}
	} else if (media.className == "album") {
		media.className = "album album_selected";
		value = new Hash();
		value.set('id', album_id);
		value.set('type',type);
		value.set('thumb',thumb);
		GLOBAL['website_album'].set(album_id, value);
	}
}

function sendWebSiteNewEvent(form_id) {
	var album = GLOBAL['website_album'];
	album.each(function(pair){
		var template = new Template("<input type='hidden' name='#{id}' value='#{title}'/>");
		var params = {'id' : pair.key, 'title' : $('title_' + pair.key).innerHTML};
		new Insertion.Bottom('web_site_new_event', template.evaluate(params));
	});

	GLOBAL['website_album'] = undefined;
    handleMessages();

    //importing from other websites may take a while
    try{
        $("img_video_list_container_id").hide();
        $("add_as_new_event_loading").show();
    }catch(e){}




    var url = 'http://www.kronomy.com/ajax/create/website_add_media_with_new_event.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onUploadNewEvent
				  }
			);
}

function youtubeLinkGetNewLB(code) {
    Lightbox.showBoxByAJAX('ajax/create/website_login_youtube_link.php?get=new_LB&code='+code,458,400);
}

function uploadToExistingEvent(type) {
	Lightbox.showBoxByAJAX('ajax/create/upload_to_existing_event.php?type=' + type,458,400);
}

function sendWebSiteUploadToExistingEvent(id, form_id) {
    if (form_id == undefined) form_id = "web_site_existing_event";
    try{
        $('lb_upload_existing_event_scroll_timelines').hide();
        $('lb_upload_existing_event_loading').show();
    }catch(e){}
    
	GLOBAL['web_crawler_media'] = undefined;
	
    
	var album = GLOBAL['website_album'];
	if (album == undefined){
        handleMessages();
        try{
        	Lightbox.hideBox();
            $('please_select_some_media').show();
        }catch(e){}
        return false;
	}

	album.each(function(pair){
		var template = new Template("<input type='hidden' name='#{id}' value='#{title}'/>");
		var params = {'id' : pair.key, 'title' : $('title_' + pair.key).innerHTML};
		new Insertion.Bottom('web_site_existing_event', template.evaluate(params));
	});
	GLOBAL['website_album'] = undefined;
    handleMessages();
    var url = 'http://www.kronomy.com/ajax/create/website_add_media_to_event.php?event_pos_id=' + id;
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onUploadNewEvent
				  }
			);
	
}

function onUploadNewEvent(resp) {
    
    mediaDeselectAll();
    var obj = resp.responseText.evalJSON();
    if (obj.errors.length > 0) {
        try {
    		//Lightbox.hideBox();
    	} catch (ex) {}
        handleErrors(obj.errors);
        return;
    }
    
	try {
		Lightbox.hideBox();
		
        if (obj.new_event == true) {
        	addEvent(obj.rss);
        } else {
        	updateEvent(obj.rss);
        }
        if (obj.event_id != undefined && obj.thumb != undefined) {
            var event = $('event_p_' + obj.event_id);
            event.setStyle({background:'url('+ obj.thumb +') no-repeat center center #000'});
            updatePreviewPic(obj.toppic_rss.media_content, obj.toppic_rss.guid);
            try {
                $('toppic_img').remove();
            } catch (ex) {}
            
            var img = new Element('img', { 'class': 'toppic', src: '_image/icons_buttons/toppic.gif', id: 'toppic_img' });
            $('pos_' + id).appendChild(img);
        }
	} catch (ex) {}
	
	$('finalize_button').show();
	
	// <pk-09-03-12>
	if (obj.timeline_alias == undefined) obj.timeline_alias = "";
	if (obj.event_pos_id == undefined) obj.event_pos_id = "0";

    
	if (obj.rldRand){
		window.location.href = 'http://www.kronomy.com/create/'+obj.timeline_alias+'&rnd=' + obj.rldRand + '#timeline|' + obj.event_pos_id;
	}else {
    	window.location.href = 'http://www.kronomy.com/create/'+obj.timeline_alias+'#timeline|' + obj.event_pos_id;
	}


}

function startSortingEvents(event_id) {
	Sortable.create("sortable_event_media", {onUpdate:function() {
				event_id = (event_id == '' || event_id == undefined) ? 0 : event_id;
				new Ajax.Request('ajax/create/sort_media.php?event_id=' + event_id,
					{method: 'post', parameters: Sortable.serialize("sortable_event_media"), onSuccess: function(resp) {
                        var obj = resp.responseText.evalJSON();
                        if (obj.errors.length != 0) {
                            handleErrors(obj.errors);
                            return;
                        }
                        updateMediaOrder(obj.eventAlias, obj.mediaIdArray);
                    }}
				);
			}
			, tag:'li', overlap:'horizontal', constraint: false});
			
		//important	
		GLOBAL['timeline_detail'] = null;	
}

function timelineDetailSelectAlbum(pos_id, type, thumb, toggle) {
	if (toggle == undefined) {
        toggle = true;
    }
	if (GLOBAL['timeline_detail'] == undefined) {
		GLOBAL['timeline_detail'] = new Hash();
	}
	var media = $('pos_' + pos_id);
    var value = undefined;
	if (media.className == "image image_selected") {
		if (toggle) {
			media.className = "image";
			if (GLOBAL['timeline_detail'].get(pos_id) != undefined) {
				GLOBAL['timeline_detail'].unset(pos_id);
			}
		} else {
			value = new Hash();
			value.set('id', pos_id);
			value.set('type',type);
			value.set('thumb',thumb);
			GLOBAL['timeline_detail'].set(pos_id, value);
		}
	} else if (media.className == "image") {
		media.className = "image image_selected";
		value = new Hash();
		value.set('id', pos_id);
		value.set('type',type);
		value.set('thumb',thumb);
		//alert("pos_id: " + pos_id + " / type: "+ type + " / thumb: " + thumb)
		GLOBAL['timeline_detail'].set(pos_id, value);
	} else if (media.className == "video video_selected") {
		if (toggle) {
			media.className = "video";
			if (GLOBAL['timeline_detail'].get(pos_id) != undefined) {
				GLOBAL['timeline_detail'].unset(pos_id);
			}
		} else {
			value = new Hash();
			value.set('id', pos_id);
			value.set('type',type);
			value.set('thumb',thumb);
			GLOBAL['timeline_detail'].set(pos_id, value);
		}
	} else if (media.className == "video") {
		media.className = "video video_selected";
		value = new Hash();
		value.set('id', pos_id);
		value.set('type',type);
		value.set('thumb',thumb);
		GLOBAL['timeline_detail'].set(pos_id, value);
	} 	else if (media.className == "album album_selected") {
		if (toggle) {
			media.className = "album";
			if (GLOBAL['timeline_detail'].get(pos_id) != undefined) {
				GLOBAL['timeline_detail'].unset(pos_id);
			}
		} else {
			value = new Hash();
			value.set('id', pos_id);
			value.set('type',type);
			value.set('thumb',thumb);
			GLOBAL['timeline_detail'].set(pos_id, value);
		}
	} else if (media.className == "album") {
		media.className = "album album_selected";
		value = new Hash();
		value.set('id', pos_id);
		value.set('type',type);
		value.set('thumb',thumb);
		GLOBAL['timeline_detail'].set(pos_id, value);
	}
}

function sendChangeTopPic(event_id) {
	if (GLOBAL['timeline_detail'] == undefined) {
		return;
	}
	var id = GLOBAL['timeline_detail'].keys().last();
	if (id != undefined) {
        handleMessages();
		new Ajax.Request('ajax/create/set_top_pic.php',
					{method: 'post', parameters: {'id' : id, 'event_id' : (event_id == undefined || event_id == "" || event_id == "default") ? 0 : event_id}, onSuccess:onSendChangeTopPic}
				);
	}
}

function onSendChangeTopPic(resp) {
    var id = GLOBAL['timeline_detail'].keys().last();
    mediaDeselectAll();

    GLOBAL['timeline_detail'] = undefined;
	var obj = resp.responseText.evalJSON();
    if (obj.errors.length != 0) {
        handleErrors(obj.errors);
        return;
    }
	if (obj.event_id != undefined && obj.thumb != undefined) {
		var event = $('event_p_' + obj.event_id);
		event.setStyle({background:'url('+ obj.thumb +') no-repeat center center #000'});

		//update flash
        setTopMedia(obj.event_alias, obj.media_id)
        
        try {
            $('toppic_img').remove();
        } catch (ex) {}

        var img = new Element('img', { 'class': 'toppic', src: '_image/icons_buttons/toppic.gif', id: 'toppic_img' });
        $('pos_' + id).appendChild(img);
        
	}
}

function sendDeleteSelectedMedia(form_id) {
	if (GLOBAL['timeline_detail'] == undefined) {
		return;
	}

	var album = GLOBAL['timeline_detail'];
    
	album.each(function(pair){
		var template = new Template("<input type='hidden' name='media_pos_ids[]' value='#{id}'/>");
		var params = {'id' : pair.key};
		new Insertion.Bottom('timeline_delete_media', template.evaluate(params));
	});
	GLOBAL['timeline_detail'] = undefined;
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/create/delete_media_from_event.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onSendDeletePics
				  }
			);
}

function onSendDeletePics(resp) {
    mediaDeselectAll();
    GLOBAL['delete_query_string'] = undefined;
	var obj = resp.responseText.evalJSON();
    if (obj.errors.length != 0) {
        $('failed_to_delete_media').show();
        handleErrors(obj.errors);
        return;
    }
	if (obj.ask != undefined) {
        GLOBAL['delete_query_string'] = $H(obj).toQueryString();
        Lightbox.showBoxByID('confirm_delete_all', 458, 400);
    }
    
    if (obj.success == true) {
    	
    	if (obj.href == false) {
        	$('delete_media_success').show();
    	} else {
    		$('delete_event_success').show();
    	}
        
        
        if (obj.href != false) {
            //when whole event has beeen delted
            document.location.href = obj.href;
            Lightbox.hideBox();
            return;
        }else{
            obj.deletedIds.each(function(s) {
                deleteMedia(s, obj.eventAlias)
            });
            //console.log(obj.deletedIds)
            obj.mediaIds.each(function(s) {
                try{
                    $("pos_"+s).remove();
                } catch (ex) {}
                
            });
        }

      

    }
    return;
}

function sendForceDeletePics() {
    handleMessages();
    mediaDeselectAll();
    var url = 'http://www.kronomy.com/ajax/create/delete_media_from_event.php';
    new Ajax.Request(url, {
                    method: 'post',
                    parameters: GLOBAL['delete_query_string'],
                    onSuccess: onSendDeletePics
                  }
            );
}

function moveMedia(event_id) {
	if (GLOBAL['timeline_detail'] == undefined) {
		return;
	}
	Lightbox.showBoxByAJAX('ajax/create/upload_to_existing_event.php?type=move_media&event_id='+event_id,458,400);
}

function sendMoveMedia(event_id, form_id) {
	Lightbox.hideBox();

	if (GLOBAL['timeline_detail'] == undefined) {
		return;
	}

	var template = new Template("<input type='hidden' name='target_event' value='#{tid}'/>");
	var params = {'tid' : event_id};
	new Insertion.Bottom('timeline_move_media', template.evaluate(params));

	var album = GLOBAL['timeline_detail'];
	album.each(function(pair){
		var template = new Template("<input type='hidden' name='media_pos_ids[]' value='#{id}'/>");
		var params = {'id' : pair.key};
		new Insertion.Bottom('timeline_move_media', template.evaluate(params));
	});
	GLOBAL['timeline_detail'] = undefined;
	handleMessages();
	var url = 'http://www.kronomy.com/ajax/create/move_media_to_event.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onSendMoveMedia
				  }
			);
}

function onSendMoveMedia(resp) {
	var obj = resp.responseText.evalJSON();
    if (obj.errors.length != 0) {
        handleErrors(obj.errors);
        return;
    }
	if (obj.ask != undefined) {
		check = confirm("do asking");
		if (check == true) {
			//alert("start merge process ...");
		} else {
			return;
		}
	}
    mediaDeselectAll();
    if (obj.success == true) {
        $('move_media_success').show();
        document.location.reload();
    }

}

function mediaSelectAll(kind) {
	var media = undefined;
    switch(kind) {
	case 'website':
		media = $$('.album', '.video');
		GLOBAL['website_album'] = undefined;
		media.each(function(n) {
			var id = n.identify().substring(5);
			if (id != "" || id != undefined) {
				var thumb = n.firstDescendant().style.background;
				thumb = thumb.substring(thumb.indexOf("url(")+4);
				thumb = thumb.substring(0,thumb.indexOf(") no"));
				websiteSelectAlbum(id, 'album', thumb, false);
			}
		});
		break;
	case 'timeline_details':
        media = $$('.video', '.image');
		GLOBAL['timeline_details'] = undefined;
		media.each(function(n) {
			var id = n.identify().substring(4);
			if (id != "" || id != undefined) {
				var thumb = n.firstDescendant().style.background;
				thumb = thumb.substring(thumb.indexOf("url(")+4);
				thumb = thumb.substring(0,thumb.indexOf(") no"));
				timelineDetailSelectAlbum(id, n.className, thumb, false);
			}
		});
		break;
	case 'timeline':
        media = $$('.event');
		GLOBAL['timeline_overview'] = undefined;
		media.each(function(n) {
			var id = n.identify().substring(4);
			if (id != "" || id != undefined) {
				var thumb = n.firstDescendant().style.background;
				thumb = thumb.substring(thumb.indexOf("url(")+4);
				thumb = thumb.substring(0,thumb.indexOf(") no"));
				timelineOverviewSelectAlbum(id, n.className, thumb, false);
			}
		});
		break;
	}
}

function mediaDeselectAll() {
	var media = $$('.album_selected', '.video_selected', '.image_selected', '.event_selected');

    GLOBAL['website_album'] = undefined;
    GLOBAL['timeline_overview'] = undefined;
    GLOBAL['timeline_details'] = undefined;
    GLOBAL['timeline_details'] = undefined;
    GLOBAL['web_crawler_media'] = undefined;
	media.each(function(n) {
           if (n.className == 'album album_selected') {
               n.className = 'album';
           }
           if (n.className == 'video video_selected') {
               n.className = 'video';
           }
           if (n.className == 'image image_selected') {
               n.className = 'image';
           }
           if (n.className == 'event event_selected') {
               n.className = 'event';
           }
	});

}

function timelineOverviewSelectAlbum(pos_id, type, thumb, toggle) {
    
	if (toggle == undefined) {
        toggle = true;
    }
	if (GLOBAL['timeline_overview'] == undefined) {
		GLOBAL['timeline_overview'] = new Hash();
	}
	var media = $('pos_' + pos_id);
    var value = undefined;
	if (media.className == "event event_selected") {
		if (toggle) {
			media.className = "event";
			if (GLOBAL['timeline_overview'].get(pos_id) != undefined) {
				GLOBAL['timeline_overview'].unset(pos_id);
			}
		} else {
			value = new Hash();
			value.set('id', pos_id);
			value.set('type',type);
			value.set('thumb',thumb);
			GLOBAL['timeline_overview'].set(pos_id, value);
		}
	} else if (media.className == "event") {
		media.className = "event event_selected";
		value = new Hash();
		value.set('id', pos_id);
		value.set('type',type);
		value.set('thumb',thumb);
		GLOBAL['timeline_overview'].set(pos_id, value);
	}
	
}

function startSortingTimeline() {
	Sortable.create("sortable_event", {onUpdate:function() {
                handleMessages();
				new Ajax.Request('ajax/create/sort_event.php', {
					method: 'post', 
					parameters: Sortable.serialize("sortable_event"), 
					onSuccess:function(resp){
                        var obj = resp.responseText.evalJSON();
                        if (obj.errors.length == 0) {
                            $('sortable_event').innerHTML = obj.content;
                            startSortingTimeline();
                            updateEventOrder(obj.guidArray);
                        } else {
                            handleErrors(obj.errors);
                        }
					}
				});
			}
			, tag:'li', overlap:'horizontal', constraint: false});
			
			//important
            GLOBAL['timeline_overview'] = null;
}

function sortTimelineForm() {
	Lightbox.showBoxByAJAX('ajax/create/timeline_sort_form.php',458,400);
}

function sortTimelineBy(form_id) {
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/create/timeline_sort_by.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onSortTimelineBy
				  }
			);
}

function onSortTimelineBy(resp) {
    mediaDeselectAll();
    Lightbox.hideBox();
    reloadTunnelConfig();
    var obj = resp.responseText.evalJSON();
    if (obj.errors.length == 0) {
       $('timeline_inner_content').innerHTML = obj.content;
        //startSortingTimeline();
        updateEventOrder(obj.sortOrder);
    } else {
        handleErrors(obj.errors);
    }

}

function mergeEvents() {
    if (GLOBAL['timeline_overview'] == undefined) {
		return;
	}

	var album = GLOBAL['timeline_overview'];
	album.each(function(pair){
		var template = new Template("<input type='hidden' name='merge_event_id[]' value='#{id}'/>");
		var params = {'id' : pair.key};
		new Insertion.Bottom('timeline_merge_event', template.evaluate(params));
	});
	GLOBAL['timeline_overview'] = undefined;
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/create/merge_events.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $('timeline_merge_event').serialize(true),
					onSuccess: onMergeEvents
				  }
			);
}

function onMergeEvents(resp) {
    mediaDeselectAll();
    var obj = resp.responseText.evalJSON();
    if (obj.success == true) {
        $('merge_event_success').show();
        // right now do this ...
		document.location.reload();
        return;
	}
    handleErrors(obj.errors);
}

function deleteEvents() {
    if (GLOBAL['timeline_overview'] == undefined) {
		return;
	}



	var album = GLOBAL['timeline_overview'];
	album.each(function(pair){
		var template = new Template("<input type='hidden' name='delete_event_id[]' value='#{id}'/>");
		var params = {'id' : pair.key};
		new Insertion.Bottom('timeline_delete_event', template.evaluate(params));
	});
	GLOBAL['timeline_overview'] = undefined;
    handleMessages();
	var url = 'http://www.kronomy.com/ajax/create/delete_events.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $('timeline_delete_event').serialize(true),
					onSuccess: onDeleteEvents
				  }
			);
}

function onDeleteEvents(resp) {
    mediaDeselectAll();
    var obj = resp.responseText.evalJSON();
    if (obj.errors.length != 0) {
        handleErrors(obj.errors);
        return;
    }
    if (obj.success == true) {
        $('delete_event_success').show();
        obj.deletedEvents.each(function(e) {
            deleteEvent(e.alias); 
            $('pos_'+e.id).hide();
        });
        return;
    }
}

function switchBackgroundCategory(select_field) {
    var selection = $F(select_field);
    var lists = $$('.background_list');
    lists.each(function(n) {
        $(n).hide();
    });
    $(selection + "_category").show();
}

function setBackground(id)
{
    var url = 'http://www.kronomy.com/ajax/create/customize_background.php?bid='+id;
    handleMessages();
	new Ajax.Request(url, {
					method: 'post',
					onSuccess: function(resp) {
                        if (resp.responseText == "" || resp.responseText == undefined){
                            var bgUrl = '_flash/assets/tunnel/default/background/'+id+'/932x300.jpg';
                            changeBackgroundTo(bgUrl)
                            $('background_success').show();
                            var lists = $$('.background_list');
                            lists.each(function(n) {
                                var bgs = $(n).childElements();
                                bgs.each(function(b) {
                                    $("a_" + $(b).identify()).className = "";
                                });
                            });
                            $("a_background_" + id).className = "selected";
                            return;
                        } else {
                            // there is an error
                            //alert("error");
                            var json = resp.responseText.evalJSON();
                            handleErrors(json.errors);
                            return;
                        }
                    }
				  }
			);
}

function setAscOrDesc(val) {
    var url = 'http://www.kronomy.com/ajax/create/customize_asc_or_desc.php?sort='+val;
    handleMessages();
	new Ajax.Request(url, {
					method: 'post',
					onSuccess: function(resp) {
                        if (resp.responseText == "" || resp.responseText == undefined) {
                            $('sort_order_success').show();
                            reloadTunnelConfig();
                            return;
                        } else {
                            // there is an error
                            var json = resp.responseText.evalJSON();
                            handleErrors(json.errors);
                            return;
                        }

                    }
				  }
			);
}

function setEventLabel(val) {
    var url = 'http://www.kronomy.com/ajax/create/customize_event_label.php?label='+val;
    handleMessages();
	new Ajax.Request(url, {
					method: 'post',
					onSuccess: function(resp) {
                        if (resp.responseText == "" || resp.responseText == undefined) {
                            $('time_stamp_or_ranking_success').show();
                            reloadTunnelConfig();
                            return;
                        } else {
                            // there is an error
                            var json = resp.responseText.evalJSON();
                            handleErrors(json.errors);
                            return;
                        }

                    }
				  }
			);
}

function saveTimeline(form_id) {
    handleMessages();
    var url = 'http://www.kronomy.com/ajax/create/save_timeline.php';
	new Ajax.Request(url, {
					method: 'post',
                    parameters: $(form_id).serialize(true),
					onSuccess: onSaveTimeline
				  }
			);
}

function quickSaveTimeline(form_id) {
    handleMessages();
    mediaDeselectAll();
    parameters = null;
    if (typeof form_id != 'undefined' && form_id != null) {
        if ($(form_id)){
            parameters = $(form_id).serialize(true);
        }
    }
    
    var url = 'http://www.kronomy.com/ajax/create/quick_save_timeline.php';
	new Ajax.Request(url, {
					method: 'post',
                    parameters: parameters,
					onSuccess: function (resp){
					    var obj = resp.responseText.evalJSON();
					    if (obj.errors.length == 0) {   
                            $("timeline_saved").show();
                            return;
                         }
                         handleErrors(obj.errors);
					}
				  }
			);
}

function onSaveTimeline(resp) {
    mediaDeselectAll();
    var obj = resp.responseText.evalJSON();

    if (obj.errors.length == 0) {
        document.location.href = "http://www.kronomy.com/create/"+obj.timelineAlias+"#add_share";
        return;
    }
    handleErrors(obj.errors);
}

function setTimelinePrevPic(id) {
    handleMessages();
    var url = 'http://www.kronomy.com/ajax/create/set_timeline_prev_pic.php';
	new Ajax.Request(url, {
					method: 'post',
                    parameters: {'id' : id},
                    onSuccess: onSetTimelinePrevPic
				  }
			);
}

function onSetTimelinePrevPic(resp) {
	var obj = resp.responseText.evalJSON();
	try { $('toppic_img').remove(); } catch (ex) {}
	var img = document.createElement("img");
    img.setAttribute("id", "toppic_img");
    img.setAttribute("class", "toppic");
    img.setAttribute("src", "_image/icons_buttons/toppic.gif");
    $('event_li_' + obj.event_id).appendChild(img);
}

function checkForDeleteSelectedSearchResult() {
	var ul = $('selected_media_items');
	if (ul.childElements().size() > 0) {
		$('search_web_error').show();
	}
}

function showEditMediaLB(media_id, event_id) {
    if (event_id == "default") {
        event_id = 0;
    }
    Lightbox.showBoxByAJAX('ajax/create/get_edit_media_lb.php?media_id='+media_id+'&event_id='+event_id,"newbox", "newbox");
}

function sendEditMedia(form_id) {
	var url = 'http://www.kronomy.com/ajax/create/edit_media.php';
    handleMessages();
	new Ajax.Request(url, {
					method: 'post',
					parameters: $(form_id).serialize(true),
					onSuccess: onEditMedia
				  }
			);
}

function onEditMedia(resp) {
	var obj = resp.responseText.evalJSON();
	if (obj.errors.length != 0) {
        handleErrors(obj.errors);
        return;
    }
    updateEvent(obj.rss);
	Lightbox.hideBox();	
	try {
   	var childs = $('pos_'+obj.content.media_id).childElements();
   	childs.each(function(n) {
   		if (n.className == "image_frame") {
            n.title = obj.content.title;
        }
  	});
	} catch (ex) {}
    
}

function moveToNewEvent(event_id) {
	Lightbox.hideBox();

	if (GLOBAL['timeline_detail'] == undefined) {
		return;
	}

	var template = new Template("<input type='hidden' name='target_event' value='new'/>");
	var params = {'tid' : event_id};
	new Insertion.Bottom('timeline_move_media', template.evaluate(params));

	var album = GLOBAL['timeline_detail'];
	album.each(function(pair){
		var template = new Template("<input type='hidden' name='media_pos_ids[]' value='#{id}'/>");
		var params = {'id' : pair.key};
		new Insertion.Bottom('timeline_move_media', template.evaluate(params));
	});
	GLOBAL['timeline_detail'] = undefined;
	handleMessages();
	var url = 'http://www.kronomy.com/ajax/create/move_media_to_event.php';
	new Ajax.Request(url, {
					method: 'post',
					parameters: $('timeline_move_media').serialize(true),
					onSuccess: onSendMoveMedia
				  }
			);
}

function setTags(title, tags) {
	var titlestring = $(title).value;
	var tagstring = $(tags).value;
	if (tagstring.length == 0) {
		tagstring = titlestring.split(" ");
		var taglist = "";
		for (i = 0; i < tagstring.length; i++) {
			if (tagstring[i].length > 3) {
				taglist = taglist + tagstring[i] + ", ";
			}
		}
		taglist = taglist.substring(0, taglist.length-2);
		$(tags).value = taglist;
	}
	return;
}
/* [END OF MODULE]  - Create *******************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Email - Cache
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: email_cache */
/* [END OF MODULE] Email - Cache ***************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Event - Media
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: event_media */
/* [END OF MODULE] Event - Media ***************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Language
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: language */
/* [END OF MODULE] Language ********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Country
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: country */
/* [END OF MODULE] Country *********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE]  - Explore
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/** history functions **/

function onHistoryExplore(data, paging, get_params)
{
	switch(data){
	    case 'latest':
			getExploreContent('latest', paging, get_params);
			break;
	    
		case 'featured':
			getExploreContent('featured', paging, get_params);
			break;
		case 'categories':
			getExploreContent('categories', paging, get_params);
			break;
		case 'categories_details':
			getExploreContent('categories_details', paging, get_params);
			break;
        case 'most_viewed':
            getExploreContent('most_viewed', paging, get_params);
            break;
        case 'most_embeded':
            getExploreContent('most_embeded', paging, get_params);
            break;
	}
}

/** history end **/

function getExploreContent(param, paging, get_params)
{
    var url = "";
    if (paging == "" || paging == undefined) {
        url = 'http://www.kronomy.com/ajax/explore/explore.php';
    } else {
        url = 'http://www.kronomy.com/ajax/explore/explore.php?page=' + paging;
    }

    if (get_params != "" || get_params != undefined) {
        url = url + get_params;
    }

	new Ajax.Request(url, {
							method: 'post',
							parameters: {'a' : param},
							onSuccess: onGetExploreContentSuccess
						  }
					);
}

function showTimeline(alias) {
	Lightbox.showBoxByAJAX('ajax/timeline/showtimeline.php?alias=' + alias ,650,600);
}

function onGetExploreContentSuccess(result) 
{
	var obj = result.responseText;
	$('prog_content_explore').innerHTML = obj;
	evalJs(result.responseText);
}
/* [END OF MODULE]  - Explore ******************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Search
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: timeline */
/** history functions **/

function onHistorySearch(data, paging, get_params)
{

	if (get_params == undefined) get_params = "";
	
	switch(data){
		
		case 'timeline':
			getSearchContent('timeline', paging);
			switchSearchTabs('search_tab_timeline');
			break;
		case 'user':
			getSearchContent('user', paging);
			switchSearchTabs('search_tab_user');
			break;
	}
}

/** history end **/

function switchSearchTabs(tab) {
	$('search_tab_user').hide();
	$('search_tab_timeline').hide();
	$(tab).show();
}

function getSearchContent(type, paging) {
	handleMessages();
	//var url = "search/#";
	var url = "http://www.kronomy.com/ajax/search/search.php/#";
	new Ajax.Request(url, {
					method: 'post',
					parameters: {'get' : 'content', 'type' : type, 'page' : paging},
					onSuccess: onGetSearchContent
				}
			);
}

function onGetSearchContent(resp) {
	var obj = resp.responseText.evalJSON();
	$('search_content').innerHTML = obj.content;
}
/* [END OF MODULE] Search **********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Comment
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: comment */
function sendNewComment(form_id) 
{
	$('comment_empty').hide();
	$('success_comment').hide();

	var url = 'http://www.kronomy.com/ajax/comment/sendComment.php';
	onSendForm(form_id);
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendNewCommentSuccess
						  }
					);
}

function onSendNewCommentSuccess(resp) {
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) 
	{	
		$('comment_empty').hide();			
		str = $('comment_insert_container').innerHTML;
		var template = new Template(str);
		new Insertion.After('comment_insert_point', template.evaluate(result_obj));		
		$('success_comment').show();
        var count = $('comment_count').innerHTML;
        count++;
        $('comment_count').innerHTML = count;
		
	} else {
		handleErrors(result_obj.errors);
	}
}

function deleteComment(comment_id){

	var url = 'http://www.kronomy.com/ajax/comment/deleteComment.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: {"comment_id":comment_id},
							onSuccess: onDeleteComment
						  }
					);
}

function onDeleteComment(resp){
	var result_obj = resp.responseText.evalJSON();
	if (result_obj.errors.length == 0) 
	{	
		handleMessages();
		$('success_comment_deleted').show();
		$('comment_'+result_obj.commentId).innerHTML = "";
		$('comment_'+result_obj.commentId).hide();
		count = $('comment_count').innerHTML;
		count--;
		$('comment_count').innerHTML = count;
		
	} else {
		handleErrors(result_obj.errors);
	}
}
/* [END OF MODULE] Comment *********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Backend
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

//** BACKEND JS **//

function emailOnFocus(e, filename)
{
    e.style.border = "2px solid #88ff88";
}

function emailOnBlur(e, filename, type)
{
    e.style.border = "2px solid #00ff00";

    GLOBAL["e"] = e;
    GLOBAL["filename"] = filename;
    // save
    var url = '../../php_bin/backend/update_email_template.php';

    var parameters = $(filename + "_form").serialize();
    parameters += "&type=" + type;
    parameters += "&filename=" + filename;

    new Ajax.Request(url, {
        method: 'post',
        parameters: parameters,
        onSuccess: onEmailOnBlurSuccess
    }
            );
}

function onEmailOnBlurSuccess(result)
{
    // ö
    var result_obj = result.responseText.evalJSON();

    // if no errors occurrend
    if (result_obj.errors.length == 0)
    {
        GLOBAL["e"].style.border = "2px solid #eeeeee";
        $(GLOBAL["filename"] + "_subject").innerHTML = result_obj.subject;
        $(GLOBAL["filename"] + "_body").innerHTML = result_obj.body;
        $(GLOBAL["filename"] + "_alt_body").innerHTML = result_obj.alt_body;
    }
    else {
        $(error_id).show();
    }
}

/* [END OF MODULE] Backend *********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Mylife
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

function loadMyLifeSection(data)
{
	if(data != null && (data.section == 'events' || data.section == 'profile' ||
	 	data.section == 'settings' || data.section == 'mylifein3d' 
	 	|| data.section == 'new_event' || data.section == 'interest' || data.section == 'similarity'
	 	|| data.section == 'account' || data.section == 'backgrounds' || data.section == 'interest' || data.section == 'webservice'
		|| data.section == 'pic_picasa') ) 
	{
		showMyLifeSection(data.section, data);
		
		$('events').removeClassName('aktiv');
		$('new_event').removeClassName('aktiv');
		$('profile').removeClassName('aktiv');
		$('settings').removeClassName('aktiv');
		$('webservice').removeClassName('aktiv');
		
		if(data.section == "interest" || data.section == "similarity")	$('profile').addClassName('aktiv');
		if(data.section == "account" || data.section == "backgrounds")	$('settings').addClassName('aktiv');
		
		$(data.section).addClassName('aktiv');
	}
	else
	
		$('events').addClassName('aktiv');
		showMyLifeSection('events', data);		
}

function showMyLifeSection(section, data)
{
	if(data == null) {
		data = new Object();
		data.section = section;
	}
		
	var url = 'php_bin/my_life/my_life.php?' + Object.toQueryString(data);
	new Ajax.Request(url, {
							method: 'post',
							evalJS: 'force',
							onSuccess: onMyLifeSectionLoaded
						  }
					);
					
	showAjaxContentLoading();
}

function onMyLifeSectionLoaded(result)
{
	hideAjaxContentLoading();
	
	$('userpage_ajax_content').innerHTML = result.responseText;	
	evalJs(result.responseText);
	prepareJsHistoryLinks($('userpage_ajax_content').getElementsByTagName("a"));	
}
/* [END OF MODULE] Mylife **********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Registration
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: registrations */
function sendRegistration(form_id)
{	
	$$('.error').each(Element.hide);
	$$('.success').each(Element.hide);
	
	var url = 'http://www.kronomy.com/ajax/registration/register.php';
	

	new Ajax.Request(url, {
							method: 'post',
							parameters: $(form_id).serialize(true),
							onSuccess: onSendRegistrationSuccess
						  }
					);
}

function onSendRegistrationSuccess(result)
{	
	var result_obj = result.responseText.evalJSON();
	
	// if no errors occurrend
	if(result_obj.errors.length == 0)
	{		
		Lightbox.hideBox();
		if (typeof result_obj.redirect_url !== undefined && result_obj.redirect_url !== "undefined"){
		    document.location.href = result_obj.redirect_url;
		    //tmp
		    document.location.reload()
		    
		}else{
		    document.location.href = "http://www.kronomy.com/";
		}
		
	}
	else
	{	
		handleErrors(result_obj.errors);		
	}
}

function resetPassword(formId){
    $$('.error').each(Element.hide);
	$$('.success').each(Element.hide);
	
	var url = 'http://www.kronomy.com/ajax/registration/reset_password.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: $(formId).serialize(true),
							onSuccess: onResetPassword
						  }
					);
}
function onResetPassword(resp){
    var result_obj = resp.responseText.evalJSON();
	
	// if no errors occurrend
	if(result_obj.errors.length == 0)
	{	
	    $('password_reset_success').show();	
	}
	else
	{	
		handleErrors(result_obj.errors);		
	}
}
function showRegistrationForm() 
{
	Lightbox.showBoxByAJAX('ajax/registration/registration_form.php',570,600); 
}
/* [END OF MODULE] Registration ****************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Timeline
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: timeline */
/** history functions **/

function onHistoryTimeline(data, paging, get_params)
{

    if (get_params == undefined) get_params = "";

    switch (data) {

        case 'comments':

            sendGetTimelineSwitchBoxLeft(data, paging);
            break;
        case 'details':
            sendGetTimelineSwitchBoxLeft(data, paging);
            break;
        case 'events':
            sendGetTimelineSwitchBoxLeft(data, paging);
            break;
        case 'user':
            sendGetTimelineSwitchBoxRight(data, paging);
            break;
        case 'related':
            sendGetTimelineSwitchBoxRight(data, paging);
            break;
        case 'share_friends':
            //toggleShareWithFriends();
            $('prog_add_and_share_container').show();
            $('prog_switch_box_left').hide();
            $('share_add').hide();
            $('share_share').show();
            $('share_share').scrollTo();
            break;
        case 'post_to':
            //toggleShareWithFriends();
            $('prog_add_and_share_container').show();
            $('prog_switch_box_left').hide();
            $('share_share').hide();
            $('share_add').show();
            postEmbedChangeTo(paging, true);
            $('share_add').scrollTo();
            break;

    }
}

/** history end **/

function sendGetTimelineSwitchBoxLeft(id, paging) {
    get = "";
    if (paging != undefined && paging != "") {
        get = "?page=" + paging;
    }
    url = 'http://www.kronomy.com/ajax/timeline/switch_left_box.php' + get;
    //$('loading').show();
    new Ajax.Request(url, {
        method: 'post',
        parameters: {'a' : id},
        onSuccess: onSendGetTimelineSwitchBoxLeftSuccess
    }
            );
}

function onSendGetTimelineSwitchBoxLeftSuccess(resp) {
    //$('loading').hide();

    $('prog_add_and_share_container').hide();

    var obj = resp.responseText;

    evalJs(obj);

    $('prog_switch_box_left').innerHTML = obj;
    $('prog_switch_box_left').show();
}

function sendGetTimelineSwitchBoxRight(id, paging) {
    get = "";
    if (paging != undefined && paging != "") {
        get = "?page=" + paging;
    }
    url = 'http://www.kronomy.com/ajax/timeline/switch_right_box.php' + get;
    //$('loading').show();
    new Ajax.Request(url, {
        method: 'post',
        parameters: {'a' : id},
        onSuccess: onSendGetTimelineSwitchBoxRightSuccess
    }
            );
}

function onSendGetTimelineSwitchBoxRightSuccess(resp) {
    //$('loading').hide();
    var obj = resp.responseText;
    $('prog_switch_box_right').innerHTML = obj;
}


/**********************/
/** add as favorite **/
/********************/

function addTimelineToFav(alias)
{
    $('success_add_as_fav').hide();
    $('error_add_as_fav').hide();

    get = "?alias=" + alias;
    url = 'http://www.kronomy.com/ajax/timeline/add_favorite.php' + get;
    new Ajax.Request(url, {
        method: 'post',
        onSuccess: onAddTimelineToFavSuccess
    }
            );
}

function onAddTimelineToFavSuccess(resp)
{
    var result_obj = resp.responseText.evalJSON();
    if (result_obj.errors.length == 0) {
        $('success_add_as_fav').show();
    } else {
        handleErrors(result_obj.errors);
    }
}

/** ADD AND SHARE **/

function showAddAndShare(id)
{
    $('share_single').hide();
    $('share_email').hide();
    $('share_sn').hide();

    $(id).show();
}

function toggleShareWithFriends()
{
    $('prog_add_and_share_container').toggle();
    $('prog_switch_box_left').toggle();


}

function changeDropdownEmail(value)
{
    if (value != '--') {
        $('email_inputs').show();
        $('dropdownEMail').selectedIndex = value;
    } else {
        $('email_inputs').show();
    }
}

function newABLogin(form_id)
{
    //$('email_import_button').hide();
    //$('email_import_loading').show();
    $('login_data_error').hide();
    $("prog_imported_contacts").hide();

    var url = 'http://www.kronomy.com/ajax/timeline/add_contact_import.php';
    new Ajax.Request(url, {
        method: 'post',
        parameters: $(form_id).serialize(true),
        onSuccess: ABLoginSuccess
    }
            );
}


function ABLoginSuccess(result)
{

    //$('email_import_button').show();
    //$('email_import_loading').hide();

    var result_obj = result.responseText.evalJSON();
    // if no errors occurrend
    if (result_obj.errors.length == 0)
    {
        $("prog_imported_contacts").show();
        $('prog_imported_contacts').innerHTML = result_obj.result;
        //$('import_select_all_csv').hide();
        //$('import_select_all_webmail').show();
        //$('import_submit_webmail').show();
        //$('import_submit_csv').hide();
        $('login_data_error').hide();
    }
    else
    {
        handleErrors(result_obj.errors);
    }
}

function ContactImportStart(form_id)
{
    //$('import_success').hide();
    var url = 'http://www.kronomy.com/ajax/timeline/add_contact_import_store.php';
    new Ajax.Request(url, {
        method: 'post',
        parameters: $(form_id).serialize(true),
        onSuccess: ContactImportSuccess
    }
            );
}
function ContactImportSuccess() {

    $('import_success').show();
}


/** SN IMPORTER **/
function changeDropdownEmail(value)
{
    try {
        $('newABImport').hide();
    } catch(e) {
    }

    if (value != '--') {
        $('email_inputs').show();
        $('dropdownEMail').selectedIndex = value;
    } else {
        $('email_inputs').show();
    }
}

function changeDropdownContacs(value) {
    handleMessages();
    try {
        $('facebook_connect').hide();
        $('ozi_fb_logged_in').hide();
        $('send_message').hide();
    } catch(e) {
    }
    try {
        childs = $("prov_com_list_img").childElements();
        childs.each(function(n) {
            n.className = n.className.gsub('active', '');
        });
        $("prov_com_list_" + value).className = 'active';
    } catch(e) {
    }

    $('sn_inputs').show();

    if (value != "--")$('dropdownContacts').selectedIndex = value;

    if (value == 1 || value == 4) {
        $('sn_email').hide();
        $('sn_username').show();
    }
    if (value == 0 || value == 3 || value == 5 || value == 6 || value == 7 || value == '--') {
        $('sn_email').show();
        $('sn_username').hide();
    }
    if (value == 4) {
        $('xing_notice').show();
    } else {
        $('xing_notice').hide();
    }
    //facebook
    if (value == 2) {
        $('sn_inputs').hide();
        $('facebook_connect').show();
        $('ozi_fb_logged_in').show();
    }

}

/** IMPORT VON NETWORKS **/
function ContactImportNetworks(form_id)
{
    //$('prog_imported_contacts').hide();


    $('user_password_wrong').hide();
    $('server_error').hide();
    $('unsupported_webmail').hide();
    $('success_import_sn').hide();


    $('sn_inputs').hide();
    $('contact_import_networks_loading').show();

    $('prog_imported_contacts_sn').innerHTML = "";
    var url = 'http://www.kronomy.com/ajax/timeline/add_contact_sn.php';
    new Ajax.Request(url, {
        method: 'post',
        parameters: $(form_id).serialize(true),
        onSuccess: ContactImportNetworksSuccess
    }
            );

}
function ContactImportNetworksSuccess(result)
{
    $('contact_import_networks_loading').hide();

    var result_obj = result.responseText.evalJSON();
    // if no errors occurrend
    if (result_obj.errors.length == 0)
    {

        $('user_password_wrong').hide();
        $('server_error').hide();
        $('unsupported_webmail').hide();

        //$('success_import_sn').show();

        $('prog_imported_contacts_sn').innerHTML = result_obj.result;
    }
    else
    {

        $('sn_inputs').show();
        handleErrors(result_obj.errors);
    }
}

function singleInviteSend(form_id)
{

    $('single_invite_success').hide();
    $('no_name').hide();
    $('no_email').hide();
    $('email_is_not_valid').hide();
    $('no_to_email').hide();

    var url = 'http://www.kronomy.com/ajax/timeline/single_invite.php';
    new Ajax.Request(url, {
        method: 'post',
        parameters: $(form_id).serialize(true),
        onSuccess: sendSingleInviteSendSuccess
    }
            );
}

function sendSingleInviteSendSuccess(result)
{
    var result_obj = result.responseText.evalJSON();

    // if no errors occurrend
    if (result_obj.errors.length == 0) {
        $('single_invite_success').show();
    }
    else {
        handleErrors(result_obj.errors);
    }

}

function ContactImportNetworksSendMessage(form_id)
{
    $('failed_to_send_message').hide();
    $('success_send_message_sn_importer').hide();

    //$('sn_message_button').hide();
    //$('sn_message_loading').show();

    var url = 'http://www.kronomy.com/ajax/timeline/add_contact_sn_send_message.php';
    new Ajax.Request(url, {
        method: 'post',
        parameters: $(form_id).serialize(true),
        onSuccess: ContactImportNetworksSendMessageSuccess
    }
            );

}
function ContactImportNetworksSendMessageSuccess(result)
{

    //$('sn_message_button').show();
    //$('sn_message_loading').hide();

    var result_obj = result.responseText.evalJSON();
    // if no errors occurrend
    if (result_obj.errors.length == 0)
    {
        $('failed_to_send_message').hide();
        $('success_send_message_sn_importer').show();
    }
    else
    {

        handleErrors(result_obj.errors);
    }
}

function toggleAddAndShare() {
    $('share_share').toggle();
    $('share_add').toggle();
}


/** ********************
 * post
 */


GLOBAL["widget"] = new Array();

var embedSizes = { "standard": [605,385], "mini": [320,200], "customize": [605,300],
    "blogger": [450,281], "facebook": [600,194], "friendster": [605,300],
    "myspace": [605,300], "typepad": [640,317], "xanga": [320,200] };

function showWidget(name) {
    childs = $('export.kronomy.to.targets').childElements();
    childs.each(function(n) {
        n.hide();
    });

    $("export.kronomy.to." + name + ".target").show();
    if (GLOBAL["widget"][name]) {
        GLOBAL["widget"][name].show();
    }

}

function hideWidget(name) {
    if (GLOBAL["widget"][name]) {
        GLOBAL["widget"][name].hide();
    }
    $("export.kronomy.to." + name + ".target").hide();
}

function postEmbedChangeTo(platform, dontTryOnHistoryTimeline) {
    
    if (typeof dontTryOnHistoryTimeline == 'undefined') {
	    try {
	        onHistoryTimeline('post_to');
	    } catch(e) {
	    }
    }

    id = "li_" + platform;

    childs = $('platform_list_navigation').childElements();
    childs.each(function(n) {
        n.className = n.className.gsub('_active', '');
        n.childElements().each(function(m) {
    		m.className = m.className.gsub('active', '');
    	});
    });
    // $(id).className = $(id).className + ' ' + $(id).className + '_active';

	childs = $(id).childElements().each( function(n) {
		n.className = (n.className + ' active').strip();
	});

    var width = embedSizes[platform][0];
    var height = embedSizes[platform][1];

    code = getEmbedCode({code: $('externalEmbed.template').innerHTML, width: width, height: height});
    $('externalEmbed.code').innerHTML = code;
    $('export.kronomy.to.myspace.code').value = code.gsub('"', '\"');
    $('embed_code_inputfield').value = code.strip();
    $('embed_code_width').value = width;
    $("embed_code_width").setAttribute("rel", width);
    $('embed_code_height').value = height;

    showWidget(platform);
}

/**
 * params:
 *     code
 *     width
 *     height
 */
function getEmbedCode(params) {
    if (typeof params.code == "undefined") return;
    if (typeof params.width == "undefined") params.width = '605';
    if (typeof params.height == "undefined") params.height = '385';

    //fixme
    params.code = params.code.gsub('&amp;', '&');
    pre = "<div style='width:" + params.width + "px' >";
    after = "</div>";

    params.code = new Template(params.code);
    params.code = params.code.evaluate({width:params.width, height: params.height});

    code = pre + params.code + after;

    //clear
    code = code.gsub(/\s\s+/m, '').strip();
    return code;
}

function updateEmbedHeight(width) {

    var anum = /(^\d+$)|(^\d+\.\d+$)/
    width = (anum.test(width)) ? width : $("embed_code_width").readAttribute('rel');
    width = (width < 300) ? 300 : width;

    var height = Math.round((width > 500) ? width / (605 / 385) : width / (320 / 200));
    $("embed_code_height").value = height;
    $("embed_code_width").value = width;
    $('embed_code_inputfield').value = getEmbedCode({code: $('externalEmbed.template').innerHTML, width: width, height: height});
}


/** ********************
 * rating
 */
ratingIndexTable = new Array(0.0, 1.0, 2.0, 3.0, 4.0, 5.0);
var voted = false;

function ratingHover(value) {
    if (voted) return;
    for (var i = 1; i <= 5; i ++) {
        $('rate_timeline' + "_" + i).src = "_image/icons_buttons/stern_" +
                                           ( value < ratingIndexTable[ i ] ? "inaktiv" : "aktiv" ) + ".png"
                ;
    }

}

function ratingUnHover() {
    if (voted) return;
    value = $('timelineRateValue').innerHTML;

    for (var i = 1; i <= 5; i ++) {
        $('rate_timeline' + "_" + i).src = "_image/icons_buttons/stern_" +
                                           ( value < ratingIndexTable[ i ] ? "inaktiv" : "aktiv" ) + ".png"
                ;
    }
}


function sendRating(timeline_id, rate) {
    if (voted) return;
    var url = 'http://www.kronomy.com/ajax/timeline/rating.php';
    new Ajax.Request(url, {
        method: 'post',
        parameters: {"timeline_id":timeline_id, "rate": rate},
        onSuccess: onSendRating
    }
            );
}

function onSendRating(resp) {
    var obj = resp.responseText.evalJSON();
    if (obj.errors.length != 0) {
        handleErrors(obj.errors);
        return;
    }
    newRate = obj.ratingSum / obj.ratingCount;
    for (var i = 1; i <= 5; i ++) {
        $('rate_timeline' + "_" + i).src = "_image/icons_buttons/stern_" +
                                           ( newRate < ratingIndexTable[ i ] ? "inaktiv" : "aktiv" ) + ".png"
                ;
    }

    $('timelineRateValue').innerHTML = newRate;
    $('timelineRatingCount').innerHTML = obj.ratingCount;
    $('success_rate_sent').show();
    voted = true;


}




/* [END OF MODULE] Timeline ********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Special
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: special */
/* [END OF MODULE] Special *********************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] User - Friends
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: user_friends */
function sendGetFriends(page) {	

	if (page == 0) {
		page = page + 1;
	}
	
	var url = 'http://www.kronomy.com/ajax/user_friends/getFriends.php';
	new Ajax.Request(url, {
							method: 'post',
							parameters: {'page' : page},
							onSuccess: onSendGetFriendsResponse
						  }
					);
}

function onSendGetFriendsResponse(result) {
	var obj = result.responseText.evalJSON();
	$('my_stuff_friends_content').innerHTML = obj.friends;
	myStuffShowStaticBox('my_stuff_friends');
}
/* [END OF MODULE] User - Friends **************************************/


/**
 * XAkasha - JavaScript Functions
 * [MODULE] Event
 * 
 * @version 0.1
 * @since ~rev. 200
 ************************************************************************/

/* JS-FUNCTIONS FOR: event */
/* [END OF MODULE] Event ***********************************************/


