<CFPROCESSINGDIRECTIVE suppresswhitespace="yes">
<cfcontent type="text/javascript">
<cfparam name="lang" type="string" default="">
<cfscript>
whatsnew = createObject('component', Application.DIRECTORY & '.components.elementloader');
if (lang EQ '') element = whatsnew.load("",true,"/assets/common/accreditations._grd");
</cfscript>
/* Date: <cfoutput>#element.edited_on#</cfoutput> */
var d=document;
<cfscript>
elementData = element.getRows();
elementDataLen = arraylen(elementData);

widthLimit = 290;
paddingRight = 5;

writeoutput("// widthLimit=[#widthLimit#]#chr(13)#");
writeoutput("// paddingRight=[#paddingRight#]#chr(13)#");

imagesData = ArrayNew(1);

// load image array
ii = 1;
for (i=1; i LTE #elementDataLen#; i=i+1) {
image = JSStringFormat(elementData[i].getElement('image').getValue());
if (image NEQ "") {
name = elementData[i].getElement('name').getValue();
if (name EQ "") name = "#i#";

a = StructNew();
a.image = JSStringFormat(image);
//a.name = "/accreditations.htm\###name#";
a.name = "/accreditations.htm";
a.title = JSStringFormat(elementData[i].getElement('title').getValue());
a.width = Val(elementData[i].getElement('image').getWidth());
a.height = Val(elementData[i].getElement('image').getHeight());
a.alt = JSStringFormat(elementData[i].getElement('image').getAlt());
if (a.alt EQ "") a.alt = a.title;
a.alt = Replace(a.alt,'"',"'","all");

if (a.width GT 0) {
imagesData[ii] = a;
ii = ii + 1;
}
}
}
imagesDataLen = ArrayLen( imagesData );

if (imagesDataLen GT 0) {

// Randomize
for (i=1; i LTE #imagesDataLen#; i=i+1) {
ArraySwap(imagesData, RandRange( 1, imagesDataLen ),RandRange( 1, imagesDataLen ));
}

totalWidth = 0;

writeoutput("d.writeln('<ul class=\'accreditations\'>');#chr(13)#");
for (i=1; i LTE #imagesDataLen#; i=i+1) {
//writeoutput("// ----------------------#chr(13)#");
//writeoutput("// i=[#i#]#chr(13)#");
//cat = JSStringFormat(elementData[i].getElement('category').getValue());
name = imagesData[i].name;
//writeoutput("// name=[#name#]#chr(13)#");
image = imagesData[i].image;
//writeoutput("// image=[#image#]#chr(13)#");
if (image NEQ "") {
image_width = imagesData[i].width;

//writeoutput("// image_width=[#image_width#]#chr(13)#");
if (totalWidth + image_width + paddingRight LTE widthLimit) {
writeoutput("d.writeln(#chr(34)#<li>");
writeoutput('<a href=\"#name#\" title=\"#imagesData[i].title#\"><img src=\"#imagesData[i].image#\" width=\"#imagesData[i].width#\" height=\"#imagesData[i].height#\" alt=\"#imagesData[i].alt#\"></a>');
writeoutput('</li>#chr(34)#);#chr(13)#');
totalWidth = totalWidth + image_width + paddingRight;
}
//writeoutput("// totalWidth=[#totalWidth#]#chr(13)#");
}
}
writeoutput("d.writeln('</ul>');#chr(13)#");
//writeoutput('d.writeln(#chr(34)#<a href=\"/accreditations.htm\" class=\"readmore\">Read more</a>#chr(34)#);#chr(13)#');

} else {
writeoutput("<!-- none found -->");
}
</cfscript>
</CFPROCESSINGDIRECTIVE>
