/**
 *  jquery.popupt
 *  (c) 2008 Semooh (http://semooh.jp/)
 *
 *  Dual licensed under the MIT (MIT-LICENSE.txt)
 *  and GPL (GPL-LICENSE.txt) licenses.
 *
 **/
(function($){
	$.fn.extend({
		imghover: function(opt){
			return this.each(function() {
        opt = $.extend({
            prefix: '',
            suffix: '_o',
            src: '',
            btnOnly: true,
            fade: false,
            fadeSpeed: 100
          }, opt || {});

        var node = $(this);
				if(!node.is('img')&&!node.is(':image')){
          var sel = 'img,:image';
          if (opt.btnOnly) sel = 'a '+sel;
          node.find(sel).imghover(opt);
          return;
        }

        var orgImg = node.attr('src');

        var hoverImg;
        if(opt.src){
          hoverImg = opt.src;
        }else{
          hoverImg = orgImg;
          if(opt.prefix){
            var pos = hoverImg.lastIndexOf('/');
            if(pos>0){
              hoverImg = hoverImg.substr(0,pos-1)+opt.prefix+hoverImg.substr(pos-1);
            }else{
              hoverImg = opt.prefix+hoverImg;
            }
          }
          if(opt.suffix){
            var pos = hoverImg.lastIndexOf('.');
            if(pos>0){
              hoverImg = hoverImg.substr(0,pos)+opt.suffix+hoverImg.substr(pos);
            }else{
              hoverImg = hoverImg+opt.suffix;
            }
          }
        }

        if(opt.fade){
          var offset = node.offset();
          var hover = node.clone(true);
          hover.attr('src', hoverImg);
          hover.css({
            position: 'absolute',
            left: offset.left,
            top: offset.top,
            zIndex: 1000
          }).hide().insertAfter(node);
          node.mouseover(
            function(){
              var offset=node.offset();
              hover.css({left: offset.left, top: offset.top});
              hover.fadeIn(opt.fadeSpeed);
              node.fadeOut(opt.fadeSpeed,function(){node.show()});
            }
          );
          hover.mouseout(
            function(){
              node.fadeIn(opt.fadeSpeed);
              hover.fadeOut(opt.fadeSpeed);
            }
          );
        }else{
          node.hover(
            function(){node.attr('src', hoverImg)},
            function(){node.attr('src', orgImg)}
          );
        }
			});
		}
	});
})(jQuery);










/**
 * jGlycy
 * (c) 2008 Semooh (http://semooh.jp/)
 * 
 */
(function($, prefix, jg){
  $[jg] = $({});
  $[jg].extend({
    invoke: function(nodes) {
      nodes.each(function(){
        var node = this;
        var funcs = $(node).attr(prefix).split(',');
        $(funcs).each(function(){
          var arg = $(node).attr(prefix + ":" + this);
          if(arg) {
            eval('var options = {' + arg + '}');
          } else {
            var options = {};
          }
          if($.fn[this]) {
            $(node)[this](options);
          }
        });
      });
    },
    invokeElement: function(node) {
      $[jg].invoke($("*[" + prefix + "]", node));
    }
  });
  $(document).ready(function(){
    $[jg].invokeElement(document);
  });
})(jQuery, "jg", "jg");







var rurl2='';
var rcount2=0;

 
function AJAX(url)
{
 rurl2=url;
    if (window.XMLHttpRequest) {
        req2 = new XMLHttpRequest();
        req2.onreadystatechange = processReqChange2;
        req2.open("GET", url, true);
        req2.send(null);
    } else if (window.ActiveXObject) {
        req2 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req2) {
            req2.onreadystatechange = processReqChange2;
            req2.open("GET", url, true);
            req2.send();
        }
    }
}

 

function processReqChange2()
{
 if (req2.readyState == 4)
 {
  if (req2.status == 200)
   {
    rcount2=0;
    if (req2.overrideMimeType)
     req2.overrideMimeType('text/html');
    var s=req2.responseText;
    eval(s);
   }
  else
  {
   if (rcount2<10)
    {
     rcount2++;
     AJAX(rurl2);
    } 
  }
 }
}



function g(id)
{
 return document.getElementById(id);
}  

function show(id)
{
 var x=g(id)
 if (x!=null)
  x.style.display='block';
}

function hide(id)
{
 var x=g(id)
 if (x!=null)
  x.style.display='none';
}


function closepopup()
{
 hide("popup");
 hide("close");
}


function addcode(s)
{
 tinyMCE.getInstanceById('newpost').focus();
 tinyMCE.activeEditor.selection.setContent(s);
}

function youtube()
{
 var t='';
 t+='<table style="padding:0; margin:0;width:100%; text-align:left;" ><tr><td rowspan=2 style="padding:0; padding-left:50px;" >';
 t+='<Br><br><br>Найдите на странице с роликом поле "Embed":<br><br><Br><table style="padding:0; margin:0;"><tr><td class=pic11 style="padding:0;margin:0"> </td><td style="padding:0;margin:0" class=picbg> </td><td style="padding:0;margin:0" class=pic12> </td></tr><tr><td style="padding:0;margin:0" class=picbg> </td><td style="padding:0;margin:0"><img src=/i/youtube1.jpg></td><td style="padding:0;margin:0" class=picbg> </td></tr><tr><td style="padding:0;margin:0" class=pic21></td><td style="padding:0;margin:0" class=picbg></td><td style="padding:0;margin:0" class=pic22> </td></tr></table><br><br>';
 t+='<table style="padding:0; margin:0;"><tr><td style="padding:0;margin:0" class=pic11> </td><td style="padding:0;margin:0" class=picbg> </td><td style="padding:0;margin:0" class=pic12> </td></tr><tr><td style="padding:0;margin:0" class=picbg> </td><td style="padding:0;margin:0"><img src=/i/youtube2.jpg></td><td style="padding:0;margin:0" class=picbg> </td></tr><tr><td style="padding:0;margin:0" class=pic21></td><td style="padding:0;margin:0" class=picbg></td><td style="padding:0;margin:0" class=pic22> </td></tr></table><br><br>Скопируйте полностью код из поля embed сюда:<br><br>';
 t+='<input id=first type=text name=login class=inp17 style="width:300px;"><br><br><br><br>';
 t+='</td><td style="padding:0;vertical-align:top; width:40px; text-align:right;"><a href=javascript:closepopup();><img style="border:1px solid black" src=/i/close.gif alt="Закрыть"></a></td></tr>';
 t+='<td style="padding:0; vertical-align:bottom; text-align:right;"><a href=javascript:addyoutube()><img src=/i/button.gif></a></td></tr></table></form>';

 g('popup').style.top="250px";
 g('popup').style.left="200px";
 g('popup').style.width="400px";
 g('popup').style.right="";

 g('popup').innerHTML=t;
 show('popup');
 show('close');
 window.scroll(0,0);
 g('first').focus();
}

function addyoutube()
{ 
 closepopup();
 var x=g('first').value;
// x="<div class=youtube><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"+x.substr(8)+"</div>";
 x="<div class=youtube>"+x+"</div>";
 addcode(x);
}

function picture()
{
 var t='';
 t+='<form onsubmit=showloader() target=loadpic action=/useruploadpic/ method=post enctype="multipart/form-data" method=post> <input type=hidden name=MAX_FILE_SIZE value=900000>';
 t+='<table style="padding:0; margin:0;width:100%; text-align:left;" ><tr><td rowspan=2 style="padding:0; padding-left:50px;" >';
 t+='<br><br><br><b>Добавление картинки</b><br><br><br>';
 t+='<iframe frameborder=0 style="margin:0;padding:0;width:1px;height:1px;" name=loadpic> </iframe>'
 t+='<div id=loading>Файл в формате jpeg, gif или png размерами до 500 кб.:</div><br><br>';
 t+='<input id=first type=file name=pic class=inp17 style="width:300px;"><br><br><br><br>';
 t+='</td><td style="padding:0;vertical-align:top; width:40px; text-align:right;"><a href=javascript:closepopup();><img style="border:1px solid black" src=/i/close.gif alt="Закрыть"></a></td></tr>';
 t+='<td style="padding:0; vertical-align:bottom; text-align:right;"><input type=image src=/i/button.gif></td></tr></table></form>';

 g('popup').style.top="250px";
 g('popup').style.left="200px";
 g('popup').style.width="400px";
 g('popup').style.right="";

 g('popup').innerHTML=t;
 show('popup');
 show('close');
 window.scroll(0,0);
 g('first').focus();
}

function showloader()
{
 g('loading').innerHTML='<img src=/i/ajax-loader.gif>';
 return true; 
}

function stoploading()
{
 g('loading').innerHTML='';
 g('picfield').value='';
 return true; 
}
