// JavaScript Document
function st_mail(name,domain, tld, outName) {

	var email = name +"@"+ domain +"."+ tld;
	var mask = "";
	var unmask = "";
	
	
	if (outName == 0 || outName == undefined)
	{
		unmask = name+"[at]"+domain+"[dot]"+tld;
	} else {
		unmask = outName;		
	}

	/* Generieren des Unicodes */

	// mailto: an den Anfang stellen 	
	mask+="&#109;&#097;&#105;&#108;&#116;&#111;&#058;"

	email=email.toLowerCase();
	for(count=0;count<email.length;count++) 
	{
		code=email.charCodeAt(count); 
		if (code<100) 
		{
			code = "0" + code;
		} else {
			String(code);
		}
		
		mask+="&#" + code + ";";
		
	} // END Loop
	
	// Link ausgeben
	document.write("<a class=st_link href="+mask+">"+unmask+"</a>");

} // END Function

function validEmail(email) {
  var strReg = "^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";
  // alert(email);
  var regex = new RegExp(strReg);
  return(regex.test(email));
}


function recalculate_picture_price()
    {

        var anzahl = parseInt($("#anzahl_abzuege").val());
        if (isNaN(anzahl)) {

            $("#anzahl_abzuege").attr("value", "");
            $("#appr_price").html("");
            return false;
        }
        var singleprice = 0;
        var total = 0;
        var format = $("#picture_order_format").val();

        if (format == "10x15") singleprice = 7.5;
        if (format == "15x20") singleprice = 8.5;
        if (format == "20x30") singleprice = 15;

        // var versand = $("#r4:checked").val();
        var versand = $("#picture_order_versandart").val();
        if (versand=="Postversand") total += 3;
        var price = anzahl * singleprice;
        total += price;

        var lastChar = total.toString().charAt(total.toString().length - 1);
        var komma = total.toString().indexOf(".");
        
        if (lastChar != "0" && komma != -1)
        {
            total+="0";
        }

        $("#appr_price").html("Gesamt: "+total+" &euro;");

        return true;
}



function recalculate_video_price()
{
    var anzahl = parseInt($("#anzahl_videos").val());
    var singleprice = 15;
    var total = 0;
    var versand = $('#video_bestellung_versandart').val();
        
    if (isNaN(anzahl))
    {
       $("#anzahl_videos").attr("value", "");
       return false;
    }
    total = singleprice * anzahl;
   
    if (versand == "Postversand") total+=3;

    var lastChar = total.toString().charAt(total.toString().length - 1);
    var komma = total.toString().indexOf(".");

    if (lastChar != "0" && komma != -1)
    {
        total+="0";
    }

    $("#video_price").html("Gesamt: " + total + " &euro; ");
    return true;
}

function stt_submitSurvey(formName, surveyID) {
        var opts = $('input[name="survey_option_'+surveyID+'"]');
        var checked = false;
        for (var i = 0 ; i < opts.length; i++)
        {
            if (opts[i].checked == true)
                {
                    checked = true;
                    break;
                }
        }

        if (!checked)
        {
            // alert("Bitte waehlen Sie eine Option aus");
            $('#stt_xajax_response').html('Bitte w&auml;hlen Sie eine Option aus');
            $('#stt_xajax_response').slideDown(500);
            window.setTimeout(hide_xajax_response, 3000);
            return false;
        }

	xajax_surveyController(xajax.getFormValues(formName), formName, 1);
        return true;
}

function stt_surveyResult(formName, surveyID) {

        var myNode = '<input type="hidden" name="showresult" value="1" />';
        $('#' + formName).appendTo(myNode);
        xajax_surveyController(xajax.getFormValues(formName), formName, 1);
        
}

function hide_xajax_response(){$('#stt_xajax_response').slideUp(500);}