function screenSize() {
    var w, h; // w - width, h - height
    w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
    h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
    return {w:w, h:h};
}

//var id=null;

function getDocumentHeight()
{
	return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
}
function showbg()
{
	id_m = document.getElementById('divmaska');
    id_m.style.top=0;
	id_m.style.left=0;
    id_m.style.display ='block';

	id_m.style.Height =getDocumentHeight()+'px';
	id_m.style.width =screenSize().w+'px';

	id_m2 = document.getElementById('maska');
	id_m2.style.Height =100+'%';
	id_m2.style.width =100+'%';
}
function hidebg()
{
	id_m = document.getElementById('divmaska');
    id_m.style.display ='none';
}
function hidepopup(popupname){
      id = document.getElementById(popupname);
      id.style.display = 'none';
      hidebg();
}
function showpopup(popupname){ //for doctor light-box
		if ((window.navigator.userAgent.indexOf ("MSIE") >= 0) && ((window.navigator.userAgent.substr(window.navigator.userAgent.indexOf("MSIE")+5,3) == 7.0) || (window.navigator.userAgent.substr(window.navigator.userAgent.indexOf("MSIE")+5,3) == 6.0))) { ; }
		else showbg();
		idpage = document.getElementById('page');
		i=document.documentElement.scrollTop;

		id = document.getElementById(popupname);
		id.style.display = 'block';
		if(screenSize().h>parseInt(id.offsetHeight)) id.style.top = (((screenSize().h-parseInt(id.offsetHeight))/2)+parseInt(i)) -120+'px';
		if(screenSize().w>450) id.style.left = (((screenSize().w-450)/2)-idpage.offsetLeft)+'px';
}
function showpopup2(popupname){  //for franchise form light-box

      if ((window.navigator.userAgent.indexOf ("MSIE") >= 0) && ((window.navigator.userAgent.substr(window.navigator.userAgent.indexOf("MSIE")+5,3) == 7.0) || (window.navigator.userAgent.substr(window.navigator.userAgent.indexOf("MSIE")+5,3) == 6.0))) { ; }
		else showbg();
      idpage = document.getElementById('page');
      i=document.documentElement.scrollTop;

      id = document.getElementById(popupname);
      id.style.display = 'block';
      id.style.top = 5+'px';
      if(screenSize().w>450) id.style.left = (((screenSize().w-450)/2)-idpage.offsetLeft) +'px';
}

function showpopup3(popupname){ //for doctor light-box
		if ((window.navigator.userAgent.indexOf ("MSIE") >= 0) && ((window.navigator.userAgent.substr(window.navigator.userAgent.indexOf("MSIE")+5,3) == 7.0) || (window.navigator.userAgent.substr(window.navigator.userAgent.indexOf("MSIE")+5,3) == 6.0))) { ; }
		else showbg();
		i=document.documentElement.scrollTop;

		id = document.getElementById(popupname);
		id.style.display = 'block';
		if(screenSize().h>parseInt(id.offsetHeight)) id.style.top = (((screenSize().h-parseInt(id.offsetHeight))/2)+parseInt(i))+'px';
		if(screenSize().w>id.offsetWidth) id.style.left = ((screenSize().w-id.offsetWidth)/2)+'px';
}

function hideAllPopup()
	{      hidebg();  ///////////////////////////////////////		if(id)
			{
				id.style.display = 'none';
				hidebg();
            }	}
img1 = new Image();
img1.src = main_img_dir +'btnclose1.png';
img2 = new Image();
img2.src = main_img_dir +'btnclose2.png';
img3 = new Image();
img3.src = main_img_dir +'bg_trans.png';
img4 = new Image();
img4.src = main_img_dir +'popuptop.png';
img5 = new Image();
img5.src = main_img_dir +'popupbottom.png';