var confirmYesCode, slt; jQuery(document).ready(function(){ var overlay = create( "div", { id: "ok_cms_overlay" }, ''); document.body.appendChild(overlay); var alertDiv = create( "div", { id: "ok_cms_op_AlertBox"}, ''); document.body.appendChild(alertDiv); var loadFileDiv = create( "div", { id: "ok_cms_op_loadFileDiv"}, ''); document.body.appendChild(loadFileDiv); $('#ok_cms_op_AlertBox').attr('innerHTML', '
'); $('#ok_cms_op_loadFileDiv').attr('innerHTML', '
Подождите пожалуйста,
идёт загрузка файла.
'); $("a:[rel=lightbox]").click(function(e) { imgPreview($(this).attr('href')); return false; }); $('#slideLeft').mouseover(function(){slideFilm(10)}); $('#slideRight').mouseover(function(){slideFilm(-10)}); $('#slideLeft').mouseout(function(){clearTimeout(slt)}); $('#slideRight').mouseout(function(){clearTimeout(slt)}); $('a.thumbnail').mouseover(function(){clearTimeout(slt)}); activatePlaceholders(); doBlink(); } ); function okAlert(content, heading, width){ width = width>0 ? width : 400; showAlertBox(width, content+'
', heading ? heading : 'Внимание!'); return false; } function okConfirm(content, heading, yesCode, width){ width = width>0 ? width : 400; confirmYesCode = yesCode; showAlertBox(width, '
'+content+'
 
', heading ? heading : 'Вопрос'); } function confirmYes(){ hideAlertBox(1); confirmYesCode.call(); } function showAlertBox(width, content, heading, callBack){ var marginLeft = Math.round(width/2)*-1; $('#ok_cms_overlay').fadeIn(300, function() { $('#alertBoxContent').attr('innerHTML', content); $('#alertBoxHeading').attr('innerHTML', heading); $('#ok_cms_op_AlertBox').width(width); var height=$('#ok_cms_op_AlertBox').height(); var marginTop = (Math.round(height/2)*-1)-30; $('#ok_cms_op_AlertBox').css('margin-top', marginTop); $('#ok_cms_op_AlertBox').css('margin-left', marginLeft); $('#ok_cms_op_AlertBox').fadeIn(300, callBack); }); } function hideAlertBox(noHideOverlay){ $('#ok_cms_op_AlertBox').fadeOut(300,function() {if(noHideOverlay!=1) hideOverlay()}); } function showOverlay(){ $('#ok_cms_overlay').fadeIn(300); } function hideOverlay(){ $('#ok_cms_overlay').fadeOut(300); } function create( name, attributes ) { var el = document.createElement( name ); if ( typeof attributes == 'object' ) { for ( var i in attributes ) { el.setAttribute( i, attributes[i] ); if ( i.toLowerCase() == 'class' ) { el.className = attributes[i]; // for IE compatibility } else if ( i.toLowerCase() == 'style' ) { el.style.cssText = attributes[i]; // for IE compatibility } } } for ( var i = 2; i < arguments.length; i++ ) { var val = arguments[i]; if ( typeof val == 'string' ) { val = document.createTextNode( val ) }; el.appendChild( val ); } return el; } function imgPreview(href){ var imgPreloader = new Image(); showOverlay(); imgPreloader.onload = (function(){ showAlertBox(imgPreloader.width+25, '', 'Просмотр изображения'); }) imgPreloader.src = href; } function ajaxRollUpDown(elementName, buttonName, ajaxURL){ $.ajax({ url: ajaxURL, type: "GET", data: {'shown': ($(elementName).is(":hidden") ? 1 : 0)}, context: document.body, success: function(){ rollUpDown(elementName, buttonName); } }); } function rollUpDown(elementName, buttonName){ if($(elementName).is(":hidden")) $(elementName).slideDown(500, function() {$(buttonName).attr("innerHTML", "[ свернуть ]")}) else $(elementName).slideUp(500, function() {$(buttonName).attr("innerHTML", "[ развернуть ]")}); } function ajaxForm(ajaxFile, width, title, parameter, callBack){ $.ajax({ url: ajaxFile, type: "GET", data: parameter, context: document.body, error: function(xhr, ajaxOptions, thrownError){ hideOverlay(); alert('Errorcode: '+xhr.status); if(thrownError) alert('Errorcode: '+thrownError); }, success: function(data){ showAlertBox(width, data, title, callBack); } }); } function showLoadFile(){ $('#ok_cms_overlay').fadeIn(300, function() { $('#ok_cms_op_loadFileDiv').fadeIn('fast'); }); } function hideLoadFile(){ $('#ok_cms_op_loadFileDiv').fadeOut('fast', function() { $('#ok_cms_overlay').fadeOut('fast'); }); }