
function openIT_2(theURL){
  open(theURL,'TraderDeck','width=780,height=540,titlebar=no,hotkeys=no');
}

function open_pricetable(theURL){
  open(theURL,'RealTimePriceTable','width=786,height=106,titlebar=no,hotkeys=no');
}

var currentdate = 0
var core = 0

function StringArray (n) {
  this.length = n;
  for (var i =1; i <= n; i++) {
    this[i] = ' '

  }
}


gal = new StringArray(4);
/*galeriak elore definialva konyvtarnev(!) alapjan */
gal[0] = 'Bright_side_of_life';
gal[1] = 'different_sides_of_BCN';
gal[2] = 'Gone_with_the_wind';
gal[3] = 'had_to_face_dangerous_animals';

function ranimage() {
  core = Math.random()
  core = Math.floor(core * 10);
  if(core>12) { core=12; }
  if(core==0) { core=1; }
  return(core)
}

function rangallery() {
  core = Math.random()
  core = Math.floor(core * 5);
  if(core>3) { core=3; }
  if(core==0) { core=1; }
  return(core)
}

function fillgallery() {
	document.getElementById('gal_container').innerHTML=document.getElementById('gal_container').innerHTML='';
	filled = new StringArray(12);
	for(x=1;x<13;x++) {
		wasPic=1;
		while(wasPic==1) {
			curr_img=ranimage();
			curr_gal=rangallery();
			wasPic=0;
			for(p=1; p<13; p++) {
				if(filled[p]==curr_gal+'_'+curr_img)
				{ wasPic=1; break; }
			}
			
			if(wasPic==0) {
				cl='';
				if(x % 3==0){ cl='class="last"'; }
				document.getElementById('gal_container').innerHTML=document.getElementById('gal_container').innerHTML+'<div id="img'+x+'" '+cl+' onclick="showPic('+'\''+curr_gal+'\''+','+'\''+curr_img+'\''+')"></div>\n';
				document.getElementById('img'+x).style.backgroundImage='url(images/gallery/'+gal[curr_gal]+'/tn_'+curr_img+'.jpg)';
				filled[x]=curr_gal+'_'+curr_img;
			} 
		}
/*		document.getElementById('img'+x).onclick=function (evt) { showPic(curr_gal,this.id.replace(/img/,"")); };*/
/*		document.getElementById('img'+x).onclick=function (evt) { showPic(curr_gal,curr_img); };*/
		
	}

}

function showPic(galid,pic) {
	/* kep beallitasa, kozepso es jobb oszlop elrejtese, onclick fv beallitasa */
	document.getElementById('bigpic_img').src='images/gallery/'+gal[galid]+'/'+pic+'.jpg';	
	document.getElementById('col_mid').style.display='none';
	document.getElementById('col_right').style.display='none';
	/**/
/*	document.getElementById('bigpic').style.opacity='0';
	document.getElementById('bigpic').style.MozOpacity='0';
	document.getElementById('bigpic').style.filter='alpha(opacity=0)';*/
	/**/
	
	document.getElementById('bigpic').style.display='block';
	// setFade('bigpic', '400');
	document.getElementById('backtogallery').onclick=function (evt) { showGal(galid); };
	document.getElementById('next').onclick=function (evt) { showPic(galid,parseInt(pic)+1); };
	document.getElementById('prev').onclick=function (evt) { showPic(galid,parseInt(pic)-1); };
	/* ha elso ill. utolso a kep, akkor elhalvanyitjuk az elso/utolso kepre mutato next, back gombokat */ 
	if(pic==1) {
		document.getElementById('prev').style.opacity='0.5';
		document.getElementById('prev').style.MozOpacity='0.5';
		document.getElementById('prev').style.filter='alpha(opacity=50)';
		document.getElementById('prev').style.cursor='default';
		document.getElementById('prev').onclick='';
	} 
	else {
		document.getElementById('prev').style.opacity='1';
		document.getElementById('prev').style.MozOpacity='1';
		document.getElementById('prev').style.filter='alpha(opacity=100)';
		document.getElementById('prev').style.cursor='pointer';
	}
	if(pic==12) {
		document.getElementById('next').style.opacity='0.5';
		document.getElementById('next').style.MozOpacity='0.5';
		document.getElementById('next').style.filter='alpha(opacity=50)';
		document.getElementById('next').style.cursor='default';
		document.getElementById('next').onclick='';
	} 
	else {
		document.getElementById('next').style.opacity='1';
		document.getElementById('next').style.MozOpacity='1';
		document.getElementById('next').style.filter='alpha(opacity=100)';
		document.getElementById('next').style.cursor='pointer';
	}

}

function showGal(galid) {
	/* Osszes link normalba allitasa */
	for(j=0;j<4;j++) {
		document.getElementById('gal_item'+j).className='gal_item';
	}
	/* aktualis galeria kiemelese */
	document.getElementById('gal_item'+galid).className='gal_item_selected';
	/* galeria feltoltese a kepekkel */
	for(i=1;i<13;i++) {
		document.getElementById('img'+i).style.backgroundImage='url(images/gallery/'+gal[galid]+'/tn_'+i+'.jpg)';	
		document.getElementById('img'+i).onclick=function (evt) { showPic(galid,this.id.replace(/img/,"")); };
	}
	/* nagykep eltuntetese, oszlopok lathatova tetele */
	document.getElementById('bigpic').style.display='none';	
	document.getElementById('col_mid').style.display='block';
	document.getElementById('col_right').style.display='block';
}

function setFade(element,time) {
	for(x=1;x<100;x++)	{
			setTimeout("document.getElementById('bigpic').style.opacity=parseInt("+x+")/100",x*15);
			setTimeout("document.getElementById('bigpic').style.MozOpacity=parseInt("+x+")/100",x*15);
			setTimeout("document.getElementById('bigpic').style.filter='alpha(opacity='+parseInt("+x+")+')'",x*15);
		}
}

var xMousePos=0;	// Horizontal position of the mouse on the screen
var yMousePos=0;	// Vertical position of the mouse on the screen
var xMousePosMax=0;	// Width of the page
var yMousePosMax=0;	// Height of the page
var x=0;

if (document.layers) // Netscape
{
	document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove=captureMousePosition;
}
else if (document.all) // Internet Explorer
{
	document.onmousemove=captureMousePosition;
}
else if (document.getElementById) // Netcsape 6
{
    document.onmousemove=captureMousePosition;
}

function captureMousePosition(e)
{
    if (document.layers) // Netscape
    {
        xMousePos=e.pageX;
        yMousePos=e.pageY;
        xMousePosMax=window.innerWidth+window.pageXOffset;
        yMousePosMax=window.innerHeight+window.pageYOffset;
    }
    else if (document.all) // Internet Explorer
    {
        xMousePos=window.event.x+document.body.scrollLeft;
        yMousePos=window.event.y+document.body.scrollTop;
        xMousePosMax=document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax=document.body.clientHeight+document.body.scrollTop;
    }
    else if (document.getElementById) // Netcsape 6
    {
        xMousePos=e.pageX;
        yMousePos=e.pageY;
        xMousePosMax=window.innerWidth+window.pageXOffset;
        yMousePosMax=window.innerHeight+window.pageYOffset;
    }
}


function browserCheck() {
	var browser=navigator.appName;
	if(browser=='Microsoft Internet Explorer') {
		return('ie');
	} else {
		return('otherandbetterbrowser');
	}
}

function showCurrency() {
	if(browserCheck()=='otherandbetterbrowser') {
		document.getElementById('currencypairs').style.backgroundImage='url(images/currencypairs.png)';
	}
	document.getElementById('currencypairs').style.left=xMousePos+15+'px';
	document.getElementById('currencypairs').style.top=yMousePos+10+'px';
	if(browserCheck()=='ie') {
		document.getElementById('currencypairs').style.top=yMousePos+document.documentElement.scrollTop+10+'px';
	}
	document.getElementById('currencypairs').style.display='block';
	
}

function hideCurrency() {
	document.getElementById('currencypairs').style.backgroundImage='';
	document.getElementById('currencypairs').style.display='none';
}

function showPopup(width,height,html) {
		/*var htmlObject = document.createElement('object');
		if(browserCheck()=='ie') {
			htmlObject.setAttribute('classid','clsid:25336920-03F9-11CF-8FD0-00AA00686F13');		
			alert('2');
		}*/

		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}

		layerleft=parseInt(myWidth/2);
		layerleft=layerleft-width/2;
		if(layerleft<265) { layerleft=265; }
		
		layertop=parseInt(myHeight/2);
		layertop=layertop-height/2;
		if(layertop<10) { layertop=10; }

		/*htmlObject.style.left=layerleft+'px';
		htmlObject.style.top=layertop+'px';
		htmlObject.setAttribute('data',html);
		htmlObject.setAttribute('type','text/html');
		htmlObject.innerHTM='This site requires JavaScript enabled, please enable in your browser!';
		htmlObject.setAttribute('style','width:'+width+'px; height:'+height+'px;');
		alert('htmlObject letrehozva, style beallitva');
		
		alert('div style beallitva');
		document.getElementById('popuplayer').innerHTML='<div class="popupclose"><a href="javascript:hidePopup()"><b>× Close this window ×</b></a></div>';
		alert(htmlObject.getAttribute('data'));
		document.getElementById('popuplayer').appendChild(htmlObject);
		alert('appendchild megvan!');*/
		//document.getElementById('popuplayer').innerHTML=document.getElementById('popuplayer').innerHTML+'<div class="popupclose"><a href="javascript:hidePopup()"><b>× Close this window ×</b></a></div>';
//		document.getElementById('popuplayer').setAttribute('style','left: '+layerleft+'px; top:'+layertop+'px; width:'+width+'px; height: '+height+'px;display: block;');
		document.getElementById('popuplayer').style.left=layerleft+'px';
		document.getElementById('popuplayer').style.top=layertop+'px';
		document.getElementById('popuplayer').style.width=width+'px';
		document.getElementById('popuplayer').style.height=height+'px';
		document.getElementById('popuplayer').style.display='block';
		document.getElementById('popuplayer').innerHTML='<div class="popupclose"><a href="javascript:hidePopup()"><b>× Close this window ×</b></a></div>'+document.getElementById(html).innerHTML;
}

function hidePopup() {
	document.getElementById('popuplayer').style.display='none';
}

