  // xajax loader
xajax.callback.global.onRequest = function() {xajax.$('cartLoading').style.display = 'inline';};
xajax.callback.global.beforeResponseProcessing = function() {xajax.$('cartLoading').style.display = 'none';};

function checkForm(obj)	{
	if(obj.rules.checked != 1)
	{
		alert('hyväksy toimitusehdot jatkaaksesi');
		return false;
	}
	return true;
}

$(document).ready(function(){

	// on pageload we get default value out of field
	var def = $('#teksti').val();
	
	// when goes out of focus
	$('#teksti').blur(function(){
		if($(this).val() == '')
			$(this).val(def);
	});

	// when gets focus
	$('#teksti').focus(function(){
		if($(this).val() == def)
			$(this).val('');
	});
	
	$(".tuotekuvaus a").click(function (event) {
		event.preventDefault();
		var id = $(this).attr("class");
		$("#dialog-modal").dialog('open');
		$("#dialog").load('/?do=showProduct&id='+id+'&ajax=1', function(){
			if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
				jQuery(function($) {
					$("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) {
						return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
					});
				});
			}
		});
	});	
	
	$("#dialog-modal").dialog({
		modal: true,
		autoOpen: false,
		height: 500,
		width: 800
	});
	
	$('.ui-widget-overlay').live("click", function() {
		//Close the dialog
		$("#dialog-modal").dialog("close");
	});
});
