var pointOpen = false;
var mouseOut = false;
var oldID = "";

function JSrot13(text) {
    var text = text.replace(/%/, "@");
    var rot13text_rotated = "";
    for (i = 1; i < (text.length + 1); i++) {
        k = text.charCodeAt(i - 1);
        if (k >= 97 && k <= 109) {
            k = k + 13;
        }
        else if (k >= 110 && k <= 122) {
            k = k - 13;
        } else if (k >= 65 && k <= 77) {
            k = k + 13;
        } else if (k >= 78 && k <= 90) {
            k = k - 13;
        }

        rot13text_rotated = rot13text_rotated + String.fromCharCode(k);
    }
    return rot13text_rotated;
}

function handleApplicationMemberStatus() {
    var str = "";
    jQuery("#plc_lt_zoneMiddle_plcMiddle_plcMiddle_lt_zoneMiddle_SECARegistrationFormular_editForm_formElem_form_MemberStatus option:selected").each(function () {
        str = jQuery(this).text();
    });
    if (str == "Full Member" || str == "Associate Member") {
        jQuery("#application_form_other_contacts").slideDown();
		jQuery("#comany_logo_upload_field").slideDown();
    }
    else {
        jQuery("#application_form_other_contacts").slideUp();
		jQuery("#comany_logo_upload_field").slideUp();
    }
}

function handleApplicationFullMemberStatus() {
    var str = "";
    jQuery("#plc_lt_zoneMiddle_plcMiddle_plcMiddle_lt_zoneMiddle_SECARegistrationFormular_editForm_formElem_form_MemberStatus option:selected").each(function () {
        str = jQuery(this).text();
    });
    if (str == "Full Member") {
		jQuery("#comany_logo_upload_field").slideDown();
    }
    else {
		jQuery("#comany_logo_upload_field").slideUp();
    }
}

function handleApplicationYoungProfessionalStatus() {
    var str = "";
    jQuery("#plc_lt_zoneMiddle_plcMiddle_plcMiddle_lt_zoneMiddle_SECARegistrationFormular_editForm_formElem_form_MemberStatus option:selected").each(function () {
        str = jQuery(this).text();
    });
    if (str == "Young professional") {
        jQuery("#application_form_young_profession").slideDown();
    }
    else {
        jQuery("#application_form_young_profession").slideUp();
    }
}

function Securemail(maillink) {
    var maillink_output; maillink_output = JSrot13(maillink);
    location.href = 'mailto:' + maillink_output;
}

function displaymailaddress(linktext) {
    var linktext_output;
    linktext_output = JSrot13(linktext);
    linktext_output = linktext_output.replace(/@/, "<span style='display:none'> *secure E-Mailaddress* <\/span>@");
    document.write(linktext_output);
}


function mycarousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function () {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function () {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function () {
        carousel.stopAuto();
    }, function () {
        carousel.startAuto();
    });
};


jQuery(document).ready(function () {

    
    ua = jQuery.browser;
    var isIE = false;
    if (ua.msie && ua.version.slice(0, 3) == "6.0") {
        isIE = true;
    }

    
    jQuery("#accordion").accordion({
        autoHeight: false
    });

    jQuery("#accordion_noopen").accordion({
        autoHeight: false,
        collapsible: true,
        active: false
    });
    
    if (!isIE) {
        jQuery(".dropdowns").jqTransform({ imgPath: 'jqtransform/jqtransformplugin/img/' });
    }
    
    jQuery("#plc_lt_zoneRight_cmssearchbox_txtWord").DefaultValue("Search...");
    jQuery(".LogonField").DefaultValue("Password");
    jQuery(".TextBoxFieldJS[value!='']").DefaultValue();


    
    // Autoformat Error Messages input
    jQuery(".EditingFormErrorLabel").each(function () {
        var e = jQuery(this);
        elementsToFormat = e.parent().add(e.parent().prev()).find("input");
        elementsToFormat.css({ "border": "1px solid #FF0000" });
        jQuery("html").scrollTop(0);
    });
    
    jQuery("#fancyBoxRegistration").fancybox({
    'transitionIn': 'elastic',
    'transitionOut': 'elastic',
    'speedIn': 600,
    'speedOut': 200,
    'overlayShow': true,
    'height' : 750,
    'type': 'iframe'
    });
	
	
	jQuery.get('/CMSPages/SECA/AjaxSponsorsScroller.aspx', function(data) {
	  jQuery('#membersBox').html(data);
	  jQuery('#members').jcarousel({
        scroll: 5,
        auto: 6,
        wrap: 'circular',
        easing: 'swing',
        initCallback: mycarousel_initCallback
		});
    });

});


