﻿/* ==================================================
	MLS-Scripts Java-Scripts:	mls_scripts.js
	My Last Change:				03:25 25.06.2011
	www.mylastsorrow.ch			DIVERSE SCRIPTS
	Copyright by 					Stephan Schallenberger
	================================================== */


// Define Domain
function getDomain () {
	var domain = "mylastsorrow"+"&#46;&#99;&#104;";
	return domain;
}

// Hide e-mail Adress from Spammers
function getMail(identifier, subject) {
	var str1 = identifier;
	var str2 = "&#64;";
	var str3 = getDomain();
	var str4 = "?subject=" + subject + ""
	var str_mail = str1 + str2 + str3;
	// compose e-mail adress and write into html-file
	document.write("<a href=" + "mail" + "to:" + str1 + str2 + str3 + str4 + " title=" + "'send us an e-mail'" + ">" + str_mail + "</a>");
}



// -------------------------------------------------------------------------------------

// Fancy-Box: Auflistung mit Thumbnails
function setThumbnails(start, anz, groupName, fileName, imgTitle, imgWidth) {
	var content = '';
	// imgTitle = "click&nbsp;to&nbsp;zoom";
	
	if ( imgWidth === undefined ) {		// optionaler Parameter abfangen
		imgWidth = 80;	// (Default)
	}

   var grp = "<a rel="+ groupName;

	for (var i=start; i <= anz; ++i) {
	
		if (i < 10) i= "0" + i;		// Zweistellige Zahl mit vorangestellter Null
		
		content += grp + " href=img/galleries/" + groupName + "/" + fileName + i + "_b.jpg title=" + imgTitle + " ><img width="+ imgWidth + " alt=Image" + i + " src=img/galleries/" + groupName + "/" + fileName + i + "_s.jpg" + " /></a>";
		
		// content += grp + " href=img/galleries/" + groupName + "/" + fileName + i + "_b.jpg title=" + imgTitle + " ><img width='80' alt='' src=img/galleries/" + groupName + "/" + fileName + i + "_s.jpg" + " /></a>";
	}
	document.write(content);		// mit title pro Bild: imgTitle + "&nbsp;(" + i + ")" +
}




// -------------------------------------------------------------------------------------
// // $Id: kanima.js: Auflistung der Animierten Bilder
function setKanima (start, anz, dir) {
	var content = '';

	for (var i=start; i <= anz; ++i) {
		
		if (i < 10) i= "0" + i;		// Zweistellige Zahl mit vorangestellter Null
		
		content += "<img class='kanima' src=img/kanimapics/" + dir + "/" + i + ".jpg" + " alt='Image Anmiations'" + " />";
	}
	document.write(content);
}


// -------------------------------------------------------------------------------------
// $Id: kanima.js 4 2010-04-04 17:58:52Z itb $

/**
 * Mit dieser Variabel wird eingestellt
 * wie lange die einzelnen Grafik stehe bleiben soll
 * bevor eine neue Grafik eingeblendet wird.
 */
var standzeit = 1000;

/**
 * Mit dieser Variable kann man die Transparent Schritte
 * steuern. Der Wert gibt an um wie viel Prozent sich die
 * Transparenz des Bildes, bei jedem Durchlauf, ändern soll.
 */
var opaschritt = 0.8;

function blende1(blendenschritt){
    var bild = document.getElementById("kanima1").getElementsByTagName("img");
    
    blendenschritt = blendenschritt || 0;
    
    bild[bildnummer].style.opacity = blendenschritt / 100;
    bild[bildnummer].style.filter = "alpha(opacity=" + blendenschritt + ")"; // IE?
    blendenschritt = blendenschritt + opaschritt;
    
    if (blendenschritt <= 100) {
        window.setTimeout(function(){
            blende1(blendenschritt);
        }, 1);
    }
    else {
        if (bildnummer == 1) {
            window.setTimeout(kanima1, standzeit / 5);
        }
        else {
            window.setTimeout(kanima1, standzeit);
        }
    }
}

function kanima1(){
    var bild = document.getElementById("kanima1").getElementsByTagName("img");
    
    if (typeof(bildnummer) != "number") {
        bildnummer = 0;
    }
    
    bildnummer++;
    
    if (bildnummer < bild.length) {
        blende1();
    }
    
    if (bildnummer == bild.length) {
        bildnummer = 1;
        for (i = 1; i < bild.length; i++) {
            bild[i].style.opacity = 0;
            bild[i].style.filter = "alpha(opacity=0)"; // IE?
        }
        kanima1();
    }
};


// copy for id=2
function blende2(blendenschritt){
    var bild = document.getElementById("kanima2").getElementsByTagName("img");
    
    blendenschritt = blendenschritt || 0;
    
    bild[bildnummer].style.opacity = blendenschritt / 100;
    bild[bildnummer].style.filter = "alpha(opacity=" + blendenschritt + ")"; // IE?
    blendenschritt = blendenschritt + opaschritt;
    
    if (blendenschritt <= 100) {
        window.setTimeout(function(){
            blende2(blendenschritt);
        }, 1);
    }
    else {
        if (bildnummer == 1) {
            window.setTimeout(kanima2, standzeit / 5);
        }
        else {
            window.setTimeout(kanima2, standzeit);
        }
    }
}

function kanima2(){
    var bild = document.getElementById("kanima2").getElementsByTagName("img");
    
    if (typeof(bildnummer) != "number") {
        bildnummer = 0;
    }
    
    bildnummer++;
    
    if (bildnummer < bild.length) {
        blende2();
    }
    
    if (bildnummer == bild.length) {
        bildnummer = 1;
        for (i = 1; i < bild.length; i++) {
            bild[i].style.opacity = 0;
            bild[i].style.filter = "alpha(opacity=0)"; // IE?
        }
        kanima2();
    }
};



// -------------------------------------------------------------------------------------

// http://w3schools.com/js/js_form_validation.asp
function validateFormOrder() {

	var frmName = "frmOrder";

	// Numerisches Feld (Anzahl T-Shirt female)
	if (!("required" in document.createElement("input"))) {					// Required
		
		var input = document.forms[frmName]["num_shirt_men"].value;			// Anzahl
		if (input==null || input=="") {
			alert("Bitte Anzahl angeben!");
			document.getElementById("id_num_shirt_men").focus();
			return false;
		}
		// Numerisches Feld (Anzahl T-Shirt male)
		var input = document.forms[frmName]["num_shirt_girl"].value;		// Anzahl
		if (input==null || input=="") {
			alert("Bitte Anzahl angeben!");
			document.getElementById("id_num_shirt_girl").focus();
			return false;
		}
		// Numerisches Feld (Anzahl CD's)
		var input = document.forms[frmName]["num_cd"].value;					// Anzahl
		if (input==null || input=="") {
			alert("Bitte Anzahl angeben!");
			document.getElementById("id_num_cd").focus();
			return false;
		}
		
		// Adressangaben
		
		// Textfeld (Name)
		var input = document.forms[frmName]["f_lastname"].value;		// Name
		if (input==null || input=="") {
			alert("Bitte Name angeben!");
			document.getElementById("id_lastname").focus();
			return false;
		}
		// Textfeld (Vorname)
		var input = document.forms[frmName]["f_firstname"].value;	// Vorname
		if (input==null || input=="") {
			alert("Bitte Vorname angeben!");
			document.getElementById("id_firstname").focus();
			return false;
		}
		// Textfeld (Strasse)
		var input = document.forms[frmName]["f_strasse"].value;		// Strasse
		if (input==null || input=="") {
			alert("Bitte Strasse angeben!");
			document.getElementById("id_strasse").focus();
			return false;
		}
		// Textfeld (PLZ)
		var input = document.forms[frmName]["f_plz"].value;			// PLZ
		if (input==null || input=="") {
			alert("Bitte Postleitzahl angeben!");
			document.getElementById("id_plz").focus();
			return false;
		}
		// Textfeld (Ort)
		var input = document.forms[frmName]["f_ort"].value;			// Ort
		if (input==null || input=="") {
			alert("Bitte Ortschaft angeben!");
			document.getElementById("id_ort").focus();
			return false;
		}				
	}

	// E-Mail
	if (!("required" in document.createElement("input"))) {				// Required			
		var input = document.forms[frmName]["f_email"].value;				// E-Mail
		var atpos = input.indexOf("@");
		var dotpos = input.lastIndexOf(".");
		if (atpos<1 || dotpos<atpos+2 || dotpos+2>=input.length) {
		  alert("Keine valide E-Mail Adresse!");
		  document.getElementById("id_email").focus();
		  return false;
		}		
	}
}


// http://w3schools.com/js/js_form_validation.asp
function validateFormContact() {

	var frmName = "frmContact";
	
	// E-Mail
	if (!("required" in document.createElement("input"))) {				// Required			
		var input = document.forms[frmName]["f_email"].value;				// E-Mail
		var atpos = input.indexOf("@");
		var dotpos = input.lastIndexOf(".");
		if (atpos<1 || dotpos<atpos+2 || dotpos+2>=input.length) {
		  alert("Keine valide E-Mail Adresse!");
		  document.getElementById("id_email").focus();
		  return false;
		}		
	}
	// Textfeld (Message)
	if (!("required" in document.createElement("textarea"))) {			// Required
		var input = document.forms[frmName]["f_message"].value;			// Nachricht in Textfeld
		if (input==null || input=="") {
			alert("Bitte erfasse deine Mitteilung!");
			document.getElementById("id_message").focus();
			return false;
		}
	}

}




