function AjaxRequest()
{
	this.mRequest = this.getHttpRequest();
	this.mHandlers = new Array();
	var self = this;
	
	this.mRequest.onreadystatechange = function()
	{
		if(	self.mHandlers[ self.mRequest.readyState ] != undefined )
		{
			for( i = 0 ; i < self.mHandlers[ self.mRequest.readyState ].length ; i++ )
			{
				self.mHandlers[ self.mRequest.readyState ][ i ]( self );				
			}
		}
	}
}

AjaxRequest.prototype.addEventListener = function( pEventType, pFunction )
{
	if(	this.mHandlers[ pEventType ] == undefined )
	{
		this.mHandlers[ pEventType ] = new Array();
	}
	
	this.mHandlers[ pEventType ].push( pFunction );
}

AjaxRequest.prototype.getHttpRequest = function()
{
	// List of Microsoft XMLHTTP versions - newest first

	var MSXML_XMLHTTP_PROGIDS = new Array
	(
		'MSXML2.XMLHTTP.5.0',
		'MSXML2.XMLHTTP.4.0',
		'MSXML2.XMLHTTP.3.0',
		'MSXML2.XMLHTTP',
		'Microsoft.XMLHTTP'
	);

	// Do we support the request natively (eg, Mozilla, Opera, Safari, Konqueror)

	if( window.XMLHttpRequest != null )
	{
		return new XMLHttpRequest();
	}
	else
	{
		// Look for a supported IE version

		for( i = 0 ; MSXML_XMLHTTP_PROGIDS.length > i ; i++ )
		{
			try
			{
				return new ActiveXObject( MSXML_XMLHTTP_PROGIDS[ i ] );
			}
			catch( e )
			{
			}
		}
	}
	
	return( null );
}

function PremiumPressDo( fileName, div )
{
	var Ajax = new AjaxRequest();

	if( Ajax.mRequest )
	{				
		Ajax.mFileName 	= fileName;		
		var obj = document.getElementById(div);				

		Ajax.mRequest.open( "GET", fileName);
		Ajax.mRequest.onreadystatechange = function() {
			if(Ajax.mRequest.readyState == 4 && Ajax.mRequest.status == 200){
				obj.innerHTML = Ajax.mRequest.responseText;
			}
		}		
	}
	Ajax.mRequest.send( null );
}



function add_image_next(current,path,ilink,type){
	 
var searchword = document.getElementById('searchBox1').value;
var a =ilink;
a=a.split("http://").join("");
PremiumPressDo('../wp-content/themes/directorypress/PPT/ajax/actions.php?action=add_image_next&p='+current+'&path='+path+'&link='+a+'&type='+type+'&search='+searchword,'DisplayImages');
	
}

function PremiumPressChangeState(current){
 
PremiumPressDo('../wp-content/themes/directorypress/PPT/ajax/actions.php?action=changestate&current='+current,'PremiumPressState');
	
}

function CatPriceBox(current){
 
PremiumPressDo('../wp-content/themes/directorypress/PPT/ajax/actions.php?action=catprice&current='+current,'PPT-catpricebox');
	
}

function CatTextBox(current){
 
PremiumPressDo('../wp-content/themes/directorypress/PPT/ajax/actions.php?action=cattext&current='+current,'PPT-cattext');
	
}

function UpdateSliderItem(){ 

	var eid = document.getElementById('ppsedit').value;
	var s1 = document.getElementById('pps1').value;
	var s2 = document.getElementById('pps2').value;
	var s3 = document.getElementById('pps3').value;
	var s4 = document.getElementById('pps4').value;
	var s5 = document.getElementById('pps5').value;
	var s6 = document.getElementById('pps6').value;
	
	PremiumPressDo('../wp-content/themes/directorypress/PPT/ajax/actions.php?action=updateSlider&s1='+s1+'&s2='+s2+'&s3='+s3+'&s4='+s4+'&s5='+s5+'&s6='+s6+'&eid='+eid,'PPT-sliderbox');

}	

function DeleteSliderItem(thisone){
	 
	PremiumPressDo('../wp-content/themes/directorypress/PPT/ajax/actions.php?action=deleteSlider&eid='+thisone,'PPT-sliderbox');
		
}

function EditsliderItem(thisone){
	
	PremiumPressDo('../wp-content/themes/directorypress/PPT/ajax/actions.php?action=editSlider&eid='+thisone,'PPT-sliderbox');
	
	
}

function addiCodes(catid, title, desc, url, code, s5,s6,s7,status,img){


	PremiumPressDo('../wp-content/themes/directorypress/PPT/ajax/actions.php?action=icodes&type='+s7+'&catid='+catid+'&title='+title+'&desc='+desc+'&url='+url+'&code='+code+'&exp='+s5+'&mer='+s6+'&st='+status+'&img='+img,'ShopperPressAlert');
}


function icodesList(a1){

	PremiumPressDo('../wp-content/themes/directorypress/PPT/ajax/actions.php?action=icodesList&type='+a1,'icodesList');
}
