﻿//################################ Box : Lieblingskünstler Check ######################-->

function Speichern(selObj)
{
    var formChanged = false;
    var formLoeschChanged = false;
    var ignoreChange = false;
    var formSubmitted = false;

	var EM   = document.RegistrationData.kundenemail.value.substr(0,3).toLowerCase()+document.RegistrationData.kundenemail.value.substr(4,4).toLowerCase();
	//var EML  = document.RegistrationData.kundenemail2.value.substr(0,3).toLowerCase()+document.RegistrationData.kundenemail2.value.substr(4,4).toLowerCase();
    
    if ((EM == "ungltig"))
    {
			alert('Ihre eMail-Adresse war leider fehlerhaft.\nBitte geben Sie diese nochmal ein. ');
	        history.go(0);
			return false;
	}
     
	
	

    for(var x = 0; x < selObj.options.length; x++)
    {
        selObj.options[x].selected = true;
	}
}
 
function submitRegistrationData()
{
	var customerlistBox = document.RegistrationData.customerlistBox;
	var musicFiles = document.RegistrationData.Kuenstlerlist;
	var customerlistFiles = document.RegistrationData.customerlist;
	var done = false;


	if (Speichern)
	{
		while (!done)
		{
			done = true;
			break;
		}
	}

	for (var i = 0; i < customerlistFiles.options.length; i++)
		customerlistFiles.options[i].selected = true;

	formLoeschChanged = false;

	return true;

} // end submitRegistrationData

function setLoeschBit()
{
	formLoeschChanged = true;
}

function setDirtyBit()
{
	// formChanged = true;
}

function deleteKuenstlerlist()
{
	var customerlistFiles = document.RegistrationData.customerlist;
	var checkboxnl = document.RegistrationData.newsletter1;
	var i = 2;
	var endcount = customerlistFiles.options.length;
	while(i < endcount )
	{
	    if (i < customerlistFiles.options.length)
		{
			if (customerlistFiles.options[i].selected == true)
			{
				customerlistFiles.options[i] = null;
				setDirtyBit();
				setLoeschBit();
				i--;
			}
		}
		i++;

	}// end while
	if (customerlistFiles.options.length==2)
	{
		checkboxnl.checked=false;}
	}

function setWordList()
{
	var i;
	var j;
	var duplicate;
	var musicFiles = document.RegistrationData.Kuenstlerlist;
	var customerlist = document.RegistrationData.customerlist;
	var checkboxnl = document.RegistrationData.newsletter1;
	var additions = new Array();
	var insertionPoint = 2;
	var numAdditions = 0;
	var dupsOK = 0; // 0 - no; 1 - prompt; 2 - yes

	for (i = 0; i < musicFiles.options.length; i++)
	{
		if (musicFiles.options[i].selected == true)
		{
			duplicate = false;
			if (dupsOK != 2)
			{
				for (j = 2; j < customerlist.options.length; j++)
				{
					if (customerlist.options[j].selected)
					{
						insertionPoint = j + 1;
						customerlist.options[j].selected = false;
					}
					if (customerlist.options[j].text == musicFiles.options[i].text)
					{
						if (dupsOK == 0 || (dupsOK == 1 && !confirm('Der Künstler "' + musicFiles.options[i].text + '" existiert bereits in Ihrer Liste.\nWollen Sie weitere Künstler auswählen?')))
						{
							duplicate = true;
							break;
						}
    				}
				}
			}
			if (!duplicate)
			{
				additions[numAdditions] = i;
				numAdditions++;
			}

			musicFiles.options[i].selected = false;
	  	}
    }

	if (numAdditions <= 0)
		return false;

	for (i = 0; i < numAdditions; i++)
		customerlist.options[customerlist.options.length] = new Option("", "", false, false);

	for (i = customerlist.options.length - numAdditions - 1; i >= insertionPoint; i--)
	{
		customerlist.options[i + numAdditions].text  = customerlist.options[i].text;
		customerlist.options[i + numAdditions].value = customerlist.options[i].value;
		customerlist.options[i + numAdditions].defaultSelected = customerlist.options[i].defaultSelected;
		customerlist.options[i + numAdditions].selected = false;
	}

	for (i = 0; i < numAdditions; i++)
	{
		customerlist.options[insertionPoint + i].text  = musicFiles.options[additions[i]].text;
		customerlist.options[insertionPoint + i].value = musicFiles.options[additions[i]].value;
		customerlist.options[insertionPoint + i].defaultSelected = false;
		customerlist.options[insertionPoint + i].selected = true;
	}

	customerlist.options[0].selected = false;
	customerlist.options[1].selected = false;

	setDirtyBit();
	
	checkboxnl.checked = true;

	return true;

         
}

function alarmbox()
{
	var customerlistFiles = document.RegistrationData.customerlist;
	var checkboxnl = document.RegistrationData.newsletter1;	
	
	
	if (customerlistFiles.options.length >= 3)
 
	{
		checkboxnl.checked = true;
		
	}
	
}

	

// end setWordList

//################################ Box : Lieblingskünstler Check ######################-->
