// JavaScript Document For Modal Window Init

var LoadingStatus				="<img src='"+SiteImagePath+"ajax_loader_small.gif'/>";
var LoadingStatusBar			="<img src='"+SiteImagePath+"ajax_bar_red_loader.gif'/>"; 
var ModalStaticContent			='';
var ModalStaticContentTitle		='';
var ModalStaticRedirectPath=	'';

messageObj = new DHTML_modalMessage();	
messageObj.setShadowOffset(5);	


function ShowModalWindow(ModalType,width,height,PostValues,AjaxFilename,AjaxCheckFormData) {
		
		
		//ModalType 	- Condition to open a modal window
		//width			- Width of the window
		//height		- Height of the window
		//PostValues 	- PostValues - ( To process the dynamic modal winow content ( Seperate it " | " && " ^^ " Ex: ProductID|123^^CategoryID"32
		//AjaxFilename	- file name
		//AjaxCheckFormData -  to validate the form data 
		
		// Note : Based on modal type condition you can perform serveral operations using if stmt
		AjaxFilename=SiteAjaxFolder+AjaxFilename;
		AjaxCheckFormData=SiteAjaxFolder+AjaxCheckFormData;
		
		if(ModalStaticContent!='') {
			messageObj.setModalStaticContentTitle(ModalStaticContentTitle);
			messageObj.setModalStaticContent(ModalStaticContent);
			ModalStaticContent='';
			ModalStaticContentTitle='';
			//ModalStaticRedirectPath='';
			messageObj.setRedirectPath(ModalStaticRedirectPath);
			messageObj.setAjaxFileNames(AjaxFilename,AjaxCheckFormData);
			messageObj.setSource(ModalType);
			messageObj.setPostValues(PostValues);
			messageObj.setCssClassMessageBox(false);
			messageObj.setSize(width,height);
			messageObj.setShadowDivVisible(false);	// Enable shadow for these boxes
			messageObj.display();
		}
		else { 
			ModalStaticContent='';
			ModalStaticContentTitle='';
			ModalStaticRedirectPath='';
			messageObj.setModalStaticContentTitle(ModalStaticContentTitle);
			messageObj.setModalStaticContent(ModalStaticContent);
			messageObj.setRedirectPath(ModalStaticRedirectPath);
			messageObj.setAjaxFileNames(AjaxFilename,AjaxCheckFormData);
			messageObj.setSource(ModalType);
			messageObj.setPostValues(PostValues);
			messageObj.setCssClassMessageBox(false);
			messageObj.setSize(width,height);			
			messageObj.setShadowDivVisible(false);	// Enable shadow for these boxes
			messageObj.display();
		}
			
		
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ShowModalWindowContent(ModalMasterID,ModalType,PostValues,AjaxFilename,AjaxCheckFormData)
	{
		
		var Filename=AjaxFilename;

		ModalMasterID_public=ModalMasterID;
		document.getElementById(ModalMasterID).innerHTML = LoadingStatus;
		var success = function(t){ShowModalWindowCont_Complete(t,ModalMasterID,ModalType,PostValues,AjaxFilename,AjaxCheckFormData);}
		var failure = function(t){ShowOnFailure(t);}
		var url = Filename;
		var pars = '&ModalTypeCondition='+ModalType+'&PostValues='+PostValues;
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	}
	
function ShowModalWindowCont_Complete(t,ModalMasterID,ModalType,PostValues,AjaxFilename,AjaxCheckFormData)
	{
		var strValue = t.responseText;
		document.getElementById(ModalMasterID).innerHTML =strValue;
	}
function ShowOnFailure(t) { alert(t); };
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	function closeMessage(RedirectCondition,RedirectConditionPage)
	{
		messageObj.close();	
			
	}
	
	function redirect_page_after_modal_closed(RedirectConditionPage) {
			window.location.href=RedirectConditionPage;
	}

		
	
	