/**
 * @author hugo
 */

/**
 * This function creates an alert with a custom button and message
 */
var pulseGif = new Image();
pulseGif.src= httpPath + 'jz_pics/ajax-loader-bar.gif';
var pulserBar = '<img src="' + pulseGif.src + '" style="width:174px;" align="center" />';
//var httpPath = 'http://www.southtexasjobzone.com/';

function createConfirm(msg,yesAct, noAct)
{
    var div = document.createElement('div');
    var span = document.createElement('span');
    var btn_yes = document.createElement('input');
    var btn_no = document.createElement('input');
    var contDiv;

    if((getId('containerDiv')) == null)
    {
        contDiv = document.createElement('div');
        contDiv.setAttribute('id', 'containerDiv');
    }
    else
    {
        contDiv = getId('containerDiv');
    }


    return contDiv;
}

function createErrorBox(errorMsg)
{
	var errorDiv = null;
	var containerDiv = null;
	if((containerDiv = document.getElementById('containerDiv')) != null)
	{
		return containerDiv;
	}
	else
	{	
		containerDiv = document.createElement('div');
		containerDiv.setAttribute('class','cssWindowContainer');
                containerDiv.className = 'cssWindowContainer';
		
		errorDiv = document.createElement('div');
		errorDiv.setAttribute('id','floatError');
		errorDiv.setAttribute('class', 'cssWindow');
                errorDiv.className = 'cssWindow';
		errorDiv.innerHTML = '<b>'+errorMsg+'</b><br />';
		errorDiv.appendChild(getButton(containerDiv));
		
		containerDiv.appendChild(errorDiv);
		return containerDiv;	
	}
}

/**
 * This function creates a button that 
 * closes its parent object.
 * @param {Object} parentElement the parent element that needs to be closed
 */
function getButton(parentElement)
{
	button = document.createElement('input');
	button.setAttribute('type','button');
	button.setAttribute('value', 'Close');
	button.onclick=function()
	{
		parentElement.parentNode.removeChild(parentElement);
	}
	
	return button;
}

/**
 * The above function is a bit of a misnomer,
 * it actually creates a close button, this
 * creates a more general button.
 * @param {String} value What should be displayed on the button
 * @return {Object} button a reference to the created button object
 */
function getGeneralButton(value)
{
	button = document.createElement('input');
	button.setAttribute('type', 'button');
	button.setAttribute('value',value);
	
	return button;
}

/**
 * this function builds and ajax object. you know for fun :P
 * @return XMLHttpRequest xmlhttp an "ajax" object.
 */

function floatingFrame(url)
{
	var iFrame = document.createElement('iframe');
	var iFContainer = document.createElement('div');
	var bodyCover = document.createElement('div');
	var btnHolder = document.createElement('div');
	
	bodyCover.setAttribute('class','cssWindowContainer');
	bodyCover.className = 'cssWindowContainer';

	iFContainer.setAttribute('id','floatError');
	iFContainer.setAttribute('class','cssWindow');
	iFContainer.className = 'cssWindow';
        
	iFrame.setAttribute('src', url);
	iFrame.setAttribute('class','winFrame');
        iFrame.className = 'winFrame';
	iFrame.setAttribute('scrolling','no');
	iFrame.setAttribute('id','dispFrame');
	
	btnHolder.setAttribute('id','btnHolder');
	btnHolder.appendChild(getButton(bodyCover));
	//alas, I do this with pain in my heart
	// but there was no easier way.
	
	iFContainer.appendChild(iFrame);
	iFContainer.appendChild(btnHolder);
	
	bodyCover.appendChild(iFContainer);
	
	return(bodyCover);
}


