/*******************************************
 Javascript functions for dwpub.com
*******************************************/

var shown;

function toggleDiv(show) 
{
	// if one is displayed, close it.
	if(shown) {
		new Effect.BlindUp(shown);
	}

	// if we're clicking the title of a just shown item, exit here so we don't expand again
	if(shown == show) {
		shown = false;
		return;
	}

        new Effect.BlindDown(show);
        shown = show;
}

function HideShow(divID) {
  var item = document.getElementById(divID);
  if (item) {
    item.className=(item.className=='hide')?'show':'hide';
  }
}


function addBookmark(title,url) 
{
		if (window.sidebar) 
		{
			window.sidebar.addPanel(title, url,"");
		}
		else if( document.all ) 
		{
			window.external.AddFavorite( url, title);
		} 
		else if( window.opera && window.print ) 
		{
			return true;
		}
} 

// magic file upload
var upload_number = 2;
function addFileInput() {

	// set max uploads
	if(upload_number > 10) 
	{ 
		alert('You can only upload 10 files'); 
		document.getElementById("moreUploadsLink").hide();
		exit(0); 
	}

 	var d = document.createElement("div");
 	var file = document.createElement("input");
 	file.setAttribute("type", "file");
 	file.setAttribute("name", "attachment"+upload_number);
 	d.appendChild(file);
 	document.getElementById("step_one").appendChild(d);	
 	
 	var d2 = document.createElement("div");
	d2.setAttribute("class", "extra_img_input");
 	
	var caption = document.createElement("input");
 	caption.setAttribute("type", "text");
	caption.setAttribute("maxlength", "40");
	caption.setAttribute("size", "40");
 	caption.setAttribute("name", "new_caption"+upload_number);
 	caption.setAttribute("value", "Caption for file "+upload_number);
 	caption.setAttribute("title", "Caption for file "+upload_number);
 	caption.setAttribute("class", "input-text-upload upload-caption");
	d2.appendChild(caption);
 	document.getElementById("moreUploads").appendChild(d2);
	
 	
 	upload_number++;
 
}

