// JavaScript Document - LAST MODIFICATION: 29-09-2009 v2.3
// MADE BY: RottenEye @ dbwt | www.dbwt.co.uk (Please don't remove this line)
// If you have any doubt referring to this document please don't be afraid, contact me at rotten_eye@iol.pt


var dbwt = new Object();
	dbwt.browserVer = null;



dbwt.getBrowserVer = function(){/*
  Desc: get the browser name and verssion; */

	if( document.all && navigator.language )// opera
		return 'opera';
	else if( !document.all )// NN / FF
		return 'gecko'; 
	else if( document.all && !navigator.language ){// IE
		if( -1 == navigator.appVersion.indexOf('MSIE 7') ){
			return "ie6";
		}else if( -1 != navigator.appVersion.indexOf('MSIE 7') )
			return "ie7";
	}
}


dbwt.getBrowser = function(browser){/*
  Desc: compare a given browser verssion with the current browser verssion and return true or false;
  browser (string) = browser verssion to compare; */

	browser = browser.toLowerCase();
	if( this.browserVer === browser )
		return true;	
	else if( browser == 'ie' && this.browserVer.substr(0, 2) == browser )
		return true;
	return false;
}


dbwt.addonLoadEvent = function(functionName, browser, replaceEvt){/*
  Desc: add a function to the page onload event;
  functionName (string) = function name to be executed on page load;
  browser (string)      = browsers where the event will be attached, possible values: all | gecko | IE | IE6 | IE7 | opera;
  replaceEvt (bool)     = tell the function to replace the existing event methods with the new expression, default: false; */

	browser = browser.toLowerCase();
	if( !replaceEvt ) var replaceEvt = false;

	if( browser != "all" && this.browserVer != browser ){
		if( this.browserVer.substr(0, 2) != browser )
			return false;
	}
	if( functionName.substr(functionName.length - 1, 1) != ')' && functionName.substr(functionName.length - 1, 1) != ';' )
		functionName += '();';
	else if( functionName.substr(functionName.length - 1, 1) != ';' )
		functionName += ';';

	return this.setEvent(window, 'onload', functionName, replaceEvt);
}


dbwt.addonUnloadEvent = function(functionName, browser, replaceEvt){/*
  Desc: add a function to the page onload event;
  functionName (string) = function name to be executed on page load;
  browser (string)      = browsers where the event will be attached, possible values: all | gecko | IE | IE6 | IE7 | opera;
  replaceEvt (bool)     = tell the function to replace the existing event methods with the new expression, default: false; */

	browser = browser.toLowerCase();
	if( !replaceEvt ) var replaceEvt = false;

	if( browser != 'all' && this.browserVer != browser ){
		if( this.browserVer.substr(0, 2) != browser )
			return false;
	}

	if( functionName.substr(functionName.length - 1, 1) != ')' && functionName.substr(functionName.length - 1, 1) != ';' )
		functionName += '();';
	else if( functionName.substr(functionName.length - 1, 1) != ';' )
		functionName += ';';

	return this.setEvent(window, 'onunload', functionName, replaceEvt);
}


dbwt.addEventToElements = function(element, _event, executeExp, property, propValue, replaceEvent){/*
  Desc: function that add an event to a group of elements;
  element (string / object) = is the element where you whant apply the event (ex: td);
  _event (string)           = event name (ex: onclick);
  executeExp (string)       = expression / code to execute when the event is triggered;
  property (string)         = is the property, of the element, to search for (ex: class) - if null is ignored;
  propValue (string)        = value of the element property "property" - if null is ignored;
  replaceEvent (bool)       = tell the function to replace the existing event methods with the new expression, default: false; */

	var elmts;

	if( !_event ) var _event = 'onclick';
	if( !replaceEvent ) var replaceEvent = false;
	if( executeExp.substr(executeExp.length - 1, 1) != ';' ) executeExp += ';';

	if( typeof element == 'object' )
		return this.setEvent(element, _event, executeExp, replaceEvent);
	else
		elmts = document.getElementsByTagName(element);


	switch( property ){
		case 'class':
			if( this.getBrowser('ie') )
				property = 'className';
			break;
		case 'className':
			if( !this.getBrowser('ie') )
				property = 'class';
			break;
	}

	for( var k = 0, len = elmts.length; k < len; k++ ){
		if( this.validateElement(elmts[k], property, propValue) )
			this.setEvent(elmts[k], _event, executeExp, replaceEvent);
	}
}


dbwt.removeEventFromElements = function(element, _event, expToRem, property, propValue){/*
  Desc: function that remove an event from a group of elements;
  element (string / object) = are the element(s) where the event(s) should be removed (ex: td);
  _event (string)           = event name (ex: onclick);
  expToRem (string)         = expression / code to be removed;
  property (string)         = is the property, of the element, to search for (ex: class) - if null is ignored;
  propValue (string)        = value of the element property "property" - if null is ignored; */

	var elmts;

	if( !_event ) var _event = 'onclick';

	if( typeof element == 'object' )
		return this.removeEvent(element, _event, expToRem);
	else
		elmts = document.getElementsByTagName(element);


	switch( property ){
		case 'class':
			if( this.getBrowser('ie') )
				property = 'className';
			break;
		case 'className':
			if( !this.getBrowser('ie') )
				property = 'class';
			break;
	}

	for( var k = 0, len = elmts.length; k < len; k++ ){
		if( this.validateElement(elmts[k], property, propValue) )
			this.removeEvent(elmts[k], _event, expToRem);
	}
}


dbwt.getElements = function(root, elemToFind, property, propValue, maxNumElems){/*
  Desc: this function will return an array with all html elements that match the given expression;
  root (string / object)    = is the root element where elemToFind should be in (ex: td);
  elemToFind (string)       = tag name of the elements to find (ex: td);
  property (string)         = is the property, of the element, to search for (ex: class) - if null is ignored;
  propValue (string)        = value of the element property "property" - if null is ignored;
  maxNumElems (int)         = max number of elements to be returned, if negative, the function will return elements counting from the end of the array;*/

	//var elmsFound, k, curElem, testExp, rslt, a_pos, rslt1, t;
	var elmsFound, k, rslt, a_pos, rslt1;

	if( !root ){
		root = document;
	}else if( typeof root == 'string' ){
		root = document.getElementsByTagName(root);
		root = root[0];
	}
	if( !elemToFind ) var elemToFind   = 'body';
	if( !maxNumElems ) var maxNumElems = null;
	else maxNumElems = parseInt(maxNumElems);

	elmsFound = root.getElementsByTagName(elemToFind);

	switch( property ){
		case 'class':
			if( this.getBrowser('ie') )
				property = 'className';
			break;
		case 'className':
			if( !this.getBrowser('ie') )
				property = 'class';
			break;
	}

	rslt = new Array(); a_pos = 0;
	for( k = elmsFound.length; 0 < k--; ){
		if( this.validateElement(elmsFound[k], property, propValue) ){
			rslt[a_pos] = elmsFound[k];
			a_pos++;
		}
	}

	if( maxNumElems === null ) return rslt

	if( maxNumElems < 0 ){
		if( maxNumElems == -1 ) return rslt[0];
		maxNumElems = maxNumElems * -1;
		rslt1 = new Array(); a_pos = 0;
		for( k = 0; k < maxNumElems; k++ ){
			rslt1[a_pos] = rslt[k];
			a_pos++;
		}
		return rslt1;
	}else{
		if( maxNumElems == 1 ) return rslt[rslt.length - 1];
		maxNumElems = ( rslt.length - maxNumElems ) - 1;
		rslt1 = new Array(); a_pos = 0;
		for( k = rslt.length; maxNumElems < k--; ){
			rslt1[a_pos] = rslt[k];
			a_pos++;
		}
		return rslt1;
	}
}


dbwt.setScroll = function(obj, x, y){/*
  Desc: set the window scroll position
  x (int)                   = position for the horizontal scroll bar;
  y (int)                   = position for the vertical sroll bar;
  object (object or string) = window object or window name that will receive the new scroll position;*/

	if( typeof obj == 'string' )
		obj = eval(obj);
	obj.scrollTo(x, y);
}


dbwt.urlencode = function(url){/*
  Desc: this function encode a string to be used as a url;
  url (string) = string to be encoded; */

	return escape(url).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
}


dbwt.navigate = function(url, target, history){/*
  Desc: this function replace or navigate to a specific page, in a given target;
  url (string)    = destiny url;
  target (string) = target where the page will be loaded: _blank is skipped, _self (default) will load the url in the same window / frame where this function is called
					and if none of this values are used, the function will try to load the url in a frame named with same value of the target var;
  history (bool)  = true will replace the url in the browser history, false (default) will do the default browser behavior; */

	if( !target ) target = '_self';
	if( !history ) history = true;

	if( target == '_blank' ){
		return false;
	}else if( target == '_self' ){
		if( history == true ) window.location.href = url;
		else window.location.replace(url);
	}else if( target == '_top' ){
		if( history == true ) top.location.href = url;
		else top.location.replace(url);
	}else{
		if( history == true ) document.frames[target].location.href = url;
		else document.frames[target].location.replace(url);
	}
}


dbwt.OpenWindow = function(url, pName, _width, _height, userFeatures){/*
  Desc: open a popup window centered in the screen and returns a reference to the new created window;
  url (string)          = url to open in the new window;
  pName (string)        = nname for the new window;
  _width (int)          = witdth of the new window;
  _height (int)         = height of the new window;
  userFeatures (string) = optional string that contains settings to use in the last param of the window.open method; */

	var wFeatures;
	if( !(_width == null || _height == null) ){
		if( screen ){
			var leftpos = (screen.width / 2) - (_width / 2);
			var toppos  = ( (screen.height / 2) - (_height / 2) ) - 20;
		}

		if( userFeatures ){
			wFeatures = '';
			if( userFeatures.indexOf('width=') == -1 )
				wFeatures += 'width=' + _width + ',';
			if( userFeatures.indexOf('height=') == -1 )
				wFeatures += 'height=' + _height + ',';
			if( userFeatures.indexOf('top=') == -1 )
				wFeatures += 'top=' + toppos + ',';
			if( userFeatures.indexOf('left=') == -1 )
				wFeatures += 'left=' + leftpos + ',';
			wFeatures += userFeatures;
			if( wFeatures.substr(wFeatures.length - 1, 1) == ',' )
				wFeatures = wFeatures.substr(0, wFeatures.length - 1);
		}else{
			wFeatures = 'width=' + _width + ',height=' + _height + ',top=' + toppos + ',left=' + leftpos;
		}

		return window.open(url, pName, wFeatures);
	}else
		return window.open(url, pName);
}


dbwt.display_text_banner = function(box, text, num_spaces, speed, _1){/*
  Desc: transform an input text type into a text banner;
  box (string / object) = text box to transform;
  text (string)         = text to display in the banner, if not defined, the value of the text box will be used;
  num_spaces (int)      = spaces to add to the base string;
  speed (int)           = banner speed;
  NOTE: you have to add this function on page load to properly create the text banner; */

	var fText;
	if( typeof box == 'string' ) box = document.getElementById(box);
	if( !text ) var text = box.value;

	if( !_1 ){// if is the first time
		for( var k = 0; k <= num_spaces; k++ )
			text += " ";
	}else
		text = text.substr(1) + text.substr(0, 1);

	box.value = text;
	// start / restart timeout
	return setTimeout("dbwt.display_text_banner('" + box.id + "', null, " + num_spaces + ', ' + speed + ', true)', speed);
}


dbwt.htmlentities = function(_string, quoteStyle){/*
  Desc: convert some caractres to her equivalents html entity;
  _string (string)    = string to convert;
  quoteStyle (string) = possible values: ENT_COMPAT | ENT_QUOTES | ENT_NOQUOTES;
						ENT_COMPAT   -> Will convert double-quotes and leave single-quotes alone.
						ENT_QUOTES   -> Will convert both double and single quotes.
						ENT_NOQUOTES -> Will leave both double and single quotes unconverted.*/

	if( !quoteStyle ) quoteStyle = 'ENT_QUOTES';

	_string = _string.replace(/[&]/gi, '&amp;');
	_string = _string.replace(/[<]/gi, '&lt;');
	_string = _string.replace(/[>]/gi, '&gt;');

	if( quoteStyle == 'ENT_COMPAT' ){
		_string = _string.replace(/["]/gi, '&quot;');
	}else if( quoteStyle == 'ENT_QUOTES' ){
		_string = _string.replace(/["]/gi, '&quot;');
		_string = _string.replace(/[']/gi, '&#39;');
	}
	return _string;
}


dbwt.correctPNG = function(){/*
  Desc: correct the png images render problem in IE6- ; */

	var img, imgName, imgID, imgClass, imgTitle, imgStyle, strNewHTML;

	for( var i = 0, len = document.images.length; i < len; i++){
		img     = document.images[i];
		if( typeof img !== 'object' ) continue;
		imgName = img.src.toLowerCase();

		if( imgName.substr(imgName.length - 3) == 'png' ){
			imgID    = ( img.id ) ? ( 'id="' + img.id + '" ' ) : ( '' );
			imgClass = ( img.className ) ? ( 'class="' + img.className + '" ' ) : ( '' );
			imgTitle = ( img.title ) ? ( 'title="' + img.title + '" ' ) : ( 'title="' + img.alt + '" ' );
			imgStyle = 'display:inline-block;' + img.style.cssText;

			if (img.align == 'left')    imgStyle  = 'float:left;'  + imgStyle;
			if (img.align == 'right')   imgStyle  = 'float:right;' + imgStyle;
			if (img.parentElement.href) imgStyle  = 'cursor:hand;' + imgStyle;

			strNewHTML = '<span ' + imgID + imgClass + imgTitle
			+ ' style="' + 'width:' + img.width + 'px; height:' + img.height + 'px;' + imgStyle
			+ 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader'
			+ '(src=\'' + imgName + '\', sizingMethod=\'image\');"></span>';
			img.outerHTML = strNewHTML;
			i = i - 1;
		}
	}
}


dbwt.getPageRealSize = function(){/*
  Desc: Get the page measures, including scroll; */

	if( document.documentElement )
		var _document = document.documentElement;// Quirk Mode
	else
		var _document = document.body;// Strict Mode

	if( window.innerHeight && window.scrollMaxY ){// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	}else if( _document.scrollHeight > _document.offsetHeight ){// all but Explorer Mac
		yWithScroll = _document.scrollHeight;
		xWithScroll = _document.scrollWidth;
	}else{// works in Explorer 6+, Mozilla (not FF) and Safari
		yWithScroll = _document.offsetHeight + _document.offsetTop;
		xWithScroll = _document.offsetWidth + _document.offsetLeft;
  	}

	arrayPageSizeWithScroll = new Array(xWithScroll, yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
}


dbwt.setFlashMeasures = function(objID, minWidth, minHeight, maxWidth, maxHeight){/*
  Desc: Set the width and/or the height of the tag object that holds the flash movie
  		Making possible to specify a max/min width/height for the flash movie (when you want it 100% of the page)
		If the window is >minWidth && <maxWidth, than the flash movie width will be 100%, if not, minWidth or maxWidth will be used;
  objID (string)  = id of the OBJECT tag that have the flash movie;
  minWidth (int)  = minimum width allowed for the flash movie to have;
  minHeight (int) = minimum height allowed for the flash movie to have;
  maxWidth (int)  = maximum width allowed for the flash movie to have;
  maxHeight (int) = maximum height allowed for the flash movie to have; */

	if( !minWidth ) minWidth = 0;
	if( !minHeight ) minHeight = 0;
	if( !maxWidth ) maxWidth = 0;
	if( !maxHeight ) maxHeight = 0;

	this.setEvent(window, 'onload', "dbwt.flash_targetFlashObject = document.getElementById('" + objID + "');", false);
	this.setEvent(window, 'onload', 'dbwt.onResizeRepairFlashMeasures(' + minWidth + ', ' + minHeight + ', ' + maxWidth + ', ' + maxHeight + ');', false);
	this.setEvent(window, 'onresize', 'dbwt.onResizeRepairFlashMeasures(' + minWidth + ', ' + minHeight + ', ' + maxWidth + ', ' + maxHeight + ');', false);
}


dbwt.parseUrl = function(url){/*
  Desc: parse the url and returns an object similar to the buildin javascript location object (property names are the same);
  url (string) = url string to parse; */

	var sArgs;
	var result = url.match(/(https?:\/\/)([a-zA-Z0-9_\-\.]+):?([0-9]+)?\/?([^?#]*)?\??([^#]*)?#?(.*)?/);

	if( !result[3] ) result[3] = null;
	if( !result[4] ) result[4] = null;
	if( !result[5] ) result[5] = null;
	else{
		sArgs     = result[5].split('&');
		result[5] = new Array();

		for( var i in sArgs ){
			if( sArgs[i] == '' ) continue;
			result[5][ sArgs[i].slice(0, sArgs[i].indexOf('=')) ] = unescape( sArgs[i].slice(sArgs[i].indexOf('=') + 1) );
		}
	}
	if( !result[6] ) result[6] = null;

	return { protocol: result[1].replace('//', ''), host: result[2], port: result[3], pathname: result[4], search: result[5], hash: result[6] };
}


dbwt.detectPlugin = function(pluginName){/*
  Desc: get the browser support for a given plugin.
  pluginName (string) = plugin name to know his browser support;
  RETURNS: true is the browser supports the given plugin, false is not supported or -1 if the plugin name is not recognized by the function*/

	var k, ieOnWin;

	ieOnWin = ( this.getBrowser('ie') && navigator.userAgent.indexOf('Win') != -1 ) ? ( true ) : ( false );

	switch( pluginName ){
		case 'pdf': case 'PDF':
		case 'acrobat': case 'Acrobat':
		case 'Acrobat Reader': case 'acrobat reader':
		case 'Adobe Acrobat': case 'adobe acrobat':
		case 'Adobe Acrobat Reader': case 'adobe acrobat reader':
			if( ieOnWin ){
				pluginName = ['AcroPDF.PDF.1', 'PDF.PdfCtrl.1'];
				for( var k = 2; k < 10; k++ )
					pluginName.push('PDF.PdfCtrl.' + k);
			}else
				pluginName = 'Acrobat';
			break;
		case 'excel': case 'Excel':
			pluginName = ( ieOnWin ) ? ( 'Excel.Application' ) : ( 'Excel' );
			break;
		case 'Flash': case 'flash':
		case 'flash player': case 'Flash Player':
			pluginName = ( ieOnWin ) ? ( ['ShockwaveFlash.ShockwaveFlash', 'ShockwaveFlash.ShockwaveFlash.1'] ) : ( 'Shockwave Flash' );
			break;
		case 'Shockwave': case 'shockwave':
		case 'Shockwave Player': case 'shockwave player':
			pluginName = ( ieOnWin ) ? ( 'SWCtl.SWCtl' ) : ( 'Shockwave for Director' );
			break;
		case 'QuickTime': case 'quicktime':
			pluginName = ( ieOnWin ) ? ( ['QuickTime.QuickTime', 'QuickTime.QuickTime.4', 'QuickTimeCheckObject.QuickTimeCheck'] ) : ( 'QuickTime' );
			break;
		case 'RealPlayer': case 'realplayer':
			if( ieOnWin )
				pluginName = ['RealPlayer', 'RealVideo.RealVideo(tm) ActiveX Control (32-bit)', 'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)', 'rmocx.RealPlayer G2 Control.1', 'rmocx.RealPlayer G2 Control'];
			else
				pluginName = 'RealPlayer';
			break;
		case 'windows media player': case 'Windows Media Player':
		case 'Media Player': case 'media player':
			pluginName = ( ieOnWin ) ? ( ['MediaPlayer.MediaPlayer.1', 'WMPlayer.OCX'] ) : ( 'Windows Media' );
			break;
		case 'java': case 'Java':
			pluginName = ( ieOnWin ) ? ( ['JavaPlugin', 'JavaWebStart.isInstalled', 'JavaWebStart.isInstalled.1.6.0.0', 'JavaPlugin.150_07'] ) : ( 'Java' );
			break;
		case 'silverlight':
			pluginName = ( ieOnWin ) ? ( 'AgControl.AgControl' ) : ( 'Silverlight' );
			break;
		default:
			return -1;
	}

	if( ieOnWin ){
		if( 'String' == typeof pluginName ){
			try{ new ActiveXObject(pluginName); return true; }
			catch(e){ return false; }
		}else{
			for( k in pluginName ){
				try{ new ActiveXObject(pluginName[k]); return true; }
				catch(e){}
			}	
		}
	}else{
		if( navigator.plugins && navigator.plugins.length > 0 ){
			var pluginsArrayLength = navigator.plugins.length;
			// for each plugin...
			for( k = 0; k < pluginsArrayLength; k++ ){
				if( navigator.plugins[k].name.indexOf(pluginName) >= 0 || navigator.plugins[k].description.indexOf(pluginName) >= 0 )
					return true;
			}
		}
	}
	return false;
}


dbwt.numberFormat = function(number, decimals, dec_point, thousands_sep){/*
  Desc: Format a number with grouped thousands;
  number (mixed)        = the number being formatted;
  decimals (mixed)      = sets the number of decimal points;
  dec_point (mixed)     = sets the separator for the decimal point;
  thousands_sep (mixed) = sets the thousands separator; */

	var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}


dbwt.phpSerialize = function(val){/*
  Desc: serialize an Object, JSON, Array or any variable into a string that can be converted back into an array in PHP using unserialize function;
  val (mixed) = data to be serialized; */

	switch( typeof(val) ){
		case 'number':
			if (val == NaN || val == Infinity) return 'i:0;';
			return (Math.floor(val) == val ? 'i' : 'd') + ':' + val + ';';

		case 'boolean':
			return 'b:' + (val ? '1' : '0') + ';';

		case 'string':
			return 's:' + val.length + ':"' + val + '";';  

		case 'object':
			if( val == null )
				return 'N;';
			else{
				var indexes = 0;
				var t = '';
				for(var key in val){
					if( key == parseInt(key) ) key = parseInt(key);
					t += this.phpSerialize(key, true) + this.phpSerialize(val[key]);
					indexes++;
				}
				return 'a:' + indexes + ':{' + t + '}';
			}

		case 'function':
			return false;

		case 'undefined':  
			return 'N;';  
	}
	return false;
}


dbwt.setEvent = function(elem, _event, _exp, replaceEvt){/*
  Desc: this function attach an exp to an element event, preserving the this scope;
  elem (object)     = element object to receive the expression in a given event;
  _event (string)   = event name (ex: onclick);
  exp (string)      = expression / code to execute when the event "_event" is triggered;
  replaceEvt (bool) = tell the function to replace the current event expression with the new one, default: false; */

	if( !elem || !_exp ) return false;
	if( !_event ) var _event = 'onclick';
	if( !replaceEvt ) var replaceEvt = false;

	var curEvt, curEvt_str, newFunction;

	_event     = _event.toLowerCase();
	curEvt     = eval('elem.' + _event);
	curEvt_str = ( typeof curEvt == 'function' ) ? (' ' + curEvt) : ('');
	curEvt_str = curEvt_str.replace(/return[\s]/ig, '');// removing returns
	curEvt_str = curEvt_str.replace(/(.|\r\n|\n)*[\{]/, '');
	curEvt_str = curEvt_str.replace(/[\}][\s]?$/, '');

	if( replaceEvt === true )
		newFunction = new Function( _exp );
	else
		newFunction = new Function( curEvt_str + _exp );
	eval('elem.' + _event + ' = ' + newFunction);
	return true;
}




/**
	PRIVATE METHODS
**/





dbwt.validateElement = function(e, p, pv){/*
  Desc: this function will return true if the passed element have the property value pair, false outherwise;
  e  (object) = element object;
  p  (string) = property name to look for;
  pv (string) = expected value for the finded property; */

	var t;
	if( p ){
		if( !(t = e.getAttribute(p)) ) return false;
		if( pv && (p == 'class' || p == 'className') )
			return ( t == pv || t.indexOf(' ' + pv + ' ') >= 0 || t.substr(0, pv.length + 1) == pv + ' ' || t.substr(t.length - (pv.length + 1)) == ' ' + pv ) ? ( true ) : ( false );
		else if( pv )
			return ( t == pv ) ? ( true ) : ( false );
		else
			return ( t ) ? ( true ) : ( false );
	}
	return true;
}


dbwt.removeEvent = function(elem, _event, expToRem){/*
  Desc: this function removes an event from an element;
  elem (object)     = element that contains the event to be changed;
  _event (string)   = event name (ex: onclick);
  expToRem (string) = expression / code to be removed; */

	var re, curEvt, curEvt_str, newFunction;

	curEvt = eval('elem.' + _event);
	if( typeof curEvt != 'function' ) return false;
	else curEvt_str = '' + curEvt;

	if( expToRem.substr(expToRem.length - 1) == ';' )
		expToRem = expToRem.substr(0, expToRem.length - 1);

	// removing the function definition part
	curEvt_str = curEvt_str.replace(/(.|\r\n|\n)*[\{][\n\r]*/, '');
	curEvt_str = curEvt_str.replace(/[\}][\s\n\r\n]?$/, '');

	// removing the specified expression
	re = eval("/(return[\\s]+)?" + expToRem + "(.)*[;\\n\\r$]+/gi");
	curEvt_str = curEvt_str.replace(re, "");

	newFunction = new Function( curEvt_str );
	eval('elem.' + _event + ' = ' + newFunction);
	return true;
}


dbwt.onResizeRepairFlashMeasures = function(minWidth, minHeight, maxWidth, maxHeight){/*
  Desc: Set the width and/or the height of the tag object that holds the flash movie
  		Making possible to specify a max/min width/height for the flash movie (when you want it 100% of the page)
		If the window is >minWidth && <maxWidth, than the flash movie width will be 100%, if not, minWidth or maxWidth will be used;
  minWidth (int)  = minimum width allowed for the flash movie to have;
  minHeight (int) = minimum height allowed for the flash movie to have;
  maxWidth (int)  = maximum width allowed for the flash movie to have;
  maxHeight (int) = maximum height allowed for the flash movie to have; */

	var fl_obj = this.flash_targetFlashObject;
	if( !fl_obj ) return false;

	var sWidth  = document.body.clientWidth;
	var sHeight = document.body.clientHeight;

	if( sWidth != null && sWidth > maxWidth )
		fl_obj.style.width = maxWidth + 'px';
	else if( sWidth != null && sWidth <= minWidth )
		fl_obj.style.width = minWidth + 'px';
	else
		fl_obj.style.width = '100%';

	if( sHeight != null && sHeight > maxHeight )
		fl_obj.style.height = maxHeight + 'px';
	if( sHeight != null && sHeight <= minHeight )
		fl_obj.style.height = minHeight + 'px';
	else
		fl_obj.style.height = '100%';
}



/* --------------------------------------------------------------------------------------------------- */

dbwt.init = function(){
	if( this.getBrowser('IE6') )
		this.correctPNG();

	// initializing descendant objects (calls the init method, if exists, of all directly descendant objects)
	for( var k in this ){
		if( typeof this[k] != 'object' ) continue;
		if( typeof this[k].init == 'function' ) this[k].init();
	}
}
dbwt.browserVer = dbwt.getBrowserVer();
dbwt.setEvent(window, 'onload', 'dbwt.init();', false);
