﻿//This prototype is provided by the Mozilla foundation and
//is distributed under the MIT license.
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
if (!Array.prototype.indexOf)
{  
Array.prototype.indexOf = function(elt /*, from*/) 
	{    
		var len = this.length;    
		var from = Number(arguments[1]) || 0;    
		from = (from < 0) ? Math.ceil(from) : Math.floor(from);    
		if (from < 0) 
			from += len;    
		for (; from < len; from++)    
		{      
			if (from in this && this[from] === elt)
				return from;    
		}    
		return -1;  
	};
}

// DOM helper routines

function StopAnyEvent (obj)
{
	obj.ondblclick = function (pEvent) {StopEventPropagation (pEvent); return false;}
	obj.onmousemove = function (pEvent) {StopEventPropagation (pEvent); return false;}
	obj.onclick = function (pEvent) {StopEventPropagation (pEvent); return false;}
	obj.onmousedown = function (pEvent) {StopEventPropagation (pEvent); return false;}
	obj.onmouseup = function (pEvent) {StopEventPropagation (pEvent); return false;}
	obj.onmousewheel = function (pEvent) {StopEventPropagation (pEvent); return false;}
}

// precond: it is click
function IsRightClick (pEvent)
{
	if (window.event) //ie
	{
		return (window.event.button == 2);
	}
	else if (pEvent)  // ff
	{
		return (pEvent.button == 2);
	}		  
	return false;
}

function GetBlock(id)
{
	var block = null;
	if(document.getElementById)
	{
		block = document.getElementById(id);
	}
	return block;
}

function GetTable(id)
{
	var table = GetBlock(id);
	if(table != null)
	{
		var tb = table.getElementsByTagName('tbody');
		if(tb.length > 0)
			return tb[0];
	}
	return table;
}

function SwapNode(a1, a2)
{
	if(a1.swapNode)
		a1.swapNode(a2);
	else
	{
		var itemtmp = a1.cloneNode(1);
		var parent1 = a1.parentNode;
		var parent2 = a2.parentNode;
		a2 = parent2.replaceChild(itemtmp,a2);
		parent1.replaceChild(a2,a1);
		parent2.replaceChild(a1,itemtmp);
		itemtmp = null;
	}
}



function DeleteChildren (pParent, strClassName)
{
	if (pParent != null)
	{
		var a = new Array ();
		var c = pParent.firstChild;
		
		while ( c != null )
		{
			if ((c.className == strClassName) || (strClassName == ""))
			{
				a[a.length] = c;
			}
			c = c.nextSibling;
		}
	}
	
	for (i = 0; i < a.length; i++)
	{
		pParent.removeChild(a[i]);
	}
}


function InsertBefore (pParent, pChild, pBefore)
{
	// pParent.insertBefore(pChild, pBefore);

	var a = new Array ();

	var c = pParent.firstChild;

	while (c!=null)
	{
		if (c == pBefore)
			break;

		c = c.nextSibling;
	}

	while (c!=null)
	{
		a[a.length] = c;
		c = c.nextSibling;
	}

	var i = 0;

	for (i = 0; i < a.length; i++)
	{
		pParent.removeChild(a[i]);
	}

	pParent.appendChild(pChild);

	for (i = 0; i < a.length; i++)
	{
		pParent.appendChild(a[i]);
	}

	delete a;
}

function RefreshChildren (pParent)
{
	var a = new Array ();

	var c = pParent.firstChild;

	while (c!=null)
	{
		a[a.length] = c;
		c = c.nextSibling;
	}

	var i = 0;

	for (i = 0; i < a.length; i++)
	{
		pParent.removeChild(a[i]);
	}

	for (i = 0; i < a.length; i++)
	{
		pParent.appendChild(a[i]);
	}

	delete a;
}

function AddTag(pChild, pParent, pBefore)
{
	if(pBefore != undefined)
		pParent.insertBefore(pChild, pBefore); //InsertBefore (pParent, pChild, pBefore)
	else
		pParent.appendChild(pChild);
}

function NewTag(id, pParent, pBefore)
{
	var tag = document.createElement(id);
	if(pParent != undefined)
		AddTag(tag, pParent, pBefore);
	return tag;
}

function NewTextTag(text, pParent, pBefore)
{
	var tag = document.createTextNode(text);
	if(pParent != undefined)
		AddTag(tag, pParent, pBefore);
	return tag;
}

function NewAutoLinkTag(text, pParent, pBefore)
{
	var strTemp = text;
	strTemp.toLowerCase();
	var iPos = strTemp.lastIndexOf(".");
	var strExt = "";
	if(iPos >= 0)
		strExt = strTemp.substr(iPos+1); 	
	
	if(strTemp.substr(0,7) == "http://" || strTemp.substr(0,6) == "ftp://" || strTemp.substr(0,4) == "www.")
	{ //link
		var a = NewTag("a", pParent, pBefore);
		a.setAttribute("target", "_blank");
		a.setAttribute("href", strTemp.substr(0,4) == "www." ? "http://"+text : text);
		NewTextTag(text, a);
	}
	else if(strTemp.indexOf("@")>=0)
	{ // email cím
		var a = NewTag("a", pParent, pBefore);
		a.setAttribute("href", "mailto:"+text);
		NewTextTag(text, a);
	} 
	else if(strExt == "png" || strExt == "gif" || strExt == "jpg" || strExt == "jpeg")
	{ // kép
		var img = NewTag("img", pParent, pBefore);
    img.setAttribute("src", text);
    img.setAttribute("alt", "");
	}
	else 
	{ // szöveg
		NewTextTag(text, pParent, pBefore);
	}
}
// <iframe src="http://index.hu/ad/lakas/utvonalterv_micro/" 
//style="width:227px;height:120px;padding:0px;margin:0px;" 
//marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>

/*IE6-ban nem lehet utolag hozzaadni a parenthez:
domfahoz adas elott> hogy nezzen ki a frameborde
utana a tartalom
*/

function NewIframe(src, width, height, parentObj, beforeObj)
{	
	var	iframe = NewTag("iframe");
	iframe.setAttribute("frameBorder","0");
	
	if (parentObj != null)
		AddTag (iframe, parentObj, beforeObj);

	iframe.style.margin = "5px";
	iframe.setAttribute("src", src);

	iframe.width = width;
	iframe.height = height;
	iframe.marginWidth = 0;
	iframe.marginHeight = 0;
	iframe.setAttribute("hspace", "0");
	iframe.setAttribute("vspace", "0");

	iframe.setAttribute("border", "0");
	iframe.setAttribute("scrolling","no");

	iframe.frameBorder = "0";
	return iframe;
}

function NewFlash(src, iWidth, iHeight, parentObj)
{
	var xmlIc=document.createElement('object');
	xmlIc.setAttribute('type','application/x-shockwave-flash');
	xmlIc.setAttribute('data', '');
	xmlIc.data=src;
	xmlIc.setAttribute('width', '');
	xmlIc.width= iWidth;
	xmlIc.setAttribute('height','');
	xmlIc.height= iHeight;

	var paramIc=document.createElement('param');
	paramIc.setAttribute('name','');
	paramIc.name="movie";
	paramIc.setAttribute('value','');
	paramIc.value=src;
	xmlIc.appendChild(paramIc);
	parentObj.appendChild(xmlIc);
	try
	{
		xmlIc.LoadMovie(0,src); 		
	}
	catch(e)
	{
	}
	return xmlIc
}

function SetEvent(obj,strEvent,strFunction)
{
	obj.setAttribute(strEvent, strFunction);
	if(navigator.appName.indexOf("Microsoft")>=0)
		obj[strEvent] = new Function(strFunction);
}

function SetImage(img, src, width, height, alt, title)
{
	if (width != undefined && width != null && width > 0 && !isNaN(width))
	{
		img.style.width = width + "px";
		img.width = width;
	}
	if (height != undefined && height != null && height > 0 && !isNaN(height))
	{
		img.style.height = height + "px";
		img.height = height;
	}

	img.style.border = 0;
	img.setAttribute('src', src);
	if(alt != null && alt != undefined ||img.alt == null || img.alt == undefined)
		img.setAttribute('alt', (alt==null || alt==undefined ? "" : alt) );
	if(title != null && title != "")
		img.setAttribute('title', title);
}

function GetEventX(pEvent)
{
	if(pEvent == undefined)
		pEvent = window.event;

	if (pEvent.target != undefined) {
		// Opera rulez.
		return GetEventXNew(pEvent) - GetAbsLayerLeft(pEvent.target);
	}
	else {
		if(pEvent.layerX != undefined) {
			return pEvent.layerX;
		}
		else if(pEvent.x != undefined) {
			return pEvent.x;
		}
	}

	/*if(pEvent.layerX != undefined) {
		return pEvent.layerX;
	}
	else if(pEvent.x != undefined) {
		return pEvent.x;
	}
	else if(pEvent.clientX != undefined) {
		return pEvent.clientX;
	}*/
	return null;
}

function GetEventY(pEvent)
{
	if(pEvent == undefined)
		pEvent = window.event;
	
	if (pEvent.target != undefined) {
		// Opera rulez.
		return GetEventYNew(pEvent) - GetAbsLayerTop(pEvent.target);
	}
	else {
		if(pEvent.layerY != undefined) {
			return pEvent.layerY;
		}
		else if(pEvent.y != undefined) {
			return pEvent.y;
		}
	}
		
/*	if(pEvent.layerY != undefined) {
		return pEvent.layerY;
	} else if(pEvent.y != undefined) {
		return pEvent.y;
	} else if(pEvent.clientY != undefined) {
		return pEvent.clientY;
	}
	return null;*/
}


// Attila
function GetLayerX(pEvent)
{
	if(pEvent == undefined)
		pEvent = window.event;
	if(pEvent.layerX != undefined) {
		return pEvent.layerX;
	} else if(pEvent.offsetX != undefined) {
		return pEvent.offsetX;
	}
	return null;
}
		
// Attila
function GetLayerY(pEvent)
{
	if(pEvent == undefined)
		pEvent = window.event;
	if(pEvent.layerY != undefined) {
		return pEvent.layerY;
	} else if(pEvent.offsetY != undefined) {
		return pEvent.offsetY;
	}
	return null;
}

// Attila new:

// posx and posy contain the mouse position relative to the document
function GetEventXNew (pEvent)
{
    var posx = 0;
    if (!pEvent) pEvent = window.event;
    if (pEvent.pageX)
		posx = pEvent.pageX;
    else if (pEvent.clientX) 	
    {
		posx = pEvent.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
	}
	return posx;
}

function GetEventYNew (pEvent)
{
    var posy = 0;
    if (!pEvent) pEvent = window.event;
    if (pEvent.pageY)
		posy = pEvent.pageY;
    else if (pEvent.clientY) 	
    {
		posy = pEvent.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	return posy;
}


// Attila
function GetEventSourceElement(pEvent)
{
	if (pEvent == undefined)
		pEvent = window.event;
	if (pEvent.srcElement!=null) {
		return pEvent.srcElement;
	} else if (pEvent.target!=null) {
		return pEvent.target;
	}
}

function GetEventRelatedElement(pEvent)
{
	if (pEvent == undefined || pEvent == null)
		pEvent = window.event;

	var relTarg = pEvent.relatedTarget || pEvent.toElement;
	return relTarg;
}

// Attila
function StopEventPropagation(pEvent)
{
	if (pEvent == undefined)
		pEvent = window.event;

	if (pEvent.preventDefault)
		pEvent.preventDefault();

	pEvent.cancelBubble = true;
	if (pEvent.stopPropagation)
		pEvent.stopPropagation();
}


function GetEventButton(pEvent)
{
	if(pEvent == undefined)
		pEvent = window.event;
	if(pEvent.button != undefined)
		return pEvent.button;
	if(pEvent.which != undefined)
	{
		if(pEvent.which == 0)  // FireFox IE kulonbseg miatt
			return 1;
		if(pEvent.which == 1)
			return 4;
		return pEvent.which;
	}
	return 1;
}

function GetStyle(el, styleProp)
{	
	if (el.currentStyle)
		var y = el.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
	return y;
}

function GetLayerLeft(block)
{
	if(block.offsetLeft != undefined)
	{
		var iLeft = 0;
		do {
			iLeft += block.offsetLeft || 0;

			block = block.offsetParent;
			if (block) {
				if (block.tagName.toLowerCase() == 'body')
					break;
				var p = GetStyle(block, 'position');
				if (p == 'relative' || p == 'absolute')
					break;
			}
		} while (block);
		return iLeft; 
	}
	if(block.pixelLeft != undefined)
		return block.pixelLeft;
	return null;
}

function GetStyle(block, strStyle)
{
	strStyle = strSyle == 'float' ? 'cssFloat' : strStyle;
	var value = block.style[strStyle];
	if (!value) {
		var css = document.defaultView.getComputedStyle(block, null);
		value = css ? css[strStyle] : null;
	}
	if (strStyle == 'opacity')
		return value ? parseFloat(value) : 1.0;
	return value == 'auto' ? null : value;
}


function GetLayerTop(block)
{
	if(block.offsetTop != undefined)
	{
		var iTop = 0;
		do {
			iTop += block.offsetTop || 0;

			block = block.offsetParent;
			if (block) {
				if (block.tagName.toLowerCase() == 'body')
					break;
				var p = GetStyle(block, 'position');
				if (p == 'relative' || p == 'absolute')
					break;
			}
		} while (block);
		return iTop; 
	}

	if(block.pixelTop != undefined)
		return block.pixelTop;
	return null;
}

/* relative to document left */
function GetAbsLayerLeft(block)
{
	return parseInt($(block).offset().left, 10);
    /*var ret = 0;
    ret += GetLayerLeft (block);
    if (block.offsetParent)
    {
        if (block.offsetParent != null)
        {
            ret += GetAbsLayerLeft (block.offsetParent);
        }
    }
    return ret;*/
}

/*relative to the document top*/
function GetAbsLayerTop (block)
{
	return parseInt($(block).offset().top, 10);
/*
    ret += GetLayerTop (block);
    if (block.offsetParent)
    {
        if (block.offsetParent != null)
        {
            ret += GetAbsLayerTop (block.offsetParent);
        }
    }
    return ret;*/
}


function GetLayerWidth(block)
{
	if(block.offsetWidth != undefined)
		return block.offsetWidth;
	if(block.pixelWidth != undefined)
		return block.pixelWidth;
	return null;
}

function GetLayerHeight(block)
{
//	if(block.height != undefined)
//		return block.height;
	if(block.offsetHeight != undefined)
		return block.offsetHeight;
	if(block.pixelHeight != undefined)
		return block.pixelHeight;
	return null;
}

function GetLayerRight(block)
{
	return GetLayerLeft(block) + GetLayerWidth(block);
}

function GetLayerBottom(block)
{
	return GetLayerTop(block) + GetLayerHeight(block);
}

function GetAbsLayerRight(block)
{
	return GetAbsLayerLeft(block) + GetLayerWidth(block);
}

function GetAbsLayerBottom(block)
{
	return GetAbsLayerTop(block) + GetLayerHeight(block);
}

function Show(block)
{
	block.style.display = "";
	block.style.visibility = "visible";
}

function Hide(block)
{
	block.style.display = "none";
	block.style.visibility = "hidden";
}

function setAlpha(strCssSelector) 
{
	if (document.all && typeof window.opera == undefined)
 {
   var styleSheets = document.styleSheets;
   for (var i = 0; i < styleSheets.length; i++) 
   {
     var rules = styleSheets[i].rules;
     for (var j = 0; j < rules.length; j++) 
     {
       if (rules[j].selectorText == strCssSelector) 
       {
         rules[j].style.filter = 'alpha(opacity = 100)';
         return true;
       }
     }
   }
 }
 return false;
};

//function SetOpac(block, iOpac)
//{
//    if (block)
//    {
//	    if (document.all && typeof window.opera == 'undefined')
//	    {
//		    if(block.filters && block.filters.alpha)
//			    block.filters.alpha.opacity = iOpac;
//	    }
//	    else if (block.style)
//		    block.style.MozOpacity = iOpac/100;
//    
//        if (block.style)	
//	        block.style.opacity = iOpac/100; 
//	}
//}


function SetOpac (block,value) {
	block.style.opacity = value/100;
	block.style.filter = 'alpha(opacity=' + value + ')';
	
    if (block)
    {
	    if (document.all && typeof window.opera == 'undefined')
	    {
		    if(block.filters && block.filters.alpha)
			    block.filters.alpha.opacity = value;
	    }
	    else if (block.style)
		    block.style.MozOpacity = value/100;
   
        if (block.style)	
	        block.style.opacity = value/100; 
	}
	
}

function GetOpac(block)
{
	if (block.filters)	
	{
		if(block.filters.alpha)
	    return	block.filters.alpha.opacity;
	  else return 100;
	}
	else if (block.style)
	{
	    if (block.style.MozOpacity)
		    return block.style.MozOpacity * 100;		    
    	else if (block.style.opacity)
	        return block.style.opacity;
	}
}

function AvoidClip(div)
{
	if (GetLayerLeft(div) + GetLayerWidth(div)-3 > GetLayerWidth(div.parentNode))
	{
		var iLeft = Math.max(0, GetLayerWidth(div.parentNode)-GetLayerWidth(div)-3);
		div.style.left = iLeft + "px";
	}
	if(GetLayerTop(div) + GetLayerHeight(div)-3 > GetLayerHeight(div.parentNode))
	{
		var iTop = Math.max(0, GetLayerHeight(div.parentNode) - GetLayerHeight(div)-3);
		div.style.top = iTop + "px";
	}
}


function GetClientWidth ()
{
	var iClientWidth = 0;
	if ( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		iClientWidth = window.innerWidth;		
	} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		iClientWidth = document.documentElement.clientWidth;		
	} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		iClientWidth = document.body.clientWidth;		
	}
	
	return iClientWidth;
}

function GetClientHeight()
{
	var iClientHeight = 0;
	if ( typeof( window.innerHeight ) == 'number' ) {
		//Non-IE
		iClientHeight = window.innerHeight;
	} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		iClientHeight = document.documentElement.clientHeight;
	} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		iClientHeight = document.body.clientHeight;
	}
	return iClientHeight;
}

function SetDivSize(div, iWidth, iHeight)
{
	div.style.width = iWidth + "px";
	div.style.height = iHeight + "px";
}

function GetStyle(element,styleProp)
{	
	if (element.currentStyle)
		var y = element.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(element,null).getPropertyValue(styleProp);
	return y;
}

// Attila
function WheelEventCalculateDelta (pEvent) 
{
	var delta = 0;
	if (!pEvent) pEvent = window.event;

	if (pEvent.wheelDelta) {
		delta = pEvent.wheelDelta/120; 
		if (window.opera) delta = -delta;
	} else if (pEvent.detail) {
		delta = -pEvent.detail/3;
	}

	if (delta)
		return delta;
}

// Attila
function pausecomp (iMillis)
{
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); }
	while(curDate-date < iMillis);
} 

function getCookie(Name)
{
	var search = Name + "=";
	if (document.cookie.length > 0) // megvizsgáljuk, hogy vannak-e cookie-k
	{
		offset = document.cookie.indexOf(search); // ha igen, megkeressük az adott nevu elejét
		if (offset != -1)  // ha van ilyen akkor:
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			// az <CODE>end <\/CODE>egyenlo a vizsgált cookie végét 
			//lezáró ; helyével
			if (end == -1) end = document.cookie.length;
			// ha nincs pontosvesszo akkor end egyenlo a cookie 
			//sztring hosszával
			return unescape(document.cookie.substring(offset, end));
		}
		return null;
	}
}

function getBoolCookie(Name, bDefault)
{
	var val = getCookie(Name);
	if(val==null)
	{
		if(bDefault)
			return true;
		return false;
	}

	if(val==true || val=='true' || val=='1')
		return true;
	else
		return false;
}

function getIntCookie(Name, iDefault)
{
	var strCookie = getCookie(Name);
	if(strCookie==null)
	{
		return iDefault;
	}
	var iVal = parseInt(strCookie, 10);
	if(isNaN(iVal))
		return iDefault;
	return iVal;
}

function getFloatCookie(Name, dDefault)
{
	var strCookie = getCookie(Name);
	if(strCookie==null)
	{
		return dDefault;
	}
	var dVal = parseFloat(strCookie);
	if(isNaN(dVal))
		return dDefault;
	return dVal;
}

function getStringCookie(Name, strDefault)
{
	var strCookie = getCookie(Name);
	if(strCookie==null)
		return strDefault;
	return strCookie;
}

function setCookie(cookieName,cookieValue,expire) 
{
	var today = new Date();
	if(expire == null)
	{
		expire = new Date();
		var nDays= 5 * 365;
		expire.setTime(today.getTime() + 3600000*24*nDays);
	}

	document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

/*
function setCookie(name, value, expire) 
{

	if(expire == null)
	{
		expire = new Date;
		expire.setYear(expire.getYear()+1);
	}
	var cookie = name + "=" + escape(value) + "; path=/" + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
	document.cookie = name + "=" + escape(value) + "; path=/" + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}
*/

function GetArrayLength(array)
{
	if(array != null)
	{
		var iUpperBound = array.length;
		while(iUpperBound--)
		{
			if(array[iUpperBound]!= null)
				return iUpperBound+1;
		}
	}
	return 0;
}

function DisableSelection (block)
{
	// Csak ovatosan! A block gyerekei kozott nem lehet input mezo!!!

	block.onselectstart = function () { return false; }; // ie
	block.onmousedown = function () { return false; }; // mozilla
}

var g_bPngHackSupported = /MSIE (5\.5)|[6789]/.test(navigator.userAgent) && navigator.platform == "Win32";


function SetTransparentPngAsBg(block, src)
{
	if(g_bPngHackSupported && block.runtimeStyle)
	{
		block.runtimeStyle.filter = block.runtimeStyle.filter || "";
		// test for png
		if ( /\.png$/.test( src.toLowerCase() ) ) {
				// set filter
				block.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
				// unset background-image
				block.style.backgroundImage = "";
		}
		else {
			// remove filter
			block.runtimeStyle.filter = "";
		}
	}
	else
	{
		block.style.backgroundImage = "url('" + src + "')";
	}
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


function SetTransparentPng(img, src, width, height, alt)
{
	var blankSrc = GetAbsUrl("images/transparent.gif");
	if(g_bPngHackSupported && img.runtimeStyle)
	{
		if ( /\.png$/.test( src.toLowerCase() ) ) {
			// set blank image
			//img.src = blankSrc;
			SetImage(img, blankSrc, width, height, alt);
			// set filter
			img.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
		}
		else {
		// remove filter
			img.runtimeStyle.filter = "";
			SetImage(img, src, width, height, alt);
		}
	}
	else
		SetImage(img, src, width, height, alt);
}

function AddEvent(obj, eventType, handler)
{
	if (obj.addEventListener) {
		obj.addEventListener(eventType, handler, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+eventType, handler);
		return r;
	} else {
		return false;
	}
}

function IncludeJS(strUrl)
{
	var script = document.createElement('script');
	script.type = 'text/javascript'; 
	script.src = strUrl;
	document.getElementsByTagName('head')[0].appendChild(script);
}

function IncludeCSS(strUrl)
{
	var link = document.createElement('link');
	link.rel = 'stylesheet';
	link.type = 'text/css'; 
	link.href = strUrl;
	document.getElementsByTagName('head')[0].appendChild(link);
}

function AddBookmark(strUrl, strTitle) 
{
	if (window.sidebar) {
		window.sidebar.addPanel(strTitle, strUrl,'');
		return true;
	}
	else if (window.external) {
		window.external.AddFavorite(strUrl, strTitle);
	}
}

function CreateRadioButton(strName, strID, strValue)
{
	var radio = null;
	if(document.all && !window.opera && document.createElement)
	{
		//MSIE 6 for windows does not support DOM-insertion of radio buttons. The following code works around that lack of support.
		if(strValue != undefined)
			radio = document.createElement("<input type='radio' name='"+strName + "' id='"+strID+"' value='"+strValue+"'/>");
		else
			radio = document.createElement("<input type='radio' name='"+strName + "' id='"+strID+"'/>");
	}
	else if(document.createElement && document.createTextNode)
	{
		radio = document.createElement("input");
		radio.type = "radio";
		radio.name = strName;
		radio.id = strID;
		if(strValue != undefined)
			radio.value = strValue;
	}
	return radio;
}

function AddCssClass(div, strCSSClass)
{
	if(div.className == "")
	{
		div.className = strCSSClass;
	}
	else
	{
		var allclasses = div.className.split(" ");
		for(var i=0; i<allclasses.length; i++)
		{
			if(allclasses[i] == strCSSClass)
				return;
		}
		allclasses[allclasses.length] = strCSSClass;
		div.className = allclasses.join(" ");
	}
}

function RemoveCssClass (div, strCSSClass)
{
	var allclasses = div.className.split(" ");
	var newclasses = new Array();
	for(var i=0; i<allclasses.length; i++)
	{
		if(allclasses[i] != strCSSClass)
		{
			newclasses[newclasses.length] = allclasses[i];
		}
	}
	div.className = newclasses.join(" ");
}

function ReplaceCSSClass (div, strOldClass, strNewClass)
{
	var o = div.className;
	RemoveCssClass(div, strOldClass);
	var mid = div.className;
	AddCssClass(div, strNewClass);
}

function RemoveCssClassPostfix (div, strPostfix)
{
	if(div.className)
	{
		var allclasses = div.className.split(" ");
		for(var i=0; i<allclasses.length; i++)
		{
			var iPos = allclasses[i].lastIndexOf(strPostfix);
			if(iPos == allclasses[i].length - strPostfix.length)
				allclasses[i] = allclasses[i].substr(0, iPos);
		}
		div.className = allclasses.join(" ");
	}
}

function setBodySize(value) 
{
	var obj = document.getElementsByTagName("body");
	obj = obj[0];

	if ( !isNaN(value) )
		window.val = value;
	if ( !value || value == "undefined" )
		window.val = 100;
	if ( !window.val || window.val == "undefined" )
		window.val = 100;
	if ( /*( window.val >= 400 && value == "up" ) ||*/ ( window.val <= 50 && value == "down" ) )
		return false;

	window.val = parseInt(window.val);
	if ( value == "up" ) {
		window.val = window.val + 20;
	} else if ( value == "down" ) {
		window.val = window.val - 20;
	}
	obj.style.fontSize = window.val + "%";
	//if( moze ) createCookie("fontsize", val, 365);
	
	setCookie("bodyFontSize", window.val, null);
}

function setActiveStyleSheet(title)
{
	var i, a, main;
	for( i = 0; ( a = document.getElementsByTagName("link")[i] ); i++ )
	{
		var rel = a.getAttribute("rel");
		if( rel != null && rel.indexOf("style") != -1 && a.getAttribute("title") )
		{
			a.disabled = true;
			if( a.getAttribute("title") == title ) a.disabled = false;
		}
	}
}

function SetAllFlashOpaque()
{
	$(document).ready(function() {
		$("embed[wmode!=opaque]").attr("wmode", "opaque");
		$("param[name=wmode]").remove();
		$("embed").before("<param name='wmode' value='opaque'>");
		$("object").wrap("<span></span>");
	});
}
