// Title: Tigra Hints
// URL: http://www.softcomplex.com/products/tigra_hints/
// Version: 2.1.1
// Date: 09/03/2007
// Note: This script is free for any kind of applications
//	The development of this software is funded by your donations

var HINTS_CFG2 = {
     'wise'       : true,
     'margin'     : 10,
     'gap'        : 20,
     'align'      : 'bctc',
     'css'        : 'hintsClass1',
     'show_delay' : 200,
     'hide_delay' : 300,
     'follow'     : false,
     'z-index'    : 100,
     'IEfix'      : false,
     'IEtrans'    : ['revealTrans(TRANSITION=3,DURATION=.5)', 'revealTrans(TRANSITION=2,DURATION=.5)'],
     'opacity'    : 90
};
  
var HINTS_CFG3 = {
	'wise'       : true, // don't go off screen, don't overlap the object in the document
	'margin'     : 10, // minimum allowed distance between the hint and the window edge (negative values accepted)
	'gap'        : -7, // minimum allowed distance between the hint and the origin (negative values accepted)
	'align'      : 'trbl', // align of the hint and the origin (by first letters origin's top|middle|bottom left|center|right to hint's top|middle|bottom left|center|right)
	'css'        : '', // a style class name for all hints, applied to DIV element (see style section in the header of the document)
	'show_delay' : 200, // a delay between initiating event (mouseover for example) and hint appearing
	'hide_delay' : 300, // a delay between closing event (mouseout for example) and hint disappearing
	'follow'     : false, // hint follows the mouse as it moves
	'z-index'    : 100, // a z-index for all hint layers
	'IEfix'      : false, // fix IE problem with windowed controls visible through hints (activate if select boxes are visible through the hints)
	'IEtrans'    : ['blendTrans(TRANSITION=3, DURATION=.3)'], // [show transition, hide transition] - transition effects, only work in IE5+
	'opacity'    : 95 // opacity of the hint in %%
};   

var GLOSS_INFO = {     
	'active_movie'		: wrap_tgloss( 250, 'ActiveMovie', 'A web technology for streaming movies from a web server to a web client. Developed by Microsoft.' ),    
	'activex'			: wrap_tgloss( 250, 'ActiveX', 'A programming interface ( <b>API</b> ) that allows web browsers to download and execute Windows programs.'),
	'ado'				: wrap_tgloss( 350, 'ADO - ActiveX Data Object', '>A Microsoft technology that provides data access to any kind of data store.',
							  		  '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/ado/default.asp">ADO tutorial on W3Schools</a>'),	
	'anchors'			: wrap_tgloss( 250, 'Anchors', 'In web terms: The starting point or ending point of a hyperlink.',
									  '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/html/html_links.asp">W3Schools HTML Tutorial</a>'),
	'ansi'				: wrap_tgloss( 350, 'ANSI - American National Standards Institute', 'Is an organization that creates standards for the computer industry.<br>Responsible for the ANSI C standard.'),
	'ansi_c'			: wrap_tgloss( 350, 'ANSI C - An international standard for the C programming language.' ),
	'api'				: wrap_tgloss( 400, 'API - Application Programming Interface', 'An interface for letting a program communicate with another program.<br />In web terms: An interface for letting web browsers or web servers communicate with other programs.'), 
	'ascii'				: wrap_tgloss( 420, 'ASCII - American Standard Code for Information Interchange', 'A set of 128 alphanumeric and special control characters used for computer storing - and printing of text.<br>Used by HTML when transmitting data over the web.'),
	'cern'				: wrap_tgloss( 450, 'CERN - European Organisation for Nuclear Research', 'is the world&acute;s largest particle physics laboratory, situated on Geneva, Swiss.'),	     							   
	'computer_virus'	: wrap_tgloss( 580, 'Computer Virus', 'A computer program that can harm a computer by displaying messages, deleting files, or even destroying the computer&acute;s operating system.'),
	'css'				: wrap_tgloss( 400, 'CSS - Cascading Style Sheets' , 'A W3C recommended language for defining style (such as font, size, color, spacing, etc.) for web documents.', 
									  '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/css/default.asp">Learn more about HTML on W3Schools</a>'),
	'dde'				: wrap_tgloss( 400,'Dynamic Data Exchange', 'is a technology for communication between multiple applications under Microsoft Windows or OS/2'),								  
	'dhtml'				: wrap_tgloss( 500,'DHTML - Dynamic HTML', 'A term commonly to describe HTML content that can change dynamically.<br>',
							      	 '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/dhtml/default.asp">DHTML tutorial on W3Schools</a>'),
	'dom'				: wrap_tgloss( 400, 'DOM - Document Object Model','Formal description of a programmable object, which can consist of one or more classes, events, functions, interfaces, methods, namespaces, objects, and properties'), 
	'dtd'				: wrap_tgloss( 580, 'DTD - Document Type Definition', 'A set of rules (a language) for defining the legal building blocks of a web document like HTML or XML.',
     								  '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/dtd/default.asp">Learn more about DTD on W3Schools</a>'),
	'firewall'			: wrap_tgloss( 500,	'Firewall', 'Software that acts as a security filter that can restrict types of network communication. Most often used between an individual computer (or a LAN) and the Internet.'),								 
	'ftp'				: wrap_tgloss( 250, 'FTP - File Transfer Protocol', 'One of the most common methods for sending files between two computers.' ),
	'gpl'				: wrap_tgloss( 600, 'GPL - GNU General Public License', 'is a widely used free software license, written for the GNU project.<br>GPL is the most popular and well-known example of the type of strong copyleft license that requires derived works to be available under the same copyleft.'),
	'html'				: wrap_tgloss( 300, 'HTML - Hypertext Markup Language', 'A programming interface for HTML documents.',
     	 							  '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/html/default.asp">Learn more about HTML on W3Schools</a>'),
	'html_tag'			: wrap_tgloss( 400, 'HTML Tags' ,'Code to identify the different parts of a document so that a web browser will know how to display it.',
     								  '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/html/default.asp">Learn more about HTML on W3Schools</a>'), 
    'http_req'			: wrap_tgloss( 500,'HTTP Request','Whenever a web browser fetches a page from a web server, it does so using HTTP, that is a request/response protocol.'),
	'intellisense'		: wrap_tgloss( 400,'Intellisense', 'is Microsoft`s implementation of autocompletion, best known for its use in the Microsoft Visual Studio integrated development environment.' ),
	'ip_address'		: wrap_tgloss( 420, 'IP Address - Internet Protocol Address', 'A unique number identifying every computer on the Internet (like 197.123.22.240).'), 		  
	'javascript'		: wrap_tgloss( 500, 'JavaScrip', 'The most popular scripting language on the internet, developed by Netscape',
         							  '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/js/default.asp">Learn more about JavaScript on W3Schools</a>'), 
	'kerberos'			: wrap_tgloss( 500, 'Kerberos Authentication','a computer network authentication protocol, which allows individuals communicating over a non-secure network to prove their identity to one another in a secure manner.' ),									  
    'lan'				: wrap_tgloss( 400, 'LAN - Local Area Network','A network between computers in a local area (like inside a building), usually connected via local cables.'),
    'malware'			: wrap_tgloss( 450, 'Malware', 'a portmanteau from the words malicious and software, is software designed to infiltrate or damage a computer system without the owner&acute;s informed consent.'), 
	'markup_lang'		: wrap_tgloss( 450, 'Markup Language', 'is an artificial language using a set of annotations to text that give instructions regarding the structure of text or how it is to be displayed' ),
	'mime'				: wrap_tgloss( 400, 'MIME - Multipurpose Internet Mail Extensions','An Internet standard for defining document types. MIME type examples: text/plain, text/html, image/gif, image/jpg.',
								 	  '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/media/media_mimeref.asp">Learn more about MIME types on W3Schools</a>'),
	'mosaic'			: wrap_tgloss( 400, 'Mosaic', 'The first commonly available web browser that was released in 1993 and started the popularity of the web. '),
	'oop'				: wrap_tgloss( 450, 'OOP - Object Oriented Programming', 'is a programming paradigm that uses &quot;objects&quot; and their interactions to design applications and computer programs.' ),
	'perl'				: wrap_tgloss( 350, 'Perl - Practical Extraction and Reporting Language ', 'A scripting language for web servers. Most often used on Unix servers.'),
	'php'				: wrap_tgloss( 400, 'PHP - Hypertext Preprocessor','A technology allowing the insertion of server executable scripts in web pages. Mostly for Unix, Linux and Solaris platforms.'), 
	'proxy_server'		: wrap_tgloss( 300, 'Proxy Server','An Internet server dedicated to improve Internet performance.'), 
	'rss'				: wrap_tgloss( 500, 'RSS', 'Feeds, also known as RSS feeds, XML feeds, syndicated content, or web feeds, contain frequently updated content published by a website.<br>They are usually used for news and blog websites, but are also used for distributing other types of digital content, including pictures, audio files, or video.'),
	'scripting_lang'	: wrap_tgloss( 450, 'Scripting Language', 'In web terms: A simple programming language that can be executed by a web browser or a web server.'),
	'semantic_web' 		: wrap_tgloss( 300, 'Semantic Web', 'A web of data with a meaning in the sense that computer programs can know enough about the data to process it.'),
	'spyware'			: wrap_tgloss( 420, 'Spyware','Computer software hidden in a computer with the purpose of collecting information about the use of the computer.'),
	'sub'				: wrap_tgloss( 500, 'Subroutine - procedure, function, method, or routine', 'is a portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code' ),
	'uddi'				: wrap_tgloss( 500, 'UDDI - Universal Description Discovery and Integration', ' platform-independent framework for describing services, discovering businesses, and integrating business services using the Internet.'),
	'uri'				: wrap_tgloss( 300, 'URI - Uniform Resource Identifier', 'Term used to identify resources on the internet. URL is one type of an URI.'),	
	'url'				: wrap_tgloss( 300, 'URL - Uniform Resource Locator', 'A web address. The standard way to address web documents (pages) on the Internet (like: http://www.w3schools.com/)'),	
    'w3c'				: wrap_tgloss( 370, 'W3C - World Wide Web Consortium', 'The organization responsible for managing standards for the WWW',
     								  '<a target="_blank" class="MenuLink" href="http://www.w3schools.com/w3c/default.asp">Learn more about W3C on W3Schools</a>'),  								 	  
	'wai'				: wrap_tgloss( 280, 'WAI -  Web Accessibility Initiative', 'is an effort to improve the accessibility of the <b>World Wide Web</b> for people with disabilities.'),
	'web_browser' 		: wrap_tgloss( 220, 'Web Browser', 'A software program used to display web pages.'),
	'web_page'			: wrap_tgloss( 400, 'Web Page','A web page or webpage is a resource of information that is suitable for the World Wide Web and can be accessed through a web browser.<br>This information is usually in HTML or XHTML format, and may provide navigation to other web pages via hypertext links.'),
	'web_server'		: wrap_tgloss( 350, 'Web Server', 'A server is a computer that delivers services or information to other computers.<br>In web terms: A server that delivers web content to web browsers.'),
	'win32_api'			: wrap_tgloss( 550, 'Win32 API', 'The Windows API, informally WinAPI, is Microsoft&acute;s core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. It was formerly called the Win32 API;'),
	'wsdl'				: wrap_tgloss( 350, 'Web Services Description Language - WSDL','an XML-based language for describing Web services and how to access them.'),
	'www'				: wrap_tgloss( 200, 'WWW - World Wide Web', 'A global network of computers using the internet to exchange web documents.'),
	'x509_token'		: wrap_tgloss( 200, 'X.509 Token', 'authentication framework with the Web Services Security: SOAP. An X.509 certificate specifies a binding between a public key and a set of attributes')
};

var QTP_INFO = { 
	'action_iter'		: wrap_qgloss( 300, 'Action/Global Iteration', 'Specifies the iterations for the test.' ),
	'assistive_prop' 	: wrap_qgloss( 400, 'Assistive Properties', 'Returns the collection representing the list of assistive properties from the Object Identification dialog box.'),
	'bitmap_check'		: wrap_qgloss( 400, 'Bitmap Checkpoint', 'Checks an area of an application as a bitmap. QuickTest captures the visible part of the specified object as a bitmap.') ,
	'checkpoint'        : wrap_qgloss( 400, 'Checkpoint', 'A verification point that compares the current value for specified properties with the expected value for those properties.'),	
	'expert_view' 		: wrap_qgloss( 400, 'Expert View', 'an alternative to using the Keyword View' ),
	'floating_license'  : wrap_qgloss( 300, 'Concurrent ( Floating ) License', 'Allows a license to be shared between machines at any given point in time.') ,
	'global_dt'			: wrap_qgloss( 400, 'Global Datasheet', 'The Global sheet contains the data that replaces parameters in each iteration of the test.'),
	'keyword_view'		: wrap_qgloss( 400, 'Keyword View', 'Enables you to create and view the steps of your component in a keyword-driven, modular, table format.'),
	'mandatory_prop'	: wrap_qgloss( 400, 'Mandatory Properties', 'A collection representing the list of mandatory or base filter properties from the Object Identification or Smart Identification dialog box.'),
	'object_spy'		: wrap_qgloss( 500, 'Object Spy', 'Enables you to view the native properties and operations of any object in an open application, as well as the test object hierarchy, identification properties, and operations of the test object that QuickTest uses to represent that object.'),
	'ordinal_id'		: wrap_qgloss( 550, 'Ordinal Identifier', 'In addition to learning the mandatory and assistive properties specified in the Object Identification dialog box, QuickTest can also learn a backup ordinal identifier for each test object.'),
	'runtime_obj'		: wrap_qgloss( 450, 'Run-Time object', 'A run-time object is the actual object in your application on which methods are performed during the run session.'),
	'test_object'		: wrap_qgloss( 400, 'Test Object', 'A test object is an object that QuickTest creates in the component to represent the actual object in your application.'),
	'update_mode'		: wrap_qgloss( 400, 'Update Mode', 'enables you to specify which aspects of your test or component you want to update, such as test object descriptions, expected checkpoint values, and/or Active Screen images and values.' ),
	'addin_mng'		    : wrap_qgloss( 400, 'Add-in Manager', 'To test applications developed in various environments, you must ensure that the relevant QuickTest add-in is installed and loaded on the computer on which you create and run your tests and components. Loading the relevant add-in enables QuickTest to work with the corresponding environment.When you start QuickTest, the Add-in Manager dialog box opens. It displays a list of all installed add-ins and the license used for each add-in.'),
	'smart_id'			: wrap_qgloss( 400, 'Smart Identification','If the learned description does not enable QuickTest to identify the specified object in a step, and a Smart Identification definition is defined (and enabled) for the object, then QuickTest tries to identify the object using the Smart Identification mechanism.')
};

function wrap2 (s_text, s_img) {
	return [
		'<table>',
		'<tr><td><img src="../img/corner_tl.gif" width="10" height="10" /></td><td style="background-image:url(../img/side_t.gif)"></td><td><img src="../img/corner_tr.gif" width="10" height="10" /></td></tr>',
		'<tr><td style="background-image:url(../img/side_l.gif)"></td><td class="hintText"><img src="', s_img ,'" border="1"><br/>', s_text ,'</img></td><td style="background-image:url(../img/side_r.gif)"></td></tr>',
		'<tr><td><img src="../img/corner_bl.gif" width="10" height="10" /></td><td style="background-image:url(../img/side_b.gif)"></td><td><img src="../img/corner_br.gif" width="10" height="10" /></td></tr>',
		'</table>'
	].join('');
}

function wrap_qgloss( w, s_title, s_text, s_lnk ) {
	return [
		'<table summary="tooltip box" class="hintClassBlue" cellspacing="0" cellpadding="5" style="width:', w, 'px">',
		'<tr><td class="titletdBlue">', s_title, '</td></tr><td class="tiptoolBlue"><p style="line-height: 15px;">', s_text, '</p></td></tr>',
		'<tr><td class="titletdBlue">', s_lnk, '</td></tr></table>'
	].join('');
}


function wrap_tgloss( w, s_title, s_text, s_lnk ) {
	return [
		'<table summary="tooltip box" class="hintClassBlackGrey" cellspacing="0" cellpadding="5" style="width:', w, 'px">',
		'<tr><td class="titletdBlackGrey">', s_title, '</td></tr><td class="tiptoolBlackGrey"><p style="line-height: 15px;">', s_text, '</p></td></tr>',
		'<tr><td class="titletdBlackGrey">', s_lnk, '</td></tr></table>'
	].join('');
}


function THints (a_items, a_cfg) {

	if (!a_items) a_items = [];
	if (!a_cfg) a_cfg = [];
	this.a_cfg = a_cfg;

	this.a_elements = [];
	this.a_hints = [];

	this.show  = f_hintShow;
	this.showD = f_hintShowNow;
	this.hide  = f_hintHide;
	this.hideD = f_hintHideNow;

	// register the object in global collection
	this.n_id = A_HINTS.length;
	A_HINTS[this.n_id] = this;
	
	if (!b_ie5 && !b_ie6)
		a_cfg.IEfix = false;

	// generate HTML
	for (var s_id in a_items) {
		s_id = String(s_id).replace(/\W/g,'');
		document.write(
			'<div style="position:absolute;left:0;top:0;visibility:hidden;z-index:',
			((a_cfg['z-index'] == null ? 2 : a_cfg['z-index']) + (a_cfg.IEfix ? 1 : 0)), ';',
			(a_cfg.IEtrans ? 'filter:' + a_cfg.IEtrans.join(' ') : '') ,
			(a_cfg.opacity ? ' alpha(opacity=' + a_cfg.opacity + '); -moz-opacity:' + (a_cfg.opacity / 100) + ';opacity:' + (a_cfg.opacity / 100) + '' : ''), '" id="h', this.n_id, '_', s_id,
			'" class="', (this.a_cfg.css ? this.a_cfg.css : 'tigraHint'),
			'" onmouseover="A_HINTS[', this.n_id + '].show(\'', s_id, '\')" onmouseout="A_HINTS[',
			this.n_id, '].hide(\'', s_id, '\')" onmousemove="f_onMouseMove(event)">',
			a_items[s_id], '</div>'
		);
		if (a_cfg.IEfix) document.write(
			'<iframe style="position:absolute;left:0;top:0;visibility:hidden;z-index:',
			(a_cfg['z-index'] == null ? 2 : a_cfg['z-index']), ';filter:alpha(opacity=0);" id="h',
			this.n_id, '_', s_id, '_if" frameborder="0" scrolling="No"></iframe>'
		);
	}
	// assign mouseover event	
	if (document.addEventListener) {
		document.addEventListener('mousemove', f_onMouseMove, false);
		window.addEventListener('scroll', f_onwindowChange, false);
		window.addEventListener('resize', f_onwindowChange, false);
	}
	if (window.attachEvent) {
		document.attachEvent('onmousemove', f_onMouseMove);
		window.attachEvent('onscroll', f_onwindowChange);
		window.attachEvent('onresize', f_onwindowChange);
	}
	else {
		document.onmousemove = f_onMouseMove;
		window.onscroll = f_onwindowChange;
		window.onresize = f_onwindowChange;
	}
}
var n_flag = false;

function f_hintShow(s_id, e_element) {

	// cancel previous delay
	if (this.e_timer) {
		clearTimeout(this.e_timer);
		this.e_timer = null;
	}

	var s_id = String(s_id).replace(/\W/g,'');
	if (!this.a_hints[s_id])
		this.a_hints[s_id] = getElement('h' + this.n_id + '_' + s_id);
	if (!this.a_hints[s_id])
		this.a_hints[s_id] = getElement(s_id);
	if (!this.a_hints[s_id])
		throw new Error('001', 'Can not find the hint with ID=' + s_id);

	this.a_elements[s_id] = e_element;

	var n_showDelay = this.a_cfg.show_delay == null ? 200 : this.a_cfg.show_delay;
	if (!n_showDelay)
		return this.showD(s_id, e_element);

	this.e_timer = setTimeout('A_HINTS[' + this.n_id + '].showD("' + s_id + '")', n_showDelay);
}

function f_hintShowNow(s_id, e_element) {
	if (s_id == this.o_lastHintID)
		return;

	if (e_element)
		this.a_elements[s_id] = e_element;
	if (this.o_lastHintID != null)
		this.hideD(this.o_lastHintID);

	this.o_lastIframe = getElement('h' + this.n_id + '_' + s_id + '_if');
	if (this.o_lastIframe)
		this.o_lastIframe.style.visibility = 'visible';
	
	// Transition in IE
	f_hintPosition(this.a_elements[s_id], this.a_hints[s_id], this.a_cfg);
	if (this.a_cfg.IEtrans && this.a_cfg.IEtrans[0]) {
		try {
			var e_currTrans = this.a_hints[s_id].filters.item(0);
			e_currTrans.apply();
			this.a_hints[s_id].style.visibility = 'visible';
			e_currTrans.play();
		} catch(e) {
			this.a_hints[s_id].style.visibility = 'visible';
		};
	}
	else {
		this.a_hints[s_id].style.visibility = 'visible';
	}

	this.o_lastHintID = s_id;
}

function f_hintHide(s_id) {

	if (this.e_timer) {
		clearTimeout(this.e_timer);
		this.e_timer = null;
	}

	if (s_id != null)
		s_id = String(s_id).replace(/\W/g,'');
	else if (this.o_lastHintID)
		s_id = this.o_lastHintID;
	else
		return;
	
	if (!this.a_hints[s_id])
		throw new Error('001', 'Can not find the hint with ID=' + s_id);

	var n_hideDelay = this.a_cfg.hide_delay == null ? 200 : this.a_cfg.hide_delay;
	if (!n_hideDelay)
		return this.hideD(s_id);

	this.e_timer = setTimeout('A_HINTS[' + this.n_id + '].hideD("' + s_id + '")', n_hideDelay);
}

function f_hintHideNow(s_id) {
	// Transition in IE
	if (this.a_cfg.IEtrans && this.a_cfg.IEtrans[1]) {
		try {
			var e_currTrans = this.a_hints[s_id].filters.item(this.a_cfg.IEtrans[0] ? 1 : 0);
			e_currTrans.apply();
			this.a_hints[s_id].style.visibility = 'hidden';
			e_currTrans.play();
		} catch(e) {
			this.a_hints[s_id].style.visibility = 'hidden';
		};
	}
	else
		this.a_hints[s_id].style.visibility = 'hidden';

	this.o_lastHintID = null;
	if (this.o_lastIframe) {
		this.o_lastIframe.style.visibility = 'hidden';
		this.o_lastIframe = null;
	}
}


function f_hintPosition (e_element, e_hint, a_params) {
	// validate params
	if (!e_hint) throw new Error('001', 'hint object reference is missing in parameters');
	if (!a_params) a_params = [];

	
	var a_ = {
		n_elementWidth: e_element ? e_element.offsetWidth : 0,
		n_elementHeight: e_element ? e_element.offsetHeight : 0,
		n_elementLeft: e_element ? f_getPosition(e_element, 'Left') : n_mouseX,
		n_elementTop: e_element ? f_getPosition(e_element, 'Top') : n_mouseY,
		n_hintWidth: e_hint.offsetWidth,
		n_hintHeight: e_hint.offsetHeight,
		n_hintLeft: 0,
		n_hintTop : 0,
		n_clientWidth: f_clientWidth(),
		n_clientHeight: f_clientHeight(),
		n_scrollTop: f_scrollTop(),
		n_scrollLeft: f_scrollLeft(),
		s_align: a_params.align ? a_params.align : 'tlbl',
		n_gap: a_params.gap == null ? 5 : a_params.gap,
		n_margin: a_params.margin == null ? 10 : a_params.margin
	};

	f_applyAlign(a_);
	if (a_.n_hintLeft == 0)
		a_.n_hintLeft = -10000;
	// smart positioning is on by default
	else if (a_params.smart || a_params.smart == null)
		f_checkFit(a_);

	e_hint.style.left = a_.n_hintLeft + 'px';
	e_hint.style.top = a_.n_hintTop + 'px';

	// synchronize iframe if exists	
	var e_iframe = getElement(e_hint.id + '_if');
	if (e_iframe) {
		e_iframe.style.left = a_.n_hintLeft + 'px';
		e_iframe.style.top = a_.n_hintTop + 'px';
		e_iframe.style.width = a_.n_hintWidth + 'px';
		e_iframe.style.height = a_.n_hintHeight + 'px';
	}
}

/* corrects hints positioning to maximize the visibility */			
function f_checkFit (a_) {

	// check if correction is required
	if (a_.n_spaceT >= 0 && a_.n_spaceR >= 0 && a_.n_spaceB >= 0 && a_.n_spaceL >= 0)
		return;

	// determine if hint clears element for horisontal shifting
	var b_horShift =
		(a_.n_hintTop + a_.n_hintHeight + a_.n_gap <= a_.n_elementTop) ||
		(a_.n_elementTop + a_.n_elementHeight + a_.n_gap <= a_.n_hintTop);
	
	// resolve by horizontal shifting
	if (b_horShift) {
		if (a_.n_spaceL < 0 || (a_.n_spaceL + a_.n_spaceR < 0))
			a_.n_hintLeft = a_.n_scrollLeft + a_.n_margin;
		else if (a_.n_spaceR < 0)
			a_.n_hintLeft = a_.n_scrollLeft + a_.n_clientWidth - a_.n_margin - a_.n_hintWidth;
	}
	// determine if hint clears element for vertical shifting
	var b_verShift =
		(a_.n_hintLeft + a_.n_hintWidth + a_.n_gap <= a_.n_elementLeft) ||
		(a_.n_elementLeft + a_.n_elementWidth + a_.n_gap <= a_.n_hintLeft);

	// resolve by vertical shifting
	if (b_verShift) {
		if (a_.n_spaceT < 0 || (a_.n_spaceT + a_.n_spaceB < 0))
			a_.n_hintTop = a_.n_scrollTop + a_.n_margin;
		else if (a_.n_spaceB < 0)
			a_.n_hintTop = a_.n_scrollTop + a_.n_clientHeight - a_.n_margin - a_.n_hintHeight;
	}

	// resolve horisontal collision by mirroring
	if (!b_horShift && (a_.n_spaceL < 0 || a_.n_spaceR < 0)) {
		// save current overlap
		var n_overlap  = a_.n_spaceL + a_.n_spaceR,
			n_hintLeft = a_.n_hintLeft,
			n_hintTop  = a_.n_hintTop;

		// mirror the align
		a_.s_align = a_.s_align.replace('r', '-');
		a_.s_align = a_.s_align.replace('l', 'r');
		a_.s_align = a_.s_align.replace('-', 'l');
		f_applyAlign(a_);

		// restore old coordinate if mirrored hint is less visible
		if (Math.min(a_.n_spaceL, a_.n_spaceR) < n_overlap)
			a_.n_hintLeft = n_hintLeft;
		a_.n_hintTop = n_hintTop;
	}
	// resolve vertical collision by mirroring
	if (!b_verShift && (a_.n_spaceT < 0 || a_.n_spaceB < 0)) {
		var n_overlap  = Math.min(a_.n_spaceT, a_.n_spaceB),
			n_hintLeft = a_.n_hintLeft,
			n_hintTop  = a_.n_hintTop;

		// mirror the align
		a_.s_align = a_.s_align.replace('t', '-');
		a_.s_align = a_.s_align.replace('b', 't');
		a_.s_align = a_.s_align.replace('-', 'b');
		f_applyAlign(a_);

		// restore old coordinate if mirrored hint is less visible
		if (Math.min(a_.n_spaceT, a_.n_spaceB) < n_overlap)
			a_.n_hintTop = n_hintTop;
		a_.n_hintLeft = n_hintLeft;
	}
}

/* decodes the align parameter and calculates the coordinates of the hint */
function f_applyAlign (a_) {

	if (!re_align.exec(a_.s_align))
		throw new Error('001', 'Invalid format of align parameter: ' + a_.s_align);
	
	// decode alignment
	var n_align = RegExp.$1,
		n_top = a_.n_elementTop;

	// element vertical align
	if (n_align == 'm')
		n_top += Math.round(a_.n_elementHeight / 2);
	else if (n_align == 'b')
		n_top += a_.n_elementHeight + a_.n_gap;
	else
		n_top -= a_.n_gap;

	// hint vertical align
	n_align = RegExp.$3;
	if (n_align == 'm')
		n_top -= Math.round(a_.n_hintHeight / 2);
	else if (n_align == 'b')
		n_top -= a_.n_hintHeight;
		
	// element horizontal align
	var n_left = a_.n_elementLeft;
	n_align = RegExp.$2;
	if (n_align == 'c')
		n_left += Math.round(a_.n_elementWidth / 2);
	else if (n_align == 'r')
		n_left += a_.n_elementWidth + a_.n_gap;
	else
		n_left -= a_.n_gap;

	// hint horisontal align
	n_align = RegExp.$4;
	if (n_align == 'c')
		n_left -= Math.round(a_.n_hintWidth / 2);
	else if (n_align == 'r')
		n_left -= a_.n_hintWidth;

	a_.n_spaceT = n_top - a_.n_scrollTop - a_.n_margin,
	a_.n_spaceB = a_.n_clientHeight + a_.n_scrollTop - a_.n_margin - n_top - a_.n_hintHeight,
	a_.n_spaceL = n_left - a_.n_scrollLeft - a_.n_margin,
	a_.n_spaceR = a_.n_clientWidth + a_.n_scrollLeft - a_.n_margin - n_left - a_.n_hintWidth;

	a_.n_hintLeft = n_left;
	a_.n_hintTop  = n_top;
}

function f_onMouseMove(e_event) {
	if (!e_event && window.event)
		e_event = window.event;
	if (!e_event)
		return true;
	n_mouseX = e_event.pageX ? e_event.pageX : e_event.clientX + f_scrollLeft();
	n_mouseY = e_event.pageY ? e_event.pageY + 2 : e_event.clientY + f_scrollTop();
	return f_onwindowChange();
}

function f_onwindowChange() {
	var o_hint;
	for (var i = 0; i < A_HINTS.length; i++) {
		o_hint = A_HINTS[i];
		if (o_hint.a_cfg.follow && o_hint.o_lastHintID)
			f_hintPosition(o_hint.a_elements[o_hint.o_lastHintID], o_hint.a_hints[o_hint.o_lastHintID], o_hint.a_cfg);
	}
	return true;
}

/* browser abstraction layer */
function f_getPosition (e_elemRef, s_coord) {
	var n_pos = 0, n_offset,
		e_elem = e_elemRef;

	while (e_elem) {
		n_offset = e_elem["offset" + s_coord];
		n_pos += n_offset;
		e_elem = e_elem.offsetParent;
	}
	// margin correction in some browsers
	if (b_ieMac)
		n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
	
	e_elem = e_elemRef;
	while (e_elem != document.body) {
		n_offset = e_elem["scroll" + s_coord];
		if (n_offset && e_elem.style.overflow == 'scroll')
			n_pos -= n_offset;
		e_elem = e_elem.parentNode;
	}
	return n_pos;
}

function f_clientWidth() {
	if (typeof(window.innerWidth) == 'number')
		return window.innerWidth;
	if (document.documentElement && document.documentElement.clientWidth)
		return document.documentElement.clientWidth;
	if (document.body && document.body.clientWidth)
		return document.body.clientWidth;
	return null;
}
function f_clientHeight() {
	if (typeof(window.innerHeight) == 'number')
		return window.innerHeight;
	if (document.documentElement && document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
	if (document.body && document.body.clientHeight)
		return document.body.clientHeight;
	return null;
}
function f_scrollLeft() {
	if (typeof(window.pageXOffset) == 'number')
		return window.pageXOffset;
	if (document.body && document.body.scrollLeft)
		return document.body.scrollLeft;
	if (document.documentElement && document.documentElement.scrollLeft)
		return document.documentElement.scrollLeft;
	return 0;
}
function f_scrollTop() {
	if (typeof(window.pageYOffset) == 'number')
		return window.pageYOffset;
	if (document.body && document.body.scrollTop)
		return document.body.scrollTop;
	if (document.documentElement && document.documentElement.scrollTop)
		return document.documentElement.scrollTop;
	return 0;
}

getElement = document.all ?
	function (s_id) { return document.all[s_id] } :
	function (s_id) { return document.getElementById(s_id) };

// global variables
var A_HINTS = [],
	n_mouseX = 0,
	n_mouseY = 0,
	s_userAgent = navigator.userAgent.toLowerCase(),
	re_align = /^([tmb])([lcr])([tmb])([lcr])$/;

var b_mac = s_userAgent.indexOf('mac') != -1,
	b_ie5    = s_userAgent.indexOf('msie 5') != -1,
	b_ie6    = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1,
	b_ieMac  = b_mac && b_ie5,
	b_safari = b_mac && s_userAgent.indexOf('safari') != -1,
	b_opera6 = s_userAgent.indexOf('opera 6') != -1;

var glossTip = new THints( GLOSS_INFO, HINTS_CFG3 );
var qtTip = new THints( QTP_INFO, HINTS_CFG3 );
