var press;

function pressIn(div_id, content_id) {

  get_press(div_id, content_id);
  setOpacityPress( 0 );
  press = 1;
  document.getElementById("mypress").style.display = "block";
  document.getElementById("content").style.display = "none";
  
}

function popupIn(div_id, content_id) {
  document.getElementById("loading").style.display = "block";	
  get_content(div_id, content_id);
  setOpacity( 0 );
  press = 0;
  document.getElementById("mypopup").style.display = "block";
  document.getElementById("content").style.display = "none";
  
  //document.body.onscroll = myPopupRelocate;
  //window.onscroll = myPopupRelocate;
}
function setOpacity( value ) {
 document.getElementById("mypopup").style.opacity = value / 10;
 document.getElementById("mypopup").style.filter = 'alpha(opacity=' + value * 10 + ')';
}
function setOpacityPress( value ) {
 document.getElementById("mypress").style.opacity = value / 10;
 document.getElementById("mypress").style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup() {
 for( var i = 0 ; i <= 100 ; i++ )
   setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
}
function fadeInMyPress() {
 for( var i = 0 ; i <= 100 ; i++ )
   setTimeout( 'setOpacityPress(' + (i / 10) + ')' , 8 * i );
}

function popupOut() {
 for( var i = 0 ; i <= 100 ; i++ ) {
   setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
 }

 setTimeout('closeMyPopup()', 800 );
}
function pressOut() {
 for( var i = 0 ; i <= 100 ; i++ ) {
   setTimeout( 'setOpacityPress(' + (10 - i / 10) + ')' , 8 * i );
 }

 setTimeout('closeMyPress()', 800 );
}
function closeMyPopup() {
 document.getElementById("content").style.display = "block";
 document.getElementById("mypopup").style.display = "none";
}
function closeMyPress() {
 document.getElementById("content").style.display = "block";
 document.getElementById("mypress").style.display = "none";
}

function get_press(div_id, content_id)
{
	subject_id = div_id;
	content1 = content_id;
	
	http.open("GET", "../press/info.php?img=" + escape(content1), true);
	
	http.onreadystatechange = handleHttpResponse2;
	http.send(null)

}

function get_content(div_id, content_id)
{
	subject_id = div_id;
	content1 = content_id;
	
	http.open("GET", "../products/info.php?sid=" + escape(content1), true);
	
	http.onreadystatechange = handleHttpResponse2;
	http.send(null)

}
subject_id = '';

function handleHttpResponse2() {
	if (http.readyState == 4) {
		if (subject_id != '') {
			document.getElementById(subject_id).innerHTML = http.responseText;
			if(press == 0){
				fadeInMyPopup();
				document.getElementById("loading").style.display = "none";	
			}else{
				fadeInMyPress();
			}
		}
	}
}
function getHTTPObject2() {
var request_type;
var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
return request_type;
}
var http = getHTTPObject2();