$(function() {

	//
	// STEP 1
	//
	setTimeout(addLine, 1000);
	
	// alles zur firma
	var countryCodeFirma = $('input[name=countryFirma_selected]').attr('value');		   
	$('select[name=countryFirma] > option[value='+countryCodeFirma+']').attr('selected', 'selected');
	
	var findout = $('input[name=findout_selected]').attr('value');		   
	$('select[name=findout] > option[value='+findout+']').attr('selected', 'selected');
	
	var mitarbeiter = $('input[name=mitarbeiter_selected]').attr('value');		   
	$('select[name=mitarbeiter] > option[value='+mitarbeiter+']').attr('selected', 'selected');

	$('.firmaCheck').click( function(e) {
        $('.mitgliedPrivatperson input').attr('value', '');
		$('.mitgliedFirma')[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
		$('.globalInformation')[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
		$('.discountTable')[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
		$('.privacyOptions').show();
		$('.submitTable')[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
		$('.mitgliedPrivatperson')[ $(this).attr('checked') ? 'hide' : 'show'](); //ausblenden
		//$('.readerTable')[ $(this).attr('checked') ? 'hide' : 'show'](); //ausbelnden
	});

    

	$('.emailSwitch').click( function(e) {
        var $emailField = $(this).closest('tr').next('.emailInvisible');
		$emailField[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
        $emailField.find("input:first").val($(this).attr('checked') ? $emailField.find("input:first").val() : "");
	});

	$('.emailSwitch').each( function() {
        var $emailField = $(this).closest('tr').next('.emailInvisible');
		$emailField[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
        $emailField.find("input:first").val($(this).attr('checked') ? $emailField.find("input:first").val() : "");
	});



	// globale 	
	// einblenden der tabellen nach abgeschicktem zustand
	$('.mitgliedFirma')[ $('.firmaCheck:first').attr('checked') ? 'show' : 'hide']();
	$('.mitgliedPrivatperson')[ ( $('.privatCheck:first').attr('checked') || $('.readerCheck:first').attr('checked') ) ? 'show' : 'hide']();

	$('.globalInformation, .submitTable') [ ( $('input[name=statusCheck]:checked').attr('value') == 'readerCheck' || $('input[name=statusCheck]:checked').attr('value') == 'firmaCheck' || $('input[name=statusCheck]:checked').attr('value') == 'privatCheck' ) ? 'show' : 'hide']();
	
	$('.discountTable') [ ( $('input[name=statusCheck]:checked').attr('value') == 'firmaCheck' || $('input[name=statusCheck]:checked').attr('value') == 'privatCheck' ) ? 'show' : 'hide']();	



	// Mitglieder antrag 
	var countryCodePrivat = $('input[name=countryPrivat_selected]').attr('value');		   
	$('select[name=countryPrivat] > option[value='+countryCodePrivat+']').attr('selected', 'selected');

	var nationalityCode = $('input[name=nationality_selected]').attr('value');		   
	$('select[name=nationality] > option[value='+nationalityCode+']').attr('selected', 'selected');


	$('.privatCheck').click( function(e) {
        $('.mitgliedFirma input').attr('value', '');
		$('.mitgliedPrivatperson')[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
		$('.globalInformation')[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
		$('.submitTable')[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
		$('.privacyOptions').show();
		$('.mitgliedFirma')[ $(this).attr('checked') ? 'hide' : 'show'](); //ausblenden
		$('.discountTable')[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden

	});
	
	$('.readerCheck').click( function(e) {
        $('.mitgliedFirma input').attr('value', '');
		$('.mitgliedPrivatperson')[ $(this).attr('checked') ? 'show' : 'hide'](); //ausblenden
	    $('.globalInformation')[ $(this).attr('checked') ? 'show' : 'hide'](); //ausblenden
		$('.mitgliedFirma')[ $(this).attr('checked') ? 'hide' : 'show'](); //ausblenden
		$('.submitTable')[ $(this).attr('checked') ? 'show' : 'hide'](); //einblenden
		$('.privacyOptions').hide();
		$('.discountTable')[ $(this).attr('checked') ? 'hide' : 'show'](); //einblenden	
	});

	//
	// STEP 2
	//

	$('input[name=emailAnsprechpartnerFirma]').blur(function(e) { $('input[name=login]').attr('value',$(this).attr('value')) });
	$('input[name=emailPrivat]').blur(function(e) { $('input[name=login]').attr('value',$(this).attr('value')) });

	$('#vatId').click( function(e) {
		$('#vatDiv')[ $(this).attr('checked') ? 'show' : 'hide']();
        $('#vatDiv').find("input").val("");
	});
	
	$('#vatDiv')[ $('#vatId:first').attr('checked') ? 'show' : 'hide']();


	$('.tooltipText').tooltip();

    $('.loginBlur').blur(function(e) {
        var login = $(this).closest('tr').next().find('input[type=text]');
        if ( login.size() == 0 )
            return;

        if ( login.attr('value') == "" )
            login.attr('value', $(this).attr('value'));
    });
    var defaultDate = $('.datepicker').val();

    $('.datepicker').datepicker({
        dateFormat:'dd.mm.yy',
        defaultDate: defaultDate
    });
    $('#countryFirma').bind('change', function() {
        var text = affiliateText($(this).val());
        $("#countryAffiliateNotice").html(text);

    });
    var text = affiliateText($('#countryFirma').val());
    $("#countryAffiliateNotice").html(text);

    $('#countryPrivat').bind('change', function() {
        var text = affiliateText($(this).val());
        $("#countryAffiliateNoticePrivat").html(text);

    });
    var text2 = affiliateText($('#countryPrivat').val());
    $("#countryAffiliateNoticePrivat").html(text2);

});

function affiliateText(val) {



    if (val == 'de') {

        var text = '<p>Would you like to sign up through <span class="error">iPHA’s German Affiliate IG '+
        'Passivhaus Deutschland</span> thereby becoming a member of both IG Passivhaus '+
        'Deutschland and iPHA at the cost of the IG Passivhaus Deutschland membership only?</p>'+
        '<p>You can register with the IG Passivhaus Deutschland '+
        '<a href="http://www.ig-passivhaus.de/antrag_auf_mitgliedschaft.php" target="_blank" class="error">here</a>.</p> ';
    }


    else if (val == 'gb') {

        var text = '<p>Would you like to sign up through <span class="error">iPHA’s UK Affiliate Passivhaus Trust (PHT)</span> '+
        'thereby becoming a member of both Passivhaus Trust and iPHA at the cost of the Passivhaus Trust '+
        'membership only?</p><p>You can register with the Passivhaus Trust '+
        '<a href="http://www.aecb.net/passivhaustrust/membership.html" target="_blank" class="error">here</a>.</p> ';
    }


     else if (val == 'ie') {

        var text = '<p>Would you like to sign up through <span class="error">iPHA’s Irish Affiliate Passive House Association of Ireland (PHAI)</span> '+
        'thereby becoming a member of both Passive House Association of Ireland and iPHA at the cost '+
        'of the Passive House Association of Ireland membership only?</p><p>You can register with '+
        'the Passive House Association of Ireland <a href="http://www.phai.ie/?page_id=12" target="_blank" class="error">here</a>.</p> ';
    }


    /*else if (val == 'se') {

        var text = '<p>Would you like to sign up through <span class="error">iPHA’s Irish Affiliate Passive House Association of Ireland (PHAI)</span> '+
        'thereby becoming a member of both Passive House Association of Ireland and iPHA at the cost '+
        'of the Passive House Association of Ireland membership only?</p><p>You can register with '+
        'the Passive House Association of Ireland <a href="http://www.phai.ie/?page_id=12" target="_blank" class="error">here</a>.</p> ';
    }

     if ($(this).val() == 'us') {

        var text = '<p>Would you like to sign up through iPHA’s US Affiliate Passive House Alliance (nPHA) '+
        'thereby becoming a member of both Passive House Alliance and iPHA at the cost of the Passive '+
        'House Alliance membership only?</p><p>You can register with the Passive House Alliance '+
        '<a href="http://phaus.org" target="_blank">here</a>.</p> ';
    }


    if ($(this).val() == 'hu') {

        var text = '<p>Would you like to sign up through iPHA’s Hungarian Affiliate Passzívházépítok Országos '+
        'Szövetsége (PAOSZ) thereby becoming a member of both Passzívházépítok Országos Szövetsége and iPHA '+
        'at the cost of the Passzívházépítok Országos Szövetsége membership only?</p><p>You can register '+
        'with the Passzívházépítok Országos Szövetsége '+
        '<a href="http://www.passzivhazepitok.hu/kapcsolat.aspx" target="_blank">here</a>.</p> ';
    }*/
    else var text = '';
    return text;

}

function toggleLock(string, id)
{
    if ( !confirm(string))
        return;

    location.href = "/memberDetails.php?member_id="+id+"&todo=toggleLock";
}



function addLine()
{
	if ( $('.twtr-tweet').size() == 0 ) {
		setTimeout(addLine, 1000);
	}
	
    $('.twtr-tweet').addClass('twitterLine');
	
	
}




















// JavaScript Document



//If using image buttons as controls, Set image buttons' image preload here true
//(use false for no preloading and for when using no image buttons as controls):
var preload_ctrl_images=true;

//And configure the image buttons' images here:
var previmg='../_img/slideshow_left.gif';
var stopimg='../_img/slideshow_stop.gif';
var playimg='../_img/slideshow_play.gif';
var nextimg='../_img/slideshow_right.gif';


var slides=[]; //THIRD SLIDESHOW
//configure the below images and descriptions to your own, note optional links, target and window specifications. 
slides[0] = ["1_side.jpg", "", "http://www.google.com", "_new", "top=250, left=300, width=500, height=300, location, resizable, scrollbars"];
slides[1] = ["2_side.jpg", ""];
slides[2] = ["3_side.jpg", "", "http://www.dynamicdrive.com"];
slides[3] = ["5_side.jpg", "", "http://www.msn.com", "_new"];
//optional properties for these images:
slides.no_descriptions=1; //use for no descriptions displayed
slides.pause=1; //use for pause onmouseover
slides.image_controls=1; //use images for controls
slides.button_highlight='#cccccc'; //onmouseover background-color for image buttons (requires image_controls=1)
slides.specs='width=300, height=250' //global specifications for this show's new window(s)
slides.random=1; //set a random slide sequence on each page load
slides.manual_start=1; //start show in manual mode (stopped)





