var maxHeight = 0;
var currentHeight = 0;
var popupLayer;
var rep;
var t_uri = "http://awmpartners.com/dispatch?p_aid=" + popup_p_aid + "&svc=" + popup_svc + "&target=" + popup_uri_target + ":/";
var imgSrc = "http://static01.awmpartners.com/static/promo/popup/qip/";
function showPopup(height, width, inner) {
	layer = document.createElement("div");
	layer.setAttribute('id', "popup");
	document.body.appendChild(layer);
	
	popupLayer = layer;
	layer.style.top = "100%"
	layer.style.left = "100%";
	layer.style.position = "fixed";
	layer.style.border = "2px solid #76a34e"; 
	layer.innerHTML = inner;
	layer.onclick = function(e) {
		window.location = t_uri;		
	}
	
	layer.onmouseover = function(e) {
		layer.style.cursor = "pointer";
	}
	
	layer.style.height = height;
	layer.style.width = width;
	layer.style.margin =  "0px 0px 0px -" + width + "px";
	maxHeight = -height;
	rep = setInterval("movePopup()", 11);

}

function movePopup() {
	if(currentHeight-- < maxHeight) {
		try {
			rep = clearInterval(rep);
			rep = null;
			setTimeout("rep = setInterval('removePopup()', 11);", 10000);
		} catch(e) {}
		return;
	}
	
	popupLayer.style.marginTop = currentHeight + "px";
}

function removePopup() {
	if(currentHeight++ > 0){
		rep = clearInterval(rep);
		rep = null;
		el = document.getElementById("popup");
		if(el != undefined && el != null) {
			try {
				setTimeout("destroyLayer()", 1000);
			} catch(e) {}
		}
	}
	popupLayer.style.marginTop = currentHeight + "px";
}

function destroyLayer() {
	el.style.display = "none";
	document.body.removeChild(el);

}

function showqip() {
	var page = "";
	contentImg = new Image();
	contentImg.onload = function() {
		page = "<div style='top: 2px; width: 170px; height: 16px; padding: 0px; background:url(" + imgSrc + "images/top_03.png);'><a href='#' style='margin-left:30px'></a></div>";
		page += "<div style='width: 170px; height: 135px; padding: 0px; margin: 0px; background:url(" + contentImg.src +")'></div>";
		showPopup(151, 170, page);	
	}
	
	contentImg.onerror = function() {
		contentImg.src = imgSrc  + "images/" + popup_uri_target + "_" + popup_version + ".gif";	
	}
	
	contentImg.src = imgSrc  + "images/" + popup_uri_target + "_" + popup_version + ".jpg";	
	
}

setTimeout("showqip()", 1000);
