function GetXmlHttpObject()
{
	try
	{    // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();  
		return xmlHttp;  
	}
	catch (e)
	{    // Internet Explorer    
		try
		{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
			return xmlHttp;    
		}
		catch (e)
		{      
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				return xmlHttp;
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!"+e.message);
				return false;
			}
		}
	}
}

function enquiry_popup(divname,status)
{
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp == null)
	{
		alert("Browser does not support HTTP Request");
		return;
	}
	var url="make_an_enquiry_appoint_form.php?status="+status;
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState==4 || xmlHttp.readyState == "complete")
		{
			document.getElementById(divname).innerHTML = xmlHttp.responseText;
			
			fireMyPopup(divname);
			
		}
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function setOpacity(value,divname)
{
	document.getElementById(divname).style.opacity = value / 10;
	document.getElementById(divname).style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup(divname)
{
	for( var i = 0 ; i <= 100 ; i++ )
		setTimeout( 'setOpacity(' + (i / 10) + ',\''+divname+'\')' , 8 * i );
}

function fadeOutMyPopup(divname) 
{
	
	for( var i = 0 ; i <= 100 ; i++ ) 
	{
		setTimeout( 'setOpacity(' + (10 - i / 10) + ',\''+divname + '\')' , 8 * i );
	}
	setTimeout('closeMyPopup(\''+divname+'\')', 800 );
}

function closeMyPopup(divname)
{
	document.getElementById(divname).style.display = "none";
}

function fireMyPopup(divname) 
{
	
	setOpacity(0,divname);
	document.getElementById(divname).style.display = "block";
	fadeInMyPopup(divname);
}


function valid_enquiry_appoint()
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.FrmEnq.txt_email.value.match(emailPat);
		var addi	= parseInt(document.FrmEnq.txt_fno.value) + parseInt(document.FrmEnq.txt_sno.value);
		if(document.FrmEnq.txt_name.value == '')
		{
			alert("Please enter your name.");
			document.FrmEnq.txt_name.focus();
			return false;
		}
		
		if(document.FrmEnq.txt_email.value=="")
		{
			alert("Please enter your email address");
			document.FrmEnq.txt_email.focus();
			return false;
		}
		else
		{
			if (matchArray == null)
			{
				alert ("Please enter your valid email address.");
				document.FrmEnq.txt_email.focus();
				return false;
			}
		}
		if(document.FrmEnq.txt_comment.value == '')
		{
			alert("Please enter the comments.");
			document.FrmEnq.txt_comment.focus();
			return false;
		}
		if(document.FrmEnq.txt_secu_code.value == "" || document.FrmEnq.txt_secu_code.value == "Enter The Total")
		{
			alert("Please enter spam authentication value");
			document.FrmEnq.txt_secu_code.focus();
			return false;
		}
		else if(document.FrmEnq.txt_secu_code.value != addi)
		{
			alert("Please enter correct addition");
			document.FrmEnq.txt_secu_code.focus();
			return false;
		}
}

if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
		
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x;//+document.body.scrollLeft;
        yMousePos = window.event.y;//+document.body.scrollTop;
		xMousePos = xMousePos+200;
		yMousePos = yMousePos+200;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
		
    } else if (document.getElementById) {
		
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX+100;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
		
    }
}
function valid_guest_book()
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.frm.txt_email.value.match(emailPat);
	if(document.frm.txt_firstname.value == "")
	{
		alert("Please enter the first name.");
		document.frm.txt_firstname.focus();
		return false;
	}
	if(document.frm.txt_lastname.value == "")
	{
		alert("Please enter the last name.");
		document.frm.txt_lastname.focus();
		return false;
	}
	if(document.frm.txt_email.value=="")
	{
		alert("Please enter the email address");
		document.frm.txt_email.focus();
		return false;
	}
	else
	{
		if (matchArray == null)
		{
			alert ("Please enter your valid email address.");
			document.frm.txt_email.focus();
			return false;
		}
	}
	if(document.frm.txt_comment.value=="")
	{
		alert("Please enter the comment");	
		document.frm.txt_comment.focus();
		return false;
	}
}
