/* ----------------------------------------------------------------------------------------------------------
   js2grosze.js  dwagrosze function library  v.1.0  February 2007
   http://www.twonuggets.com  telecram@ascad.com
   copyright (c)2007-11 TwoNuggets.com - All Rights Reserved.
   ----------------------------------------------------------------------------------------------------------
*/


//var popbackground="#8aa46d"; 						//specify backcolor or background image for a popup window
var popbackground="#ffffffd"; 						
var windowtitle="dwagrosze.com" ;	 				//popup window title
var imagesource="http://www.twonuggets.com/dwagrosze/images/";		//base URI of images
var twonuggets='Prywatny newsletter poświecony inwestowaniu w aktywa materialne, ze szczególnym uwzględnieniem metali szlachetnych i sektora surowców. Dostępny za abonamentem inwestorom <a href="http://www.twonuggets.com">TwoNuggets Global Investment Community</a>.';

var NN='<p>';
NN=NN+'Redagowany przez <i>cynika9<\/i>';
NN=NN+' <b>TwoNuggets Newsletter<\/b> (18 wydań rocznie)';
NN=NN+' jest publikacją poświęconą inwestowaniu w aktywa';
NN=NN+' materialne. Tematyka obejmuje sektor metali';
NN=NN+' szlachetnych, metali';
NN=NN+' bazowych, energii, innych surowców w tym surowców';
NN=NN+' rolnych oraz nieruchomości.<\/br><\/br>';
NN=NN+' TwoNuggets Newsletter dostępny jest jako';
NN=NN+' część <a href="http://www.twonuggets.com/node/1391">';
NN=NN+' <b>abonamentu dostępowego<\/b><\/a> witryny';
NN=NN+' <a href="http://www.twonuggets.com">Twonuggets.com<\/a>, która jest jego wydawcą. ';
NN=NN+'<\/p>';


if (document.images){ 
    img1on = new Image( ); img1on.src = imagesource+"dwagrosze_t_on.gif"; 
    img1off = new Image( ); img1off.src = imagesource+"dwagrosze_t_off.gif"; 
    img2on = new Image( ); img2on.src = imagesource+"2nuggets_t_on.gif"; 
    img2off = new Image( ); img2off.src = imagesource+"2nuggets_t_off.gif"; 
    img3on = new Image( ); img3on.src = imagesource+"2N_name_on.gif"; 
    img3off = new Image( ); img3off.src = imagesource+"2N_name_off.gif"; 
} 
	 

// ----------------------------------------------------------------------------------------------------------
// check for existence of document.images object (NS3+,IE4+) and, if present, preload all graphics here
 //  if (document.images) {						
  //   Preload('radio00','radio11'); Preload('back_but','back_but_red');
 //  };

// ----------------------------------------------------------------------------------------------------------
function SetImage(imgName,imgObj){document.images[imgName].src = eval(imgObj+".src");}

// ----------------------------------------------------------------------------------------------------------
function StringArray (n) {
  this.length = n;
  for (var i = 0; i <= n; i++) {this[i] = "";}
  return this
}
// ----------------------------------------------------------------------------------------------------------
function Preload() {
  for (var i=0; i<arguments.length; i++) {
  eval(arguments[i]+' = new Image()');
  eval(arguments[i]+'.src = "tc_images/"+"'+arguments[i]+'.gif"');
  }
}

// ----------------------------------------------------------------------------------------------------------	
function imgAct(imgName) { 
  if (document.images) {
     document[imgName].src = eval(imgName + "on.src");
  }
} 
// ----------------------------------------------------------------------------------------------------------
function imgInact(imgName) {
  if (document.images) {
     document[imgName].src = eval(imgName + "off.src");
  }
} 


// ----------------------------------------------------------------------------------------------------------
function detectexist(obj){return (typeof obj !="undefined"); }

// ----------------------------------------------------------------------------------------------------------
function pp_m(a){a.setAttribute('target','_new');}
//  function to invoke stooq quotes

// ----------------------------------------------------------------------------------------------------------
function aspopimage(imgpath, popwidth, popheight, textdescription){
// best generic function opening a popup window and writing a text into it, plus self-close button

	function getpos(){
		leftpos=(detectexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
		toppos=(detectexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
		if (window.opera){
			leftpos-=screenLeft;
			toppos-=screenTop;
		}
	}
	getpos()
	var  winattributes = 'width='+popwidth+', height='+popheight+', resizable=yes, left='+leftpos+', top='+toppos;
	var bodyattribute = 'topmargin=0 leftmargin=0 bgcolor='+popbackground;
              bodyattribute = bodyattribute+' onBlur=\"window.focus();\"  ' ;
        var str = '';
 
	if (typeof aspopwin=="undefined" || aspopwin.closed){
		aspopwin = window.open("","",winattributes);
	} else {
		//getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
		//aspopwin.moveTo(leftpos, toppos)
		aspopwin.resizeTo(popwidth, popheight+30);
	}
	aspopwin.document.open();
        aspopwin.document.write("<html><title>");
	aspopwin.document.write(windowtitle+'</title><body '+bodyattribute+'>');
        aspopwin.document.write("<font face=\"arial,helvetica\" color=black size=2>");
        if(imgpath != "") { str='<img src="'+imgpath+'" style="margin-bottom: 0.5em"><br>'; }
        aspopwin.document.write(str+'<center>' + textdescription);
        aspopwin.document.write("<FORM><INPUT TYPE=\'BUTTON\' VALUE=\'zamknij\' onClick=\'window.close()\'></FORM></center>");
        aspopwin.document.write("</body></html>");
	aspopwin.document.close();
	aspopwin.focus();
}

// ----------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------
// browser/os checking section, based on the objects supported; global browser vars follow:

var d, dom, ie, ie4, ie5x, moz, mac, win, lin, old, ie5mac, ie5xwin, op, top, OS, browser;
d = document; n = navigator; na = n.appVersion; nua = n.userAgent; 

win = ( na.indexOf( 'Win' )!= -1 );		if (win){OS = "windows"};
mac = ( na.indexOf( 'Mac' )!= -1 );		if (mac){OS = "mac"};
lin = ( nua.indexOf( 'Linux' )!= -1 );		if (lin){OS = "linux"};

if (!d.layers ){
  dom = ( d.getElementById );
  op = ( nua.indexOf( 'Opera' )!= -1 );		if (op){browser = "opera"};
  konq = ( nua.indexOf( 'Konqueror' )!= -1 );	if (konq){browser = "konqueror"};
  saf = ( nua.indexOf( 'Safari' )!= -1 );	if (saf){browser = "safari"};
  moz = ( nua.indexOf( 'Gecko' )!= -1 );	if (moz && !saf){browser = "mozilla"};
  ie = ( d.all &&!op );				if (ie){browser = "iexplorer"};
  ie4 = ( ie &&!dom );				if (ie4){browser = "iexplorer4"};
/*
  ie5x tests only for functionality. ( dom¦¦ie5x ) would be default settings.
  Opera will register true in this test if set to identify as IE 5
*/
  ie5x = ( d.all && dom );			if (ie5x){browser = "iexplorer5"};
  ie5mac = ( mac && ie5x ); 
  ie5xwin = ( win && ie5x );
} 
/*
  common DOM1 functionality of top browsers (mozilla, ie6, konq)
*/
top = (dom && d.createElement); 		if (browser && top){browser = browser+"+"} ;


// ----------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------


// ----------------------------------------------------------------------------------------------------------
function errHandler() {
// function run when window object triggers onerror event. further processing stops (netscape only)
   alert("NS: Applet could not be loaded"); //consume();
}


function winFeatures(w,h,x,y,letters) {
/* ----------------------------------------------------------------------------------------------------------
  control string generator for window.open. accepts window parameters and returns a features string.
  x,y are positions of left top corner. if either is <0 then window is centered
  if absolute value of either width or height exceeds available screen dimension
  then the window will be full screen 
*/
  var width = w; var height = h;   var left = x; var top = y;
  
  // if abs width or height exceeds screen size make the window full screen 
  if (window.screen) {
    if ((Math.abs(width) > screen.availWidth) || (Math.abs(height) > screen.availHeight)) {
       width = screen.availWidth; height = screen.availHeight;
    }
  }

  var features="width=" + width + ",height=" + height;

  // if either coordinate of top-left corner position is negative then center the window
  if ((x < 0) || (y < 0) || window.screen ) {  
    var ah = screen.availHeight - 2;    var aw = screen.availWidth  - 2;
    left = (aw - width) / 2;            top  = (ah - height) / 2;
  }
  features += ",top=" + top + ",left=" + left;
  if ( letters.indexOf( 't' )!= -1 ) { features += ",toolbar=yes" };
  if ( letters.indexOf( 'l' )!= -1 ) { features += ",location=yes" };
  if ( letters.indexOf( 'd' )!= -1 ) { features += ",directories=yes" };
  if ( letters.indexOf( 'a' )!= -1 ) { features += ",status=yes" };
  if ( letters.indexOf( 'm' )!= -1 ) { features += ",menubar=yes" };
  if ( letters.indexOf( 's' )!= -1 ) { features += ",scrollbars=yes" };
  if ( letters.indexOf( 'r' )!= -1 ) { features += ",resizable=yes" };
  if ( letters.indexOf( 'p' )!= -1 ) { features += ",replace=yes" };

  return features; 

} // winFeatures

function popwin(url) {
// ----------------------------------------------------------------------------------------------------------
// pops up a new window and returns a variable associated with it.  usage: var w; w=popwin(winurl)

   win=window.open(url,'_blank',winFeatures(640, 360,-1,-1,'sr'));
   if (!win.opener) win.opener = self; // for NS2 (no opener supp) we make one and set to self
   if (window.focus) {win.focus()}
   return win;
} // popwin


function shutwin(win) {
// ----------------------------------------------------------------------------------------------------------
// clears the contents of a window, copies a farewell message and closes window in 5 sec.  
// usage: return shutwin(mywin)

  this.location.href='http://dwagrosze.com';
  if (win){
     win.location.href='http://www.twonuggets.com/dwagrosze/dwagrosze_thankyou.html'; 
     win.focus();
  }
  return false;
}

// ----------------------------------------------------------------------------------------------------------
function SoundOn(audiodir, i) {
// dynamically loads wav file with the name sound[i] from directory audiodir into a span named "audio"

  str=audiodir+"/"+sound[i]+".wav";  
  document.all.audio.innerHTML=" <embed src='"+str+"' hidden='true'> ";
}


function EvalSound(soundobj) {
  thissound=document.getElementById(soundobj);
  thissound.Play();
}



// ----------------------------------------------------------------------------------------------------------
function playSound(soundobj) {
// plays a sound by taking the ID of the hidden embedded player and calling its Play() method.
// uses JavaScript getElementById() function. preferred method for recent browsers, not supported by older versions.

  thissound= eval("document."+soundobj);
  thissound.Play();
}


// ----------------------------------------------------------------------------------------------------------
function Y2K(the_year){  if (the_year < 1000)the_year = the_year + 1900; return the_year; }

// ----------------------------------------------------------------------------------------------------------
function getNiceDate(){
    var the_string="";  var now = new Date(); var the_month = now.getMonth();
    var the_day = now.getDate();     var the_year = now.getYear();
    var the_fixed_year = Y2K(the_year);
//  translate the number of the month to a word  so 0 => Jan, 1 => Feb, etc..
    if (the_month == "0")	the_month = "  January ";	else
    if (the_month == "1")	the_month = "  February ";	else
    if (the_month == "2")	the_month = "  March ";	else
    if (the_month == "3")	the_month = "  April ";	else
    if (the_month == "4")	the_month = "  May ";	    else
    if (the_month == "5")	the_month = "  June ";	    else
    if (the_month == "6")	the_month = "  July ";	    else
    if (the_month == "7")	the_month = "  August ";	else
    if (the_month == "8")	the_month = "  September ";else
    if (the_month == "9")	the_month = "  October ";	else
    if (the_month == "10")	the_month = "  November ";	else
    if (the_month == "11")	the_month = "  December ";
    the_string =the_string + the_month  + the_day + ", " + the_fixed_year;
    return the_string
} //--getNiceDate

// ----------------------------------------------------------------------------------------------------------
function Dummy() {;}


