var imagesCount = 14 var imagesLinks = new Array(); var loadedImages = new Array(1, 0, 0, 0, 0, 0, 0, 0); var logoChangeTimeout = 6500; for(i=0; i<=imagesCount; i++) switch(i) { case 3: imagesLinks[i] = "http://www.bo-mond.ru/"; break; default: imagesLinks[i] = ""; break; } ;jQuery.loadMyImages = function(imgUrls, callback, delay) { var allImgs = [], loaded = 0, needto = imgUrls.length, errorDelay = 999, errorTimer function onImgComplete() { if (++loaded == needto) callback() else loadImg() } function loadImg() { allImgs[loaded] = new Image() $(allImgs[loaded]).bind('error load', onImgComplete) allImgs[loaded].src = imgUrls[loaded] } loadImg() return 0 }; function mouseX(e) { if (e.pageX) return e.pageX; if (e.clientX) return e.clientX + document.body.scrollLeft; } function mouseY(e) { if(e.pageY) return e.pageY; if(e.clientY) return e.clientY + document.body.scrollTop; } function getElementPosition(element) { var left = element.offsetLeft; var top = element.offsetTop; for (var parent = element.offsetParent; parent; parent = parent.offsetParent) { left += parent.offsetLeft - parent.scrollLeft; top += parent.offsetTop - parent.scrollTop } return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight}; } function showFileDiv(id, e) { var div = document.getElementById(id); div.style.left = (mouseX(e) - Math.round(div.offsetWidth/2)) + "px"; div.style.top = (mouseY(e) - Math.round(div.offsetHeight/2)) + "px"; div.style.visibility = "visible"; } function moveFileDiv(div, elementId, e) { var position = getElementPosition(document.getElementById(elementId)); var move = true; var divX = parseInt(div.style.left) + Math.round(div.offsetWidth/2); var divY = parseInt(div.style.top) + Math.round(div.offsetHeight/2); if ((divX < position.left || divX > (position.left + position.width)) || (divY < position.top || divY > (position.top + position.height))) move = false; if (move) { div.style.left = (mouseX(e) - div.offsetWidth/2 - 100) + "px"; div.style.top = (mouseY(e) - div.offsetHeight/2) + "px"; } else div.style.visibility = "hidden"; } function AddImage(fileName) { SetText("[картинка=\"/images/upload/" + fileName + "\"]"); } function DeleteImage(fileId) { $.get("/index.php?page=admin&module=drop&image=" + fileId, {}, function(data){ if (data.indexOf('') >= 0) { data = data.split('')[1]; if (data.indexOf('') >= 0) { data = data.split('')[0]; if (data == '1') { document.getElementById("file" + fileId).style.display = "none"; } else alert("Не удалось удалить файл!"); } else alert("Ошибка соединения с сервером!"); } else alert("Ошибка соединения с сервером!"); }); } function uploadComplete(fileId, fileName) { document.getElementById('files').innerHTML += "" + fileName + " (просмотр, удалить)
"; $("a[@rel='lightbox-file" + fileId + "']").slimbox(); document.getElementById("uploadLinkWait").style.display = 'none'; document.getElementById("uploadLink").style.display = 'block'; } function uploadFail(errorMessage) { alert(errorMessage); document.getElementById("uploadLinkWait").style.display = 'none'; document.getElementById("uploadLink").style.display = 'block'; } function uploadForm() { document.getElementById("uploadLink").style.display = 'none'; document.getElementById("uploadLinkWait").style.display = 'block'; document.forms["uploadFileForm"].submit(); } var thumbs = new Array(0, 0, 0, 0, 0) function ThumbMouseOver(id) { if (thumbs[id] == 0) { thumbs[id] = 1; $("img#thumb" + id).fadeIn(300, function() { if (thumbs[id] == 2) { thumbs[id] = 3; ThumbMouseOut(id); } thumbs[id] = 3; } ); } else if (thumbs[id] == 2) thumbs[id] = 1; else if ((thumbs[id] == 4) || (thumbs[id] == 5)) thumbs[id] = 2; } function ThumbMouseOut(id) { if (thumbs[id] == 1) thumbs[id] = 2; else if (thumbs[id] == 3) { thumbs[id] = 4; $("img#thumb" + id).fadeOut(300, function() { if (thumbs[id] == 5) { thumbs[id] = 0; ThumbMouseOver(id); } thumbs[id] = 0; } ); } else if (thumbs[id] == 5) thumbs[id] = 4; } function SetText(text) { obj = document.forms["editform"].desc obj.focus(); if (document.selection) { var s = document.selection.createRange(); s.text = text // s.select(); } else if (typeof(obj.selectionStart)=="number") { var start = obj.selectionStart; var end = obj.selectionEnd; obj.value = obj.value.substr(0,start)+text+obj.value.substr(end); obj.setSelectionRange(end,end); } else SetQTag(st,fn,pr) } function SetQTag(st,fn,pr) { text = prompt("Magic Holidays",pr) if (text != null) SetText(st+text+fn) } function SetTag(st,fn,pr) { obj = document.forms["editform"].desc obj.focus(); if (document.selection) { var s = document.selection.createRange(); if (s.text.length > 0) { s.text = st + s.text + fn // s.select(); } else SetQTag(st,fn,pr) } else if (typeof(obj.selectionStart)=="number") { if (obj.selectionStart!=obj.selectionEnd) { var start = obj.selectionStart; var end = obj.selectionEnd; var rs = st+obj.value.substr(start,end-start)+fn obj.value = obj.value.substr(0,start)+rs+obj.value.substr(end); obj.setSelectionRange(end,end); } else SetQTag(st,fn,pr) } else SetQTag(st,fn,pr) } function GetObjectById(id) { src = "/images/magicholidays/logo_" + id + ".jpg"; if (imagesLinks[id] == "") { $("img#uplogo_image").attr("src", src); return $("img#uplogo_image"); } else { $("img#uplogo_linked_image").attr("src", src); $("a#uplogo_link").attr("href", imagesLinks[id]); return $("a#uplogo_link"); } } var lastObject = null; function ChangeImage(id) { lastObject.fadeOut(600, function() { LoadImage(id, ShowImage); } ); } function ShowImage(id) { lastObject = GetObjectById(id); lastObject.fadeIn(600, function() { id++; if (id > imagesCount) id = 1; setTimeout("ChangeImage(" + id + ")", logoChangeTimeout); } ); } function LoadImage(id, callback) { if (loadedImages[id] == 0) { $.loadMyImages(new Array("/images/magicholidays/logo_" + id + ".jpg"), function() { loadedImages[id] = 1; callback(id); }, 0); } else callback(id); } function Init() { $("a[rel='captcha_refresh']").each( function() { this.href = 'javascript:void(0);' $(this).click( function() { src = '/index.php?page=captcha&key=' + String(Math.random()).substr(2) $.loadMyImages(new Array(src), function () { $("img[@rel='captcha']").each( function() { this.src = src } ) } ) } ) } ); $("img#thumb1").fadeOut(1); $("img#thumb2").fadeOut(1); $("img#thumb3").fadeOut(1); $("img#thumb4").fadeOut(1); lastObject = $("img#uplogo_image"); setTimeout("ChangeImage(2)", logoChangeTimeout); } $(document).ready(Init)