// Vignette Generated Content Marker - DO NOT REMOVE
// stores reference to XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject();
	
//Retrieves XMLHttpRequest object
function createXmlHttpRequestObject() {
	//will store the reference to the XMLHttpRequest object
	var xmlHttp;
	//if running Internet Explorer
	if(window.ActiveXObject) {
       try {
           xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
       }
		catch (e) {
		xmlHttp = false;
		}
	} else {
		// if running Mozilla or other
		try {
			xmlHttp = new XMLHttpRequest();
		}
		catch (e) {
			xmlHttp = false;
		}
	}
	//return the created object or display an error message
	if (!xmlHttp) {
		alert("Error here");
	} else {
		return xmlHttp;
	}
}
	
//Make asynchronous HTTP request using the XMLHttpRequest object
function comment(id) {
	//proceed only if xmlHttp object isn't busy
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
		xmlHttp.open("GET", "http://www.ivillage.co.uk/articlecomments.xml?view=yes&id=" + id, true);
		//define the method to handle server responses
		xmlHttp.onreadystatechange = handleServerResponse;
		//make the server request
		xmlHttp.send(null);
	} else {
		//if the connection is busy try again after 1 second
		setTimeout('comment(id)', 1000);
	}
}
	
//executed automatically when a message is received from the server
function handleServerResponse() {
	//move forward only if transaction has completed
	if (xmlHttp.readyState == 4) {
		//status of 200 indicates the transaction completed successfully
		if (xmlHttp.status == 200) {
			//extract the XML received from the server
			xmlResponse = xmlHttp.responseXML;
			//obtain the document element (the root element) of the XML structure
			xmlDocumentElement = xmlResponse.documentElement;
			postDateArray = xmlDocumentElement.getElementsByTagName("post_date");
			posterArray = xmlDocumentElement.getElementsByTagName("poster");
			postArray = xmlDocumentElement.getElementsByTagName("post");
	
			var html = "<a href=\"javascript:hide('divMessage')\">Hide comments</a><br /><br />";
			//iterate through arrays to create html structure
			for (var i=0; i<postArray.length; i++) {
				html += "<span style=\"color:#204Da8;font-family:12px;\">" + postArray.item(i).firstChild.data + "</span><br /> <span style=\"font-family:verdana;font-weight:bold;font-size:10px;float:right;color:#204Da8;\">" + posterArray.item(i).firstChild.data + "&nbsp;&nbsp;" + postDateArray.item(i).firstChild.data + "</span><br /><br />";
			}
			//update the client display with data received from the server
			var divMessage = document.getElementById("divMessage");
			divMessage.innerHTML = html;
			document.getElementById('divMessage').style.display = 'block';
			//restart sequence
			//setTimeout('vote()',1000)
		} else {
			//a http status different that 200 signals an error
			alert("problem: " + xmlHttp.statusText);
		}
	}
}

function hide(divid) {
	document.getElementById(divid).style.display = 'none';
	//divid.style.display = 'none';	
}

function GoToAuth () {
  var baseLocation = "http://auth.ivillage.co.uk/login/login?s=uk&dt=rurlc&dd=";
  var currentLocation = document.location.toString();
  currentLocation = currentLocation.split("?");
  document.location.href = baseLocation + currentLocation[0];
}

function GoToJoin () {
  var baseLocation = "http://auth.ivillage.co.uk/uk/registrationPage1?destinationData=";
  var currentLocation = document.location.toString();
  currentLocation = currentLocation.split("?");
  document.location.href = baseLocation + authQuery + currentLocation[0];
}

function GoToProfile (pAction) {
  var baseLocation = "http://messageboards.ivillage.co.uk/dir-app/bbcard/profile.asp?webtag=iv-ukrldating"
  var memberName = "&cName=" + GetCookie("iv_id");
  document.location.href = baseLocation  + memberName;
}
