<!-- 
//==================================================================================================
// Configuration properties
//--------------------------------------------------------------------------------------------------
//var x = 0;	//....
//==================================================================================================



//================ RESIZE IFRAME ===========================
//RESIZE IFRAME's height - used by (the_iframe)'s onload=""
function resizeIframeH(id, bool_width) {	//functia se va apela de 2 ori -odata cand redim pagina default si apoi pagina dorita
	var the_height=document.getElementById(id).contentWindow.document.body.scrollHeight;	//find internal page's height

	document.getElementById(id).height=the_height;	//change iframe's height

	if (bool_width == 1){
		var the_width=document.getElementById(id).contentWindow.document.body.scrollWidth;
		document.getElementById(id).width=the_width;	//doesn't work for the first time - it needs reload - 
	}													// better off without it - use iframe's width property or use iFrameResizeWH()
}

//Used by the_footer_iframe for resize
function resizeIframeH_footer(id, bool_width) {
	var the_height=document.getElementById(id).contentWindow.document.body.scrollHeight;	//find internal page's height
	document.getElementById(id).height=the_height-6;
}

//Used after innerHTML page local update
function resizeIframe(id) {
	var the_height = parent.document.getElementById(id).contentWindow.document.body.scrollHeight;	//find internal page's height
	parent.document.getElementById(id).height=the_height;
}

//MANUAL RESIZE IFRAME's width & height - manually inputed values
//currently not used
/*function resizeMIframeWH(iframe_id, newWidth, newHeight) {
	if (newWidth!='-1')
		document.getElementById(iframe_id).width=newWidth;
	if (newHeight!='-1')
		document.getElementById(iframe_id).height=newHeight;
}*/




//================ OPEN LINKS using IFRAME ===========================

//Open link in iFrame using JavaScript - faster than openLink() 'cause it loads only the iframe BUT the address remains without '?'
//currently not used
/*function openLinkInIframe(iFrameId, url) {
	document.getElementById(iFrameId).src=url;
}*/

//Open link in an iFrame from another iFrame (there are 2 iFrames on page and we change the contents of both)	
//currently not used
/*function openLinkInIframeFromIframe(iFrameId1, iFrameId2, url1, url2) {
	document.getElementById(iFrameId1).src=url1;
	document.getElementById(iFrameId2).src=url2;
}*/

// opens links from anywhere (iframe/parent) - uses address command
// reloads all - should be used when chanding parent only and use
// events resize for the rest, with semi-manual resize for innerHTML commands
function openLink(urlNewPage, NewPageIframeId, urlIframe){
	createCookie('iframe_name', NewPageIframeId, 1);
	top.location.href = urlNewPage + '?' + urlIframe; //address command
}



//^^
//================ ADDRESS MANAGEMENT - ex: www.a.ro/1.htm?2.htm ===========================

// the page checks if it's iframe-ing itself and gets out of iframe
// only for top parent pages
// deploy:  in page's onload="" event
function isParent(){
	if (top != self)
	    top.location.href = location.href;
}

//address management - the page FINDS IT'S PARENT and automatically loads it - uses address command
//!!! must be used only for single pages direct address - NOT for linking (through auto
//    loading) 'cause it causes unnecessary loads - use openLink() for that
function loadParent(parentName, parentIframeName, thisAdrName){		//la iframe si la iframe_footer
//alert('in loadparent');
	if (parent.location.href == self.location.href){
		createCookie('iframe_name', parentIframeName, 1);		//set infos to load in parent's iframe
		createCookie('iframe_src', thisAdrName, 1);				//set infos to load in parent's iframe
		top.location.href = parentName + '?' + thisAdrName;		//set the address in special format - loads parent - address command
	}
}


//history.localPage - cookie for innerHTML (localPageUpdate) JS history navigation (back,fwd)
//history.pageName - cookie for
//					- at the moment i use it for refresh - 
function startLocalPageHistory(){ // called on page's onload event
	//create !!ARRAY!! cookie localPageHistory //see http://www.felgall.com/jsdom10.htm   and   http://www.felgall.com/javadom5.htm
//	if (existsCookie('history.pageName') && readCookie('history.pageName')== )
	createCookie('history.localPage','',1);
	
}
function updateLocalPageHistory(){	//needs to be called after each JS function that uses .innerHTML,    //= localPageUpdate
	//add function call statement to array cookie
	modifyCookie('localPageHistory', '?',1);
}

//address management - loads page - 'chopps' address command
var loadIframeDone = false;
function loadIframe(defaultIframeName,defaultPage){			// used by iframe onload=
	if (!loadIframeDone){
		if ( !existsCookie('iframe_name') ){
			document.getElementById(defaultIframeName).src = (location.search ? location.search.substring(1) : defaultPage); 
						//detects if url is composed (has '?' ex:www.a.ro/index.htm?b.htm) if
						//it has [it takes the info (b.htm) and loads it in defaultIframeName] else [it takes the default and loads]
			//var addr_js_command = location.search ? location.search.substring(2) : '';
			//alert(addr_js_command); 
			//if (existsCookie('history.localPage')){
				//alert(existsCookie('history.localPage'));
				//eval(readCookie('localPageHistory'));
				// comanda de executie a ce scrie in cookie - deschide in iframe	- used through page refresh (address command)
			//}
		}
		else
			document.getElementById(readCookie('iframe_name')).src = (location.search ? location.search.substring(1) : readCookie('iframe_src'));
						//detects if url is composed (has '?' ex:www.a.ro/index.htm?b.htm) if
						//it has [it takes the info (b.htm) and loads it in defaultIframeName] else [it uses cookie infos to load]
		loadIframeDone = true;
	}
	eraseCookie('iframe_name');
	eraseCookie('iframe_src');	
	
//	if (getAddrParam('inner')!=false){
/*		alert(getAddrParam('inner'));
		try{
			var x = window.frames['the_iframe'] + getAddrParam('inner');
			alert(x);
			//eval(window.frames['the_iframe'] + getAddrParam('inner'));
		}catch(err){alert('eroare: '+err);}
*/
//	}
}

//address management - loads page - 'chopps' address command
var loadIframeDone = false;
function loadIframe(defaultIframeName,defaultPage){			// used by iframe onload=
	if (!loadIframeDone){
		if ( !existsCookie('iframe_name') )
			document.getElementById(defaultIframeName).src = (location.search ? location.search.substring(1) : defaultPage); 
						//detects if url is composed (has '?' ex:www.a.ro/index.htm?b.htm) if
						//it has [it takes the info (b.htm) and loads it in defaultIframeName] else [it takes the default and loads]
		else
			document.getElementById(readCookie('iframe_name')).src = (location.search ? location.search.substring(1) : readCookie('iframe_src'));
						//detects if url is composed (has '?' ex:www.a.ro/index.htm?b.htm) if
						//it has [it takes the info (b.htm) and loads it in defaultIframeName] else [it uses cookie infos to load]
		loadIframeDone = true;
	}
	eraseCookie('iframe_name');
	eraseCookie('iframe_src');	
}

//================ Cookie management - for iframes ===========================
// document.cookie = 'name = value;  expires=Thu, 2 Aug 2001 20:47:11 UTC;  path=/'
function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+1+"; path=/";		//eraseCookie
	document.cookie = name+"="+value+expires+"; path=/";	//create
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function existsCookie(name){
	if (readCookie(name)!=null)
		return true;
	else
		return false
}

function modifyCookie(name, value, days) {
	eraseCookie(name);
	createCookie(name, value, days);	
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


//-->
