
function showPopup(popup){
	popup = $('#'+popup);
	blind = $('<div class="blind"></div>');

        var iBlindHeight = 0;

        if (document.documentElement.offsetHeight > document.body.clientHeight) {
            iBlindHeight = document.documentElement.offsetHeight;
        }
        else {
            iBlindHeight = document.body.clientHeight;
        }
        if ( iBlindHeight < document.documentElement.scrollHeight ) {
            iBlindHeight = document.documentElement.scrollHeight;
        }

	blind.height(iBlindHeight).click(function(){
	}).appendTo('body');
	setCenter(popup);
	popup.find('.p-close').click(function(){
		closePopup(popup,blind);
		return false;
	});
	popup.show();
	
}
function setCenter(item) {
	windowHeight = document.documentElement.clientHeight;
	currentOffset = document.documentElement.scrollTop || document.body.scrollTop;
	currentOffset = currentOffset + parseInt((windowHeight - ($(item).height()+56)) / 2);
	pLeft = $(item).width() / 2 + 5;
	$(item).css({top:currentOffset,marginLeft:-pLeft}).show();
}
function closePopup(popup,blind) {
	blind.remove();
	popup.find('.p-close').unbind();
	popup.hide();
}

function check_field(){ 

    FAQpopup = $('#faqPopup');
    var err = 0;
    if ( FAQpopup ) {
        $(FAQpopup).find('textarea, input').each(function(){
            if (this.type != "submit" ) {
                $(this).css('border', '1px solid red');

                switch (this.id) {
                    case "faq-email":

                        var email = this.value;

                        if ( email.match(/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i) ) {
                            $(this).css('border', '1px solid #6B6B6B');
                        }
                        else {

                            $(this).css('border', '1px solid red');
                            err = 1
                        }
                        break;
                        case"faq-name":
                        case"faq-question":

                            if ( this.value != "" ) {
                                $(this).css('border', '1px solid #6B6B6B');
                            }
                            else {
                                $(this).css('border', '1px solid red');
                                err = 1
                            }

                            break;
                }
            }
        });

        if ( err == 1 ) {
            $('#faq-request').attr('disabled', true);
        }
        else {
            $('#faq-request').attr('disabled', false);
        }
    }
}
