function	ajaxRequest()
{
	this.Send	= send;
}
//////////////////////////////////////////////////////////////////////////////////////////////
// Create ajax request object.
//////////////////////////////////////////////////////////////////////////////////////////////

function createRequest()
{
	 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
	 
	 if (window.ActiveXObject)
	 { //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
		  for (var i=0; i<activexmodes.length; i++)
		  {
			   try
			   {
				return new ActiveXObject(activexmodes[i])
			   }
			   catch(e)
			   {
				//suppress error
			   }
		  }
	 }
	 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
	  return new XMLHttpRequest()
	 else
	  return false
}
//////////////////////////////////////////////////////////////////////////////////////////////
// Send ajax requests.
//////////////////////////////////////////////////////////////////////////////////////////////	

function send( url, divID )
{
	var request	= new createRequest();
	// Set up a function for the server to run when it's done
	request.onreadystatechange=function()
	{
		 if (request.readyState==4)
		 {		
				var	divToChange		= document.getElementById( divID );
				
				if( request.responseText == "" )
				{
					//	We have reached the end/ start of all the products.
					return;
				}
				else
				{
					divToChange.innerHTML	= request.responseText;
				}
		 }
	}
	
  // Open a connection to the server
  request.open("POST", url, true);

  // Set up a function for the server to run when it's done

  // Send the request
  request.send("");
  
}

function	setCurrentPage()
{
	var page		= document.getElementById( "pagingbotpart" );
	
	if( page == null )
		return;
		
	page.innerHTML =  "1";
}
//////////////////////////////////////////////////////////////////////////////////////////////

function	showNext( showType )	// 1 - rely, 2 ebivet, 3 pantex
{
	 var hiddenID		= document.getElementById( "hiddenID" ).value;
	 
	 var	lreq	= new ajaxRequest();
	 if( showType == 1  )
		lreq.Send( "show-rely.php?next=1&relyID=" + hiddenID, "midDetail" );
	if( showType == 2 )
		lreq.Send( "show-ebivet.php?next=1&ebivetID=" + hiddenID, "midDetail" );
	if( showType == 3 )
		lreq.Send( "show-pantex.php?next=1&pantexID=" + hiddenID, "midDetail" );
}
//////////////////////////////////////////////////////////////////////////////////////////////

function	showPrev( showType )	// 1 - rely, 2 ebivet, 3 pantex
{
	 var hiddenID		= document.getElementById( "hiddenID" ).value;
	 
	 var	lreq	= new ajaxRequest();
	 if( showType == 1 )
		lreq.Send( "show-rely.php?next=0&relyID=" + hiddenID, "midDetail" );
	if( showType == 2 )
		lreq.Send( "show-ebivet.php?next=0&ebivetID=" + hiddenID, "midDetail" );
	if( showType == 3 )
		lreq.Send( "show-pantex.php?next=0&pantexID=" + hiddenID, "midDetail" );
}
//////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////
// Details zoom image.
//////////////////////////////////////////////////////////////////////////////////////////////

{
	PositionX = 100;
	PositionY = 100;
	
	
	defaultWidth  = 500;
	defaultHeight = 500;
	var AutoClose = true;
	
	if (parseInt(navigator.appVersion.charAt(0))>=4){
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
	var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
	function popImage(imageURL,imageTitle){
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	with (imgWin.document){
	writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
	writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
	writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
	writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
	writeln('width=300-(document.body.clientWidth-document.images[0].width);');
	writeln('height=300-(document.body.clientHeight-document.images[0].height);');
	writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
	writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
	writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
	if (!AutoClose) writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
	else writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
	writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
	close();		
	}}
}

//////////////////////////////////////////////////////////////////////////////////////////////
// Show pop-up.
//////////////////////////////////////////////////////////////////////////////////////////////

function	showMessageBox()
{
	document.getElementById ('ModalPopup').style.visibility			= 'visible';
	document.getElementById ('ModalPopup').style.display			= '';
	document.getElementById ('ModalPopup').style.top				= (document.documentElement.clientHeight - 200 ) / 2 + "px";
	document.getElementById ('ModalPopup').style.left				= (document.documentElement.clientWidth - 400 ) / 2+ "px";
		
	document.getElementById ('TransparentBackgr').style.display		= '';
	document.getElementById ('TransparentBackgr').style.visibility	= 'visible';
	document.getElementById ('TransparentBackgr').style.top			= '0px';
	document.getElementById ('TransparentBackgr').style.left		= '0px';
	document.getElementById ('TransparentBackgr').style.opacity		= 0.7;
	document.getElementById ('TransparentBackgr').style.filter		= 'alpha(opacity = 70)';
	document.getElementById ('TransparentBackgr').style.width		= document.body.clientWidth + 'px';
	document.getElementById ('TransparentBackgr').style.height		= document.body.clientHeight+ 'px';
}

//////////////////////////////////////////////////////////////////////////////////////////////
// Close opened pop-up.
//////////////////////////////////////////////////////////////////////////////////////////////

function	onCancel()
{
	/*var inputs		= window.document.getElementsByTagName('input');

	for( var i=0; i < inputs.length; i++ ) //iterate through all input elements
	{
		if (inputs[i].type.toLowerCase() == 'checkbox') //if the element is a checkbox
		{ 
			inputs[i].checked = false;
		}
	}*/
	
	document.getElementById ('TransparentBackgr').style.display		='none';
    document.getElementById ('ModalPopup').style.display			='none';
    document.getElementById ('ConfirmAddress').style.display		='none';
	
}
//////////////////////////////////////////////////////////////////////////////////////////////
// Show pop-up.
//////////////////////////////////////////////////////////////////////////////////////////////

function	confirmAddress()
{
	document.getElementById ('ModalPopupMessageAddress').style.visibility		= 'visible';
	document.getElementById ('error').style.display								= 'none';
	document.getElementById ('ChangeAddressFrm').style.display					= 'none';
	
	document.getElementById ('ConfirmAddress').style.visibility			= 'visible';
	document.getElementById ('ConfirmAddress').style.display			= '';
	document.getElementById ('ConfirmAddress').style.top				= (document.documentElement.clientHeight - 200 ) / 2 + "px";
	document.getElementById ('ConfirmAddress').style.left				= (document.documentElement.clientWidth - 400 ) / 2+ "px";
		
	document.getElementById ('TransparentBackgr').style.display		= '';
	document.getElementById ('TransparentBackgr').style.visibility	= 'visible';
	document.getElementById ('TransparentBackgr').style.top			= '0px';
	document.getElementById ('TransparentBackgr').style.left		= '0px';
	document.getElementById ('TransparentBackgr').style.opacity		= 0.7;
	document.getElementById ('TransparentBackgr').style.filter		= 'alpha(opacity = 70)';
	document.getElementById ('TransparentBackgr').style.width		= document.body.clientWidth + 'px';
	document.getElementById ('TransparentBackgr').style.height		= document.body.clientHeight+ 'px';
}
//////////////////////////////////////////////////////////////////////////////////////////////
// Change address form.
//////////////////////////////////////////////////////////////////////////////////////////////

function	changeAddress()
{
	document.getElementById ('ModalPopupMessageAddress').style.visibility		= 'hidden';
	document.getElementById ('ChangeAddressFrm').style.display					= 'block';
}

