// JavaScript Document
$.fn.stt_akkordion = function(params){

    params = $.extend({
        duration: 'slow'
    }, params)

    $(this).find(">dd:not(:first)").hide();
    $(this).find(">dt a").click(function(){
        $(this).parent().parent().find("> dd:visible").slideUp(params.duration);
        $(this).parent().next().slideDown(params.duration);
        return false;
    })
}

$(document).ready(function(){
    if ($('a.metzpano').length > 0) {
        $('a.metzpano').colorbox();
    }
})


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);}

function openPageInPrintView(url)
{
	w = window.open(url,"w","width=640,height=480,resizable=1,scrollbars=1,location=0,menubar=1")
}


$(document).ready(function(){
    
    $("a.ssl").bind("mouseover mousemove", function(e){
        $("#sslinfo").show();
        $("#sslinfo").css("left", e.pageX + 10);
        $("#sslinfo").css("top", e.pageY + 10);
    })

    $("a.ssl").bind("mouseout", function(e){
        $("#sslinfo").hide();
    })

    $("a[rel=extended_author_info]").bind("mouseover mousemove", function(e){
        $("#extendedAuthorInfo").show();
        $("#extendedAuthorInfo").css("left", e.pageX + 10);
        $("#extendedAuthorInfo").css("top", e.pageY + 10);
    })

    $("a[rel=extended_author_info]").bind("mouseout", function(e){
        $("#extendedAuthorInfo").hide();
    })

    /* Activate SocialSharePrivacy Plugin */
    if ( $('div[id=heiseSocialShareClick]').length > 0 && $('div[id=heiseSocialShareClick]').html() == '' ) {
        $('#heiseSocialShareClick').socialSharePrivacy({
            services : {
                facebook : {
                    'status'      : 'on',
                    'app_id'      : '100000196296742', 
                    'perma_option': 'on',
                    'dummy_img'   : '/pu_all/styles/socialshareprivacy/images/dummy_facebook.png'
                }, 
                twitter : {
                    'status'    : 'on',
                    'dummy_img' : '/pu_all/styles/socialshareprivacy/images/dummy_twitter.png'
                },
                gplus : {
                    'status'       : 'on',
                    'display_name' : 'Google Plus',
                    'dummy_img'    : '/pu_all/styles/socialshareprivacy/images/dummy_gplus.png'
                }
            },
            'cookie_domain'  : document.location.host,
            'css_path'       : '/pu_all/styles/socialshareprivacy/socialshareprivacy.css',
            'cookie_expires' : '365',
            'settings_perma' : 'Aktivieren Sie die Checkbox, um den jeweiligen Dienst permanent zu aktivieren.'

        });
    }

})



