var contID = ''; //look at ln. 24
var affiliateID = 1931;
var hits = 3;
var country = 'es';
var debug = 0;


var hostIpAddress = '';

var referralUrl = window.location.href;

//random ContentID
function randomContent() {
	var Contentlist = new Array(
  "Inicio",
  "Realbetis",
  "Sevilla",
  "Futbol",
  "FutbolSevillano",
  "Polideportivo",
  "ED",
  "Suscripciones",
  "Publicidad"
  );
	var triger = Math.ceil(Contentlist.length*Math.random())-1;
	contID = Contentlist[triger];
}


function changeBoxesContent2() {
   randomContent();
   var headID = document.getElementsByTagName("head")[0]; 
   var newScript2 = document.createElement('script');
   newScript2.type = 'text/javascript';
   newScript2.src = 'http://search.' + country + '.miva.com/search/content/implementations/Results.asp?hits=' + hits + '&contentidentifier=' + contID + '&affiliateid=' + affiliateID +'&host=' + hostIpAddress + '&referralUrl=' + referralUrl + '&resulttype=objectFeed2';
   headID.appendChild(newScript2);
   return true;
}

// this function defines the display of the box
function mivaFeed2 (feed) {
    //alert (feed.hits);
    var	htmlString = '';
	htmlString += '' + '\n';
	htmlString += '<div style="width:500px;color:#ccc;padding:1px;font-family:arial, verdana, tahoma;">' + '\n';

	    for (x=0; x < feed.hits; x++) {

			htmlString += '<div><a style="color:#00f;text-decoration:none;font-weight:bold;" href="' + feed.links[x].redir + '" onmouseover="self.status=\''+ feed.links[x].url +'\'" onmouseout="self.status=\'\';return true" target="_blank">' + '\n';
				htmlString += '<img src="' + feed.links[x].logopath + '" border="0" align="left"> \n';
		    htmlString += '</a>' + '\n';
			htmlString += '<a style="color:#00f;text-decoration:none;font-weight:bold;" href="' + feed.links[x].redir + '" onmouseover="self.status=\''+ feed.links[x].url +'\'" onmouseout="self.status=\'\';return true" target="_blank">' + '\n';
				htmlString +=  feed.links[x].title + '\n';
		    htmlString += '</a><br/>' + '\n';
			htmlString += '<a style="color:#666;text-decoration:none;font-size:11px;" href="' + feed.links[x].redir + '" onmouseover="self.status=\''+ feed.links[x].url +'\'" onmouseout="self.status=\'\';return true" target="_blank">' + '\n';
				htmlString +=  feed.links[x].description.substring(0,250) + '...' + '\n';
		    htmlString += '</a><br/>' + '\n';
			htmlString += '<a style="color:#c00;text-decoration:none;" href="' + feed.links[x].redir + '" onmouseover="self.status=\''+ feed.links[x].url +'\'" onmouseout="self.status=\'\';return true" target="_blank">' + '\n';
				htmlString +=  feed.links[x].url.substring(7,30) + '\n';
		    htmlString += '</a><br/><br/></div>' + '\n';
		
 	   }
	htmlString += '<div>' + '\n';

    document.getElementById('mivaBox2').innerHTML=htmlString;

}





//<!-- 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/>');
}

document.write('<div name="mivaBox2" id="mivaBox2"></div>');




changeBoxesContent2();

