/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

BSCaptionCart = "Te recomendamos los siguientes productos para completar tu compra";
BSCaptionProduct = "Recomendados para tí";

BSdiv = "BSDivContainer";

BSModifyDescription = function( name ) {
    var toReturn = name;
    if( name.length > 40 )
       toReturn = name.substring( 0, 40 ) + "...";


   return toReturn;

}

function BSAlrededorDelVinoCart( json ) {

    BSAlrededorDelVino( json, BSCaptionCart );

}

function BSAlrededorDelVinoProduct( json ) {

    BSAlrededorDelVino( json, BSCaptionProduct );

}

function BSAlrededorDelVino( json, caption ) {

    json = json.data;

    if( json.count > 0 ) {
		var html = "";
        //html += "<h3>" + caption + "<span style='float:right'><img src=''><a href='http://www.brainsins.com' title='BrainSINS: Recomendaciones de Productos' target='_blank'><img height='15px' border='0' src='http://static.brainsins.com/brainsins.png' style='vertical-align: top'></a></span></h3>";
		
        html = "<div id='productGroupContainer'>";

        for( var i = 0; i < json.count; i++ ) {

            html += "<a class='productGroup' href='" + json.list[i].url + "' onClick='BrainSINSTracker.clickId(\"" + json.list[i].url + "\", \"" + json.list[i].id + "\"); return false;'>";
            html += "<span class='borderTop'></span>";
			html += "<span class='image'>";
            html += "<img border='0' width='130px' height='140px' alt='" + json.list[i].name + "' src='" + json.list[i].imageUrl + "' />";
			html += "</span>";
            html += "<span class='groupTitle'>" + json.list[i].name + "</span>";
            html += BSModifyDescription( json.list[i].description ) + "<br>";
           

            html += "<span class='price'>" + json.list[i].price + "€</span>";
            html += "<span class='productGroupButton'>Comprar</span>";
            html += "<span class='borderBottom'></span>";
            html += "</a>";
        }

        html += "</div>";
		html += "<div><a href='http://www.brainsins.com' title='BrainSINS: Recomendaciones de Productos' target='_blank'><img height='15px' border='0' src='http://static.brainsins.com/brainsins.png' style='vertical-align: top; margin:5px 0 0 5px'></a></div>";


    }

    document.getElementById( BSdiv ).innerHTML = html;

}




function BSAlrededorDelVinoHome( json ) {

    json = json.data;

    if( json.count > 0 ) {

        var html = "<div class='landingContainer'>";
        html += "<a href='#' id='landingLeftArrowLeft_5' class='landingLeftArrowDead' onclick='return moveLandingSection(5, -1)'></a>";
        html += "<a href='#' id='landingLeftArrowRight_5' class='landingRightArrow' onclick='return moveLandingSection(5, 1)'></a>";
        html += "<div class='landingContainerInner'><div class='landingContainerScroll' id='lc_5'>";



        for( var i = 0; i < json.count; i++ ) {

            html += "<a class='productGroup' href='" + json.list[i].url + "' >";
            html += "<span class='borderTop'></span>";
			html += "<span class='image'>";
            html += "<img border='0' width='130px' height='140px' alt='" + json.list[i].name + "' src='" + json.list[i].imageUrl + "'>";
			html += "</span>";
            html += "<span class='groupTitle'>" + json.list[i].name + "</span>";
            html += BSModifyDescription( json.list[i].description ) + "<br>";
            

            html += "<span class='price'>" + json.list[i].price + "€</span>";
            html += "<span class='productGroupButton'>Comprar</span>";
            html += "<span class='borderBottom'></span>";
            html += "</a>";
        }




        html += "</div></div></div>";
    }

    document.getElementById( BSdiv ).innerHTML = html;

}
