  function openme(url) {
    window.open(url, '', 'width=600,height=600,scrollbars=no,resizable=no,status=no,toolbar=no,menubar=no');
    return;
  }

  function openme_scroll(url) {
    window.open(url, '', 'width=600,height=700,scrollbars=yes,resizable=no,status=no,toolbar=no,menubar=no');
    return;
  }

  var popup_win;

  function openme_small(url) {
    if (popup_win !== undefined) {
      popup_win.close();
    }
    popup_win = window.open(url, 'tuneclub_popup', 'width=135,height=220,scrollbars=no,resizable=no,status=no,toolbar=no,menubar=no');
    return;
  }

function openme_scroll_ani(url) {
  window.open(url, '', 'width=400,height=500,scrollbars=yes,resizable=no,status=no,toolbar=no,menubar=no');
  return;
}

function not_active() {
  alert("Diese Funktion wird in K�rze freigeschaltet.");
}

function check_pw2(pw1, pw2) {
  if (pw1!='' && pw2!=pw1) {
	 alert("Bitte zwei gleiche Passw�rter eingeben!");
	 return false;
  }

  if (pw1!='' && pw1.length<3) {
	 alert("Bitte mindestens drei Zeichen eingeben!");
	 return false;
  }
  return true;
}

function check_exist_pw(pw1, pw2) {
  if (pw2!=pw1) {
    alert("Bitte zwei gleiche Passw�rter eingeben!");
    return false;
  }

  if (pw1.length<3) {
    alert("Bitte mindestens drei Zeichen eingeben!");
    return false;
  }
  return true;
}

function update_vorwahl(select_obj, input_obj) {
  input_obj.value = select_obj.options[select_obj.selectedIndex].value;
  return true;
}

function check_pw(input_obj) {

  var x=input_obj.value;
  var return_value=true;

  var re_digit = /^[0-9]{6}$/;

  if (!re_digit.test(x)) {
    alert("Bitte gib als Passwort eine sechstellige Zahl an!");
    input_obj.focus();
    return false;
  }
  return true;
}


function set_checked(form_obj, name, checkbox_obj) {
  if (!checkbox_obj.checked)
    return;

  eval("var re = /"+name+"/;");
  for (i=0; i<form_obj.elements.length; i++) {
    if (re.test(form_obj.elements[i].name))
      form_obj.elements[i].checked=true;
  }
}

function check_max(form_obj, name) {
  var cnt=0;
  eval("var re = /"+name+"/;");
  for (i=0; i<form_obj.elements.length; i++) {
    if (re.test(form_obj.elements[i].name) && form_obj.elements[i].checked)
      cnt++;
  }

  if (cnt>10)
    alert("Bitte nur maximal 10 Themen ausw�hlen!");
}


function update_char_left(obj) {
  //  myspan=document.getElementsByName("charleft");
  //  myspan.item(0).data="10";
  var len = 144 - obj.value.length;
  if (len < 0) {
    len=0;
  }
  document.getElementById('charleft').innerHTML= len;
}

function button_toggle(obj_name, add_css, remove_css){
  $(obj_name).addClassName(add_css)
  $(obj_name).removeClassName(remove_css)
}

function reset_layout_tab(){
    $$('div.reiter a').each(function(item) {
        item.removeClassName('reiter_select')
    });
    $$('div.reiter a')[6].addClassName('reiter_select')
}

function MM_Form_Validator(text){
    if(!checkBoxesSelected()) {
       alert(text);
       return false;
    }
    return true;
}

function checkBoxesSelected() {
     var oTracks          = document.getElementsById('trackid');
     var bNoTrackSelected = true;
     for(var i=0; i<oTracks.length; i++) {
         if(oTracks[i].checked)
             bNoTrackSelected = false;
     }
     if(bNoTrackSelected) {
        return false;
     }
     return true;
}

var checkflag = "false";
function check(field, on, off) {
    if (checkflag == "false") {
      for (i = 0; i < field.length; i++) {
      field[i].checked = true;}
      checkflag = "true";
      return off; //off text -> remove
    }
    else {
      for (i = 0; i < field.length; i++) {
      field[i].checked = false;}
      checkflag = "false";
      return on; // on text -> get
    }
}

function music_redirect() {
    //setTimeout("download_now('/music/download')",50);
    //show_facebook_permission_dialog({closeable:true,modal:true});
    show_tunestar_dialog({closeable:true,modal:true});
}

function music_facebook() {
    //setTimeout("download_now('/music/download')",50);
    //show_facebook_permission_dialog({closeable:true,modal:true});
    //show_tunestar_dialog({closeable:true,modal:true});
    jQuery.facebox({ajax: '/iframe/fb_anmeldung'});
}

function connect_facebook_login(name, description) {
    var attachment = {'name': name ,'href':'http://tunestar.de/music/index?fb_callback=1','description': description ,'media':[{'type':'image','src':'http://media.tunestar.de/themes/musicbox/images_tc/logo_new.png','href':'http://tunestar.de/music/index?fb_callback=1'}]};
    var publish = FB.Connect.ifUserConnected(FB.Connect.streamPublish('', attachment, null, null,'', null, true, ''));
    if (publish == false) {
        FB.Connect.ifUserConnected(FB.Connect.streamPublish('', attachment, null,'',''));
    }
}

function playlist_facebook(cover,name,description) {
    var action_link = [{'text':'TuneStar Fanpage','href':'http://www.facebook.com/tunestars'}];
    var attachment = {'name': name ,'href':'http://tunestar.de/music/index?fb_callback=1','description': description ,'media':[{'type':'image','src':''+cover+'','href':'http://tunestar.de/music/index?fb_callback=1'}]};
    var publish = FB.Connect.ifUserConnected(FB.Connect.streamPublish('', attachment, action_link, null,'', null, true, ''));
    if (publish == false) {
        FB.Connect.ifUserConnected(FB.Connect.streamPublish('', attachment, action_link,'',''));
    }
}

function order_facebook(name,description) {
    var action_link = [{'text':'TuneStar Fanpage','href':'http://www.facebook.com/tunestars'}];
    var attachment = {'name': name ,'href':'http://tunestar.de/music/index?fb_callback=1','description': description};
    var publish = FB.Connect.ifUserConnected(FB.Connect.streamPublish('', attachment, action_link, null,'', null, true, ''));
}

function music_redirect_without() {
    //setTimeout("download_now('/music/download')",50);
}

function download_now(url) {
    window.location.href = url;
}

function show_facebook_permission_dialog(options) {
    options = $j.extend({title: "Anmeldung"}, options || {});
    Boxy.load('/iframe/fb_anmeldung',options);
    return false;
}

function show_tunestar_dialog(options) {
    options = $j.extend({title: "Das NEUE TuneStar"}, options || {});
    Boxy.load('/iframe/tunestar',options);
    return false;
}

function show_facebook() {
      FB.Connect.showPermissionDialog("publish_stream");
}

document.observe("dom:loaded", function() {
  // the element in which we will observe all clicks and capture
  // ones originating from pagination links
  var container = $(document.body)

  if (container) {
    var img = new Image
    img.src = '/themes/musicbox/images/spinner.gif'

    function createSpinner() {
      return new Element('img', {src: img.src, 'class': 'spinner'})
    }

    container.observe('click', function(e) {
      var el = e.element()
      if (el.match('.paginationajax .pagination a')) {
        el.up('.paginationajax').insert(createSpinner())
        document.getElementById("pagination_ajax").hide();
        new Ajax.Request(el.href, {method: 'get'})
        e.stop()
      }
      if (el.match('.paginationajax_2 .pagination a')) {
        el.up('.paginationajax_2').insert(createSpinner())
        document.getElementById("pagination_ajax_2").hide();
        new Ajax.Request(el.href, {method: 'get'})
        e.stop()
      }
    })
  }
})

/*
*  function will check if form fields current
 */

//var $j = jQuery.noConflict();
var allDialogs = [];
var seq = 0;
function form_validator_mytunestars(){
    var title   = $j('#album_title').val();

    var wordcharacter = /^[\w\d\s\&\`\'öäüß]*$/m;

    if (!wordcharacter.test(title)) {

        Boxy.alert('<div style="width:450px"><h2>Sonderzeichen sind nicht erlaubt !!!</h2> <br />(Sonderzeichen wie z.b: !"§$%/\(){}[]?*# sind nicht erlaubt)</div>',null,{title: 'Message'});
        return false;
    }
    if (!title) {
        Boxy.alert('<div style="width:450px;"><h2>Bitte einen <b>Title</b> eingeben</h2> </div>',null,{title: 'Message'});
        return false;
    }
    return true;
}

function create_album_cover_choise(options,boxytitle) {
    options = $j.extend({title: boxytitle + " ..."}, options || {});
    //var dialog = new Boxy('<div width="800px"><iframe src="/iframe/album_cover" width="780px" height="600px" name="box" marginheight="0" marginwidth="0" frameborder="0"><p>No frames allowed!</p></iframe></div>', options);
    //allDialogs.push(dialog);
    Boxy.load('/iframe/album_cover', options);
    return false;
  }

function album_choise(options,track_id,titlename,artist,boxytitle, spinner){
    options = $j.extend({title: boxytitle + " ..."}, options || {});
    if(!spinner){
        new_spinner = ''
    }
    else{
        new_spinner = '&spinner='+spinner
    }
    //var dialog = new Boxy('<div width="800px"><iframe src="/iframe/album_cover" width="780px" height="600px" name="box" marginheight="0" marginwidth="0" frameborder="0"><p>No frames allowed!</p></iframe></div>', options);
    //allDialogs.push(dialog);
    Boxy.load('/iframe/album_choise?id='+track_id+'&title='+titlename+'&artist='+artist+new_spinner, options);
    return false;
}
/*
 * get_useralbum
 *
 * parameter
 *  boxy options
 *  album_id
 *  boxytitle
 *  spinner
 *
*/
function get_useralbum(options,album_id,boxytitle, spinner){
    options = $j.extend({title: boxytitle + " ..."}, options || {});
    if(!spinner){
        new_spinner = ''
    }
    else{
        new_spinner = '&spinner='+spinner
    }
    //var dialog = new Boxy('<div width="800px"><iframe src="/iframe/album_cover" width="780px" height="600px" name="box" marginheight="0" marginwidth="0" frameborder="0"><p>No frames allowed!</p></iframe></div>', options);
    //allDialogs.push(dialog);
    Boxy.load('/mytunestars/'+album_id +  '?layout=true' + new_spinner, options);
    return false;
}

function get_mm_album(options,album_id,artistname,albumname,boxytitle, spinner){
    options = $j.extend({title: boxytitle + " ..."}, options || {});
    if(!spinner){
        new_spinner = ''
    }
    else{
        new_spinner = '&spinner='+spinner
    }
    //var dialog = new Boxy('<div width="800px"><iframe src="/iframe/album_cover" width="780px" height="600px" name="box" marginheight="0" marginwidth="0" frameborder="0"><p>No frames allowed!</p></iframe></div>', options);
    //allDialogs.push(dialog);
    Boxy.load('/music/alben_tracks?albumid='+album_id + '&artist_name='+artistname+'&album_name='+albumname +  '&layout=true' + new_spinner, options);
    return false;
}

function get_album_cover(path,name,boxyobject){
    $j('#titlecover').attr('src', path + name);
    $j('#covername').val(name);
    $j('#indicator').hide()
    Boxy.get(boxyobject).hide();
     return false;
}

function create_a_newsbox(options,news_id) {
  options = $j.extend({title: "News und Infos"}, options || {});
  Boxy.load('/iframe/news?news_id='+news_id,options);
  return false;
}

function create_a_activation_box(options) {
  options = $j.extend({title: "Account Aktivierung"}, options || {});
  Boxy.load('/iframe/activation',options);
  return false;
}

function create_a_albuminfo_box(options,artistname,albumname,albumid) {
  options = $j.extend({title: "Info"}, options || {});
  Boxy.load('/iframe/album?artist_name='+artistname+'&album_name='+albumname+'&album_id='+albumid,options);
  return false;
}


function tabSwitch_2(active, number, tab_prefix, content_prefix, content_active ) {

  if (!content_active){
      content_active = active
  }

  for (var i=1; i < number+1; i++) {
    document.getElementById(content_prefix+i).style.display = 'none';
    if(document.getElementById(tab_prefix+i)){
        document.getElementById(tab_prefix+i).className = '';
    }
  }
  document.getElementById(content_prefix+content_active).style.display = 'block';
  document.getElementById(tab_prefix+active).className = 'active';

}

function boxy_close(obj_name){
    Boxy.linkedTo($j('#' + obj_name)[0]).hide();
    Boxy.linkedTo($j('#' + obj_name)[0]).unload();
}


