
function fu_TextMaxLen(poEvent,piMaxLen, psOutID){
/*Запрещает ввод в TextArea больше определенной длины*/

	poEvent = poEvent || window.event

  var loClickedE = poEvent.target || poEvent.srcElement

  if(loClickedE.value.length>piMaxLen){
		loClickedE.value=loClickedE.value.substr(0,piMaxLen)
  }
	
	if (psOutID) {
		fu_CalcInputSimb(poEvent, psOutID)
	}
}

function fu_CalcInputSimb(poEvent, psOutID){
	/*Считает к-во символов введенных в поле и отображает в другом объекте*/
	poEvent = poEvent || window.event

  var loClickedE = poEvent.target || poEvent.srcElement
	
	document.getElementById(psOutID).innerHTML=loClickedE.value.length
}


function ajaxRB(BID, ARB_BID, ARB_TARGET, ARB_BLOCK, ARB_DATA)
{
var arb_target=document.getElementById(ARB_TARGET);
var arb_owner=document.getElementById(ARB_BID);
var arb_block=document.getElementById(ARB_BLOCK);
//$.ajax('plug.php?e=ajax', {uid: UID, bid: BID}, function(data){stats.innerHTML=data;});
$.ajax({
  type: 'GET',
  url: 'plug.php?e=ajax&'+BID,
  beforeSend: function(){
	if(arb_owner){arb_owner.style.color = '#5e720f'; arb_owner.style.cursor = 'auto';}
	arb_block.Sunny_progressBar = 1;
	fu_TMenu_OpacityReset(ARB_BLOCK);
    arb_block.innerHTML='<center><img style="margin-top:5px;" src="http://www.sunny-cat.ru/js/loader.gif" alt="" /></center>';
	fu_TMenu_OpacityDown(ARB_BLOCK,0.1,100);	
  },
  success: function(answ){
	arb_block.Sunny_progressBar = 0;
    arb_target.innerHTML=answ;
	$('#'+ARB_TARGET).slideToggle('slow');
	userblock_notice_hide(ARB_BLOCK, ARB_DATA);
  }
});
}

function ajaxTB(BID, XS, ATB_BID, ATB_TARGET, ATB_BLOCK, ATB_DATA)
{
var atb_target=document.getElementById(ATB_TARGET);
var atb_owner=document.getElementById(ATB_BID);
var atb_block=document.getElementById(ATB_BLOCK);

var p1=document.getElementById('p1');
var p2=document.getElementById('p2');
var p3=document.getElementById('p3');
var p4=document.getElementById('p4');
var p5=document.getElementById('p5');
var p6=document.getElementById('p6');
var p7=document.getElementById('p7');
var p8=document.getElementById('p8');
var p9=document.getElementById('p9');
var p10=document.getElementById('p10');
var p11=document.getElementById('p11');
var p12=document.getElementById('p12');
var p13=document.getElementById('p13');
var p14=document.getElementById('p14');
var p15=document.getElementById('p15');
var p16=document.getElementById('p16');
var p17=document.getElementById('p17');
var p18=document.getElementById('p18');
var p19=document.getElementById('p19');
var p20=document.getElementById('p20');

$.ajax({
  type: 'POST',
  url: BID,
  data:  {x: XS, p1: p1.value, p2: p2.value, p3: p3.value, p4: p4.value, p5: p5.value, p6: p6.value, p7: p7.name, p8: p8.value, p9: p9.value, p10: p10.value, p11: p11.value, p12: p12.value, p13: p13.value, p14: p14.value, p15: p15.value, p16: p16.value, p17: p17.value, p18: p18.value, p19: p19.value, p20: p20.value},
  beforeSend: function(){
	if(atb_owner){atb_owner.style.color = '#5e720f'; atb_owner.style.cursor = 'auto';}
	atb_block.Sunny_progressBar = 1;
	fu_TMenu_OpacityReset(ATB_BLOCK);
    atb_block.innerHTML='<center><img style="margin-top:5px;" src="http://www.sunny-cat.ru/js/loader.gif" alt="" /></center>';
	fu_TMenu_OpacityDown(ATB_BLOCK,0.1,100);
  },
  success: function(answ){
	atb_block.Sunny_progressBar = 0;
    atb_target.innerHTML=answ;
	$('#'+ATB_TARGET).slideToggle('slow');
	userblock_notice_hide(ATB_BLOCK, ATB_DATA);
  }
});
}

var PrevID='NON';
var PrevTARGET='NON';
function ajaxblock_show(BID, ABS_BID, ABS_TARGET, ABS_BLOCK, ABS_DATA)
{	
	if(PrevID!=ABS_BID || ABS_BID=='error_string'){
	if(PrevID!='NON'){	
		var abs_owner=document.getElementById(PrevID);
		if(abs_owner){
		abs_owner.style.color = '#93392b';
		abs_owner.style.cursor = 'pointer';}
		if(PrevTARGET!=ABS_TARGET && PrevTARGET!='NON')
		{$('#'+PrevTARGET).slideToggle('slow');}
		else{$('#'+ABS_TARGET).slideToggle('slow');}
	}
	ajaxRB(BID, ABS_BID, ABS_TARGET, ABS_BLOCK, ABS_DATA);}	
	PrevID=ABS_BID;
	PrevTARGET=ABS_TARGET;
}

function ajaxRblock_show(BID, XS, ARS_BID, ARS_TARGET, ARS_BLOCK, ARS_DATA)
{	
	if(PrevID!=ARS_BID || ARS_BID=='error_string'){
	if(PrevID!='NON'){	
		var ars_owner=document.getElementById(PrevID);
		if(ars_owner){
		ars_owner.style.color = '#93392b';
		ars_owner.style.cursor = 'pointer';}
		if(PrevTARGET!=ARS_TARGET && PrevTARGET!='NON')
		{$('#'+PrevTARGET).slideToggle('slow');}
		else{$('#'+ARS_TARGET).slideToggle('slow');}
	}
	ajaxTB(BID, XS, ARS_BID, ARS_TARGET, ARS_BLOCK, ARS_DATA);}	
	PrevID=ARS_BID;
	PrevTARGET=ARS_TARGET;
}

function ajaxblock_hide(ABH_BID, ABH_TARGET)
{
	var abh_owner=document.getElementById(ABH_BID);
	var abh_target=document.getElementById(ABH_TARGET);
	PrevID='NON';
	PrevTARGET='NON';
	if(abh_owner){abh_owner.style.color = '#93392b'; abh_owner.style.cursor = 'pointer';}
	$('#'+ABH_TARGET).slideToggle('slow');
}

function userblock_notice_show(UNS_BLOCK, UNS_DATA)
{
	var uns_block=document.getElementById(UNS_BLOCK);
	if(typeof uns_block.Sunny_progressBar=='undefined' || uns_block.Sunny_progressBar==0){		
		fu_TMenu_OpacityReset(UNS_BLOCK);
		uns_block.innerHTML = UNS_DATA;
		//uns_block.style.display='block';
		fu_TMenu_OpacityDown(UNS_BLOCK,0.1,100);}
}

function userblock_notice_hide(UNH_BLOCK, UNH_DATA)
{
	var unh_block=document.getElementById(UNH_BLOCK);	
	if(typeof unh_block.Sunny_progressBar=='undefined' || unh_block.Sunny_progressBar==0){
		fu_TMenu_OpacityReset(UNH_BLOCK);
		unh_block.innerHTML = UNH_DATA;
		fu_TMenu_OpacityDown(UNH_BLOCK,0.1,100);}	
	
}

function fu_TMenu_OpacityDown(psObjID,pfOpacityStep,piTimeInterval){ 
var loObj=document.getElementById(psObjID);
var lfOpacityOld=parseFloat(loObj.style.opacity);
if(!lfOpacityOld){lfOpacityOld=0.0;}
var lfOpacityNew=lfOpacityOld + pfOpacityStep;
if(lfOpacityNew>1){lfOpacityNew=1;}
loObj.style.opacity=lfOpacityNew;
loObj.style.filter='alpha(opacity='+(0+loObj.style.opacity*100)+')';
if(loObj.style.opacity>=1){return;}
loObj.Yes_TMenu_Opacity_TimeOut = setTimeout("fu_TMenu_OpacityDown('"+psObjID+"',"+pfOpacityStep+","+piTimeInterval+")",piTimeInterval);}

function fu_TMenu_OpacityReset(psObjID){
var loObj=document.getElementById(psObjID);
loObj.style.filter='alpha(opacity='+0+')';
clearTimeout(loObj.Yes_TMenu_Opacity_TimeOut);
loObj.Yes_TMenu_Opacity_TimeOut=null;
loObj.style.opacity =0.0;}







function out(username)
{
  image = new Image();
  image.src= 'plug.php?e=top&a=out&u=' + username;
}

function checkmail(el) {
	if (el.value!='') {
		exit;
	} else {
		el.value='ваш e-mail';
	}
}

function vis(div) {
div.style.display="none";
divs=document.getElementById('rssform_fon');
divs.style.display="block";
}

function hide() {
divhide=document.getElementById('rssform_fon');
divhide.style.display="none";

divvis=document.getElementById('rss_small');
divvis.style.display="block";
}

function popup(code,w,h)
	{ window.open('plug.php?o='+code,'','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width='+w+',height='+h+',left=32,top=16'); }

function pfs(id,c1,c2)
	{ window.open('pfs.php?userid='+id+'&cq='+c1+'&cw='+c2,'PFS','status=1, toolbar=0,location=0,directories=0,menuBar=0,resizable=1,scrollbars=yes,width=1024,height=512,left=32,top=16'); }

function help(rcode,c1,c2)
	{ window.open('plug.php?h='+rcode+'&c1='+c1+'&c2='+c2,'Help','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=808,height=512,left=32,top=16'); }

function comments(rcode)
	{ window.open('comments.php?id='+rcode,'Comments','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=808,height=512,left=16,top=16'); }

function ratings(rcode)
	{ window.open('ratings.php?id='+rcode,'Ratings','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=808,height=512,left=16,top=16'); }

function polls(rcode)
	{ window.open('polls.php?id='+rcode,'Polls','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=808,height=448,left=16,top=16'); }

function pollvote(rcode,rvote)
	{ window.open('polls.php?a=send&id='+rcode+'&vote='+rvote,'Polls','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=608,height=448,left=16,top=16'); }

function picture(url,sx,sy)
	{ window.open('pfs.php?m=view&v='+url,'Picture','toolbar=0,location=0,directories=0,menuBar=0,resizable=1,scrollbars=yes,width='+sx+',height='+sy+',left=0,top=0'); }

function redirect(url)
	{ location.href = url.options[url.selectedIndex].value; }

function toggleblock(id)
	{
	var bl = document.getElementById(id);
	if(bl.style.display == 'none')
		{ bl.style.display = ''; }
	else
		{ bl.style.display = 'none'; }
	}
function confirmDelete(ask, url)
	{
	temp=window.confirm(ask);
	if(temp){window.location=url;}
	}

window.name='main';



function ajaxRG(BID)
{
var content=document.getElementById('aj_content');

$.ajax({
  type: 'GET',  
  url: BID,
  async: false,
  beforeSend: function(){	
    content.innerHTML='<center><img style="margin:50px;" src="http://www.sunny-cat.ru/js/loader.gif" alt="" /></center>';
  },
  success: function(answ){	 
    content.innerHTML=answ;	
  }
});
}


function aj_cont(BID, CONT)
{
var contentdiv=document.getElementById(CONT);

$.ajax({
  type: 'GET',
  url: BID,
  async: false,
  beforeSend: function(){
	fu_TMenu_OpacityReset(CONT);
  },
  success: function(answ){
    contentdiv.innerHTML=answ;	
	fu_TMenu_OpacityDown(CONT,0.1,100);	
  }
});
}


function fu_TMenu_Show_Delay(HREFID, BID, CONT, piDelay){
	var loHREFID=document.getElementById(HREFID);
	loHREFID.Yes_TMenu_Show_TimeOut = setTimeout("aj_cont('"+BID+"','"+CONT+"')",piDelay);
}

function fu_TMenu_Show_tmClear(HREFID){
	var loHREFID=document.getElementById(HREFID);
	if(typeof loHREFID.Yes_TMenu_Show_TimeOut !=='undefined'){if(loHREFID.Yes_TMenu_Show_TimeOut){clearTimeout(loHREFID.Yes_TMenu_Show_TimeOut);}}
}


function ajaxCB(BID, XS)
{
var content=document.getElementById('aj_content');

var p1=document.getElementById('p1');
var p2=document.getElementById('p2');
var p3=document.getElementById('p3');
var p4=document.getElementById('p4');
var p5=document.getElementById('p5');
var p6=document.getElementById('p6');
var p7=document.getElementById('p7');
var p8=document.getElementById('p8');
var p9=document.getElementById('p9');
var p10=document.getElementById('p10');
var p11=document.getElementById('p11');
var p12=document.getElementById('p12');
var p13=document.getElementById('p13');
var p14=document.getElementById('p14');
var p15=document.getElementById('p15');
var p16=document.getElementById('p16');
var p17=document.getElementById('p17');
var p18=document.getElementById('p18');
var p19=document.getElementById('p19');
var p20=document.getElementById('p20');

$.ajax({
  type: 'POST',
  url: BID,
  data:  {x: XS, p1: p1.value, p2: p2.value, p3: p3.value, p4: p4.value, p5: p5.value, p6: p6.value, p7: p7.value, p8: p8.value, p9: p9.value, p10: p10.value, p11: p11.value, p12: p12.value, p13: p13.value, p14: p14.value, p15: p15.value, p16: p16.value, p17: p17.value, p18: p18.value, p19: p19.value, p20: p20.value},
  beforeSend: function(){
    content.innerHTML='<center><img style="margin:50px;" src="http://www.sunny-cat.ru/js/loader.gif" alt="" /></center>';
  },
  success: function(answ){
    content.innerHTML=answ;
  }
});
}






















function createIFrame() {
  var id = 'f' + Math.floor(Math.random() * 99999);
  var div = document.createElement('div');
  div.innerHTML = '<iframe style="display:none" src="about:blank"'+' id="'+id+'" name="'+id+'" onload="sendComplete(\''+id+'\')"></iframe>';
  document.body.appendChild(div);
  return document.getElementById(id);
}

function sendForm(form, url, func, arg, SF_BLOCK, BID, DATA) {
  if (!document.createElement) return; // not supported
  if (typeof(form)=="string") form=document.getElementById(form);
  var frame=createIFrame();
  frame.onSendComplete = function() { func(arg, getIFrameXML(frame), BID, SF_BLOCK, DATA); };
  form.setAttribute('target', frame.id);
  form.setAttribute('action', url);
  sf_block=document.getElementById(SF_BLOCK);
  sf_block.innerHTML='<center><img style="margin-top:5px;" src="http://www.sunny-cat.ru/js/loader.gif" alt="" /></center>';
  form.submit();
}

function sendForm1(form, url, func, arg) {
  if (!document.createElement) return; // not supported
  if (typeof(form)=="string") form=document.getElementById(form);
  var frame=createIFrame();
  frame.onSendComplete = function() { func(arg, getIFrameXML(frame)); };
  form.setAttribute('target', frame.id);
  form.setAttribute('action', url);
  sf_block=document.getElementById(arg);
  sf_block.innerHTML='<center><img style="margin-top:50px;" src="http://www.sunny-cat.ru/js/loader.gif" alt="" /></center>';
  form.submit();
}

function sendComplete(id) {	
  var iframe=document.getElementById(id);
  if (iframe.onSendComplete && typeof(iframe.onSendComplete) == 'function')
    iframe.onSendComplete();
}

function getIFrameXML(iframe) {
  var doc=iframe.contentDocument;
  if (!doc && iframe.contentWindow) doc=iframe.contentWindow.document;
  if (!doc) doc=window.frames[iframe.id].document;
  if (!doc) return null;
  if (doc.location=="about:blank") return null;
  if (doc.HTMLDocument) doc=doc.HTMLDocument;
  return doc;
}

var cnt=0;
function uploadComplete(element, doc, BID, SF_BLOCK, DATA) {	
	if (!doc) return;
	if (typeof(element)=="string") element_div=document.getElementById(element);
	if_result=doc.getElementById('if_result');
	bid=document.getElementById(BID);
	element_div.innerHTML=if_result.innerHTML;
	if(bid){bid.style.color = '#5e720f'; bid.style.cursor = 'auto';}
	$('#'+element).slideToggle('slow');
	userblock_notice_hide(SF_BLOCK, DATA);
	PrevID=BID;
	PrevTARGET=element;
}

function uploadComplete1(element, doc) {	
	if (!doc) return;
	if (typeof(element)=="string") element_div=document.getElementById(element);
	if_result=doc.getElementById('if_result');	
	element_div.innerHTML=if_result.innerHTML;
}




































