//these are the array elements to call for results.
//feed.links[0].redir
//feed.links[0].url
//feed.links[0].logopath
//feed.links[0].description.substring(0,180)
//feed.links[0].title.substring(0,180)

// constant variable to define the PCMS code to call.
var contID = 'banner01'; //look at
var affiliateID = 621;
var bannerurl = '468x60-barclays-hipoteca.gif';

var country = 'es';
var debug = 0;

//var theip = new java.net.InetAddress.getLocalHost();
//var theipStr = new java.lang.String(theip);
//var hostIpAddress = (theipStr.substring(theipStr.indexOf("/")+1));

var hostIpAddress = '';

var referralUrl = window.location.href;

// this function call a refresh of the 2 contentCodes and call the display on both boxes to be refreshed
function changeBoxesContent() {

   var headID = document.getElementsByTagName("head")[0]; 
   var newScript1 = document.createElement('script');
   newScript1.type = 'text/javascript';
   newScript1.src = 'http://search.' + country + '.miva.com/search/content/implementations/Results.asp?hits=1&contentidentifier=' + contID + '&affiliateid=' + affiliateID +'&host=' + hostIpAddress + '&referralUrl=' + referralUrl + '&resulttype=objectFeed';
   headID.appendChild(newScript1);
   return true;
}



// this function defines the display of the box
function mivaFeed (feed) {
    //alert (feed.hits);
    var	htmlString = '';


    for (x=0; x < feed.hits; x++) {


			htmlString += '<a href="' + feed.links[x].redir + '" onmouseover="self.status=\''+ feed.links[x].url +'\'" onmouseout="self.status=\'\';return true" target="_blank" class="textoazulon">' + '\n';
			htmlString += '¿Quieres Ganar Dinero con Tu Hipoteca?Comisión apertura y cancelación parcial 0€. Y, además, disfruta de los intereses en tu cuenta corriente.Te contamos como...' + '\n';
			htmlString += '</a>' + '\n';
    }
    // assign html code to the relevant box
    document.getElementById('mivaBox1').innerHTML=htmlString;

    //alert ('mivaFeed executed');    

}



// <!-- this is the MIVA box html code -->

//<!-- debugg -->
if (debug == 1){
document.write('hits = ' + hits + '<br/>');
document.write('contID = ' + contID + '<br/>');
document.write('affiliateID = ' + affiliateID + '<br/>');
document.write('referralUrl = ' + referralUrl + '<br/>');
document.write('hostIpAddress = ' + hostIpAddress + '<br/>');
}
// <!-- change here the css -->


document.write('<div name="mivaBox1" id="mivaBox1"></div>');



// first command to display the default codes
changeBoxesContent();
