//
// Copyright (c) Art. Lebedev Studio | http://www.artlebedev.ru/
// Author - Leechy | leechy@design.ru
//


/*****************************
**   Event listeners
******************************/

function addEvent(objElement, strEventType, ptrEventFunc) {
	if (objElement.addEventListener) objElement.addEventListener(strEventType, ptrEventFunc, false);
		else if (objElement.attachEvent) objElement.attachEvent('on' + strEventType, ptrEventFunc);
}

function removeEvent(objElement, strEventType, ptrEventFunc) {
	if (objElement.removeEventListener) objElement.removeEventListener(strEventType, ptrEventFunc, false);
		else if (objElement.detachEvent) objElement.detachEvent('on' + strEventType, ptrEventFunc);
}


/*****************************
**   Common class methods
******************************/

function switchClass( objNode, strCurrClass, strNewClass ) {
	if ( matchClass( objNode, strNewClass ) ) replaceClass( objNode, strCurrClass, strNewClass );
		else replaceClass( objNode, strNewClass, strCurrClass );
}

function removeClass( objNode, strCurrClass ) {
	replaceClass( objNode, '', strCurrClass );
}

function addClass( objNode, strNewClass ) {
	replaceClass( objNode, strNewClass, '' );
}

function replaceClass( objNode, strNewClass, strCurrClass ) {
	var strOldClass = strNewClass;
	if ( strCurrClass && strCurrClass.length ){
		strCurrClass = strCurrClass.replace( /\s+(\S)/g, '|$1' );
		if ( strOldClass.length ) strOldClass += '|';
		strOldClass += strCurrClass;
	}
	objNode.className = objNode.className.replace( new RegExp('(^|\\s+)(' + strOldClass + ')($|\\s+)', 'g'), '$1' );
	objNode.className += ( (objNode.className.length)? ' ' : '' ) + strNewClass;
}

function matchClass( objNode, strCurrClass ) {
	return ( objNode.className.length && objNode.className.match( new RegExp('(^|\\s+)(' + strCurrClass + ')($|\\s+)') ) );
}


/*****************************
**   Common cookie methods
******************************/

// Functions from Netscape's JavaScript Guide
// http://developer.netscape.com/docs/manuals/js/client/jsguide/

function setCookie(name, value, expire, path) {
	document.cookie = name + '=' + escape(value)
		+ ((expire == null)? '' : ('; expires=' + expire.toGMTString()))
		+ ((path == null)? '' : ('; path=' + path));
}

function getCookie(Name) {
	var search = Name + '='
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search)
		if (offset != -1) { // if cookie exists
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(';', offset)
			// set index of end of cookie value
			if (end == -1)
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		}
	}
	return '';
}


/*****************************
**   Some other methods
******************************/

function getTextValue( objNode ) {
	var strValue = new String();
	if ( objNode.childNodes.length ) {
		for ( var i = 0; i < objNode.childNodes.length; i++ ) {
			if ( objNode.childNodes[i].nodeType == 1 ) strValue += getTextValue( objNode.childNodes[i] );
			if ( objNode.childNodes[i].nodeType == 3 ) strValue += objNode.childNodes[i].nodeValue;
		}
	}
	return strValue;
}

function mailLink( strName, strDomain, strLinkText ){
	document.writeln('<a href="mailto:' + strName + '@' + strDomain + '">' + strLinkText + '</a>');
}
function tover(q) {q.children.tags('a')[0].style.color = "#000066";}
function trtover(q) {q.style.backgroundColor='#E0E0E0'; q.style.cursor='hand'}
function tout(q) {q.children.tags('a')[0].style.color = "#000066";}
function trtout(q) {q.style.backgroundColor = '#FFFFFF';}
function vipover(q) {q.style.backgroundColor='#FFFFFF'; q.style.cursor='hand'}
function vipout(q) {q.style.backgroundColor ='#E5E5E5';}
function LmUp(path) {location.href = path;}

function show(file, width, height)
	{
			file=file;
			//window.open(file, "_blank", "width="+width+",height="+height+",titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
			window.open(file, "_blank", "width="+width+",height="+height+",titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
	}



