/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";
function JSFX_FloatDiv(id, sx, sy)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
	el.flt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth :
		document.documentElement && document.documentElement.clientWidth ?
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ?
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0)
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ?
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.flt()", 40);
	}
	return el;
}

/* function for email validation */
function validate_email(form_id,email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms[form_id].elements[email].value;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
      document.forms[form_id].elements[email].value='';
      document.forms[form_id].elements[email].focus();
      return false;
   }
   return true;
}

/* function for move on date validation */
function checkdate(mdate)
{

var movedate=document.getElementById(mdate).value;
if(movedate!='')
{
var validformat=/^\d{2}\-\d{2}\-\d{4}$/ ; //Basic check for format validity
	if (!validformat.test(movedate))
		{
			alert("Invalid Date Format. Please correct and submit again.");
			return false;
		}
} else {
			alert('Please Enter move on date');
			return false;
			}
var mmonth=movedate.split("-")[0];
var mday=movedate.split("-")[1];
var myear=movedate.split("-")[2];

var myDate=new Date();

var today = new Date();

var cmonth = today.getMonth() + 1
var cday = today.getDate()
var cyear = today.getFullYear()

if (cmonth < 10){
cmonth = "0" + cmonth;
}
if (cday < 10){
cday = "0" + cday;
}
var currdate=cmonth + "/" + cday + "/" + cyear;

myDate.setFullYear(myear,(mmonth-1),mday);
today.setFullYear(cyear,(cmonth-1),cday);

if (myDate < today)
  {
  alert("Expected move on date should be greater than today");
  return false;
  }
  return true;
}

//function for checking whitespace
function IsEmpty(aTextField) {

	var ff=true;
	for (i = 0; i < aTextField.length; i++)
	{
	// Check that current character isn't whitespace.
	var c = aTextField.charAt(i);
	if (c=="" ||  c==" "){ }
		else
		{
		ff=false;
		return ff;
		}
	}
  return ff;
}//function	 IsEmpty(aTextField) close


function setVisible(obj,flg)
{
	//alert(flg);
	obj = document.getElementById(obj);

	obj.style.visibility = (flg== '0' || flg== 0) ? 'hidden' : 'visible';
}
//script for setting value to cookies


function showCookie()
{
alert(document.cookie);
}

//insert the $100 reward listings to DB, if user is not login
function ajaxReward(target_div, query_string)
{
var MyHttpRequest = false;
//alert('inside => '+query_string);
if(window.XMLHttpRequest) // client use Firefox, Opera etc - Non Microsoft product
{
	try
	{
		MyHttpRequest = new XMLHttpRequest();
	}
	catch(e)
	{
		MyHttpRequest = false;
	}
}
	else if(window.ActiveXObject) // client use Internet Explorer
	{
		try
			{
				MyHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
			}
		catch(e)
			{
				try
				{
					MyHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e)
				{
					MyHttpRequest = false;
				}
		}
	}
else
{
MyHttpRequest = false;
}

if(MyHttpRequest) // browser supports httprequest
{

MyHttpRequest.open("post", 'http://www.gardenstateapartments.com/reward_insert.php', true); // <-- run the httprequest using POST

//Send the proper header information along with the POST request
MyHttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
MyHttpRequest.setRequestHeader("Content-length", query_string.length);
MyHttpRequest.setRequestHeader("Connection", "close");
MyHttpRequest.send(query_string);

// handle the httprequest
MyHttpRequest.onreadystatechange = function()
	{
	if(MyHttpRequest.readyState == 4) // done and responded
		{
   		if (MyHttpRequest.status == 200)
   		{
     		 document.getElementById(target_div).innerHTML = MyHttpRequest.responseText; // display result
   		}
		}
	}
}// if browser supports httprequest closed
}//function closed


