// --------------------------
// activates different interface steps
function activateSteps(myStep)
{
	// elements by id
	myPart1 = document.getElementById("formcentercol");
	myPart2 = document.getElementById("fileupload");
	mySubmitButton1 = document.getElementById("submit1");
	mySubmitButton2 = document.getElementById("submit2");
	mytarget = document.getElementById("mytarget");
	mytargethidden = document.getElementById("mytargethidden");
	myteam = document.getElementById("myteam");
	myteamhidden = document.getElementById("myteamhidden");
	mycpemail = document.getElementById("mycpemail");
	mycpemailhidden = document.getElementById("mycpemailhidden");
	myname = document.getElementById("myname");
	mynamehidden = document.getElementById("mynamehidden");
	myemail = document.getElementById("myemail");
	myemailhidden = document.getElementById("myemailhidden");
	myphone = document.getElementById("myphone");
	myphonehidden = document.getElementById("myphonehidden");
	mycomment = document.getElementById("mycomment");
	mycommenthidden = document.getElementById("mycommenthidden");
	fileUpload1 = document.getElementById("fileUpload1");
	fileUpload2 = document.getElementById("fileUpload2");
	fileUpload3 = document.getElementById("fileUpload3");
	fileUpload4 = document.getElementById("fileUpload4");
	fileUpload5 = document.getElementById("fileUpload5");
	//
	if(myStep == '1'){
		setVisibility(myPart2, "false", 100);
	} else if(myStep == '2'){
		if(validateForm1() == true){
			setVisibility(myPart1, "true", 30);
			setVisibility(myPart2, "true", 100);
			mySubmitButton1.disabled = true;
			mytargethidden.value = mytarget.value;
			mytarget.disabled = true;
			myteamhidden.value = myteam.value;
			myteam.disabled = true;
			mynamehidden.value = myname.value;
			mycpemail.disabled = true;
			mycpemailhidden.value = mycpemail.value;
			myname.disabled = true;
			myemailhidden.value = myemail.value;
			myemail.disabled = true;
			myphonehidden.value = myphone.value;
			myphone.disabled = true;
			mycommenthidden.value = mycomment.value;
			mycomment.disabled = true;
			
			initFancyUpload();
		}
	} else if(myStep == '3'){
		setVisibility(myPart2, "true", 30);

		mySubmitButton2.disabled = true;
		//window.open('flush.php','detail','width=400, height=300, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')
		document.getElementById("dropoffForm").submit();
	} else if(myStep == '4'){
		setVisibility(myPart2, "true", 30);
	}
}
// --------------------------
// set element visible/non visible
function setVisibility(myElement, isVisible, myopacity)
{
	if(isVisible == "true"){
		myElement.style.display = "block";
		myElement.style.visibility = "visible";
		//myElement.style.opacity = myopacity/100;
	} else {
		myElement.style.display = "none";
	}
}
// --------------------------
//
function validateForm1()
{
	myRet = true;
	if( document.getElementById("mytarget").value == ""){
		document.getElementById("mytarget").style.backgroundColor = "#EA7A90";
		myRet = false;
	} else {
		document.getElementById("mytarget").style.backgroundColor = "";
	}
	if( document.getElementById("mycpemail").value != "" &&  echeckpresplit(document.getElementById("mycpemail").value) != true ){
		document.getElementById("mycpemail").style.backgroundColor = "#EA7A90";
		myRet = false;
	} else {
		document.getElementById("mycpemail").style.backgroundColor = "";
	}
	if( trim(document.getElementById("myname").value) == ""){
		document.getElementById("myname").style.backgroundColor = "#EA7A90";
		myRet = false;
	} else {
		document.getElementById("myname").style.backgroundColor = "";
	}
	if( document.getElementById("myemail").value == "" || echeck(document.getElementById("myemail").value) != true){
		document.getElementById("myemail").style.backgroundColor = "#EA7A90";
		myRet = false;
	} else {
		document.getElementById("myemail").style.backgroundColor = "";
	}
	if( trim(document.getElementById("myphone").value) == ""){
		document.getElementById("myphone").style.backgroundColor = "#EA7A90";
		myRet = false;
	} else {
		document.getElementById("myphone").style.backgroundColor = "";
	}
	if (document.getElementById("myteam").value == "0" && document.getElementById("myteam").disabled != "true") {
		document.getElementById("myteam").style.backgroundColor = "#EA7A90";
		myRet = false;
	} else {
		document.getElementById("myteam").style.backgroundColor = "";
	}
	return myRet;
}
// --------------------------
//
function activateNextUploder(myUlCount)
{
	myUlPart = document.getElementById("fileuploader" + myUlCount);
	setVisibility(myUlPart, "true");
	if(myUlCount >= 2){
		mySubmitButton2 = document.getElementById("submit2");
		mySubmitButton2.disabled = false;
	}
}
// --------------------------
//
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
// --------------------------
//
function compJumpMenu(targ,selObj,restore){
  eval(targ+".location='/?setcid="+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
// --------------------------
//
function callBack(myError)
{
	//alert(myError);
	if(myError != "true" && myError != "1"){
		activateSteps('4');
	} else {
		alert("Fatal Error, please try again!");
	}
}
// --------------------------
//
function iSave_init()
{
	var f = document.getElementById("dropoffForm");
	f.setAttribute("target", "uploaderframe", 0);
	f.setAttribute("action", "uploader.php", 0);
}
// --------------------------
//
function echeckpresplit(str){
	myMailAdd = str.split(",");
	for(i=0;i<myMailAdd.length;i++){
		if(echeck(trim(myMailAdd[i])) == false){
			return false;
		}
	}
	return true;
}
// --------------------------
//
function trim (zeichenkette) {
  // Erst f�hrende, dann Abschlie�ende Whitespaces entfernen
  // und das Ergebnis dieser Operationen zur�ckliefern
  return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
}
// --------------------------
//
function echeck(str){
    var at = "@"
    var dot = "."
    var lat = str.indexOf(at)
    var lstr = str.length
    var ldot = str.indexOf(dot)
    if (str.indexOf(at) == -1) {
        //alert("Invalid E-mail ID")
        return false
    }
    if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
        //alert("Invalid E-mail ID")
        return false
    }
    if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
        //alert("Invalid E-mail ID")
        return false
    }
    if (str.indexOf(at, (lat + 1)) != -1) {
        //alert("Invalid E-mail ID")
        return false
    }
    if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
        //alert("Invalid E-mail ID")
        return false
    }
    if (str.indexOf(dot, (lat + 2)) == -1) {
        //alert("Invalid E-mail ID")
        return false
    }
    if (str.indexOf(" ") != -1) {
        //alert("Invalid E-mail ID")
        return false
    }
    return true
}
// --------------------------
//
function reloadSite(){
	location.reload();
}
// --------------------------
//
function checkJS(){
	document.getElementById("jsHint").style.display = "none";
}





