

function autoFillEntityForm(entityType,entityID) {

	//alert('getting code for entityType ' + entityType);
	//alert('getting id for entityID' + entityID);
	
	//alert ('doing request');
	doJSONSeriesRequest(entityID,entityType);
	
}


function fillProductForm(obj) {

	//alert ('filling');
	//alert('obj is ' + obj);
	
	//alert (obj.productName);
	//alert (obj.productPrice);
	
	
	$("#productName").val(obj.productName);
	$("#productPrice").val(obj.productPrice);
	$("#productKeywords").val(obj.productKeywords);
	$("#description").val(obj.description);
	$("#publisher").val(obj.publisher);
	$("#printing").val(obj.printing);
	$("#consultants").val(obj.consultants);
	$("#editors").val(obj.editors);
	$("#photoEditors").val(obj.photoEditors);
	$("#volume").val(obj.volume);
	$("#issue").val(obj.issue);
	$("#pinups").val(obj.pinups);
	
	
	//alert ('set');
	
	/*

	$("input[@name='productName']").val(obj.productName); 
	$("input[@name='productPrice']").val(obj.productName); 
	$("input[@name='productKeywords']").val(obj.productName);
	$("input[@name='description']").val(obj.description);
	$("input[@name='publisher']").val(obj.publisher);
	$("input[@name='printing']").val(obj.printing);
	$("input[@name='consultants']").val(obj.consultants);
	$("input[@name='editors']").val(obj.editors);
	$("input[@name='photoEditors']").val(obj.photoEditors);
	$("input[@name='volume']").val(obj.volume);
	$("input[@name='issue']").val(obj.issue);
	$("input[@name='pinups']").val(obj.pinups);
	$("input[@name='description']").val(obj.description);
	*/
}


function showLoadingDialog(content) {

	//alert (content);
	boxy = new Boxy('<div id = "boxyDiv">' + content + '</div>', {title: "System Message", closeable: true, modal: true});	

	//alert(boxy);

}

function closeDialogBox() {

	boxy.hide();
	
}
function updateDialog(content,success) {

	//alert ('updating with ' + content);
	//boxy.setContent(content);
	//alert(boxy);
	
	/*
	if (body == undefined) {
		showLoadingDialog(content);
	}
	*/
		
	
	if (!success) {
		boxy.setContent('<div id = "boxyDiv">' + content + '</div>');
		//handler();
	} else {
		boxy.setContent('<div id = "boxyDiv">' + content + '</div>');
		//handler();
	}
	//boxy.hide();

}


function addHiddenValue(formName,key,value) {

	var formObject = document[formName];
	//alert(formObject);
	
	$(formObject).append('<input type = "hidden" name = "' + key + '" value = "' + value + '" />"');
		

}

function getDisplayObject(mainContainer) {
	
	displayObject = new Object();
	displayObject.mainContainer = mainContainer;
	
	//alert('main container is ' + displayObject.mainContainer);
	
	displayObject.overlayDiv = overlayDiv;
	
	
	
	return displayObject;
	
}

function removeOverlay(callback) {
	
	//alert  ('removing');
	var existing = jQuery('.hf_DisplayBox');
	if (existing.length > 0) {
		jQuery('.hf_DisplayBox').slideToggle(function() { jQuery('.hf_DisplayBox').remove(); } );
		jQuery('.hf_DisplayBoxBkgrnd').animate( { 'opacity':'0'},function() {
			jQuery('.hf_DisplayBoxBkgrnd').remove();
			callback();
		});
	}	
}

function showUpdate(message) {
	
	var overlay = new overlayDiv(300,100,20);
	jQuery(overlay).append('<p>' + message + '</p>');
	return overlay;

}

function overlayDiv(theWidth,theHeight,padding) {
	
	var existing = jQuery('.hf_DisplayBox');
	//alert (existing.length);
	
	if (!padding) {
		padding = 0;
	}
	
	
	if (existing.length < 1) {
	
		// make box itself
	
		jQuery('body').prepend('<div class = "hf_DisplayBox" />');
		jQuery('.hf_DisplayBox').css({
			width:theWidth,
			height:theHeight
		});
		jQuery('.hf_DisplayBox').css({
			display:'none',
			left:( jQuery(window).width() - jQuery('.hf_DisplayBox').width() )/2,
			top:( jQuery(window).height() - jQuery('.hf_DisplayBox').height() )/2 -20,
			position:'absolute',
			border: '4px solid #fff'
		
		});
		jQuery('.hf_DisplayBox').css('z-index','9999');
		jQuery('.hf_DisplayBox').css('color','#ffffff');
		jQuery('.hf_DisplayBox').css('padding',padding + 'px');
		jQuery('.hf_DisplayBox').css('background-color','#333');
		
		// make close button
		jQuery('.hf_DisplayBox').append('<a class = "hf_DisplayClose" href = "#">Close</a>');
		jQuery('.hf_DisplayBox').find('.hf_DisplayClose').css('color','#ffffff');
		jQuery('.hf_DisplayBox').find('.hf_DisplayClose').css('position','absolute');
		jQuery('.hf_DisplayBox').find('.hf_DisplayClose').css('top','5px');
		jQuery('.hf_DisplayBox').find('.hf_DisplayClose').css('right','10px');
		jQuery('.hf_DisplayBox').find('.hf_DisplayClose').click(function() {
			
			removeOverlay();
		
		});
		
		jQuery('.hf_DisplayBox').append('<div class = "hf_DisplayFooter">System Design By <a target = "_blank" href = "http://www.heaveninteractive.com">Heaven Interactive</a></div>');
		jQuery('.hf_DisplayFooter').css('position','absolute');
		jQuery('.hf_DisplayFooter').css('bottom','5px');
		jQuery('.hf_DisplayFooter').css('right','20px');
		jQuery('.hf_DisplayFooter').css('text-align','right');
		jQuery('.hf_DisplayFooter').css('color','#fff');
		jQuery('.hf_DisplayFooter').css('border-top','1px solid #fff');
		jQuery('.hf_DisplayFooter').css('font-size','9px');
		jQuery('.hf_DisplayFooter').css('width','70%');
		
		// make background
		jQuery('body').prepend('<div class = "hf_DisplayBoxBkgrnd" />');
		jQuery('.hf_DisplayBoxBkgrnd').css({
			display:'block',
			width: jQuery(window).width(),
			height:jQuery(window).height(),
			position:'absolute'
		});
		jQuery('.hf_DisplayBoxBkgrnd').css('z-index','9998');
		
		jQuery('.hf_DisplayBoxBkgrnd').css('opacity','0');
		jQuery('.hf_DisplayBoxBkgrnd').css('background-color','#000000');
		jQuery('.hf_DisplayBoxBkgrnd').animate( { 'opacity':'0.5'} );
		

	
		
	} else {
		//alert ('already exists');
	}
	jQuery('.hf_DisplayBox').slideToggle();

	return jQuery('.hf_DisplayBox');
	

	
}
