/*$(document).ready(function(){
	$('div.file a.fileLink').click(function(){showFiles(this);return false;});
});*/
function toggleWindow(a,wnd) {
	if ( $('div.'+wnd).css('display') == 'none' ) {
		$('div.personalBar a').removeClass('active');
		$(a).addClass('active');
		$('div.ppWindow').hide();
		$('div.'+wnd).show();
	} else {
		$(a).removeClass('active');
		$('div.ppWindow').hide();
		//$('div.'+wnd).show();
	}
};
function showFiles(a) {
	$(a).parent().toggleClass('fileActive');
	return false;
}

function setCenter(item) {

    windowHeight = document.documentElement.clientHeight;
    currentOffset = document.documentElement.scrollTop || document.documentElement.scrollTop;
    currentOffset = currentOffset + parseInt((windowHeight - $(item).height()) / 2);
    pLeft = (document.body.clientWidth - $(item).width()) / 2;
    $(item).css({top:currentOffset,left:pLeft}).show();
}

function showPhoto() {
    var photoPopup = $('#photoPopup');
    setCenter(photoPopup);
    photoPopup.show();
}

function showPopup(popup) {

    currentOffset2 = 0;
    currentOffset = document.documentElement.scrollTop || document.documentElement.scrollTop;

    var windowHeight;
    if (!($.browser.opera)) { windowHeight = document.documentElement.clientHeight } else { windowHeight = document.body.clientHeight }
    if (windowHeight < $('#'+popup).height()) {
        currentOffset = (currentOffset + 10);
    } else {
        currentOffset2 = parseInt((windowHeight - $('#'+popup).height()) / 2);
    }
    pLeft = (document.body.clientWidth - $('#'+popup).width()) / 2;
    $('.iframe').show();
    $('#black').show();
    $('#'+popup).css({top:currentOffset+currentOffset2,left:pLeft}).show();
}
function sendByEmailShow(fileID) {
    popup = $('<form class="sendByEmail" id="send_by_email">'+
    '<p class="close"><a href="#" onClick="$(\'#send_by_email\').remove();return false;"><img src="/img/des/x.gif" alt="Закрыть"></a></p>'+
    '<div class="msg"></div>'+
    '<div class="inputs_items">'+
    '<p><label for="sendf_email">Кому: <em>(электронная почта)</em></label><br><input type="text" class="textInput ch_oblig" id="sendf_email" onkeyup="checkForm(this.id,\'send_by_email\')"></p>'+
    '<p><label for="topic">Тема сообщения:</label><br><input type="text" class="textInput ch_oblig" id="topic" onkeyup="checkForm(this.id,\'send_by_email\')"></p>'+
    '<input type="submit" class="button send" value="Отправить" onclick="fileSend('+fileID+'); return false" disabled>'+
    '</div>'+
	'</form>');
	popup.appendTo('body');
	setCenter(popup);
	popup.show();

};

function showPhotoPopup() {
	blackBack = $('<div id="blackBack"></div>');
	blackBack.height(document.body.clientHeight).click(closePopup).appendTo('body');
	iframeBack = $('<iframe id="iframeBack"></iframe>');
	iframeBack.height(document.body.clientHeight).appendTo('body');
	var photoPopup = $('#photoPopup');
	setCenter(photoPopup);
}
function closePopup() {
	$('#iframeBack').remove();
	$('#blackBack').remove();
	$('.popup').hide();
}
