function createModal(state,page,location){
	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 modalFrameId = '';
	if(location==null){location='top';}
	
	if(page==null){page=0;}
	switch(page){
    case 1:
      modalFrameId = 'price-guarantee';
      break;
    case 2:
      modalFrameId = 'return-policy-modal';
      break;
    case 3:
      modalFrameId = 'satisfaction-guarantee-modal';
      break;
    case 4:
      modalFrameId = 'privacy-policy-modal';
      break;
    case 5:
      modalFrameId = 'shipping-policy-modal';
      break;
    case 6:
      modalFrameId = 'copyright-notice-modal';
      break;
    case 7:
      modalFrameId = 'payment-methods-modal';
      break;
  }
	var modalFrame = document.getElementById('modalOverlay-frame'); //modal frame div
	var cHeight = (container&&container!='undefined')?container.offsetHeight+"px":"1600px";
	var fHeight = (container&&container!='undefined')?(container.offsetHeight-400)+"px":"1200px";
	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='350px';modalFrame.style.display='block';if(location=='bottom'){modalFrame.style.top=fHeight;}else{modalFrame.style.top='180px';}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');document.body.appendChild(modalFrame);}
	if(modalFrame&&modalFrame!='undefined'&&page!=0){modalFrame.id='modalOverlay-frame';modalFrame.innerHTML='<iframe src="'+modalFrameId+'.html" width="500px" height="350px" frameborder="0"></iframe>';}
	if (state=="on")on();
	if (state=="off")off();
	if (state="on") {modal.onclick=function(){
				if(clickToClose)off();
			}
      modalFrame.onclick=function(){
				if(clickToClose)off();
			}}
} 
