// Matrix-Navi
function toggleNavi (id) {
	
    /*$('v1').hide; 
	$('v1').show; */
	Effect.toggle(id,'blind',{duration:0.6});
	if($('flashcontent')){
		toggleFlashPlayer(id);
	}
}

function openNavi (id) {
	Effect.BlindDown(id,{duration:0.6});
}

var active = false;

function closeNavi (id) {

	Effect.BlindUp(id,{duration:0.6});
	/* $('v1').toggleClassName(id.'_hide'); */
	/*$('v1').removeClassName('video_' + id + '_hide'); */
	if($('flashcontent')){
		$('flashcontent').removeClassName('video_' + id + '_hide');
	}

}

function toggleNaviNode (elemID, targetID, lineID, navi, mode) {

	var makeNum = /\d+/;
	var parentID = makeNum.exec(lineID);
  // get childnodes
    ajaxGetNaviNode(parentID, targetID, navi, mode);
  
	Effect.toggle(targetID,'blind',{duration:0.6});
  var siblings = $(lineID).siblings();

	if ( $(elemID).hasClassName('opened') ) {
		$(elemID).removeClassName('opened');
		$(elemID).addClassName('closed');
    siblings.each(function(sibling,at) {
      if (sibling.hasClassName('line')) {
        Effect.toggle(sibling,'blind',{duration:0.6});
      }
      // sibling.show();
    });
	} else {	
		$(elemID).removeClassName('closed');
		$(elemID).addClassName('opened');
    siblings.each(function(sibling,at) {
      if (sibling.hasClassName('line')) {
        Effect.toggle(sibling,'blind',{duration:0.6});
      }
      // sibling.hide();
    });
	}
}

function ajaxGetNaviNode(parentID, targetID, navi, path) {
  if ( ! parentID ) parentID=1;
  if ( ! path ) path = ''; //path has a different meaning if undefined
  
  url = '/navi/ajax_matrix/'+ navi + '/' + parentID + '/' + path; 
   
  new Ajax.Updater({ success: targetID }, url, { method: 'get'} );
}


// ask on delete button
function confirmDelete()
{
    conf  = confirm('Möchten Sie diesen Datensatz wirklich löschen?');
    if(!conf)
        return false;
}

function toggleFlashPlayer (id) {


	/*
	$('v1').toggle(); 
	*/
	/* $('v1').addClassName('video_' + id + '_hide'); */
	$('flashcontent').toggleClassName('video_' + id + '_hide');

	/*
	if($(id).getWidth() > 0){
		$(id).style.width = '0px';
	}else{
		$(id).style.width = '410px';
	}*/
	/*alert($('v1').getWidth()); */
	
	Effect.toggle(id,'blind',{duration:0.6});
}

function openFlashPlayer (id) {	
	$(id).style.width = '410px';
}

function closeFlashPlayer (id) {

	/*alert($('v1').getWidth());*/
	/*$(id).style.width = '0px';*/
}

/*  this is used in only for the tags enviroment - maybe we should clean this out for global use */
function load_tags_proposal (sport_id) {
    new Ajax.Updater('tags_proposal', '/content/ajax_tags_proposal/' + sport_id);
  }
   
function add_tag(tagname){
    $("tags").value
      = $A([$("tags").value.split(/\s*,\s*/), tagname]).flatten().without('').uniq().join(', ');
  }

function t_filter_ajax(filter){
    conf.set(['t_filter'], filter);
    new Ajax.Updater('t_filter_ajax', '/content/t_filter_ajax/'+ort_id+"/"+sport_id+'?'+conf.toQueryString());
}

function t_filter_ajax(filter,eventaltneu){
    conf.set(['t_filter'], filter);
    conf.set(['eventaltneu'],eventaltneu);
    new Ajax.Updater('t_filter_ajax', '/content/t_filter_ajax/'+ort_id+"/"+sport_id+'?'+conf.toQueryString());
}

function ajaxChooseNaviItem_region (id,linkname) {
    document.location.href = "/home/"+id+"_"+linkname+"/"+sport_id+"_"+sport_linkname
}

function ajaxChooseNaviItem_sport (id,linkname) {
    document.location.href = "/home/"+ort_id+"_"+ort_linkname+"/"+id+"_"+linkname
}

function whole_list(navi) {
    document.location.href = "/list/"+navi+'/'+ort_id+"/"+sport_id
}
 
