var popup=0;

window.onresize=scheckAndSetBG;
//======================================================
// Function to generate div for form
//======================================================
function generateDiv(){
	if(document.getElementById("lightBox")==null){
		var iFrame = document.createElement("DIV");
		iFrame.setAttribute("id", "lightBox");
		iFrame.className="white_content";
		
		var inneriFrame = document.createElement("DIV");
		inneriFrame.setAttribute("id", "formLoader");
				
		iFrame.appendChild(inneriFrame);
		document.body.appendChild(iFrame);
		
		//This is for background div to display on complete screen
		iFrame = document.createElement("DIV");
		iFrame.setAttribute("id", "fade");	
		iFrame.className="white_overlay";
		document.body.appendChild(iFrame);
	}
}


function showSoftPopUp(whichForm,fileName,pageHead){
	popup=1;
	generateDiv();
	
	
	
	var windowSize = getWindowSize();
	
	var totalHeight = (Window1.getWindowHeight() > Window1.getScrollHeight())?Window1.getWindowHeight():Window1.getScrollHeight();
	var totalWidth = (Window1.getWindowWidth() > Window1.getScrollWidth())?Window1.getWindowWidth():Window1.getScrollWidth();
	//alert(totalHeight);
	if(windowSize.X <978){
		totalWidth = 1000;
	}
	
	var feedbackX = (totalWidth - 640)/2;
	var feedbackY = (totalHeight - 640)/2;
	var feedbackY = feedbackY - 100;
	
	document.getElementById("fade").style.height = totalHeight + "px";
	document.getElementById("fade").style.width = totalWidth + "px";
	
	document.getElementById("fade").style.display='block';
	
	//alert(document.getElementById("wrapper").width + " :: " + windowSize.X + " : " + document.getElementById("wrapper").offsetHeight)
	
	if(whichForm=="bed_breakfast"){

		leftPos = ((Window1.getWindowWidth() / 2) - 305)+Window1.getScrollLeft();
		topPos = ((Window1.getWindowHeight() / 2) - 240)+Window1.getScrollTop();
	}
	else if(whichForm=="bed_breakfast2"){
		leftPos = ((Window1.getWindowWidth() / 2) - 205)+Window1.getScrollLeft();
		topPos = ((Window1.getWindowHeight() / 2) - 240)+Window1.getScrollTop();
	}
	
	else if(whichForm=="surroundings"){
		leftPos = ((Window1.getWindowWidth() / 2) - 305)+Window1.getScrollLeft();
		topPos = ((Window1.getWindowHeight() / 2) - 205)+Window1.getScrollTop();
	}
		
	document.getElementById("lightBox").style.top = topPos + 'px';
	document.getElementById("lightBox").style.left = leftPos + 'px';
		
	document.getElementById("lightBox").style.display='block';
	document.getElementById("formLoader").style.display='block';
	    	
	generateForm(whichForm,fileName,pageHead);

}

function hideFeedback(){
		
	for(var i = 0; i < arguments.length; i++)
	{
		var divObj = document.getElementById(arguments[i]);
		document.body.removeChild(divObj);
	}
		
}

function generateForm(whichForm,fileName,pageHead){
	var myform = document.getElementById("formLoader");

	
	if(whichForm=="bed_breakfast"){
		myform.innerHTML="<iframe id='myframe' src='/gallery/slideshow.php?xml_name="+fileName+"&pageHead="+pageHead+"' height=630 width=630 frameborder=0 scrolling=no marginheight=0 marginwidth=0 allowtransparency='true'></iframe>";

	}else if (whichForm=="bed_breakfast2"){
		myform.innerHTML="<iframe id='myframe' src='/gallery/slideshow.php?xml_name="+fileName+"&pageHead="+pageHead+"' height=480 width=410 frameborder=0 scrolling=no marginheight=0 marginwidth=0 allowtransparency='true'></iframe>";
	}
	else if (whichForm=="surrounding"){
		myform.innerHTML="<iframe id='myframe' src='/gallery/slideshow.php?xml_name="+fileName+"&pageHead="+pageHead+"' height=640 width=640 frameborder=0 scrolling=no marginheight=0 marginwidth=0 allowtransparency='true'></iframe>";
	}
   
}



//This is to reset bacground size of soft popup when resize the window
function scheckAndSetBG(){
	if(document.getElementById("fade")!=null){
		if(document.getElementById("fade").style.display=="block"){
			var totalHeight = (Window1.getWindowHeight() > Window1.getScrollHeight())?Window1.getWindowHeight():Window1.getScrollHeight();
			var totalWidth = (Window1.getWindowWidth() > Window1.getScrollWidth())?Window1.getWindowWidth():Window1.getScrollWidth();
				
			document.getElementById("fade").style.height = totalHeight + "px";
			document.getElementById("fade").style.width = totalWidth + "px";
		}
	}
}



//To get window size
function getWindowSize()
{
  var myWidth = 0, myHeight = 0;
 
  if( typeof( window.innerWidth ) == 'number' )
  {
    //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
  }
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
  {
       //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth ;
        myHeight = document.documentElement.clientHeight;
  }
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
  {
    //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
  }
 
  var X= myWidth;
  var Y= myHeight;
 
  return {X:X, Y:Y};
}

Window1 = {	
	//Returns an integer representing the width of the browser window (without the scrollbar).
	getWindowWidth : function() {
	return (document.layers||(document.getElementById&&!document.all)) ? window.outerWidth : (document.all ? document.body.clientWidth : 0);
	},
	
	//Returns an integer representing the height of the browser window (without the scrollbar).
	getWindowHeight : function() {	
	return window.innerHeight ? window.innerHeight :(document.getBoxObjectFor ? Math.min(document.documentElement.clientHeight, document.body.clientHeight) : ((document.documentElement.clientHeight != 0) ? document.documentElement.clientHeight : (document.body ? document.body.clientHeight : 0)));
	},	
	
	//Returns an integer representing the scrollWidth of the window. 
	getScrollWidth : function() {
		return document.all ? Math.max(Math.max(document.documentElement.offsetWidth, document.documentElement.scrollWidth), Math.max(document.body.offsetWidth, document.body.scrollWidth)) : (document.body ? document.body.scrollWidth : ((document.documentElement.scrollWidth != 0) ? document.documentElement.scrollWidth : 0));
	},
	
	//Returns an integer representing the scrollHeight of the window. 
	getScrollHeight : function(){		
		return document.all ? Math.max(Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight), Math.max(document.body.offsetHeight, document.body.scrollHeight)) : (document.body ? document.body.scrollHeight : ((document.documentElement.scrollHeight != 0) ? document.documentElement.scrollHeight : 0));
	},			
	
	//Returns an integer representing the scrollLeft of the window (the number of pixels the window has scrolled from the left).
	getScrollLeft : function() {
		return document.all ? (!document.documentElement.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft) : ((window.pageXOffset != 0) ? window.pageXOffset : 0);
	},
	
	//Returns an integer representing the scrollTop of the window (the number of pixels the window has scrolled from the top).
	getScrollTop : function() {
		return document.all ? (!document.documentElement.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop) : ((window.pageYOffset != 0) ? window.pageYOffset : 0);
	}
}
		
//Test function		
function OpenTestPopup() {
	alert("Window Width : " + Window1.getWindowWidth() + " px\n"
		+ "Window Height : " + Window1.getWindowHeight() + " px\n"
		+ "Scroll Width : " + Window1.getScrollWidth() + " px\n"
		+ "Scroll Height : " + Window1.getScrollHeight() + " px\n"
		+ "Scroll Left : " + Window1.getScrollLeft() + " px\n"
		+ "Scroll Top : " + Window1.getScrollTop() + " px");
}

/*------------------Function to check cookies enabled  ------------------------- */
function check_cookies(){
	    if(!navigator.cookieEnabled){
             //alert('Your browser has cookies disabled.');
			 //document.getElementById("cookies_div").style.display="block";
			 showSoftPopUp('cookies','how to enable browser cookies');
			 return false;
		}else{
			 return true;
		}
}//End Of check_cookies()------------------------------------------------------














