// JavaScript Document
function mycarousel_itemLoadCallback(carousel, state)
{
    // Since we get all URLs in one file, we simply add all items
    // at once and set the size accordingly.
    if (state != 'init')
        return;

    jQuery.get('bestbuysbb.html', function(data) {
        mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
    });
};


function mycarousel_itemAddCallback(carousel, first, last, data)
{
    // Simply add all items at once and set the size accordingly.
    var items = data.split('|');

    for (i = 0; i < items.length; i++) {
        carousel.add(i+1, mycarousel_getItemHTML(items[i]));
    }

    carousel.size(items.length);
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(url)
{
	var temp, kleur, LastChar 
	//temp = url.replace('_kleur','')
	temp = url.split("med/");
	temp2 = temp[1];
	temp3 = temp2.split("_kleur");
	temp4 = temp3[0];
	//temp = temp.replace('.jpg','')
	//temp = temp.replace('/upload/bb/','')
	//window.alert(temp4);
	//temp = temp.substring(0, temp.length-1);
	
	//kleur = url.substring(0, url.length-4);
	//LastChar = kleur.substring(kleur.length-1);
	kleur = url.split("_kleur");
	kleur2 = kleur[1];
	kleur3 = kleur2.replace('.jpg','');
	
	
	//window.alert( kleur3 ) ;
	
	
    return '<a href="/prd.html?ProductID='+temp4+'&kleur='+kleur3+'&maat=size"><img src="' + url + '" width="150" height="193" alt="" /></a>';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
		scroll: 5,
		start: 1,
        itemLoadCallback: mycarousel_itemLoadCallback
    });
});

function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

<!--
function copytext() {
if (document.form1.SameDelivery.checked) {
document.form1.Title2.value=document.form1.Title.value
document.form1.FirstName2.value=document.form1.FirstName.value
document.form1.LastName2.value=document.form1.LastName.value
document.form1.DeliveryAddress1.value=document.form1.BillingAddress1.value
document.form1.DeliveryAddress2.value=document.form1.BillingAddress2.value
document.form1.DeliveryAddress3.value=document.form1.BillingAddress3.value
document.form1.ShipCity.value=document.form1.BillingCity.value
document.form1.ShipPostalCode.value=document.form1.BillingPostalCode.value
document.form1.AfleverLand.value=document.form1.Factuurland.value
}
else {
document.form1.LastName2.value=""
document.form1.FirstName2.value=""
document.form1.Title2.value=""
document.form1.DeliveryAddress1.value=""
document.form1.DeliveryAddress2.value=""
document.form1.DeliveryAddress3.value=""
document.form1.ShipCity.value=""
document.form1.ShipPostalCode.value=""
document.form1.AfleverLand.value=""
}
}

function cp() {
var cperr=''
if (document.form1.CustomerPassword.value != document.form1.Confirm.value) { cperr += 'Please confirm password' }
if (cperr !='') { alert(cperr) }  
document.MM_returnValue2 = (cperr=='')
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//-->
