function loadjscssfile( filename, filetype ){
	if ( filetype == "js" ) { //if filename is a external JavaScript file
		var fileref = document.createElement( 'script' );
		fileref.setAttribute( "type", "text/javascript" );
		fileref.setAttribute( "src", filename );
		} else if ( filetype == "css" ) { //if filename is an external CSS file
			var fileref = document.createElement( "link" );
			fileref.setAttribute( "rel", "stylesheet" );
			fileref.setAttribute( "type", "text/css" );
			fileref.setAttribute( "href", filename );
			}
	if ( typeof fileref != "undefined" )
		document.getElementsByTagName( "head" )[0].appendChild( fileref );
	}

loadjscssfile("/js/jquery.min.js", "js");
loadjscssfile("/js/handler.js", "js");
loadjscssfile("/js/ccdk.js", "js");
loadjscssfile("/js/gallery.js", "js");

var oldEl = '';

function onMouse( el ) {
	if ( oldEl ) { outMouse( oldEl ) }
	if ( document.getElementById( el + 'sub' ) ) {
		document.getElementById( el ).style.color = '#305DA0';
		document.getElementById( el + 'sub' ).style.top = ( parseInt( getElementPosition2( el ).top + getElementPosition2( el ).height ) + 0 ) + 'px';
		document.getElementById( el + 'sub' ).style.left = ( parseInt( getElementPosition2( el ).left ) ) - 1 + 'px';
		document.getElementById( el + 'sub' ).style.width = getElementPosition2( el ).width + 3 + 'px' ;
		document.getElementById( el + 'sub' ).style.visibility = 'visible';
		document.getElementById( el + 'sub' ).onmouseover = document.getElementById( el + 'subf' ).onmouseover = function() { onMouse( el ) }
		document.getElementById( el + 'sub' ).onmouseout = document.getElementById( el + 'subf' ).onmouseover = function() { outMouse( el ) }
		oldEl = el;
		}
	}

function outMouse( el ) {
	if ( oldEl && document.getElementById( oldEl + 'sub' ).style.visibility == 'visible' ) { document.getElementById( el ).style.color = '#808080'; document.getElementById( oldEl + 'sub' ).style.visibility = 'hidden'; }
	}

function getElementPosition2 ( val ) {
	var elem =  ( parent.document.getElementById (val) ) ? parent.document.getElementById (val) : document.getElementById (val) ;
	var widthElem = elem.offsetWidth; var heightElem = elem.offsetHeight;
	var leftElem = 0; var topElem = 0;
	while (elem) {
		leftElem += elem.offsetLeft;
		topElem += elem.offsetTop;
		elem = elem.offsetParent;
		}
	return {"left":leftElem, "top":topElem, "width": widthElem, "height":heightElem};
	}

function verSend( form ) {
	form = ( form.tagName == 'IMG' ) ? form.parentNode : form ;
	if ( document.getElementById('search').value.length && document.getElementById('search').value!='Поиск...' ) {
		form.submit();
		}
	return false;
	}

function readFullText() {
	if ( !document.getElementById('fulltext').style.display || document.getElementById('fulltext').style.display == 'none' ) {
		document.getElementById('fulltext').style.display = 'block'; document.getElementById('plus').innerHTML = '-'; document.getElementById('plus').style.width = '13px'; document.getElementById('plus').style.marginLeft = '7px';
		} else {
			document.getElementById('fulltext').style.display = 'none'; document.getElementById('plus').innerHTML = '+'; document.getElementById('plus').style.width = '15px'; document.getElementById('plus').style.marginLeft = '5px';
			}
	}

