function getQuickSearch() {
    new Ajax.Updater('object', '/index/search/addhead/1', {
        method: 'POST',
            parameters: {
                cpu_name: 		$F('cpu_name_fast'),
                memory_size:	$F('memory_size_fast'),
                video_quality: 	$F('video_quality_fast'),
                price: 			$F('price_fast'),
                monitor_diag: 	$F('monitor_diag_fast'),
                weight: 		$F('weight_fast')
            }
        }
    );
}

function getAlert() {
	new Ajax.Updater('notebooks', '/index/search', {
		method: 'POST',
			parameters: {
				company: 		$F('company'),
				price: 			$F('price'),
				os: 			$F('os'),
				cpu_name: 		$F('cpu_name'),
				cpu_speed: 		$F('cpu_speed'),
				hdd_size: 		$F('hdd_size'),
				hdd_speed: 		$F('hdd_speed'),
				weight: 		$F('weight'),
				memory_size:	$F('memory_size'),
				battery: 		$F('battery'),
				video_quality: 	$F('video_quality'),
				monitor_diag: 	$F('monitor_diag'),
				resolution: 	$F('resolution'),
				optical: 		$F('optical'),
				warranty: 		$F('warranty'),
				modem:	 		$F('modem'),
				lan:	 		$F('lan'),
				wlan:	 		$F('wlan'),
				spdif:	 		$F('spdif'),
				iumds:	 		$F('iumds'),
				firewire: 		$F('firewire'),
				vga_out:	 	$F('vga_out'),
				svideo:	 		$F('svideo'),
				web_cam:	 	$F('web_cam'),
				serial:	 		$F('serial'),
				id_card: 		$F('id_card'),
				dok:	 		$F('dok'),
				ir:       $F('ir'),
				bluetooth:	 	$F('bluetooth')
			},
		onCreate: progressStart,
		onComplete: progressEnd
		}
	);
}

function progressStart() {
  $('progress').style.visibility = '';
}

function progressEnd() {
  $('progress').style.visibility = 'hidden';
}
function help(url) {
	newwindow=window.open(url,'help','height=600,width=544,scrollbars=1');
	if (window.focus) {
        newwindow.focus()
    }
	return false;
}

function calc(url) {
	newwindow=window.open(url,'help','height=400,width=450,scrollbars=1');
	if (window.focus) {
        newwindow.focus()
    }
	return false;
}

function picture(url) {
	newwindow=window.open(url,'Pictures','height=500,width=700,scrollbars=1');
	if (window.focus) {
        newwindow.focus()
    }
	return false;
}

function cleanLinks(data) {
	var find = "";
	var replace = "";
	var pos = data.indexOf("<a ");

	while(pos > -1) {
		find = data.substring(pos, data.indexOf("</a>")+4 );
		replace = find.substring(find.indexOf(">") +1, find.indexOf("</a>"));

		data = data.replace(find, replace);
		pos = data.indexOf("<a ");
	}
	return data;
}

function printbyid() {
	var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";
	disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25";

	var content_vlue = document.getElementById("print_op_c");
	var footer = document.getElementById("footer_position").innerHTML;

	if(!content_vlue) {
		content_vlue = document.getElementById("print_op");
	}

	if(!content_vlue) {
		content_vlue = document.getElementById("object").innerHTML;
	} else {
	  	content_vlue = content_vlue.innerHTML;
	}

	var docprint=window.open("","",disp_setting);
	docprint.document.open();
	docprint.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
	docprint.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
	if (lang == 'lt') {
	  docprint.document.write('<title>Flex24</title>');		
	}
	else {
	  docprint.document.write('<title>Flex sülearvutikeskus - client</title>');		
	}
	docprint.document.write('<link rel="stylesheet" href="/main_img/css/print.css" type="text/css">');
	docprint.document.write('</head><body><table align="center" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" width="544" class="content">');
    content_vlue = cleanLinks(content_vlue);
	content_vlue = content_vlue.replace(/<script.*script>/mig, '');
	docprint.document.write(content_vlue);
	if (lang == 'lt') {
	  docprint.document.write('FLEX24  -  Švitrigailos g. 3, Vilnius  -  tel: 852330005  -  vilnius@flex24.lt');		
	}
	else {
	  docprint.document.write('FLEX Sülearvutikeskus  -  aadress: Mustamäe tee 29, Tallinn 10616<br/>tel: 6 776 280  -  fax: 6 776 285  -  e-post: flex@flex.ee');		
	}
	docprint.document.write('</td></tr></table></body></html>');
	docprint.document.close();
	docprint.focus();
	docprint.print();
}

function getPic(src) {
    document.getElementById('pic').src = src;
}

function openLeasing() {
  opener.location = '/index/info/object/10';
}

function calculate() {
	new Ajax.Updater('calc_result', '/index/calculate', {
		method: 'POST',	parameters: {'period': $F('period'), 'payment': $F('payment'), 'price': $F('price')}});
}

jQuery(document).ready(function() {
	jQuery('#price').change(function() {
		getAlert();
		return false;
	});
});	
