﻿
// JScript File
//==============================================
//This file will contain the javascript and AJAX code needed to:
//  --> Display ads 
//  --> Collect the information when the page is viewed
//  --> Collect the information when the ad is clicked
//  --> Call a DB routine to register the collected information into the database
//==============================================

/* Declarations and Initialisations */
/* This class will contain the list of variables which will be used to collect and hold the necessary information */
var AdInfo =
 {
     HitIP: null,                         /* The ID of the box which will show the filter */
     /* Members to be set with the passed values from the Ad Generation Script */
     betURL: null,                        /* The path to the .aspx page which is used to accept the AJAX call */
     betChannelID: null,                 /* The ID of the channel */
     betAdUnitID: null,                  /* The ID of the ad display unit ( table with single text ads) */
     /* Members to be set when user clicks on any ad (onClick event of the ad link */
     AdGroupID: 0,                        /* The ID of the Ad Group */
     ImpressionRecordID: 0,               /* the ID of the record in the Click table, created when a user viewed the page */
     betAdUnitHeight: 0,                /* the height to form an iframe holding the text ads */
     betAdUnitWidth: 0                 /* the width to form an iframe holding the text ads */


 };
var xmlHttp;
var iFrameSrc;

/* Call a function to get the details for all the ads */
GetInfoFromScript();

/* Put a Div element on the client's file in order to display the ads there */
//document.write("<div id='divBetooAds'></div>"); //See if in the FireFox this works??
document.write("<iframe src='" + iFrameSrc + "' frameborder=0  height='" + AdInfo.betAdUnitHeight + "px' +  width='" + AdInfo.betAdUnitWidth + "px' noresize marginwidth='0' marginheight='0' scrolling='no'></iframe>");

/*=========================================================*/
/*                   FUNCTIONS                             */
/*=========================================================*/

/* ---------------------------------------
Name:  GetInfoFromScript
Goal:  To set the class members to the current values and start Ajax functionality
----------------------------------------
*/
function GetInfoFromScript() 
{
    
    /* Assign the class members with the passed values */
    AdInfo.betChannelID = bettooChannelID;
    AdInfo.betAdUnitID =  bettooAdUnitID;
    AdInfo.betURL = bettooURL;
    AdInfo.betAdUnitHeight = bettooAdUnitHeight;
    AdInfo.betAdUnitWidth = bettooAdUnitWidth;
    //alert(AdInfo.betAdUnitHeight);
    //alert(AdInfo.betAdUnitWidth);
     
    /* Form the URL to server as Iframe src property */
    iFrameSrc = AdInfo.betURL + "/DisplayAds.aspx";
    iFrameSrc = iFrameSrc + "?cID=" + AdInfo.betChannelID + "&adUnitID=" + AdInfo.betAdUnitID + "&HitIP=" + AdInfo.HitIP + "&type=1";


}
/* ===============================================*/

