function updateBandMemberPhotoPreview (photo_id, member_no) {
  var post = {
    'photo_id':	photo_id
  }

  queryString = $H(post).toQueryString();

	new Ajax.Updater(
		{ success: 'bandMemberPhotoPreview' + member_no },
		'/profile/updateBandMemberPhotoPreview',
		{
			method: 		'post',
			parameters:	queryString
		}
	);
}

function highlightProfileTab(tabid)
{
  var tabs = $$('.show');
  
  for(var i = 0; i < tabs.length; i++)
  {
    if(tabs[i].hasClassName('current'))
    {
      tabs[i].removeClassName('current');
      //tabs[i].addClassName('btn_black8');
    }
  }
  
  //$(tabid).removeClassName('btn_black8');
  $(tabid).addClassName('current');
}



function addGenreSelection(skipSubgenres)
{
  var genre = $('genre').value;
  //var subgenres = document.getElementsByName('music_subgenre[]');
  var subgenres = $$('input[name="music_subgenre[]"]');

  var selectedSubgenres = new Array();
  
  if(skipSubgenres == false)
  {
    for(var i = 0; i < subgenres.length; i++)
    {
      if(subgenres[i].checked == true)
      {
        selectedSubgenres.push(subgenres[i].value);
      }
    }
  }

  var post = {
    'genre':       genre,
    'subgenres[]': selectedSubgenres
  }

  queryString = $H(post).toQueryString();

  new Ajax.Updater(
    { success: 'selected_music' },
    '/profile/addGenreSelection',
    {
      method: 'post',
      parameters: queryString
  });
}

function checkform(form, type) {
	var msg = "";

  if (type == 'Artist') {
    if ($("data_Birthdate_day") && $F("data_Birthdate_day") == "" && $("data_Birthdate_month") && $F("data_Birthdate_month") == "" && $("data_Birthdate_year") && $F("data_Birthdate_year") == "") msg += "Bitte gib deinen Geburtstag an\n";
    if ($("selectedGenresCount") && $F("selectedGenresCount") == 0) msg += "Bitte gib Dein Musikgenre an\n";
  }
  if (type == 'Band') {
    // Besetzung (1-20...keine Ausweichmöglichkeit)
    if ($("selectedGenresCount") && $F("selectedGenresCount") == 0) msg += "Bitte gebt euer Musikgenre an\n";
  }
  if (type == 'Club') {
    if ($("data_Category") && $F("data_Category") == 0) msg += "Bitte gib Deine Kategorie an\n";
    if ($("selectedGenresCount") && $F("selectedGenresCount") == 0) msg += "Bitte mache Angaben beim Musikgenre\n";
  }
  if (type == 'Company') {
  	if (selectedTab == 'aboutMe') {
    	var company_cat = "";
      	if ($F("data_CategoryTv") != null)               company_cat += $F("data_CategoryTv");
	      if ($F("data_CategoryRadio") != null)            company_cat += $F("data_CategoryRadio");
	      if ($F("data_CategoryMagazine") != null)         company_cat += $F("data_CategoryMagazine");
	      if ($F("data_CategoryPublishingHouse") != null)  company_cat += $F("data_CategoryPublishingHouse");
	      if ($F("data_CategoryMusicLabelMajor") != null)  company_cat += $F("data_CategoryMusicLabelMajor");
	      if ($F("data_CategoryMusicLabelIndie") != null)  company_cat += $F("data_CategoryMusicLabelIndie");
	      if ($F("data_CategoryDjPool") != null)           company_cat += $F("data_CategoryDjPool");
	      if ($F("data_CategoryManagement") != null)       company_cat += $F("data_CategoryManagement");
	      if ($F("data_CategoryConcertAgency") != null)    company_cat += $F("data_CategoryConcertAgency");
	      if ($F("data_CategoryEventAgency") != null)      company_cat += $F("data_CategoryEventAgency");
	      if ($F("data_CategoryRecordingStudio") != null)  company_cat += $F("data_CategoryRecordingStudio");
	      if ($F("data_CategoryVideoProduction") != null)  company_cat += $F("data_CategoryVideoProduction");
	      if ($F("data_CategoryOther") != "")              company_cat += $F("data_CategoryOther");
    	if (company_cat == "") msg += "Bitte gib mindestens eine Kategorie an\n";
    	if ($("selectedGenresCount") && $F("selectedGenresCount") == 0) msg += "Bitte mache Angaben beim Musikgenre\n";
  	}
  }
  if (type == 'Dancer') {
    if ($("data_Birthdate_day") && $F("data_Birthdate_day") == "" && $("data_Birthdate_month") && $F("data_Birthdate_month") == "" && $("data_Birthdate_year") && $F("data_Birthdate_year") == "") msg += "Bitte gib deinen Geburtstag an\n";
    if ($("selectedGenresCount") && $F("selectedGenresCount") == 0) msg += "Bitte gib Dein Musikgenre an\n";
  }
  if (type == 'Dj') {
    if ($("data_Birthdate_day") && $F("data_Birthdate_day") == "" && $("data_Birthdate_month") && $F("data_Birthdate_month") == "" && $("data_Birthdate_year") && $F("data_Birthdate_year") == "") msg += "Bitte gib deinen Geburtstag an\n";
    if ($("selectedGenresCount") && $F("selectedGenresCount") == 0) msg += "Bitte gib Dein Musikgenre an\n";
  }
  if (type == 'Member') {
    if ($("data_Birthdate_day") && $F("data_Birthdate_day") == "" && $("data_Birthdate_month") && $F("data_Birthdate_month") == "" && $("data_Birthdate_year") && $F("data_Birthdate_year") == "") msg += "Bitte gib deinen Geburtstag an\n";
    if ($("selectedGenresCount") && $F("selectedGenresCount") == 0) msg += "Bitte gib Deinen Musikgeschmack an\n";
  }
  if (type == 'Model') {
    if ($("data_Birthdate_day") && $F("data_Birthdate_day") == "" && $("data_Birthdate_month") && $F("data_Birthdate_month") == "" && $("data_Birthdate_year") && $F("data_Birthdate_year") == "") msg += "Bitte gib deinen Geburtstag an\n";
    if ($("selectedGenresCount") && $F("selectedGenresCount") == 0) msg += "Bitte gib Deinen Musikgeschmack an\n";
  }

  if ($("address_Country") && $F("address_Country") == "") msg += "Bitte gib Dein Land an\n";

  if (msg != "") {
  	alert(msg);
  }
  else {
    new Ajax.Updater("profiledata", "/profile/save",
    {
      asynchronous:true,
      evalScripts:false,
      onComplete:function(request, json)
      {
        Element.hide("loader");
        Element.show("profiledata");
      },
      onLoading:function(request, json)
      {
        Element.show("loader");
        Element.hide("profiledata");
      },
      onSuccess:function(request, json)
      {
        alert("Profil wurde gespeichert!");
        edited=false;
        Element.show("editbutton");
      },
      parameters:Form.serialize(form)
    });
    
  }
  return false;
}


