function windowNew( sAdres, iWidth, iHeight, sTitle, iReturn ){
  if ( !sTitle )
    sTitle = '';
  if( !iReturn )
    iReturn = false;

	if( !iWidth )
		var iWidth = 750;
	if( !iHeight )
		var iHeight = 530;

	if( +iWidth > 750 )
		iWidth = 750;
	else
		iWidth = +iWidth + 40;

	if( +iHeight > 530 )
		iHeight = 530
	else
		iHeight = +iHeight + 40;

	var iX = ( screen.availWidth - iWidth ) / 2;
	var iY = ( screen.availHeight - iHeight ) / 2;

  var refOpen = window.open( sAdres, sTitle, "height="+iHeight+",width="+iWidth+",top="+iY+",left="+iX+",resizable=yes,scrollbars=yes,status=0;" );
  
  if( iReturn == true )
  	return refOpen
}


function windowGallery( iPhoto, iIdLink, iType ){
  var refFoto = window.open( "index.html?p=galleryGalleryShow&iIdLink="+ iIdLink +"&iType="+ iType +"&iPhoto="+ iPhoto, 'Gallery', "heigth=550,width=710,top=20,left=20,resizable=yes,scrollbars=yes,status=0;" );
}

function imgWindow(iIdLink){
  var refFoto = window.open("large_img.php?p="+ iIdLink, 'Gallery', "heigth=430,width=500,top=20,left=20,resizable=yes,scrollbars=yes,status=0;" );
}

function termsWindow(iIdLink){
  var refFoto = window.open("terms.php?p="+ iIdLink, 'Terms', "heigth=430,width=570,top=20,left=20,resizable=yes,scrollbars=yes,status=0;" );
}

function ordprint(iIdLink){
  var refFoto = window.open("ord_print.php?p="+ iIdLink, 'Print', "heigth=430,width=770,top=20,left=20,resizable=yes,scrollbars=yes,status=0;" );
}

function datprint(iIdLink){
  var refFoto = window.open("dat_print.php?p="+ iIdLink, 'Print', "heigth=430,width=770,top=20,left=20,resizable=yes,scrollbars=yes,status=0;" );
}

function gEBI( objId ){

  return document.getElementById( objId );

}

function fix( f ){
	f	= f.toString( );
	var re	= /\,/gi;
	f	= f.replace( re, "\." );

	f = Math.round( f * 100 );
	f = f.toString( );
	var sMinus = f.slice( 0, 1 );
	if( sMinus == '-' ){
	 f = f.slice( 1, f.length )
	}
	else
	 sMinus = '';
	if( f.length < 3 ) {
		while( f.length < 3 )
			f = '0' + f;
	}

	var w = sMinus + f.slice( 0, f.length-2 ) + "." + f.slice( f.length-2, f.length );

  var poprawnyFloat = /^-?[0-9]{1,}[.]{1}[0-9]{1,}$/i;
	if( w.search( poprawnyFloat ) == -1 )
		w = '0.00';
	return w;

}

_bUa=navigator.userAgent.toLowerCase();
_bOp=(_bUa.indexOf("opera")!=-1?true:false);
_bIe=(_bUa.indexOf("msie")!=-1&&!_bOp?true:false);
_bIe4=(_bIe&&(_bUa.indexOf("msie 2.")!=-1||_bUa.indexOf("msie 3.")!=-1||_bUa.indexOf("msie 4.")!=-1)&&!_bOp?true:false)
isIe=function(){return _bIe;}
isOldIe=function(){return _bIe4;}
var olArray=[];

function AddOnload( f ){
  if( isIe && isOldIe ){
    window.onload = ReadOnload;
    olArray[olArray.length] = f;
  }
  else if( window.onload ){
    if( window.onload != ReadOnload ){
      olArray[0] = window.onload;
      window.onload = ReadOnload;
    }
    olArray[olArray.length] = f;
  }
  else
    window.onload=f;
}
function ReadOnload(){
  for( var i=0; i < olArray.length; i++ ){
    alert( olArray[i] );
    olArray[i]();
  }
}


//Start AJAX

var xmlHttp

function switchstate(st)
 { 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
 var url="sw_state.php"
 url=url+"?k="+st
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=stateswitched 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 } 

function stateswitched() 
{ 
if (xmlHttp.readyState==4)
 { 
 document.getElementById("txtstate").innerHTML=xmlHttp.responseText 
 } 
}


function evtShow(str)
 { 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
 var url="http://www.victorphillips.org/cal/show_event.php"
 url=url+"?k="+str
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=stateswitcheq 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 } 

function stateswitcheq() 
{ 
if (xmlHttp.readyState==4)
 { 
 document.getElementById("evtShow").innerHTML=xmlHttp.responseText 
 } 
}


// for ALL

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

// end of AJAX

// step 2 address copy over

function CopyInput(form) {
form.sh_sFirstName.value = form.sFirstName.value;
form.sh_sLastName.value = form.sLastName.value;
form.sh_sCompany.value = form.sCompany.value;
form.sh_sStreet.value = form.sStreet.value;
form.sh_sCity.value = form.sCity.value;
form.sh_sState.value = form.sState.selectedIndex;
form.sh_sZipCode.value = form.sZipCode.value;
form.sh_sState.value = form.sState.value;
form.sh_sCountry.value = form.sCountry.selectedIndex;
form.sh_sCountry.value = form.sCountry.value;
form.sh_sTelephone.value = form.sTelephone.value;
form.sh_sEmail.value = form.sEmail.value;
}
