var rootUrl = "http://sex.kitoks.com/";
function putIntoBasket(prod_id) { 
	url = rootUrl + 'ajax/basket/put.php?prod_id=' + prod_id;	
	new Ajax.Updater('basket', url, {
		method: 'get'
	});		
	
	url = rootUrl + 'ajax/basket/report.php';	
	new Ajax.Updater('reportContainer', url, {
		method: 'get'
	});	
	document.getElementById('in'+prod_id).style.color = '#393939';
}

function deleteFromBasket(prod_id) {
	url = 'ajax/basket/manage.php?action=delete&prod_id=' + prod_id;	
	new Ajax.Updater('basket_preview', url, {
		method: 'get'
	});	
	putIntoBasket(0);
}

function manageBasket(pressed) {
	if (pressed == 1)
		recalc();
	else
		buy();
}

function recalc() { 
	url = 'ajax/basket/manage.php?action=recalc&' + $('basket_preview_form').serialize();	
	new Ajax.Updater('basket_preview', url, {
		method: 'get'
	});	
	putIntoBasket(0);
}

function buy() {
	url = 'ajax/basket/selectPayment.php';	
	new Ajax.Updater('basket_preview', url, {
		method: 'get'
	});			
}

function recommendForm(prod_id, full_url) {
	url = rootUrl + 'ajax/recommendForm.php?prod_id=' + prod_id + "&full_url=" + full_url;	
	new Ajax.Updater('recommendFormDiv', url, {
		method: 'get'
	});			
}

function sendRecommendation() {
	url = rootUrl + 'ajax/recommendForm.php?' + $('recommendForm').serialize();	
	new Ajax.Updater('recommendFormDiv', url, {
		method: 'get'
	});		
}

function submitCode() {
	url = 'ajax/basket/put.php?' + $('code_form').serialize();	
	new Ajax.Updater('basket', url, {
		method: 'get'
	});
	
//	$('code_form_report').update('nuolaida ivesta').style.color = 'green'
//	this.down().setStyle({ background:null, borderColor:null });
}

function win1() {

var win = new Window({id: "win1", className: "alphacube", title: "Sample", width:250, height:150, top:0, left: 1, parent:$('container')});
win.getContent().innerHTML = "<h1>Constraint inside a div !!</h1>constraint: {left:10, right:20}<br><a href='#' onclick='Windows.getWindow(\"win1\").maximize()'>Maximize me</a>";

win.setDestroyOnClose();
win.show();
win.setConstraint(true, {left:10, right:20})
win.toFront();
}

function data_change(field) {
	var check = true;
	var value = field.value; //get characters
	//check that all characters are digits, ., -, or ""
	for(var i=0;i < field.value.length; ++i) {
		var new_key = value.charAt(i); //cycle through characters
		if(((new_key < "0") || (new_key > "9")) && !(new_key == "")) {
			check = false;
			break;
		}
	}
	//apply appropriate colour based on value
	if(!check)
		field.style.backgroundColor = "red";
	else
		field.style.backgroundColor = "white";
}

function goBack()
  {
  window.history.back()
  }

