var G__BGColor = '';
var G__Navigator = navigator.userAgent.toUpperCase();
var rotateBannerGoID = 0;
//var G__DNS_MojMultiFundPl = 'multikonto.netfield-test.nq.pl';
var G__DNS_MojMultiFundPl = 'multikonto.multifund.pl';
var G__Okno_MojMultiFundPl = null;
var G__DNS_MultiAgentMultiFundPl = 'multiagent.multifund.pl';
//var G__DNS_MultiAgentMultiFundPl = 'multiagent.netfield-test.nq.pl';
var G__Okno_MultiAgentMultiFundPl = null;



/// wycina wszystkie spacje
// ****************************************
function KillAllSpace( Text_ )
{
var Zwrot_ = '';

Zwrot_ = Text_.replace( / /g , '' );

return Zwrot_;
} // koniec KillAllSpace()



//  blokada prawego klawisza
// *****************************************
function LoadAndRun( Text_ )
{

try
  {
  AfterLoad();
  }
 catch (e)
  {
  }
 finally
  {
}     

return true;
} // koniec LoadAndRun()


function open_window(arg, name)
{
    window.open(arg, name, "width=766, height=550, resizable=no, scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, fullscreen=no, channelmode=no").focus();
	return false;
}

function open_window_size(arg, name, width, height)
{
    window.open(arg, name, "width="+width+", height="+height+", resizable=no, scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, fullscreen=no, channelmode=no").focus();
	return false;
}

function open_window_scroll(arg, name, width, height)
{
    window.open(arg, name, "width="+width+", height="+height+", resizable=no, scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, fullscreen=no, channelmode=no").focus();
	return false;
}

function open_picture(src, title) 
{
	neww = window.open("","","width=500, height=400, resizable=yes, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no");
	neww.document.open();
	neww.document.write('<html><head><title>'+title+'</title></head><body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF"><img src="'+src+'" alt="" border="0"></body></html>');
	neww.document.close();
}

function handle_action(action, arg)
{
	if((action == "delete" || action == "remove") && !confirm("Skasowaæ?")) return;
	if((action == "save" || action == "saveexit") && !validate_form()) return;
    document.forms.main.form_arg.value = arg;
    document.forms.main.form_action.value = action;
    window.setTimeout("document.forms.main.submit()", 100);
}

function validate_ne(name, field)
{
    if(document.forms.main[field].value.length == 0)
	{
	    alert("Pole " + name + " nie mo¿e byæ puste.");
		return false;
	}
	else return true;
}

function loadImages(path, nr, max) {
	imageToLoad = new Image();
	imageToLoad.src = path;
	document.large.src = imageToLoad.src;
	for ( var j=1 ; j<=max; j++ )
	{
		document.getElementById('Karta_Guzik'+j).style.color = "#000000";
		document.getElementById('Karta_Guzik'+j).style.backgroundColor = "#ffffff";  
	}
	document.getElementById('Karta_Guzik'+nr).style.color = "#205795";
	document.getElementById('Karta_Guzik'+nr).style.backgroundColor = "#eeeeee";
}

function loadImageIG(path, nr) {
	imageToLoad = new Image();
	imageToLoad.src = path;
	document.stockexchangeImage.src=imageToLoad.src;
	for ( var j=1 ; j<=3; j++ )
	{
		document.getElementById('SE_Guzik'+j).style.color = "#000000";
		document.getElementById('SE_Guzik'+j).style.backgroundColor = "#ffffff";  
	}
	document.getElementById('SE_Guzik'+nr).style.color = "#205795";
	document.getElementById('SE_Guzik'+nr).style.backgroundColor = "#eeeeee";
}

function porownajFundusze(path)
{
  if (!document.getElementById) return;
  var elarray = document.getElementsByTagName("input");
  var par=str='';
  var j=1;
  for (var i = 0; i < elarray.length; i++) {
    var str = elarray[i].id;
	if (j<5 && !str.search('check_') && elarray[i].checked) {
		par = par+(par=='' ? "" : "&")+'fund'+j+'='+elarray[i].value;
		j++;
    }
  }
  if(j<3){
	  alert("Wybierz fundusze do porównania.");
	  return;
  }
  document.location.href = path+'?action=compare&'+par;
}

function changeRotateBanner(i, max, stop)
{
	if(stop){
		clearTimeout(rotateBannerGoID);
	}
	if (!document.getElementById) return;
		
	for (var j = 1; j <= max; j++) {
		document.getElementById("rotateBanner"+j).style.display = 'none';
		document.getElementById("rotateBannerGuzik"+j).style.color = "#000000";
		document.getElementById("rotateBannerGuzik"+j).style.backgroundColor = "#f6f6f6";
	}
	document.getElementById("rotateBanner"+i).style.display = '';
	document.getElementById("rotateBannerGuzik"+i).style.color = "#205795";
	document.getElementById("rotateBannerGuzik"+i).style.backgroundColor = "#eeeeee";
}

function rotateBannerGo(i, max)
{
	changeRotateBanner(i, max, false);
	i++;
	if(i>max) i=1;
	rotateBannerGoID = setTimeout("rotateBannerGo("+i+", "+max+")", 5000);
}

function FormMainSeekCheck()
{
	if(document.getElementById("mainSeek").value.length <= 2)
	{
	    alert("Wpisz szukany zwrot (min. 3 znaki)!");
		return false;
	}
	else return true;
}

function changeSelectFundButton(checked, fid)
{
	document.getElementById("SelectFundToNotatnik_"+fid).value=(checked ? fid : 0);
}

function changeSelectFundButtonCompare(checked, fid)
{
	document.getElementById("SelectFundToNotatnik_"+fid).value=(checked ? fid : 0);
	document.getElementById("SelectFundToNotatnik_"+fid).checked=checked;
	document.getElementById("SelectFundToNotatnik2_"+fid).checked=checked;
}

// *********************************
function PodswietlPoz( Obj_ , Stan_ )
{
if ( Stan_ == 1 )
  {
  Kolor_ = '#cbdaeb';      
  G__BGColor = Obj_.style.backgroundColor;
  }
 else
  {
  Kolor_ = G__BGColor;
  G__BGColor = '';
}     
Obj_.style.backgroundColor = Kolor_; 
} // koniec PodswietlPoz()





// ***********************************************
function DodajDoObserwowanych()
{
window.open( '', 'multifund_notatnik', 'top=30,left=30,width=800,height=500' );

document.getElementById('DodajDoObserwowanych').action = 'https://'+G__DNS_MojMultiFundPl+'/watchlist/index.php';  
document.getElementById('DodajDoObserwowanych').method = 'post';
document.getElementById('DodajDoObserwowanych').target = 'multifund_notatnik';
document.getElementById('DodajDoObserwowanych').submit();      

} // koniec DodajDoObserwowanych()




// ***********************************************
function OtworzSerwisKontoKlienta()
{

//if ( top.window.opener  && !top.window.opener.closed )
//  { 
//  top.window.opener.focus();
//  }  
 //else if ( typeof(G__Okno_MojMultiFundPl) == "object" && G__Okno_MojMultiFundPl && !G__Okno_MojMultiFundPl.closed )
  //{
  //G__Okno_MojMultiFundPl.focus();  
  //}
 //else
  //{
  G__Okno_MojMultiFundPl = window.open('https://'+G__DNS_MojMultiFundPl+'','strefa_klienta','toolbar=yes, menubar=yes, location=yes, status=yes, resizable=yes, scrollbars=yes');
  G__Okno_MojMultiFundPl.focus();
//}

} // koniec OtworzSerwisKontoKlienta()





// ***********************************************
function OtworzSerwisMultiAgent()
{

if ( top.window.opener  && !top.window.opener.closed )
  { 
  top.window.opener.focus();
  }  
 else if ( typeof(G__Okno_MultiAgentMultiFundPl) == "object" && G__Okno_MultiAgentMultiFundPl && !G__Okno_MultiAgentMultiFundPl.closed )
  {
  G__Okno_MultiAgentMultiFundPl.focus();  
  }
 else
  {
  G__Okno_MultiAgentMultiFundPl = window.open('https://'+G__DNS_MultiAgentMultiFundPl+'','strefa_agenta','toolbar=yes, menubar=yes, location=yes, status=yes, resizable=yes, scrollbars=yes');
  G__Okno_MultiAgentMultiFundPl.focus();
}

} // koniec OtworzSerwisMultiAgent()

// pobiera parametry z GET i zwraca
function getParm( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


function showNotowania( name ) {
	//indeksy
	// stopyklas
	// 

	switch (name) {
	
	case 'stopyklas':
		document.getElementById("indeksytab").style.display   = 'none';
		document.getElementById("menu_indeksytab").style.backgroundImage   = '';
		document.getElementById("stopyklas").style.display  = 'block';
		document.getElementById("menu_stopyklas").style.backgroundImage   = 'url(/templates/images/bg/indeksy_blue.jpg)';
		document.getElementById("stopyfund").style.display  = 'none';
		document.getElementById("menu_stopyfund").style.backgroundImage   = '';
	break;
	case 'indeksytab':
		document.getElementById("indeksytab").style.display   = 'block';
		document.getElementById("menu_indeksytab").style.backgroundImage   = 'url(/templates/images/bg/indeksy_blue.jpg)';
		//font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);
		document.getElementById("stopyklas").style.display  = 'none';
		document.getElementById("menu_stopyklas").style.backgroundImage   = '';
		document.getElementById("stopyfund").style.display  = 'none';
		document.getElementById("menu_stopyfund").style.backgroundImage   = '';
	break;
	case 'stopyfund':
		document.getElementById("indeksytab").style.display   = 'none';
		document.getElementById("menu_indeksytab").style.backgroundImage   = '';
		document.getElementById("stopyklas").style.display  = 'none';
		document.getElementById("menu_stopyklas").style.backgroundImage   = '';
		document.getElementById("stopyfund").style.display  = 'block';
		document.getElementById("menu_stopyfund").style.backgroundImage   = 'url(/templates/images/bg/indeksy_blue.jpg)';
	break;
	default:
		document.getElementById("indeksytab").style.display   = 'none';
		document.getElementById("menu_indeksytab").style.backgroundImage = '';  
		document.getElementById("stopyklas").style.display  = 'block';
		document.getElementById("menu_stopyklas").style.backgroundImage   = 'url(/templates/images/bg/indeksy_blue.jpg)';
		document.getElementById("stopyfund").style.display  = 'none';
		document.getElementById("menu_stopyfund").style.backgroundImage   = '';
	break;
	}
	
	
}

function FormMainPomocnikCheck()
{
	Zapisz_ = true;
	
	if(document.forms.FormMainPomocnik.pyt1.value == null)
	{
	    alert("Zaznacz odpowied¼ na pytanie 1");
	    Zapisz_ = false;
	}
	else if(!document.forms.FormMainPomocnik.pyt2.value.length)
	{
	    alert("Zaznacz odpowied¼ na pytanie 2");
	    Zapisz_ = false;
	}
	else if(document.FormMainPomocnik.pyt2.value.length > 2)
	{
	    alert("Zaznacz odpowied¼ na pytanie 3");
	    Zapisz_ = false;
	}
	else if(document.FormMainPomocnik.pyt2.value.length > 2)
	{
	    alert("Zaznacz odpowied¼ na pytanie 4");
	    Zapisz_ = false;
	}
	
 return Zapisz_;
}

