<?php if (!defined('PmWiki')) exit ();

/*  copyright 2007 Benoit Dutilleul (benoit.dutilleul@gmail.com) 
    This file is distributed under the terms of the GNU General Public 
    License as published by the Free Software Foundation; either 
    version 2 of the License, or (at your option) any later version.  

    This module enables embedding of Amazon.com widgets into pmwiki pages. 
*/

#Markup('amazonpl', '<img', '/\\(:amazonpl (\\d+) (\\d+):\\)/e', #"ShowAmazonProductLink('$1','$2')");

Markup('amazonpl', '<img', '/\\(:amazonpl (.*?) (.*?):\\)/e', "ShowAmazonProductLink('$1','$2')");


function ShowAmazonProductLink($assoid,$asin) {
        #$assoid='wefa-20';
        #$asin='B000JVZKFK';
        ## iframe tag
        $out = "<iframe src='http://rcm.amazon.com/e/cm?t=$assoid";
        $out .= "&o=1&p=8&l=as1&asins=$asin&fc1=000000&IS2=1&lt1=_blank&lc1=0000FF&bc1=FFFFFF&bg1=FFFFFF&npa=1&f=ifr'";
        $out .= " style='width:120px;height:240px;' scrolling='no' marginwidth='0' marginheight='0' frameborder='0'></iframe>";
        return Keep($out);
}