var bookwin = null;
function OpenBooklet(bookname)
{
	//all booklets and forms are stored in the folder booklets_forms on
	//wellknit.ca website
	var win_url = 'https://secure.wellknit.ca/user/booklets_forms/' + bookname;
	//var win_url = "http://www.microsoft.com";
	
	//alert( win_url );
	if( bookwin != null && bookwin.closed != true)
		bookwin.close();
		
	bookwin = window.open("bookforms.html","WinBook","toolbar=no");
	bookwin.frames.mainframe.location = win_url;
	//alert( bookwin.height );
	
	//bookwin.document.title = "Booklets";
	//bookwin.personalbar.visible = false;
}

// Fixes the infamous Netscape 4 resize bug;  
     // Adapted by jon stephens from an unknown source  
     // Copyleft 1998-99 -- use it, enjoy it, share the wealth :-)  
       
     // ... function resizeFix() ...  
     // This checks to see if the window's dimensions  
     // have actually changed (because Netscape 4 often  
     // fires a false Resize event when it forms  
     // scrollbars); if they have, the document is reloaded.  
     // Note that document.location is not  
     // supposed to be settable, but here's yet  
     // another case where the implementation does *not* 
     // match the specs!  
          
     function resizeFix(){  
        if(document.resizeFix.initWidth!=window.innerWidth 
           ||document.resizeFix.initHeight!=window.innerHeight) 
              document.location=document.location;  
     }  
          
     // ... function checkBrowser() ...  
     // This function checks to see if the browser  
     // supports the Layer object (i.e., Netscape 4.X);  
     // if it does, then it creates a new object with  
     // properties to hold the current window width &  
     // height and assigns the resizeFix() function to  
     // the window's onResize event.  
          
     function checkBrowser(){  
        if(document.layers){  
           if(typeof document.resizeFix=="undefined"){  
              document.resizeFix=new Object();  
              document.resizeFix.initWidth=window.innerWidth;  
              document.resizeFix.initHeight=window.innerHeight;  
           }  
           window.onresize=resizeFix;  
        }  
     }  
          
     // This calls the browser check function above  
    checkBrowser(); 


// Image preloading
	var Open = ""
	var Closed = ""
	
	function preload(){
		if(document.images){
			Open = new Image(16,13)    
			Closed = new Image(16,13)
			Open.src = "open.gif"
			Closed.src = "closed.gif"
		}
	}
	
// Function to show or hide layers. (As used in the Admin pop-open/closed menu.
	function showhide(what,what2){
		if (what.style.display=='none'){
			what.style.display='';
			what2.src=Open.src
		}
		else{
			what.style.display='none'
			what2.src=Closed.src
		}
	}

// Popup calendar function
	function PopUpCalendar(formName, fieldName, openDate) {
		var h = 250;
		var w = 200;
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = "height="+h+",width="+w+",top="+wint+",left="+winl+",scrollbars=yes,toolbar=no,location=no,menu=no";

		window.dateField = eval("document." + formName + "." + fieldName);
		calendar = window.open('popupcalendar.htm', 'PopUpCalendar', winprops);

		if (parseInt(navigator.appVersion) >= 4) { calendar.window.focus(); }
		return false;	
 	}

// Function for implementing a "Select All" for checkboxes.
	function selectAllOptions(obj) {
		for (var i=0; i<obj.form.div_id.length; i++) {
			obj.form.div_id[i].selected = true;
		}
	}

// Function for implementing a "Unselect All" for checkboxes.
	function unselectAllOptions(obj) {
		for (var i=0; i<obj.form.div_id.length; i++) {
			obj.form.div_id[i].selected = false;
		}
	}
	
// This function gets the file name with full path of an file-upload routine, parses it 
// and leaves only the file name and extention.
	function copyname( form, from, to, checkUp ) 
	{
		var strTmp = from.value;
		var strLength = strTmp.length; 
		var LengthFile = 0;
		var counter = 0;
		for( var i=0; i<strLength; i++ ) {
			if( ( strTmp.substring( i, i+1 ) == "\\" ) || ( strTmp.substring( i, i+1 ) == "/" )  ) {
				counter = i;
			}
		}
		LengthFile = strLength - ( counter + 1 );
		to.value = strTmp.substring((counter + 1), strLength );
		checkUp.value = 1;
	}
	
	
	function NewWindow(mypage, myname, w, h, scroll, menubars, locationbar, titlebar, statusbar, toolbar, resize) {
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars =' + scroll + ', menubar =' + menubars + ', locationbar = ' + locationbar + ', titlebar=' + titlebar + ', status = '+ statusbar + ', toolbar =' + toolbar + ',resizable ='+ resize;
		win = window.open(mypage, myname, winprops);
		if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	}

