var contID = ''; //look at ln. 24
var affiliateID = 1483;
var hits = 3;
var country = 'it';
var debug = 0;


var hostIpAddress = '';

var referralUrl = window.location.href;

//random ContentID
function randomContent() {
	var Contentlist = new Array("BEEGLERADULT");
	var triger = Math.ceil(Contentlist.length*Math.random())-1;
	contID = Contentlist[triger];
}


function changeBoxesContent() {
   randomContent();
   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=' + hits + '&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 = '';
	htmlString += '<div class="Maddheader"><img src="http://pics.adooscore.com/web/icons/icon_home.gif" border="0" />Annunci MIVA</div>' + '\n';
	htmlString += '<div class="Maddbox">' + '\n';

	    for (x=0; x < feed.hits; x++) {

			
			htmlString += '<div class="Maddcontainer"><a class="Maddtitle" 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 class="Madddesc" 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 class="Maddurl" 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 + '\n';
		    htmlString += '</a><br/></div>' + '\n';
		
 	   }
	htmlString += '<div>' + '\n';

    document.getElementById('mivaBox1').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('<link rel="stylesheet" type="text/css" href="/miva/miva.css"/>');

document.write('<div name="mivaBox1" id="mivaBox1"></div>');




changeBoxesContent();
