// constant variable to define the PCMS code to call.REVISTAMAN
var contID = '';

var affiliateID = 1853;
var hits = 3;
var country = 'es';
var debug = 0;

//Randomize CID's
function RandomContentID() {
var Contentlist = new Array('chicas','serMan','personajes','bienestar','manselecciona','moda','galerias','esteMes','calendarioman');
						triger = Math.ceil(Contentlist.length*Math.random())-1;
						return Contentlist[triger]
}

var hostIpAddress = '';

var referralUrl = window.location.href;


function changeBoxesContent() {

  contID = RandomContentID();

   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);
   
}



function mivaFeed (feed) {
    //alert (feed.hits);
    var	htmlString = '';

htmlString += '<table class="Maddoutbox">' + '\n';


    for (x=0; x < feed.hits; x++) {
    	htmlString += '<tr valign="top" align="left">' + '\n';
		htmlString += '<td class="Maddbox">' + '\n';
			htmlString += '<a class="Maddlnk" href="' + feed.links[x].redir + '" onmouseover="self.status=\''+ feed.links[x].url +'\'" onmouseout="self.status=\'\';return true" target="_blank">' + '\n';
//				htmlString += '<img class="Maddimg" src="' + feed.links[x].logopath + '" border="0" /><br/>' + '\n';
				htmlString += '<span class="Maddtitle">' + feed.links[x].title + '</span>' + '\n';
		htmlString += '</a>' + '\n';
	
			htmlString += '<a class="Maddlnk" href="' + feed.links[x].redir + '" onmouseover="self.status=\''+ feed.links[x].url +'\';return true" onmouseout="self.status=\'\';return true" target="_blank"><br/>' + '\n';
				htmlString += '<span class="Madddesc">' + feed.links[x].description.substring(0,80) + '...</span><br/>' + '\n';
		htmlString += '<span class="Maddurl">' + feed.links[x].url.substring(11,41)+ '</span>' + '\n'; 
			htmlString += '</a>' + '\n';
		htmlString += '<td>' + '\n';
			htmlString += '</tr>' + '\n';
    }
    

htmlString += '</table>' + '\n';


    // assign html code to the relevant box
    document.getElementById('mivaBox1').innerHTML=htmlString;


}

// <!-- this is the MIVA box html code -->
// <!-- change here the css -->


document.write('<table border="0" cellpadding="0" cellspacing="0" height="30" class="MaddHeader">');
document.write('<tr>');
document.write('<td colspan="2" valign="top">');
document.write('<div class="MivaBOXtitle">');
document.write('PATROCINADOS');
document.write('</div>');
document.write('</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td colspan="2">');

document.write('<table border="0" cellpadding="0" cellspacing="0">');
document.write('<tr>');
document.write('<td valign="top">');
document.write('<div name="mivaBox1" id="mivaBox1"></div>');
document.write('</td>');
document.write('</tr>');
document.write('</table>');

document.write('</td>');
document.write('</tr>');
document.write('</table>');


// <!-- 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('<link rel="stylesheet" type="text/css" href="/css/MAN/miva.css"/>');


// first command to display the default codes
changeBoxesContent();
