function Offer (parent, imgSrc, printId, couponValue, urlLink, thumbWidth, thumbHeight,ClientName,FileName,imgSrcMO){ //class
	//alert("CreateOffer "+printId+ " CouponValue "+couponValue+" ClientName "+ClientName)
	var _parent=parent;
	var _imgSrc=imgSrc;
	var _imgSrcMO=imgSrcMO;
	var _printId=printId;
	var _billPos;
	var _displayPos;
	var _isShowing = false;
	var _couponValue=couponValue;
	var _thumbWidth=thumbWidth?thumbWidth:130;
	var _thumbHeight=thumbHeight?thumbHeight:80;
	var _url = urlLink?urlLink:"";
	var _clickable = urlLink?true:false;
	var _loadingGraphic="img/ad/loading.jpg";
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	this.Select = function(){

	//alert("CreateOffer "+printId+ " CouponValue "+couponValue+" ClientName "+ClientName) // SELECTED ADS
		ajaxadscount();
		AjaxAdsTrack(1,printId);
		_parent.SelectOffer(this);
		if (returnDocumentName()=="MyOffers.asp" || returnDocumentName()=="MyOffers.asp#" || returnDocumentName()== "MemOrderViewAlbum.asp"){
			location.reload(true);
			}
	
	}	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.Visit = function(){
		var visUrl = _url
		ajaxadscount();
		AjaxAdsTrack(1,printId);
		if (!_url.match("http://")) visUrl="http://"+visUrl;
		window.open(visUrl, 'AdSite');
		//this.Select ()
	
	}
	//-------------------------------------------------------------AJAX ADS COUNT ------------------------------------------------------------------------------------------
	function ajaxadscount()
  {
	var xmlHttp;
	var url="../AJAXSVC/AdsCount.asp?AdsID="+_printId;
	try
    {    
	xmlHttp=new XMLHttpRequest();    
	}
  catch (e)
    {   
	// Internet Explorer   
		try
     {      
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	}
    catch (e)
    {      
	  try
        {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
		}
      catch (e)
        { 
		alert("Your browser does not support AJAX!");
        return false;        
		}      
	}    
	}
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
       //alert(xmlHttp.responseText)
	    }
      }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);  
}
	//---------------------------------------------------------------------------------------------------------------------------------
	
//---------------------------------------------------------------------------------------------------------------------------------
	
	this.SetClickable = function(url){
		_url = url;
		_clickable = true;
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.IsClickable = function(){
		return _clickable;
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.Refresh = function(){
		_parent.RefreshAd(this, 'refresh');
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.IsShowing = function(){
		return _isShowing;
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.SetShowing = function(state){
		//alert("CreateOffer "+printId+ " CouponValue "+couponValue+" ClientName "+ClientName)//  SHOWING ADS
		_isShowing=state;
		
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.toString=function(){ 
		//returnstring="Img Src: "+_imgSrc+"<br/>";
		returnstring="Print ID: "+_printId;//+"<br/>";
		//returnstring+="Coupon Value: $"+_couponValue+"<br/>";
		return _printId;
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	// ---------------------------------------------------------------- Get/Set Functions -------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.SetThumbDimensions = function(width, height){
		_thumbWidth=width;
		_thumbHeight=height;
	}
		
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.GetThumbDimensions = function(){
		return [_thumbWidth, _thumbHeight];
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.GetImgSrc = function(){
		return _imgSrc;
	}
	this.GetImgSrcMO =function(){
		return _imgSrcMO;
	}
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.GetPrintId = function(){
		return _printId;
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.GetCouponValue = function(){
		return _couponValue;
	}
		
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------Billboard Position---------------------------------------------------------------------
	
	this.SetBillboardPos = function(billPos){
		_billPos=billPos;
	}
		
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.GetBillboardPos = function(){
		return _billPos;
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------Display Position----------------------------------------------------------------------
	
	this.SetDisplayPos = function(displayPos){
		_displayPos=displayPos;
	}
		
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	
	this.GetDisplayPos = function(){
		return _displayPos;
	}
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------

	
//------------------------------------------------------------------------------------------------------------------------------------------------------
	
}

function AjaxAdsTrack(EventType,printId){
	//alert(printId)
//1	Click-Select
//2 View - Show
//3 MouseOver - In PopUp
//alert(EventType)

var xmlHttp;
	var url="../AJAXSVC/AdTrack.asp?AID="+printId+"&EID="+EventType+"&P="+returnDocumentName();
	try
    {    
	xmlHttp=new XMLHttpRequest();    
	}
  catch (e)
    {   
	// Internet Explorer   
		try
     {      
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	}
    catch (e)
    {      
	  try
        {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
		}
      catch (e)
        { 
		alert("Your browser does not support AJAX!");
        return false;        
		}      
	}    
	}
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
       //alert(xmlHttp.responseText)
	    }
      }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);  
}