// JavaScript Document

//hide safari address bar
var pix = 0;
var t;
function hideAddress() {
	window.scrollBy(0,1);
	pix++;
	if (pix < 6) {
    	t = setTimeout(hideAddress, 100);
	} else {
		clearTimeout(t);	
	}
}

//send share with friends email
function share(name, url) {
	if (confirm("Would you like to share this Web App with your friends?")) {
		var tmp = "mailto:?subject="+encodeURI("New iPhone Web App recommended from your friend!");
		tmp = tmp+"&body="+encodeURI(name+"<br>>> <a href='http://www.biocourseware.com/iphone/"+url+"'>Look at it now</a>");	
		window.location.href = tmp;
	}
}

//send visit page data
var xmlHttp_log; //get xmlHTTP object

function GetXmlHttpObject() {
	var xmlHttp_log = null;
	try	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp_log = new XMLHttpRequest();
	} catch (e)	{
		//Internet Explorer
		try	{
			xmlHttp_log = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)	{
		  xmlHttp_log = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp_log;
}

function addLog(app) {
	xmlHttp_log = GetXmlHttpObject();
	if (xmlHttp_log == null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url = "../_php/visit_log.php?app="+app;
	
	xmlHttp_log.open("GET",url,true);
	xmlHttp_log.send(null);
}
