// kontent - tartalmi frame

/*******************************************************************************
 * oldal általános működése, ne bátsd!
 ******************************************************************************/
// Frame nélküli nézet tiltása
var loc = window.location.href
var toploc = window.top.location.href
var myloc, myfile;

if ( loc == toploc ) {
	if ( window.name != 'PrintWindow' ) {
		myfile = loc.substring( ( loc.lastIndexOf( "/", loc ) + 1 ), loc.length )
		myloc  = loc.substring( 0, loc.lastIndexOf( "/", loc ) )
		myloc += '/?page=' + myfile
		window.location.replace( myloc )
	}
}

loadEventBinding( window, initPage );
// betöltjük a <link rel="up"> -ban megadott html oldalt a menü frame-be
function initPage() {
	var elLink, windowMenu, sMenuHref;
	elLink = document.getElementById('pg-menupage-link');
	windowMenu = parent.frames['menu-frame'];
	if ( !elLink || typeof windowMenu == 'undefined' ) {
		throw 'nXError:: hibás menü konfiguráció :: content!';
		return;
	}
	// nem kell váltani
	if ( elLink.getAttribute('href') == '#' )
		return;
	// ellenőrzés, hogy nem egyezik-e meg a jelenlegi és akért URL.
	// Ha megyegyezik, akkor nem cseréljük (menünyitás így következetes)
	sMenuHref = windowMenu.location.href.substr( windowMenu.location.href.lastIndexOf('/') + 1 )
	if ( sMenuHref.indexOf('#') > -1 )
		sMenuHref = sMenuHref.substring( 0, sMenuHref.length - 1 )
	//alert( elLink.getAttribute('href') + ' : ' +  sMenuHref )
	if ( elLink.getAttribute('href') != sMenuHref )
		windowMenu.location.replace( elLink.href );
	elExt = document.getElementById('pg-menupage-ext');
}

/*******************************************************************************
 * egyes oldalak igényei, kiegészíthető!
 ******************************************************************************/
function pictureWiever( elImg ) { // elImg lehet elLink is!
	var oPending, sPath, sSrc, sTitle, winImage = null, oImage = null, bResize;
	if ( !is.min ) return false;
	if ( elImg.bPending ) // ha folyamatban van, visszadob
		return false;
	elImg.bPending = true;
	elImg.elType = ( isSpecified( elImg, 'href' ) ) ? 'link' : 'image';

	/* config */
	oPending = {                                // folyamat-felirat
		backgroundColor : 'rgb(88, 129, 181)',
		color : 'white',
		padding : '2px 20px 2px 20px',
		margin : '10px',
		fontSize : '12px',
		fontFamily : 'Arial, Helvetica, sans-serif',
		text : 'töltés... '
	}
	sPath = 'big/';                                 // a nagy képek általános könyvtára, felüldefiniálása path="" attribútummal
	sPageTitle = 'www.kiskunhalas.hu';                      // az megnyiló ablak címe
	sPrintIconURL = 'image/printer.gif';                    // a print icon elérése
	bResize = true;                                         // engedélyezett-e az ablak átméretezése képenyőnél nagyobb kép esetén
	function initPage( oImage ) {
		var aCSS = [], aHTMLPage = [], nLeft = 0, nTop = 0, nWidth, nHeight, nInnerWidth, nInnerHeight, sScrollbars, sResizable, sSettings, bRealResizeW, bRealResizeH ; 
		// CSS beállítások
		aCSS[aCSS.length] = 'BODY { margin: 0px; padding: 0px; background-color: white; color: black }';
		aCSS[aCSS.length] = 'P { font-family : "Times New Roman", Times, serif; font-size : 14px; color: #A31000;font-size : 16px; color: #A31000; font-weight : bold; }';
		aCSS[aCSS.length] = 'IMG{ border: 0px; }';
		aCSS[aCSS.length] = 'DIV#pg-title { position: ' + ( ( is.ie ) ? 'absolute' : 'fixed' ) + '; left: 10px; top: 10px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(88, 129, 181); color: white; padding: 2px 10px 2px 10px; }';
		aCSS[aCSS.length] = 'DIV#pg-print { position: ' + ( ( is.ie ) ? 'absolute' : 'fixed' ) + '; right: 10px; top: 10px; display: none }';
		// HTML beállítások
		aHTMLPage[aHTMLPage.length] = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
		aHTMLPage[aHTMLPage.length] = '<html><head><title>' + sPageTitle + '</title><style>' 
		aHTMLPage[aHTMLPage.length] = aCSS.join('\n');
		aHTMLPage[aHTMLPage.length] = '</style>';
		aHTMLPage[aHTMLPage.length] = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />';
		aHTMLPage[aHTMLPage.length] = '<link rel="up" href="menu_halas_turi.html" id="pg-menupage-link" />';
		aHTMLPage[aHTMLPage.length] = '</head>';
		aHTMLPage[aHTMLPage.length] = '<body>';                           
		if ( sTitle != '' )
			aHTMLPage[aHTMLPage.length] = '<div id="pg-title">' + sTitle + '</div>';
		aHTMLPage[aHTMLPage.length] = '<div id="pg-print"><a href="javascript:window.print()"><img src="' + sPrintIconURL + '" border="0"></a></div>';
		aHTMLPage[aHTMLPage.length] = '<a href="javascript:window.close();" hidefocus><img src="' + sSrc + '" border="0"></a>';
		aHTMLPage[aHTMLPage.length] = '</body></html>';    
		/* /config */

		bRealResizeW = ( bResize && ( window.screen.width <= oImage.width * 1.1 ) ) ? true : false;
		bRealResizeH = ( bResize && ( window.screen.height <= oImage.height * 1.1 ) ) ? true : false;
		if ( is.ie5mac ) { // hibásan adja vissza minden esetben a kép méreteinek értékét (1px)
		 	oImage.width = 400;
		 	oImage.height = 400;
		};
		nLeft = ( !bRealResizeW ) ? Math.round( ( window.screen.width - oImage.width ) / 2 ) : 0;
		nTop = ( !bRealResizeH ) ? Math.round( ( window.screen.height - oImage.height ) / 3 ) : 0;
		nInnerWidth = parseInt( oImage.width );
		nInnerHeight = parseInt( oImage.height );
		sScrollbars = 'no';
		sResizable = 'no';
		if ( bRealResizeW ) {
			sScrollbars = 'yes';
			sResizable = 'yes';
			nInnerWidth =  Math.round( window.screen.width * 0.97 ); // 0.9
			nInnerHeight = nInnerHeight + 15; //scrollbar y
		};
		if ( bRealResizeH ) {
			sScrollbars = 'yes';
			sResizable = 'yes';
			if ( !bRealResizeW )
				nInnerWidth =  nInnerWidth + 15 // scrollbar x
			nInnerHeight = Math.round( window.screen.height * 0.90 ); // 0.9
		};
		if ( is.ie5mac ) { 
			sScrollbars = 'yes';
			sResizable = 'yes';
		};
		nWidth = nInnerWidth; // + 12;
		nHeight = nInnerHeight; // + 30;
		sSettings = 'height=' + nHeight +',width=' + nWidth + ',innerWidth=' + nInnerWidth + ',innerHeight=' + nInnerHeight + ',top=' + nTop + ',left=' + nLeft + ',scrollbars=' + sScrollbars +  ',resizable=' + sResizable;
		winImage = window.open( '', '', sSettings);
		winImage.document.open( 'text/html' );
		winImage.document.write( aHTMLPage.join('\n') );
		winImage.document.close();
		// folyamat-felirat eltávolítása		
		elImg.bPending = false;
		if ( elImg.elType == 'image' )
			document.body.removeChild( elImg.elPending );
		else if ( elImg.elType == 'link' ) {
			// nem kell a 'töltés...' szöveg
			//elImg.innerHTML = elImg.innerHTML.substr( 0, elImg.innerHTML.length - oPending.text.length - 1 );
		}
	}
	// adatok átvétele;
	sTitle = elImg.getAttribute('alt') || elImg.getAttribute('title') || '';
//	sTitle = elImg.getAttribute('title') || elImg.getAttribute('alt');
	if ( elImg.elType == 'link' )
		elImg.src = elImg.href;
	if ( isSpecified( elImg, 'resize' )  )
		bResize =  new Boolean( elImg.getAttribute('resize') );
	if ( isSpecified( elImg, 'path' ) )
		sSrc = elImg.src.substr( 0, elImg.src.lastIndexOf('/') + 1 ) + elImg.getAttribute('path') + elImg.src.substr( elImg.src.lastIndexOf('/') + 1, elImg.src.length )
	else 
		sSrc = elImg.src.substr( 0, elImg.src.lastIndexOf('/') + 1 ) + elImg.src.substr( elImg.src.lastIndexOf('/') + 1, elImg.src.length - 5 - elImg.src.lastIndexOf('/') ) + ".jpg";
		//sSrc = elImg.src.substr( 0, elImg.src.lastIndexOf('/') + 1 ) + elImg.src.substr( elImg.src.lastIndexOf('/') + 1, elImg.src.length - 5 - elImg.src.lastIndexOf('/') ) + "_n.jpg";
//		sSrc = elImg.src.substr( 0, elImg.src.lastIndexOf('/') + 1 ) + sPath + elImg.src.substr( elImg.src.lastIndexOf('/') + 1, elImg.src.length );
	// folyamat-felirat készítése
//alert( sSrc );
sSrc = elImg.src
//alert(elImg.src);
	if ( elImg.elType == 'image' ) {
		createFullOffset( elImg );
		elPending = document.createElement( 'div' );
		elPending.style.position = 'absolute';
		elPending.style.left = elImg.offsetX + 'px';
		elPending.style.top = elImg.offsetY + 'px';
		elPending.style.margin = oPending.margin;
		elPending.style.padding = oPending.padding;
		elPending.style.color = oPending.color;
		elPending.style.fontSize = oPending.fontSize;
		elPending.style.fontFamily = oPending.fontFamily;
		elPending.style.backgroundColor = oPending.backgroundColor;
		elPending.appendChild( document.createTextNode( oPending.text + sTitle ) );
		elImg.elPending = elPending;
		document.body.appendChild( elPending );
	}
	else if ( elImg.elType == 'link' ) {
		// nem kell a 'töltés...' szöveg
		//elImg.innerHTML = elImg.innerHTML + " " + oPending.text;
	}
	// kép letöltése és inicializáció indítása
	oImage = new Image();
	oImage.src = sSrc;
	if ( oImage.complete ) {
		initPage( oImage );
	}
	else {
		oImage.onload = function () {
			initPage( this )
		};
	};
	return false;
};