function createModal(state,page){
	var clickToClose = true; // set to true to close modalby clicking anywhere
	var container = document.getElementById('mss-container'); // page container id
	var modal = document.getElementById('modalOverlay'); // modal div id
	var modalFrame = document.getElementById('modalOverlay-frame'); //modal frame div
	var cHeight = (container&&container!='undefined')?container.offsetHeight+"px":"1600px";
	var selects = document.getElementsByTagName('select');
	function off(){modal.style.display='none';modalFrame.style.display='none';for (i=0;i<selects.length;i++){selects[i].style.visibility='visible';}}
	function on(){modal.style.height=cHeight;modal.style.display='block';modalFrame.style.height=cHeight;modalFrame.style.display='block';for(i=0;i<selects.length;i++){selects[i].style.visibility='hidden';}}
	if(!modal||modal=='undefined'){modal=document.createElement('div');modal.id='modalOverlay';document.body.appendChild(modal);}
	if(!modalFrame||modalFrame=='undefined'){modalFrame=document.createElement('div');modalFrame.id='modalOverlay-frame';document.body.appendChild(modalFrame);}
	if (state=="on")on();
	if (state=="off")off();
	if (state="on") {modal.onclick=function(){
				if(clickToClose)off();
			}
      modalFrame.onclick=function(){
				if(clickToClose)off();
			}}
} 
