		/*function sav(str,type) 
	{
		if(typeeof str=="undefined")	str="";
		if(typeeof type!="number") 		type=2;
		
		type = Math.max(0,Math.min(3,parseInt(type)));
		
		var from	= new Array(/</g,/>/g);
		var to		= new Array("&lt;","&gt;");
		if(type==1 || type==3)
		{
			from.push(/'/g);
			to.push("&#039;");
		}
		if(type==2 || type==3)
		{
			from.push(/"/g);
			to.push("&quot;");
		}
		for(var i in from)
			str=str.replace(from[i],to[i]);

		return str;
	}*/
	function Appear(str)
	{
		var content  = gE(str);
		var _Content = new ZAppearObj(1,0,content);
		_Content.Appear();
	}
	
	function gE(el)
	{ return document.getElementById(el); }
	
	function gEv(el)
	{ return document.getElementById(el).value; }
	
	function UcWords(str)
	{ return str.toLowerCase().replace(/\w+/g, function(s){return s.charAt(0).toUpperCase() + s.substr(1);}) }
	
	function Trim(str)
	{ str = str.replace(/\s+$/, ''); str = str.replace(/^\s+/, ''); return str; }
	
	function GetX(el)
	{
			var left = 0;
			do
			{
				left += el.offsetLeft || 0;																	
				el 	 =  el.offsetParent;
			} while (el);
			return left+(window.ie6||window.ie7?1:0);
	}
	
	function GetY(el)
	{
			var top = 0;
			do
			{
				top += el.offsetTop || 0;
				el 	=  el.offsetParent;
			} while (el);
			return top+(window.ie6||window.ie7?1:0);
	}
	
	function SetOpacity(obj,value)
	{
		obj.style.MozOpacity = value/100;
		obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+value+")";
	}
	
	function Hide(el)
	{ el.style.display = 'none'; }
	
	function Show(el)
	{ el.style.display = 'block'; }
	
	function ValidateEmail(str)
	{
		var re_1 = /^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/i;
		return (Trim(str).length && Trim(str).match(re_1))?true:false;
	}
	
	function InArray(needle, haystack)
	{	
		for (var i = 0; i < haystack.length; i++)
			if (haystack[i] == needle) return true;
		return false;
	}
	
	function IsInt(v)
	{ return parseInt(v).toString()===v.toString(); }
	
	function ToInt(v)
	{ return (v*1); }
	
	function AddLoadEvent(func)
	{
		var oldonload = window.onload;
		if (typeof window.onload != 'function')
			window.onload = func;
		else
		{
			window.onload = function()
			{
				oldonload();
				func();
			}
		}
	}
	
	/******************************************** [Special funtions] ************************************************/
	function ChangeLanguage(lang_id)
	{
		var str = document.location.href;
		str = str.replace(/lang=[\w&]+/gi, '');
		str = str.replace(/&$/gi, '');
		if (str.indexOf("?") > -1)
		{
			window.location=str+'&lang='+lang_id;
		}
		else
		{
			window.location='?lang='+lang_id;
		}
		
		return false;
	}
	
	function ChangeLimitNews(count)
	{
		var str = document.location.href;
		str = str.replace(/limit=[\w&]+/gi, '');
		str = str.replace(/&$/gi, '');
		if (str.indexOf("?") > -1)
		{
			window.location=str+'&limit='+count;
		}
		else
		{
			window.location='?limit='+count;
		}
		
		return false;
	}
	/******************************************** [/Special funtions] ************************************************/

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
		Char = sText.charAt(i); 
	    if (ValidChars.indexOf(Char) == -1) IsNumber = false;   
   }
   return IsNumber;
}

function explode(delimiter, string ) {    // Split a string by string
    // 
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: kenneth
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 
    var emptyArray = { 0: '' };
 
    if ( arguments.length != 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
 
    return string.toString().split ( delimiter.toString() );
}

function	getTextValue(el) {
	return	typeof(el.textContent)=='string'?el.textContent:el.innerText;
}

function	is_int(v) {
	return	parseInt(v).toString()===v.toString();
}

function	pagelist(npage,cntrows,perpage,range)
{
	if (!range) range = 9;

	var totalpage	=	Math.ceil(cntrows/perpage);
	var crange		=	Math.ceil(range/2);

	if(totalpage>1) {

		if(npage>totalpage)	npage	=	totalpage;

		if(npage<crange) {

			var fromurl	=	1;
			var tourl		=	fromurl+(range-1);

			if(tourl>totalpage)	tourl	=	totalpage;

		} else if(npage>(totalpage-crange)) {


			var fromurl	=	totalpage-(range-1);
			var tourl	=	totalpage;

			if(fromurl<1)	fromurl	=	1;

		} else {
			fromurl	=	npage-(crange-1);
			tourl	=	npage+(crange-1);
		}

		var llpoint	=	npage-range;
		var lpoint		=	npage-1;
		var rpoint		=	npage+1;
		var rrpoint	=	npage+range;

		if(llpoint<1)
			llpoint	=	1;
		if(lpoint<1)
			lpoint		=	1;
		if(rpoint>totalpage)
			rpoint		=	totalpage;
		if(rrpoint>totalpage)
			rrpoint	=	totalpage;
	}

	return	{"npage":npage,"total":totalpage,"ll":llpoint,"l":lpoint,"from":fromurl,"to":tourl,"r":rpoint,"rr":rrpoint};
}

function parseUrls(str)
{
	var pr = /((?:(?:http|https|ftp|mailto):(?:(?:[A-Za-z0-9\$_.+!*(),;\/?:@&\~=-])|%[A-Fa-f0-9]{2}){2,}(?:#(?:[a-zA-Z0-9][a-zA-Z0-9\$_.+!*(),;\/?:@&\~=%-]*))?(?:[A-Za-z0-9\$_+!*();\/?:\~-]))|(?:www\.[A-Za-z0-9\$_.+!*(),;\/?:@&\~=-]{2,}\.(?:(?:com)|(?:co)|(?:uk)|(?:org))(?:(?:[a-zA-Z0-9#\$_.+!*,;\/?:@&\~=%-]*))?))/im;

	str = str.replace(pr,'<a href="$1">$1</a>');

	return str;
}

function htmlspecialchars(str,typ) 
{
	if(typeof str=="undefined") str="";
	if(typeof typ!="number") typ=2;
	typ=Math.max(0,Math.min(3,parseInt(typ)));
	var from=new Array(/</g,/>/g);
	var to=new Array("&lt;","&gt;");
	if(typ==1 || typ==3) {from.push(/'/g); to.push("&#039;");}
	if(typ==2 || typ==3) {from.push(/"/g); to.push("&quot;");}
	for(var i in from) str=str.replace(from[i],to[i]);
	return str;
}

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}

function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}


function isset(varname)  {
  if(typeof(varname) != "undefined") return true;
  else return false;
}

function strlen (string) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Sakimori
    // +      input by: Kirk Strobeck
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +    revised by: Brett Zamir
    // %        note 1: May look like overkill, but in order to be truly faithful to handling all Unicode
    // %        note 1: characters and to this function in PHP which does not count the number of bytes
    // %        note 1: but counts the number of characters, something like this is really necessary.
    // *     example 1: strlen('Kevin van Zonneveld');
    // *     returns 1: 19
    // *     example 2: strlen('A\ud87e\udc04Z');
    // *     returns 2: 3
 
    var str = string+'';
    var i = 0, chr = '', lgth = 0;
 
    var getWholeChar = function (str, i) {
        var code = str.charCodeAt(i);
        var next = '', prev = '';
        if (0xD800 <= code && code <= 0xDBFF) { // High surrogate(could change last hex to 0xDB7F to treat high private surrogates as single characters)
            if (str.length <= (i+1))  {
                throw 'High surrogate without following low surrogate';
            }
            next = str.charCodeAt(i+1);
            if (0xDC00 > next || next > 0xDFFF) {
                throw 'High surrogate without following low surrogate';
            }
            return str[i]+str[i+1];
        } else if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
            if (i === 0) {
                throw 'Low surrogate without preceding high surrogate';
            }
            prev = str.charCodeAt(i-1);
            if (0xD800 > prev || prev > 0xDBFF) { //(could change last hex to 0xDB7F to treat high private surrogates as single characters)
                throw 'Low surrogate without preceding high surrogate';
            }
            return false; // We can pass over low surrogates now as the second component in a pair which we have already processed
        }
        return str[i];
    };
 
    for (i=0, lgth=0; i < str.length; i++) {
        if ((chr = getWholeChar(str, i)) === false) {
            continue;
        } // Adapt this line at the top of any loop, passing in the whole string and the current iteration and returning a variable to represent the individual character; purpose is to treat the first part of a surrogate pair as the whole character and then ignore the second part
        lgth++;
    }
    return lgth;
}





