hex=0;

function fadetext(){
	if(hex<255) {
		hex+=21;
		$("user").style.color="rgb("+hex+","+hex+","+hex+")";
		setTimeout("fadetext()",20); 
	}
	else {
		$("user").value = '';
		$("user").style.color="#000";
	}
}

function change(id,part) {
	if (part == 'sct') {
		d = '/d/' + $F('d');
		ct = '/ct/' + $F('ct');
		sct = '/sct/' + $F('sct');
		location.href='/index.cfm/m/bestellen' + d + ct  + sct;
	}
	else {
		if (part == 'ct') {
			d = '/d/' + $F('d');
			ct = '/ct/' + $F('ct');
			location.href='/index.cfm/m/bestellen' + d + ct;
		}
		else {
			d = '/d/' + $F('d');
			location.href='/index.cfm/m/bestellen' + d;
		}
	}
}

function add(q) {
	/* Generate a unique random number to always refresh the result */
	var url = '/shop/act_add.cfm/r/' + Math.floor(Math.random()*100001);
	var pars = '';
	var basketRow = '';
	
	/* Only execute when q = full */
	if (q!='') {

		if ($F(q) >= 15 && !confirm('Weet u zeker dat u ' + $F(q) + ' keer dit artikel wilt bestellen?')) {
			/* Stop, user doesn't approve */
			return false;
		}
		
		aId = q.split('_');
		basketRow = 'i' + aId[1];
		url = url + '/id/' + q + '/q/' + $F(q);
		
		/* Clear row from basket */
		if ($(basketRow) && $F(q) == 0) {
			$(basketRow).style.display='none';
		}
	}
	
	var myAjax = new Ajax.Updater( 'side_bag', url, { method: 'get', parameters: pars });
}

function switchGFX(ff) {
	var gfx = $(ff).value;
	var idstr = 'prev_' + ff;
	
	if ($(idstr)) {
		$(idstr).src = gfx;
	}
}

var popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 800,
      height: 600,
      name:"protowin",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"yes",
      scrollbars:"yes",
      resizable:"yes",
      left:"",
      top:"",
      normal:false
    }
    Object.extend(this.options, options || {});

    if (this.options.normal){
        this.options.menubar = "no";
        this.options.status = "no";
        this.options.toolbar = "no";
        this.options.location = "no";
    }

    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    window.open(this.options.url, this.options.name,openoptions );
    return false;
  }
}

var edit = {
  open: function(options)
  {
    this.options = {
      url: '#'
    }
    Object.extend(this.options, options || {});

    window.open(this.options.url, this.options.name,openoptions );
    return false;
  }
}

