

function showPopUp() {
/*
    var blanket = document.getElementById("blanket");
    blanket.style.display = "block";
    var popup = document.getElementById("popup");
    popup.style.display = "block";
    window_pos("popup");
    blanket_size("popup");
    */
   
    //var html = "<div id='blanket' style='display:none;'>";
    var html = "<div id='popup' class='popup' style='display:none;'>";
    html = html + "<fieldset>";
    html = html + "<legend class='style_a'><b>Write to the artist</b></legend>";
    html = html + "<form name='feedback'>";
    html = html + "<table class='style_a'>";
    html = html + "<tr><td>Name:</td><td>&nbsp;</td><td align='left' width='150px'><input type='text' id='name' /></td></tr>";
    html = html + "<tr><td>Email or Phone:</td><td>&nbsp;</td> <td align='left' width='150px'><input type='text' id='emailORphone' /></td></tr>";
    html = html + "<tr><td>Comments:</td><td>&nbsp;</td><td align='left' width='150px'><textarea id='comment' rows='5'></textarea></td></tr>";
    html = html + "<tr><td colspan='3' align='center'><br /><a href='#' onclick='handleSubmit();'><img src='images/submit.JPG' border='0'/></a>&nbsp;&nbsp;<a href='#' onclick='handleClose();'><img src='images/close.JPG' border='0' /></a></td></tr>";
    html = html + "</table></form></fieldset></div>";

    var old = document.getElementById("blanket");
    if (null != old) {
        document.body.removeChild(old);
    }
    var blanket = document.createElement("div");
    blanket.setAttribute("id", "blanket");
    blanket.setAttribute("style", "display:none");
    blanket.innerHTML = html;
    
    document.body.appendChild(blanket);
    //alert(document.body.innerHTML);
    
 
    var blanket = document.getElementById("blanket");
    blanket.style.display = "block";
    var popup = document.getElementById("popup");
    popup.style.display = "block";
    window_pos("popup");
    blanket_size("popup");
       
}
function handleClose() {

   var blanket = document.getElementById("blanket");
   blanket.style.display = "none";

   var popup = document.getElementById("popup");
   popup.style.display = "none";
   //document.body.removeChild(blanket);}

function handleSubmit() {
    //alert('your email has been submitted');
    var sXML = "<data>";
    sXML += "<subject>" + document.getElementById("name").value + "</subject>";
    sXML += "<emailorphone>" + document.getElementById("emailORphone").value + "</emailorphone>";
	sXML += "<comments>" + document.getElementById("comment").value + "</comments>"; 
	sXML += "</data>" ;
	
	//alert(sXML);
	
	var ua = navigator.userAgent.toLowerCase();
	if (!window.ActiveXObject)
		request = new XMLHttpRequest();
	else if (ua.indexOf('msie 5') == -1)
		request = new ActiveXObject("Msxml2.XMLHTTP");
	else
		request = new ActiveXObject("Microsoft.XMLHTTP");
	
	//request.onreadystatechange=function stateChanged()
	request.onreadystatechange=function() {
	if (request.readyState==4) {
	// alert(request.responseText)
	}
	}

	request.open("POST", "http://www.technicaltrack.com/services/email/vg.aspx");
	request.send(sXML);
	
	

	alert('your feedback has been submitted');
	handleClose();
}


function FlipDisplay(d1, d2) {
    if (document.getElementById(d1).style.display == "none") {
        document.getElementById(d1).style.display = "";
        document.getElementById(d2).style.display = "none";
    } else {
        document.getElementById(d1).style.display = "none";
        document.getElementById(d2).style.display = "";
    }
}


function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-150;//150 is half popup's height
	//alert(popUpDiv_height);
	/*
	if(popUpDiv_height > 400) {
	    popUpDiv_height = 310;
	}
	*/
	popUpDiv.style.top = popUpDiv_height + 'px';
	
	
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-150;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}

