// Functionality to show/hide the Modal Window to show parter details/licence agreement div popup into the screen.

function getModalWindowContent(webpagename)
{
	var returnFunction = function()
	{
		
		if (ajax.isReady())
		{
			var myDiv = document.getElementById("modalWindowContent");
			myDiv.innerHTML = ajax.getResponse();
		}
	}
					
	ajax.send("/repairnet/" + webpagename, "GET", returnFunction);
}

/*
 * Display the modal window according to the following types:
 * windowType = 0: Modal Window with a close button at the top-right
 * windowType = 1: Modal Window without a close button and a yes/no option at the bottom, centered.
*/
function setModalWindowVisible(visible, windowType)
{
	var myDiv = document.getElementById("modalWindow");				
	var myDiv1 = document.getElementById("modalWindowBackground");	
	var myClosebutton = document.getElementById("modalWindowCloseButton");	
	var myDiv3 = document.getElementById("modalWindowContent");		
	var myYesNoButtons = document.getElementById("modalWindowYesNoButton");		
	if (visible)
	{																	
		myDiv.style.visibility = "visible";
		myDiv1.style.visibility = "visible";
		if (windowType == 0)
		  myClosebutton.style.visibility = "visible";
		  
		myDiv3.style.visibility = "visible";
		
		if (windowType == 1)
			myYesNoButtons.style.visibility = "visible";		
	}
	else
	{ 
	  	myDiv.style.visibility = "hidden";
	  	myDiv1.style.visibility = "hidden";
		myClosebutton.style.visibility = "hidden";
		myDiv3.style.visibility = "hidden";	
		myYesNoButtons.style.visibility = "hidden";			  	
	}
}
/*
 * Display the content in the modal window with a close button at the top-right.
*/
function displayModalWindowContent(webpagename)
{
	if (webpagename)
		getModalWindowContent(webpagename);
	else
		getModalWindowContent("allResellerDetails.htm");
	setModalWindowVisible(true, 0); 
}

/*
 * Display the content in the modal window with yes/no buttons at the bottom of the screen.
*/
function confirmModalWindowContent(webpagename, functionIfYes, functionIfNo)
{
	if (webpagename)
		getModalWindowContent(webpagename);
	else
		getModalWindowContent("allResellerDetails.htm");		
	setModalWindowVisible(true, 1); 
	
	var myYesbutton = document.getElementById("modalWindowYesButton");
	var myNobutton = document.getElementById("modalWindowNoButton");
	
	myYesButton.onClick=functionIfYes;
	myNoButton.onClick=functionIfNo;
	
}


