var confirmYesCode, slt, tabShown; var W3CDOM = (document.createElement && document.getElementsByTagName); var redirectTimer = 15; var agt=navigator.userAgent.toLowerCase(); var is_major = parseInt(navigator.appVersion); var IE = /*@cc_on!@*/false; var FF = /a/ [-1] == 'a'; var IE6 = (IE && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) ); jQuery(document).ready(function(){ var ajaxBoxMouseOver = false; $('input[placeholder],textarea[placeholder]').placeholder(); jQuery.validator.addClassRules("required", { required: true, date: false }); $("a:[rel=lightbox]").click(function(e) { imgPreview($(this).attr('href')); return false; }); var alertDiv = create("div",{ id: "ok_cms_op_AlertBox"},''); document.body.appendChild(alertDiv); $('#ok_cms_op_AlertBox').html('

x

'); $("#ok_cms_op_AlertBox").draggable({handle: 'h1.infoBoxHeading', opacity: 0.8}); $('.tab').click(function(){showTab(this.id, this.onclick); return false;}); $('.tab1').click(function(){showTab1(this.id, this.onclick); return false;}); $('.hideTab1').click(function(){hideTab1( (this.id).replace('hide_', ''), this.onclick); return false;}); redrawSelects(); $(".list tr:nth-child(odd)").addClass("odd"); $('.showItemPopup').click(function(){ajaxForm(this.href,650,this.title,{'id':this.rel},this.onclick); return false}); $('#selectAllRows').click(function(){$('.checkTableRow').attr('checked',$(this).attr('checked'));}); initShowHide(); // doBlink(); $(document).pngFix({ blankgif:'/img/blank.gif' }); } ); function okChangeLanguage(language_id){ $.ajax({ url: "http://mvorobiev.de/ajaxJobs/ok_cms_op/ok-cms-op-selectLanguage.php", type: "GET", data: {'language_id': language_id}, context: document.body, error: function(xhr, ajaxOptions, thrownError){ alert('Errorcode: '+xhr.status); if(thrownError) alert('Errorcode: '+thrownError); }, success: function(data){ if(data=='ok') reloadPage(); else alert(data); } }); } 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 handleEscape(e){ if(e.keyCode == 27)hideAlertBox(); } function confirmYes(){ hideAlertBox(1); confirmYesCode.call(); } function showAlertBox(width, content, heading, callBack){ var marginLeft = Math.round(width/2)*-1; showOverlay(function() { $('#alertBoxContent').html( content); $('#alertBoxHeading').html( heading); $('#ok_cms_op_AlertBox').width(width); $('#ok_cms_op_AlertBox').css('left','50%'); $('#ok_cms_op_AlertBox').css('top',Math.max($(document).scrollTop() + Math.round($(window).height()/2) - Math.round($('#ok_cms_op_AlertBox').height()/2),20)); $('#ok_cms_op_AlertBox').css('margin-left',marginLeft); $('#ok_cms_op_AlertBox').fadeIn(300, callBack); redrawSelects(); alertShow=false; }); $(document).keypress(function(e){handleEscape(e)}); } function hideAlertBox(noHideOverlay){ $(document).unbind("keydown",handleEscape); $('#ok_cms_op_AlertBox').fadeOut(300,function(){if(noHideOverlay!=1){hideOverlay();}}); } function showOverlay(callBack){ var overlay = create( "div", { id: "ok_cms_overlay" }, ''); document.body.appendChild(overlay); $('#ok_cms_overlay').css("opacity","0.5").fadeIn(300,callBack); } function hideOverlay(){ $('#ok_cms_overlay').fadeOut(300,function(){document.body.removeChild(document.getElementById("ok_cms_overlay"));}); } 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(); var imgPreviewDiv = create( "div", { id: "imgPreview"}, ''); document.body.appendChild(imgPreviewDiv); showOverlay(); $('.buttonBar').fadeOut('fast'); $('#ok_img_preview').fadeOut('fast') $('#imgPreview').fadeIn('fast'); var objects = $('a:[rel=lightbox]'); var imgCount = objects.length; objects.each(function(index, element) { if( $(element).attr('href') == href ) imgIndex = index+1; }); var imgAlt = $(objects[imgIndex-1]).attr('title'); imgPreloader.onload = (function(){ $('#imgPreview').html( '
'+(imgAlt!='' && imgAlt!='undefined' ? ''+imgAlt+' – ' : '')+'изображение '+imgIndex+' из '+imgCount+'
'+ (imgCount > 1 && imgIndex > 1 ? 'перейти к первому изображению' : '
  • перейти к первому изображению
  • ')+ (imgIndex > 1 ? '' : '')+ ((imgIndex < imgCount) && (imgCount > 1) ? '' : '')+ (imgCount > 1 && imgIndex < imgCount ? 'перейти к последнему изображению' : '
  • перейти к последнему изображению
  • ')+ 'Закрыть
    '); var marginTop = Math.round(imgPreloader.height/2)*-1; var marginLeft = Math.round(imgPreloader.width/2)*-1; $('#imgPreview').animate({ 'width': imgPreloader.width, 'marginLeft': marginLeft }, 500, function(){ $('#imgPreview').animate({ 'height': imgPreloader.height, 'marginTop': marginTop-40 }, 500, function(){ $('#ok_img_preview').fadeIn('fast', function(){ $('#imgPreview').animate({'height': imgPreloader.height+40},300, function(){ $('.buttonBar').fadeIn('fast'); }); }); }); }); }); imgPreloader.src = href; } function hidePreview(){ $('#imgPreview').fadeOut('fast',function(){document.body.removeChild(document.getElementById("imgPreview"));hideOverlay();}); } 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() { var loadFileDiv = create( "div", { id: "ok_cms_op_loadFileDiv"}, ''); document.body.appendChild(loadFileDiv); $('#ok_cms_op_loadFileDiv').html('
    Подождите пожалуйста,
    идёт загрузка файла.
    '); $('#ok_cms_op_loadFileDiv').fadeIn('fast'); }); } function hideLoadFile(){ $('#ok_cms_op_loadFileDiv').fadeOut('fast', function() { document.body.removeChild(document.getElementById("ok_cms_op_loadFileDiv")); $('#ok_cms_overlay').fadeOut('fast'); }); } function getAjaxBox(item,tableName,fieldName,whereClause){ if($(item).val().length>1){ var ajaxBoxDiv = create("div",{id:"ajaxBoxDiv",onmouseover:"ajaxBoxMouseOver=true",onmouseout:"ajaxBoxMouseOver=false"},''); document.body.appendChild(ajaxBoxDiv); $('#ajaxBoxDiv').css("background-image","url(/img/animations/ajax-loader-small.gif)"); $.ajax({ url: "http://mvorobiev.de/ajaxJobs/getAjaxBox.php", type: "POST", data: {'item': item, 'value': $(item).val(),'tableName': tableName,'fieldName': fieldName,'whereClause': whereClause}, context: document.body, error: function(xhr, ajaxOptions, thrownError){ alert('Errorcode: '+xhr.status); if(thrownError) alert('Errorcode: '+thrownError); }, success: function(data){ if(data){ $('#ajaxBoxDiv').css("background-image","none"); $('#ajaxBoxDiv').css({"left": $(item).offset().left,"top": ($(item).offset().top + $(item).height()) }); $('#ajaxBoxDiv').width($(item).width()); $('#ajaxBoxDiv').attr("innerHTML",data); $('#ajaxBoxDiv').show(); } else { $('#ajaxBoxDiv').hide(); ajaxBoxMouseOver=false; } } }); } else { $('#ajaxBoxDiv').hide(); ajaxBoxMouseOver=false; } return true; } function setAjaxBox(item,value){ $(item).val(value); $('#ajaxBoxDiv').hide(); ajaxBoxMouseOver=false; return true; } function hideAjaxBox(item,value){ if(!ajaxBoxMouseOver) { $('#ajaxBoxDiv').hide(); ajaxBoxMouseOver=false; } } function showTab(id, callBack){ if(id!=tabShown){ if(tabShown) $('#tab_'+tabShown).slideUp('fast'); $('#tab_'+id).slideDown('fast', function(){$('#'+id).css('background-image','url(/img/buttons/up.png)'); $('#'+id).addClass('hover'); $('#'+tabShown).css('background-image','url(/img/buttons/down.png)',$('#'+tabShown).removeClass('hover')); tabShown=id; if(typeof callBack == 'function') callBack.call()}); $.ajax({ url: "http://mvorobiev.de/ajaxJobs/saveTabSession.php", type: "GET", data: {'varName':tabSessionVariable,'tabId': id}, context: document.body }); } } function showTab1(id, callBack){ $('#'+id).hide(); $('#tab1_'+id).slideDown('fast', function(){if(typeof callBack == 'function') callBack.call()}); } function hideTab1(id, callBack){ $('#'+id).show(); $('#tab1_'+id).slideUp('fast', function(){if(typeof callBack == 'function') callBack.call()}); } function showItemMap(lat,lng,mapZoom,marker){ initialize_map(lat,lng,mapZoom); if(marker) map.addOverlay(new GMarker(new GLatLng(lat,lng))); } function clearFormFileds(formName){ $(':input',formName) .not(':button, :submit, :reset, :hidden') .val(''); $('input[placeholder],textarea[placeholder]').placeholder(); } function activateTinyMCE(){ } function activateTinyMCElight(mode, element){ tinyMCE.init({ mode : mode ? mode : "textareas", language : "ru", elements : element, theme : "advanced", skin : "o2k7", skin_variant : "silver", plugins : "safari,advhr,advlink,emotions,contextmenu,paste,directionality,visualchars,nonbreaking,xhtmlxtras,inlinepopups", // Theme options theme_advanced_buttons1 : "bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,fontsizeselect,cut,copy,paste,pastetext,pasteword,selectall", theme_advanced_buttons2 : "bullist,numlist,undo,redo,link,unlink,forecolor,backcolor,code", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_resizing : false, // Example content CSS (should be your site CSS) content_css : "/css/tinyMCE-content.css", force_br_newlines : true, forced_root_block : '', paste_create_paragraphs : false, paste_create_linebreaks : false, paste_use_dialog : true, paste_auto_cleanup_on_paste : true, paste_strip_class_attributes : true, paste_remove_spans : true, paste_remove_styles : true, paste_remove_styles_if_webkit : true, paste_convert_middot_lists : false, paste_unindented_list_class : "unindentedList", paste_convert_headers_to_strong : true, //Mad File Manager relative_urls : true, remove_script_host : true, file_browser_callback : MadFileBrowser }); } function activateTinyMCEeasy(mode, element){ tinyMCE.init({ mode : mode ? mode : "textareas", language : "ru", elements : element, theme : "advanced", skin : "o2k7", skin_variant : "silver", plugins : "safari,advhr,advlink,emotions,contextmenu,paste,directionality,visualchars,nonbreaking,xhtmlxtras,inlinepopups", // Theme options theme_advanced_buttons1 : "bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,fontsizeselect,cut,copy,paste,bullist,numlist,undo,redo,forecolor,backcolor,emotions", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "center", theme_advanced_resizing : false, // Example content CSS (should be your site CSS) content_css : "/css/tinyMCE-content.css", force_br_newlines : true, forced_root_block : '', paste_create_paragraphs : false, paste_create_linebreaks : false, paste_use_dialog : true, paste_auto_cleanup_on_paste : true, paste_strip_class_attributes : true, paste_remove_spans : true, paste_remove_styles : true, paste_remove_styles_if_webkit : true, paste_convert_middot_lists : false, paste_unindented_list_class : "unindentedList", paste_convert_headers_to_strong : true }); } function MadFileBrowser(field_name, url, type, win) { tinyMCE.activeEditor.windowManager.open({ file : "/script/tiny_mce/plugins/mfm.php?field=" + field_name + "&url=" + url + "", title : 'BOXHEADING_FILE_MANAGER', width : 640, height : 450, resizable : "no", inline : "yes", close_previous : "no" }, { window : win, input : field_name }); return false; } function redrawSelects(){ $.each($('select.rounded'),function(i,k){$(k).selectmenu({style:'dropdown', width: $(k).css('width')});}); } function goTo(URL, target) { if (target == null) target = 'parent'; if (navigator.appName == "Netscape") eval('window.' + target + '.location = "' + URL + '"'); else eval('window.' + target + '.navigate("' + URL + '")') } function checkFields(elmts, rules, formID) { var valid = true; var requredOK = true; var errorMessage = []; $.each($((formID?'#'+formID+' ':'')+'.required').get().reverse(),function(i,k){ $(k).removeClass('errorField'); $('#label_' + $(k).attr('id')).removeClass('error'); if($(k).val()=='') { $('#label_' + $(k).attr('id')).addClass('error'); $(k).addClass('errorField'); if(valid) errorMessage[errorMessage.length] = 'ERROR_FIELD_REQUIRED'; valid = valid && false; requredOK = requredOK && false; $(k).focus(); } }); if(elmts.length>0){ elmts.reverse(); rules.reverse(); for (index = 0; index < elmts.length; index++) { elmt = elmts[index]; $('#label_' + elmt).removeClass('error'); $('#' + elmt).removeClass('errorField'); if (typeof rules[index][0] == 'object') { for (ind = 0; ind < rules[index][0].length; ind++) { if (eval(rules[index][0][ind])) { $('#label_' + elmt).addClass('error'); $('#' + elmt).addClass('errorField'); valid = false; if(requredOK){ $('#' + elmt).focus(); errorMessage[errorMessage.length] = rules[index][1][ind]; } break; } } } else if (eval(rules[index][0])) { $('#label_' + elmt).addClass('error'); $('#' + elmt).addClass('errorField'); valid = false; if(requredOK){ $('#' + elmt).focus(); errorMessage[errorMessage.length] = rules[index][1]; } } } } errorMessage.reverse(); return [valid, errorMessage]; } function checkEmail(eMail) { var pattern1 = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}([\w-]+\.)+[a-zA-Z]{2,7}$/; var pattern2 = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/; return (pattern1.test(eMail) || pattern2.test(eMail)) } function redirectToURL(url) { if (redirectTimer == 0) { goTo(url) } else { $('#timerContainer').attr('innerHTML', redirectTimer); setTimeout("redirectToURL('" + url + "')", 1000); redirectTimer-- } } function selectAllRows() { $('.rowSelect').attr('checked', $('#rowSelectAll:checked').val() == 1) } function toInt(x) { return parseInt(parseFloat(x)) } function doBlink() { $('.blink').fadeOut('slow', function () { $('.blink').fadeIn('slow') }); setTimeout("doBlink()", 3000) } function reloadPage() { window.location.reload(); return 0 } function initShowHide(){ $('.showHide').click(function(){ var containerId = '#'+this.rel; if($(containerId).is(':hidden')) $(containerId).slideDown(); else $(containerId).slideUp(); }); }