jQuery(document).ready(function(){
    /*Для IE выставляем рабочую высоту документа*/
    if (jQuery.browser.msie) {
        h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight)-25);
        jQuery("#layout").css({
            height:h
        });
    }
    preload_1   = new Image;
    preload_1.src="/public/img/btnClose.gif";
    preload_2   = new Image;
    preload_2.src="/public/img/ie_background.gif";
    preload_3   = new Image;
    preload_3.src="/img/ie_cornerBottom.png";
    preload_4   = new Image;
    preload_4.src="/img/ie_cornerTop.png";
    preload_5   = new Image;
    preload_5.src="/img/buttonBg.png";
    preload_5   = new Image;
    preload_5.src="/img/woman.png";
    preload_5   = new Image;
    preload_5.src="/img/man.png";
});
/** */


var arrWindow  = new Array();
var argument1  = 0;
var captcha    = 'Тили-тили тесто жених и ...';

arrWindow['guiRegistrationForm'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont">'
+ '<h3 style="margin-bottom:17px;">Новый участник</h3>'
+ '<form id="registrationForm">'
+ '<table border="0" width="100%">'
+	'<tr><th><label for="guiStrLogin">Ваше имя:</label></th><td class="doShake"><input type="text" id="guiStrLogin" name="guiStrLogin" class="inputText" value="" lang="ru-en" maxlength="25" />'

+ '<div class="guiError"></div></td></tr>'

+ '<tr><th><label for="guiStrEmail">Эл. почта:</label></th><td class="doShake"><input type="text" id="guiStrEmail" name="guiStrEmail" value="" class="inputText" lang="ru-en" maxlength="40" />'
+ '<div class="guiError"></div></td></tr>'

+ '<tr><th><label for="guiStrPassword">Пароль:</label></th><td class="doShake"><input type="password" id="guiStrPassword" name="guiStrPassword" class="inputText" lang="ru-en" maxlength="20" value="" />'
+ '<div class="guiError"></div></td></tr>'

+ '<tr><th style="padding-top:12px;color:#333;">Пол:</th><td>'
+ '<table width="100"><tr>'
+ '<td><img src="/img/woman.png" /></td><td><input type="radio" id="guiBoolSexFemale" name="guiBoolSex" value="f" checked="checked"></td>'
+ '<td><img src="/img/man.png"  /></td><td><input type="radio" id="guiBoolSexMale" name="guiBoolSex" value="m"></td></tr>'
+ '</table></td></tr>'

+ '<tr><th colspan="2" style="text-align: left; width: 100%;"><label for="guiStrCapcha">Защита от роботов. Продолжи фразу:</label></th>'
+ '</tr><tr><td colspan="2"><div id="guiSpnCaptcha"></div><br />' // переменная-шаблон для капчи

+ '<input type="text" class="inputText capcha" id="guiStrCapcha" name="guiStrCapcha" value="" lang="ru-en" maxlength="40" />'
+ '<div class="guiError"></div>'
+ '<input type="hidden" id="guiHdnCaptchaIdent" name="guiHdnCaptchaIdent" value="">'
+ '</td></tr><tr><td colspan="2" align="center"><input type="submit" value="Зарегистрироваться" id="guiHdnRegistration" class="inputButton"></td></tr>'
+ '<tr><td colspan="2" align="center" class="grayText" style="padding-top:7px;font-size:8pt;">Нажимая эту кнопку, я принимаю <a href="/rules/show-registration-rule/1" target="_blank">пользовательское соглашение</a></td>'
+ '</tr></table></form></div><div class="cornerBottom"></div>';

arrWindow['guiForgotForm'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3>Восстановление пароля</h3>'
+ '<form id="forgotForm"><table border="0" width="100%">'
+ '<tr><th>Эл. почта:</th>'
+ '<td width="300"><input type="text" id="guiStrEmail" name="guiStrEmail" class="inputText" value="" maxlength="40" />'
+ '<div class="guiError"></div></td></tr>'
+ '<tr style="display:none;"><td colspan="2" align="center" class="modalAddText"><div id="blockMessage"></div></td></tr>'
+ '<tr><td colspan="2" align="center"><div id="guiSubmit"><input type="submit" value="Напомнить" class="inputButton" /></div>'
+ '<div id="guiSuccess" style="display: none;"></div></td>'
+ '</tr></table></form></div><div class="cornerBottom"></div>';

arrWindow['guiBlockedIPForm'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3 id="guiH3Caption">Напоминание пароля</h3>'
+ '<form id="blockedIPForm"><table border="0" width="100%">'

+ '<tr><td align="center">'
+ '<div id="guiBlockMessage"></div>'
+ '</td></tr>'

+ '</table></form></div><div class="cornerBottom"></div>';

arrWindow['guiAuthForm'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><div class="modalAddText" id="guiModalAuthText"></div>'
+ '<h3>Вход</h3>'
+ '<form id="authForm">'
+ '<table border="0" width="100%">'
+ '<tr><th>Эл. почта:</th><td class="doShake"><input type="text" id="guiStrEmail" name="guiStrEmail" class="inputText" value="" maxlength="40" /></td></tr>'
+ '<tr><th>Пароль:</th><td class="doShake"><input type="password" id="guiStrPassword" name="guiStrPassword" class="inputText" maxlength="20" value="" /></td></tr>'
+ '<tr><th colspan="2" class="modalAddLinks" style="text-align:right;">'
//+ '<input type="checkbox" id="rememberMe"> <label for="rememberMe">запомнить</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
+ '<a href="javascript://" class="orangeLink" onClick="closeModal(\'guiAuthForm\');showPopUpWindow(\'guiRegistrationForm\');">Регистрация</a>&nbsp;&nbsp;&nbsp;'
+ '<a href="javascript://" onClick="closeModal(\'guiAuthForm\');showPopUpWindow(\'guiForgotForm\');">Напомнить пароль</a>&nbsp;&nbsp;'
+ '</th></tr>'
+ '<tr><td colspan="2">'
+ '<table cellpadding="0" cellspacing="0" width="100%"><tr><td>'
+ '<input type="checkbox" id="guiChkRememberMe" name="guiChkRememberMe" value="1" CHECKED/>'
+ '<label for="guiChkRememberMe" style="font-size:11pt;margin:0 15px 0 0;">запомнить меня на этом компьютере</label>'
+ '</td><td align="right">'
+ '<input type="submit" value="Войти" class="inputButton" />&nbsp;'
+ '</td></tr></table></td>'
+ '</tr></table></form></div><div class="cornerBottom"></div>';

arrWindow['guiMessages'] = '<div class="bigCornerTop"></div>'
+ '<div class="bigPopUpWindowCont"><div class="modalAddText" id="guiModalAuthText"></div>'
+ '<form id="commentsForm">'
+ '<table border="0" width="585">'
+ '<tr><td id="guiTdUserBlock">'

+ 'загрузка данных ...'

+ '</td></tr>'
+ '<tr><td>'
+ '<div class="bigMsgWin" id="guiPersonalMessageList">загрузка списка сообщений ...'
+ '</div>'
+ '</td></tr>'
+ '<tr><td><h4>Напишите сообщение</h4></td></tr>'
+ '<tr><td><textarea cols="55" rows="6" class="textarea" style="width:578px;" id="guiTxtMessageBody"></textarea><br /><br /></td></tr>'
+ '<tr style="display:none;" id="errorTr"><td align="center"><div id="guiMessage" class="error"></div></td></tr>'
+ '<tr style="display:none;" id="errorTr"><td align="center"><div id="guiMessage" class="error"></div></td></tr>'
+ '<tr><td align="center"><input type="submit" value="Отправить" class="inputButton"></td>'
+ '</tr></table></form></div><div class="bigCornerBottom"></div>';

arrWindow['guiComplaint'] = '<div class="cornerTop"></div>'
    + '<div class="popUpWindowCont"><div class="modalAddText" id="guiModalAuthText"></div>'
    + '<h3>Сообщение о нарушении правил</h3>'
    + '<form id="complaintForm">'
    + '<table border="0" width="100%">'
    + '<tr><td>Уважаемые модераторы! Проверьте пожалуйста <a href="' + window.location + '" id="guiHrefUrlPage" name="guiHrefUrlPage">' + window.location + '</a></td></tr>'
    + '<tr><td><textarea cols="55" rows="6" class="textarea" id="guiTxtBodyCompl" name="guiTxtBodyCompl">По моему мнению, содержимое не соответствует правилам портала</textarea><br /><br /></td></tr>'
    + '<tr><td align="center"><div id="guiMessage" style="margin:0 0 8px 0;font-weight:bold;"></div></td>'
    + '<tr><td align="center"><input type="submit" value="Отправить" class="inputButton"></td>'
    + '</tr></table></form></div><div class="cornerBottom"></div>';

arrWindow['guiConfirmForm'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3 id="guiHeaderMessage">Вы уверенны?</h3>'
+ '<table border="0" width="100%">'
+ '<tr><td align="center">'
+ '<div id="guiBlockMessage" style="margin-bottom:15px;"></div>'
+ '<input type="hidden" name="id_record" id="id_record" value="">&nbsp;'
+ '<input type="button" id="guiBtnConfirmWin" onClick="submitConfirmWindow()" value="Да">'
+ '</td></tr>'
+ '</table></div><div class="cornerBottom"></div>';


arrWindow['guiDeleteComments'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Удаление комментария</h3>'
+ '<form id="deleteCommentsForm">'
+ '<table border="0" width="100%">'

+ ' <tr><td><input type="radio" id="guiRbtnDeleteOnlyThisComment" name="guiChkDeleteOnlyThisComment" value="1" checked/>&nbsp;<label for="guiRbtnDeleteOnlyThisComment" class="label" id="guiLabelDelCaption1">Удалить комментарий только из этой темы</label></td></tr>'
+ ' <tr><td style="padding-top:10px;"><input type="radio" id="guiRbtnDeleteAllMyComment" name="guiChkDeleteOnlyThisComment" value="1" />&nbsp;<label for="guiRbtnDeleteAllMyComment" class="label">Удалить комментарии со всего портала</label></td></tr>'

+ '<tr><td align="center" style="padding-top:10px;"><div id="guiSubmit"><input type="submit" value="Удалить" id="guiBtnSbmtDelComments" class="inputButton" /></div></td></tr>'
+ '</table>'
+ ' <input type="hidden" name="guiIsDefaultValue" id="guiIsDefaultValue" value="0">'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';

arrWindow['guiDeleteTopic']    = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Удаление темы</h3>'
+ '<form id="deleteTopicForm">'
+ '<table border="0" width="100%">'

+ ' <tr><td><input type="radio" id="guiRbtnDeleteOnlyFromForum" name="guiRbtnDeleteOwnTopic" value="1" checked/>&nbsp;<label for="guiRbtnDeleteOnlyFromForum" class="label">Удалить тему только из форума</label></td></tr>'
+ ' <tr><td style="padding-top:10px;"><input type="radio" id="guiRbtnDeleteTopicFromProject" name="guiRbtnDeleteOwnTopic" value="1" />&nbsp;<label for="guiRbtnDeleteTopicFromProject" class="label">Удалить тему со всего портала</label></td></tr>'

+ '<tr><td align="center" style="padding-top:10px;"><div id="guiSubmit"><input type="submit" value="Удалить" class="inputButton" /></div></td></tr>'
+ '</table>'
+ ' <input type="hidden" name="guiIsDefaultValue" id="guiIsDefaultValue" value="0">'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';

arrWindow['guiLinkWindow']     = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3>Вставить ссылку</h3>'
+ '<form id="guiFrmLinkForm">'
+ '<table border="0" width="100%">'

+ ' <tr><td><input type="text" name="guiStrLink" class="inputText" style="width:350px;" id="guiStrLink" value="" size="50"  maxlength="150">'
+ ' <div class="guiError red" id="guiErrorDiv"></div></td></tr>'

+ '<tr><td align="center"><div id="guiSubmit"><input type="button" value="Вставить" class="inputButton" onClick="insertLinkToEditor();"/></div></td></tr>'
+ '</table>'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';

arrWindow['guiAlertWindow'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3 id="guiH3Caption">Уведомление</h3>'
+ '<form id="guiFrmLinkForm">'
+ '<table border="0" width="100%">'

+ ' <tr><td><div id="guiDivMessage" style="text-align:center"></div></td></tr>'
+ '</table>'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';

arrWindow['guiUnSubscribeWin'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Отписаться от комментариев</h3>'
+ '<form id="unSubScribeCommentsForm">'
+ '<table border="0" width="100%">'

+ ' <tr><td><input type="checkbox" id="guiChkSubscribeTopic" name="guiChkSubscribeTopic" value="1" checked/>&nbsp;<label for="guiChkSubscribeTopic">Следить за всей темой</label></td></tr>'
+ ' <tr><td style="padding-top:10px;"><input type="checkbox" id="guiChkSubscribePost" name="guiChkSubscribePost" value="1" checked/>&nbsp;<label for="guiChkSubscribePost">Следить за ответами только на мои комментарии</label></td></tr>'

+ '<tr><td align="center" style="padding-top:10px;"><div id="guiSubmit"><input type="submit" value="Сохранить" class="inputButton" /></div></td></tr>'
+ '</table>'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';




arrWindow['guiSubscribeWin']  = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3>Подписаться на рассылку</h3>'
+ '<form id="guiFrmScribeCommentsForm">'
+ '<table border="0" width="100%">'

+ ' <tr><td><input type="checkbox" id="guiChkSubscribeTopic" name="guiChkSubscribeTopic" value="1" checked/>&nbsp;<label for="guiChkSubscribeTopic">Следить за всей темой</label></td></tr>'
+ ' <tr><td style="padding-top:10px;"><input type="checkbox" id="guiChkSubscribePost" name="guiChkSubscribePosts" value="2" checked/>&nbsp;<label for="guiChkSubscribePost">Следить за ответами только на мои комментарии</label></td></tr>'

+ '<tr><td align="center" style="padding-top:10px;"><div id="guiSubmit"><input type="submit" value="Сохранить" class="inputButton" /></div></td></tr>'
+ '</table>'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';





arrWindow['guiUnSubscribePhotoWin'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Отписаться от комментариев</h3>'
+ '<form id="unSubScribeCommentsForm">'
+ '<table border="0" width="100%">'

+ ' <tr><td><input type="checkbox" id="guiChkSubscribeTopic" name="guiChkSubscribeTopic" value="1" checked/>&nbsp;<label for="guiChkSubscribeTopic">Следить за всей темой</label></td></tr>'
+ ' <tr><td style="padding-top:10px;"><input type="checkbox" id="guiChkSubscribePost" name="guiChkSubscribePost" value="1" checked/>&nbsp;<label for="guiChkSubscribePost">Следить за ответами только на мои комментарии</label></td></tr>'

+ '<tr><td align="center" style="padding-top:10px;"><div id="guiSubmit"><input type="button" value="Сохранить" class="inputButton" id="guiBtnSavePhotoSubscribe"/></div></td></tr>'
+ '</table>'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';




arrWindow['guiDeleteCatalog'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3 id="guiH3Caption">Подтверждение удаления записи</h3>'
+ '<form id="guiFrmLinkForm">'
+ '<table border="0" width="100%">'

+ '<tr><td><div id="guiDivMessage">'
+ 'Вы хотите удалить свою запись в Свадебном каталоге<br />'
+ 'Запись нельзя будет восстановить и все рейтинги<br />'
+ 'и комментарии будут стерты</div><br /><br />'
+ '<div style="font-size:16px;text-align:center;">Вы уверены?</div><br />'
+ '</td></tr>'
+ '<tr><td align="center">'
+ '<input type="button" value="Удалить" onclick="deleteCatalog();closeModal();">'
+ '<input type="button" value="Отмена" onclick="closeModal();">'
+ '</td></tr>'
+ '</table>'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';

arrWindow['guiConfirmDelTopic'] = '<div class="cornerTop"></div>'
+ '<form id="guiFrmDelTopic">'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Удаление темы</h3>'
+ '<table border="0" width="100%">'
+ '<tr><td style="padding-top:10px;">Удалить тему со всего портала?</td></tr>'
+ '<tr><td align="center"><input type="hidden" name="guiHdnIdRecord" id="guiHdnIdRecord" value="0"><div id="guiBlockMessage"></div></td></tr>'

+ '<tr><td align="center"><input type="button" id="guiBtnDelOwnTopic" onClick="deleteOwnTopicAction()" value="Да, удалить"></td></tr>'

+ '</table></div><div class="cornerBottom"></div>'
+ '</form>';

arrWindow['guiDeleteInterestFirm'] = '<div class="cornerTop"></div>'
+ '<form id="guiFrmDelInterestFirm">'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Удаление</h3>'
+ '<table border="0" width="100%">'
+ '<tr><td style="padding-top:10px;">Удалить фирму со списка Избранных фирм?</td></tr>'
+ '<tr><td align="center"><input type="hidden" name="guiHdnIdRecord" id="guiHdnIdRecord" value="0"><div id="guiBlockMessage"></div></td></tr>'

+ '<tr><td align="center"><input type="button" id="guiBtnDelOwnTopic" onClick="deleteInterestFirmAction()" value="Да, удалить"></td></tr>'

+ '</table></div><div class="cornerBottom"></div>'
+ '</form>';

arrWindow['guiConfirmDelForm'] = '<div class="cornerTop"></div>'
+ '<form id="guiFrmDelComment">'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Удаление комментария</h3>'
+ '<table border="0" width="100%">'
+ '<tr><td style="padding-top:10px;" id="guiTdDeleteCaption">Удалить комментарий со всего портала?</td></tr>'
+ '<tr><td align="center"><input type="hidden" name="guiHdnIdRecord" id="guiHdnIdRecord" value="0"><div id="guiBlockMessage"></div></td></tr>'

+ '<tr><td align="center"><input type="button" onClick="deleteOwnCommentAction()" id="guiBtnDeleteOwnComment" value="Да, удалить"></td></tr>'

+ '</table></div><div class="cornerBottom"></div>'
+ '</form>';

arrWindow['guiCfrmDelFromTopic'] = '<div class="cornerTop"></div>'
+ '<form id="guiFrmDelCommentFromOwnTopic">'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Удаление комментария</h3>'
+ '<table border="0" width="100%">'
+ '<tr><td style="padding-top:10px;">Удалить комментарий из темы?</td></tr>'
+ '<tr><td align="center"><input type="hidden" name="guiHdnIdRecordNotMyComment" id="guiHdnIdRecordNotMyComment" value="0"><div id="guiBlockMessage"></div></td></tr>'

+ '<tr><td align="center"><input type="button" onClick="deleteCommentFromOwnTopicAction()" value="Да, удалить"></td></tr>'

+ '</table></div><div class="cornerBottom"></div>'
+ '</form>';


arrWindow['guiPhotoKonkursAgree'] = '<div class="cornerTop"></div>'
+ '<form id="guiFrmDelCommentFromOwnTopic">'
+ '<div class="popUpWindowCont"><h3 id="guiCompetCaption">Добавление фотографии в конкурс</h3>'
+ '<table border="0" width="100%">'
+ '<tr><td style="padding-top:10px;" id="guiTdCompetBody">Проверьте название и описание фотографии. После добавления на конкурс - фотографию и её описание нельзя будет редактировать.</td></tr>'
+ '<tr><td align="center"><div id="guiBlockMessage"></div></td></tr>'

+ '<tr><td align="center"><input type="button" id="guiBtnAddInKonkurs" value="Добавить">&nbsp;<input type="button" id="guiBtnDelFromKonkurs" value="Отказаться"></td></tr>'

+ '</table></div><div class="cornerBottom"></div>'
+ '</form>';

arrWindow['guiToDeleteComments'] = '<div class="cornerTop"></div>'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Удаление комментария</h3>'
+ '<form id="deleteCommentsForm">'
+ '<table border="0" width="100%">'

+ ' <tr><td><input type="radio" id="guiRbtnDeleteOnlyThisComment" name="guiChkDeleteOnlyThisComment" value="1" checked/>&nbsp;<label for="guiRbtnDeleteOnlyThisComment" class="label" id="guiLabelDelCaption1">Удалить комментарий только с фотогалереи</label></td></tr>'
+ ' <tr><td style="padding-top:10px;"><input type="radio" id="guiRbtnDeleteAllMyComment" name="guiChkDeleteOnlyThisComment" value="1" />&nbsp;<label for="guiRbtnDeleteAllMyComment" class="label">Удалить комментарии со всего портала</label></td></tr>'

+ '<tr><td align="center" style="padding-top:10px;"><div id="guiSubmit"><input type="button" value="Да, удалить" id="guiBtnSbmtDelComments" class="inputButton" /></div></td></tr>'
+ '</table>'
+ ' <input type="hidden" name="guiIsDefaultValue" id="guiIsDefaultValue" value="0">'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';

arrWindow['guiAddPortfolio'] = '<div class="cornerTop"></div>'
+ '<div style="padding-top:20px;" class="popUpWindowCont"><h3 style="font-weight: normal;" id="guiH3Caption">Вы пытаетесь добавить чужую фотографию в свое Портфолио</h3>'
+ '<form id="guiFrmLinkForm">'
+ '<table border="0" width="100%">'

+ '<tr><td><div id="guiDivMessage">'
//+ 'Вы пытаетесь добавить чужую фотографию в свое Портфолио.<br />'
+ '<div style="font-size:16px;text-align:center;padding-top:10px;">Вы уверены?</div><br />'
+ '</td></tr>'
+ '<tr><td align="center">'
+ '<input type="button" value="Да, добавить" onclick="addFavoritPortfolioForeign();closeModal();"> '
+ '<input type="button" value="Отменить" onclick="closeModal();">'
+ '</td></tr>'
+ '</table>'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';

arrWindow['GuiAutorize'] = '<div class="cornerTop"></div>'
+ '<div style="padding-top:20px;" class="popUpWindowCont">'
+ '<form id="guiFrmLinkForm">'
+ '<table border="0" width="100%">'

+ '<tr><td><div id="guiDivMessage">'
//+ 'Для данного действия требуется авторизация<br />'
+ '<div style="font-size:13px;text-align:center;padding-top:10px;">Доступно только для зарегистрированных</div><br />'
+ '</td></tr>'
+ '<tr><td align="center">'
+ '<input type="button" style="font-size:16px;" value="Регистрация" onClick="closeModal(\'guiAuthForm\');showPopUpWindow(\'guiRegistrationForm\');"> '

+ '</td></tr>'
+ '</table>'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>';

arrWindow['GuiAutorizeMess'] = '<div class="cornerTop"></div>'
+ '<div style="padding-top:20px;" class="popUpWindowCont">'
+ '<form id="guiFrmLinkForm">'
+ '<table border="0" width="100%">'

+ '<tr><td><div id="guiDivMessage">'
//+ 'Для данного действия требуется авторизация<br />'
+ '<div style="font-size:13px;text-align:center;padding-top:10px;">Личная переписка доступна только для зарегистрированных</div><br />'
+ '</td></tr>'
+ '<tr><td align="center">'
+ '<input type="button" style="font-size:16px;" value="Регистрация" onClick="closeModal(\'guiAuthForm\');showPopUpWindow(\'guiRegistrationForm\');"> '

+ '</td></tr>'
+ '</table>'
+ '</form>'
+ '</div>'
+ '<div class="cornerBottom"></div>'; 

arrWindow['guiConfirmDelPhoto'] = '<div class="cornerTop"></div>'
+ '<form id="guiFrmDelComment">'
+ '<div class="popUpWindowCont"><h3 style="color:#d90606">Удаление фотографии</h3>'
+ '<table border="0" width="100%">'
+ '<tr><td style="padding-top:10px;">Удалить фотографию?</td></tr>'
+ '<tr><td align="center"><input type="hidden" name="guiHdnIdRecord" id="guiHdnIdRecord" value="0"><div id="guiBlockMessage"></div></td></tr>'

+ '<tr><td align="center"><input type="button" id="guiBtnDeletePhoto" value="Да, удалить"></td></tr>'

+ '</table></div><div class="cornerBottom"></div>'
+ '</form>';

/**
'<a href="javascript://" class="orangeLink" onClick="closeModal(\'guiAuthForm\');showPopUpWindow(\'guiRegistrationForm\');">Регистрация</a>&nbsp;&nbsp;&nbsp;'


 ========================================================================= */

function showPopUpWindow(index,arg1){
    var dialog = jQuery('#popUpWindow');

    argument1 = arg1;
    var str = arrWindow[index];

    var intIndexOfMatch = str.indexOf('REPLACEMENT');

    while (intIndexOfMatch != -1){
        str = str.replace('REPLACEMENT',arg1);
        intIndexOfMatch = str.indexOf('REPLACEMENT');
    } // while


    jQuery('#popUpWindow').html(str);




    /** if open registration modal box */
    if (index == "guiRegistrationForm"){
        initRegistrationValidate();
    } else if (index == "guiAuthForm"){
        initAuthFormValidate();
    } else if (index == "guiForgotForm"){
        initForgotFormValidate();
    }else if (index == "guiForumImageForm") {
        initImageLoadForm();
    }else if (index == "guiDeleteComments") {
        initDeleteCommentsdForm();
    }else if (index == "guiUnSubscribeWin") {
        initUnSubscribeForm();
    }else if (index == "guiSubscribeWin") {
        initSubscribeForm();
    }else if (index == "guiDeleteTopic") {
        initDeleteOwnTopic();
    }else if (index == "guiArticleImageForm") {
        initArticleImageLoadForm();
    }
    /*else if (index == "guiConfirmForm"){
  initConfirmFormValidate();
 }*/

    /** ***** */
    var options = {
        containerId : 'modalContainer',
        //    position:  ["center", "top"],
        onShow : function() {
            if (index == "guiRegistrationForm"){
                jQuery(':input[id="guiStrLogin"]').focus();
            } else if (index == "guiAuthForm"){
                jQuery(':input[id="guiStrEmail"]').focus();
            } else if (index == "guiForgotForm"){
                jQuery(':input[id="guiStrEmail"]').focus();
            }
        },
        onClose : function() {
            if (index == "guiArticleImageForm") {
                // при закрытии окошка загрузки изображения к статьям, убираем выделение selectionArea
                if (jQuery('#aimage').attr('id') == 'aimage') {
                    jQuery('.imgareaselect-handle').css('display', 'none');
                    jQuery('.imgareaselect-outer').css('display', 'none');
                    jQuery('.imgareaselect-border1').css('display', 'none');
                    jQuery('.imgareaselect-border2').css('display', 'none');
                    jQuery('.imgareaselect-border3').css('display', 'none');
                    jQuery('.imgareaselect-border4').css('display', 'none');
                    jQuery('.imgareaselect-selection').css('display', 'none');
                }
            }
            closeModal();
        }
    };

    //if (jQuery.browser.msie) {
    //    options['position'] = ["center", "top"];
    //}

    dialog.modal(options);

    /*
  *  Для сафари исправляем баг с вводом паролей
  */
    var usAgent = navigator.userAgent.toLowerCase();
    if(usAgent.indexOf("safari") != -1){
        var F = document.forms;
        for(var j=0; j<F.length; ++j) {
            var f = F[j];
            for (var i=0; i<f.length; ++i) {
                if (f[i].type.toLowerCase() == "password") {
                    var el = f[i];
                    el.type = "text";
                    el.style.cssText = "-webkit-text-security: disc";
                }
            }
        }
    }
}


/**
  *
  * Show form for inserting LINKS
  *
  * @last 28.09.2009
  *
  *
  */
function insertLink(editor,pid){
    idComment  = pid;
    currEditor = editor;

    showPopUpWindow('guiLinkWindow');
    jQuery('#guiStrLink').focus();
}

/**
 *
 * Insert Link to editor
 *
 * @last 28.09.2009
 *
 **/
function insertLinkToEditor(){
    var link = jQuery('#guiStrLink').val();

    var regexp = new RegExp("(^(http\://|https\://|ftp\://)|(www.))+(([a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9%:/-_\?\.'~]*)?");

    if (!regexp.test(link)) {
        jQuery('#guiErrorDiv').html('Ссылка не соответсвует формату.');
        return false;
    }else{
        jQuery('#guiErrorDiv').html('');
    }

    if (idComment > 0) {
        var tmpEditor = editor;
    }else{
        var tmpEditor = fastEditor;
    }

    var captionLink = '';

    if(link.indexOf("http://", 0) == -1) {
        captionLink = link;
        link        = 'http://' + link;
    }else{
        captionLink = link;
    }


    tmpEditor.insertHtml('<a href="'+ link +'" target="_blank" title="'+ captionLink +'" />'+captionLink+'</a>');
    closeModal();

}

function initArticleImageLoadForm() {
// если удалять, то также убрать else if (index == "guiArticleImageForm") из showPopUpWindow()
}

function initImageLoadForm(){
    jQuery('#guiSpnSaldoImage').html('0');
    jQuery('#guiSpnPostfix').html('изображений');
    jQuery('#guiPDescription').css('color','#000000');
}

function closeModal(){
    var dialog = jQuery('#popUpWindow');
    jQuery.modal.close();
}

function showUserWindow(u_id) {
    jQuery.get('/member/block-mini/'+u_id, function(data) {
        var dialog = jQuery('#popUpWindow');
        jQuery('#popUpWindow').html(data);

        var options = {
            containerId : 'modalBigContainer',
            onShow : function() {

            },
            onClose : function() {
                closeModal();
            }
        };


        dialog.modal(options);
    });
}

function showPhotoWindow(p_id) {
    jQuery.get('/gallery/block-mini/'+p_id, function(data) {
        var dialog = jQuery('#popUpWindow');

        dialog.html(data);
        dialog.hide();
        dialog.load(function () {
            jQuery(this).show();
        });

        var options = {
            containerId : 'modalBigContainer',
            onClose : function() {
                closeModal();
            }
        };


        dialog.modal(options);
    });
}

/*
function showImgBigItems() {
    jQuery('#show_img_big_click').hide();
    jQuery('#show_img_preview_click').show();

    var img_curr;
    var img_count = jQuery('.img_showbig_item').get().length;

    for (i = 0; i < img_count; i++) {
        img_curr = jQuery('.img_showbig_item').eq(i).attr('src');

        var img = img_curr.replace('208x208_', '');
        jQuery('.img_showbig_item').eq(i).attr('src', img);
    }

}

function showImgPreviewItems() {
    jQuery('#show_img_preview_click').hide();
    jQuery('#show_img_big_click').show();

    var img_curr;
    var img_count = jQuery('.img_showbig_item').get().length;

    var regexp = /^(.+?)\/([^\/]+?)$/i;

    for (i = 0; i < img_count; i++) {
        img_curr = jQuery('.img_showbig_item').eq(i).attr('src');

        var img = img_curr.replace(regexp, '$1/208x208_$2');
        jQuery('.img_showbig_item').eq(i).attr('src', img);
    }

}
*/

function showImgBigItems(obj, not_left) {
    var img, img_curr;
    var img_count = obj.find('.img_showbig_item').get().length;

    for (i = 0; i < img_count; i++) {
        img_curr = obj.find('.img_showbig_item').eq(i).attr('src');

        var regexp = /^(.+)\/208x208_([a-z0-9\.]+)$/;
        if (regexp.test(img_curr)) {
            img = img_curr.replace('208x208_', '');
            obj.find('.img_showbig_item').eq(i).attr('src', img);

            obj.find('.img_showbig_item').eq(i).parents('div.comm-fotos-block').addClass('comm-fotos-block-big');

            if (not_left == 0) {
                if (obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText').length) {
                    obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText').parent().addClass('commentmove_59');
                    var mleft1 = obj.find('.img_showbig_item').eq(i).parents('div.pageContent').offset();
                    var mleft2 = obj.find('.img_showbig_item').eq(i).parents('table').offset();
                    obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText').parent().css("margin-left", mleft1.left-mleft2.left - 52).addClass(mleft1.left+"_"+mleft2.left);
                } else {
                    if (obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText1').length) {
                        obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText1').parent().addClass('commentmove_59');
                        obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText1').parent().css("margin-left", "-62px");
                    } else {
                        //obj.find('.img_showbig_item').eq(i).parents('div.comm-fotos-block').addClass('commentmove_59');
                        //obj.find('.img_showbig_item').eq(i).parents('div.comm-fotos-block').css("margin-left", "-59px");
                    }
                }
            }
            
            obj.find('.img_showbig_item').eq(i).addClass('bigs');
			obj.find('.img_showbig_item').parent().find('a').addClass('showbig_link');
        } else {
            img = img_curr.replace(/^(.+)\/([a-z0-9\.]+)$/, '$1/208x208_$2');
            obj.find('.img_showbig_item').eq(i).attr('src', img);
            
            obj.find('.img_showbig_item').eq(i).parents('div.comm-fotos-block').removeClass('comm-fotos-block-big');

            if (not_left == 0) {
                if (obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText').length) {
                    obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText').parent().removeClass('commentmove_59');
                    obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText').parent().css("margin-left", "0px");
                } else {
                    if (obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText1').length) {
                        obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText1').parent().removeClass('commentmove_59');
                        obj.find('.img_showbig_item').eq(i).parents('div.guiDivPostText1').parent().css("margin-left", "0px");
                    }
                }
            }

            obj.find('.img_showbig_item').eq(i).removeClass('bigs');
			obj.find('.img_showbig_item').parent().find('a').removeClass('showbig_link');
			
        }
    }

}

function showImgBigItemsBind() {
    jQuery('.img_showbig_item').live('click', function() {
        var post = false;

        post = jQuery(this).parents('table.article-index');
        if (post.find('.img_showbig_item').get().length) {
            showImgBigItems(post, 1);
            return true;
        }

        post = jQuery(this).parents('table.article-prev-tbl');
        if (post.find('.img_showbig_item').get().length) {
            showImgBigItems(post, 0);
            return true;
        }
        
        post = jQuery(this).parents('div.guiDivPostText');
        if (post.find('.img_showbig_item').get().length) {
            showImgBigItems(post, 0);
            return true;
        }

        post = jQuery(this).parents('#catalog-show-item-descr');
        if (post.find('.img_showbig_item').get().length) {
            showImgBigItems(post, 0);
            return true;
        }

        return true;
    });
}


jQuery(document).ready(function(){
    showImgBigItemsBind();
});

