Показать сообщение отдельно
  #2 (permalink)  
Старый 05.07.2013, 11:12
Новичок на форуме
Отправить личное сообщение для Sn1k3rS Посмотреть профиль Найти все сообщения от Sn1k3rS
 
Регистрация: 05.07.2013
Сообщений: 3

<script type="text/javascript" src="./js/utils.js"></script>
//
// Custom project scripts
//
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function getElementsByClass(searchClass,node,tag)
{
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
	for (i = 0; i < els.length; i++)
		if ( pattern.test(els[i].className) )
			classElements.push(els[i]);
	return classElements;
}

function getBody(){
	return document.body||document.documentElement||(document.getElementsByTagName ? document.getElementsByTagName("body")[0] : null);
}

function getPageRect(){
	var b = document.body || document.documentElement,
	sTop = window.pageYOffset || b.scrollTop,
	sLeft = window.pageXOffset || b.scrollLeft,
	sWidth=  b.clientWidth || window.innerWidth,
	sHeight= b.clientHeight || window.innerHeight,
	oWidth=  b.scrollWidth || b.offsetWidth,
	oHeight= b.scrollHeight || b.offsetHeight;
	return {top: sTop, left: sLeft, width: sWidth, height: sHeight, scrollX: oWidth, scrollY: oHeight};
}

function getBounds(e)
{
	var left = e.offsetLeft, top = e.offsetTop, width = e.offsetWidth, height = e.offsetHeight;
	while (e = e.offsetParent){
		left += e.offsetLeft;
		top += e.offsetTop;
	}
	return {left: left, top: top, width: width, height: height};
}

function insertElement(parent, tag, id)
{
	if(parent.insertAdjacentHTML)
	{
		parent.insertAdjacentHTML("afterBegin", '<'+tag+ ' id="'+id+'"></'+tag+'>');
		return document.getElementById(id);
	}
	else if(document.createElement && parent.appendChild)
	{
		var el = document.createElement(tag);
		el.id = id;
		parent.appendChild(el);
		return el;
	}
	return 0;
}
function addEvent(el, sEvt, PFnc)
{
	if(el)
	{
		if(el.addEventListener)
			el.addEventListener(sEvt, PFnc, false);
		else
			el.attachEvent("on" + sEvt, PFnc);
	}
}
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
		window.onload = func;
	else
		window.onload = function(){oldonload();func();}
}
function removeEvent(el, sEvt, PFnc)
{
	if(el)
	{
		if(el.removeEventListener)
			el.removeEventListener(sEvt, PFnc, false);
		else
			el.detachEvent("on" + sEvt, PFnc);
	}
}
function ChangeCssProperty(myclass, element, value)
{
	var CSSRules = document.styleSheets[0].rules || document.styleSheets[0].cssRules;
	for (var i = 0; i < CSSRules.length; i++)
		if (CSSRules[i].selectorText.toLowerCase() == myclass.toLowerCase())
			CSSRules[i].style[element] = value;
}
function getOpaSettings()
{
	var p = null;
	var s = document.body.style;
	if (typeof s.opacity == 'string') p = 'opacity';
	else if (typeof s.MozOpacity == 'string') p =  'MozOpacity';
	else if (typeof s.KhtmlOpacity == 'string') p =  'KhtmlOpacity';
	else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) p='filter';
	return p;
}
function setOpacity(oElem, nOpacity)
{
	var p = getOpaSettings();
	if (p=='filter')
		setOpacity = new Function('oElem', 'nOpacity', 'if (nOpacity >= 100) {oElem.style.filter = ""; return;} var oAlpha = oElem.filters["DXImageTransform.Microsoft.alpha"] || oElem.filters.alpha; if (oAlpha) oAlpha.opacity = nOpacity;else {oElem.style.zoom = 1;oElem.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";}');
	else if (p)
		setOpacity = new Function('oElem', 'nOpacity', 'oElem.style.'+p+' = nOpacity/100;');
	else
		setOpacity = new Function(oElem, nOpacity);
	return setOpacity(oElem, nOpacity);
}
function getOpacity(oElem)
{
	var p = getOpaSettings();
	if (p=='filter')
		getOpacity = new Function('oElem', 'var m = oElem.style.filter.match(/alpha\(opacity=(.+)\)/i); return m ? parseFloat(m[1]) : 1;');
	else if (p)
		getOpacity = new Function('oElem', 'var v = oElem.style.'+p+'; return v*100;');
	else
		getOpacity = new Function(oElem);
	return getOpacity(oElem);
}
Number.prototype.Timer = function(s, iT, bUrge){
	this.EndTimer();
	if(!this.value || bUrge)
		this.value = window.setTimeout(s, iT);
}
Number.prototype.EndTimer = function(){
	if(this.value){
		window.clearTimeout(this.value);
		this.value = 0;
	}
}
Ответить с цитированием