function addEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType,fn,useCapture);
		return true;
	} else if(obj.attachEvent){
		return obj.attachEvent("on"+evType,fn);
	} else {
		return false;
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if (node == null) node = document;
	if (tag == null) tag = '*';
	var elems = node.getElementsByTagName(tag);
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	var i = 0;
	for (var j = 0; j < elems.length; j++) {
		if ( pattern.test(elems[j].className) ) {
			classElements[i++] = elems[j];
		}
	}
	return classElements;
}

function collapsible() {
	return false;
	var collap = getElementsByClass("collapsible",null,"div");
	if (collap) {
		for(i in collap) {
			var dt = collap[i].getElementsByTagName("dt");
			for(j in dt) {
				dt[j].onclick = function() {
					this.parentNode.className = this.parentNode.className?'':'active';
					return false;
				}
			}
		}
	}
}

addEvent(window, 'load', collapsible);

function popup(url,name,width,height,wplus,hplus,focus,left,top,menubar,status,toolbar,scrollbar,resizable,scrx,scry,directories,loc) {
	if ( !url ) return false;
	if ( !name ) name = 'popupWin';
	if ( !width ) width = '';
	if ( !height ) height = '';
	if ( !directories ) directories = 'no';
	if ( !loc ) loc = 'no';
	if ( !menubar ) menubar = 'no';
	if ( !status ) status = 'no';
	if ( !toolbar ) toolbar = 'no';
	if ( !scrollbar ) scrollbar = 'no';
	if ( !resizable ) resizable = 'no';
	if ( !scrx ) scrx = '100';
	if ( !scry ) scry = '100';
	if ( !left ) left = '100';
	if ( !top ) top = '100';
	if ( wplus ) width  += wplus;
	if ( hplus ) height += hplus;

    var popupWin = window.open(url,name,'width='+width+'px,height='+height+'px,left='+left+',top='+top+',menubar='+menubar+',status='+status+',toolbar='+toolbar+',scrollbars='+scrollbar+',resizable='+resizable+',screenX='+scrx+',screenY='+scry+'directories='+directories+',location='+loc);

	if ( focus ) popupWin.focus();
}

function copyField(from, to) {
  document.getElementById(to).value = document.getElementById(from).value;
}

function set(input) {

  input.value = '';
}

function leave(input) {

  input.value = (input.value == '') ? input.defaultValue : input.value;
}
function changeImage(img, img_src) {

  img.src = img_src;
}

var old_table = '';
var old_link = '';
var is_opened  = 'none';

function toggle( image, link ) {

    table_obj = document.getElementById(image);
	link_obj = document.getElementById(link);
    is_opened = table_obj.style.display;

	if (image != 'faq_0')
	{
		document.getElementById('faq_0').style.display = 'none';
		document.getElementById('link_0').style.fontWeight = 'normal';		
	}

    if (old_table != '' && is_opened == 'none') {
        old_table_obj = document.getElementById(old_table);
        old_table_obj.style.display = 'none';

		old_link_obj = document.getElementById(old_link);
        old_link_obj.style.fontWeight = 'normal';
		old_link_obj.style.textDecoration = 'underline';
		old_link_obj.style.cursor = 'pointer';
    }

    if (old_table != image || is_opened == 'none') {

        table_obj.style.display = 'block';
		link_obj.style.fontWeight = 'bold';
		link_obj.style.textDecoration = 'none';
		link_obj.style.cursor = 'default';
    }

    old_table = image;
	old_link = link;
}

var old_table02 = '';
var old_link02 = '';
var is_opened02  = 'none';

function toggle_tech( image, link ) {

    table_obj = document.getElementById(image);
	link_obj = document.getElementById(link);
    is_opened02 = table_obj.style.display;

	/*if (image != 'tech_01')
	{
		document.getElementById('tech_01').style.display = 'none';
		document.getElementById('a01').style.fontWeight = 'normal';
	}*/

    if (old_table02 != '' && is_opened02 == 'none') {
        old_table_obj = document.getElementById(old_table02);
        old_table_obj.style.display = 'none';

		old_link_obj = document.getElementById(old_link02);
        old_link_obj.style.fontWeight = 'normal';
    }

    if (old_table02 != image || is_opened02 == 'none') {

        table_obj.style.display = 'block';
		link_obj.style.fontWeight = 'bold';
    }

    old_table02 = image;
	old_link02 = link;
}

function showKalkFlash()
{
	if($('webspotdiv2') != null)
	{
		var kf = new FlashObject('top', 'gfx/kalkulacio.swf', '200', '300');
		kf.write('webspotdiv2'); // ]]>
	}
}

function setForm()
{
	var case_type = $('case_type');
	var ct_value = case_type.options[case_type.selectedIndex].value;
	if(ct_value == 13 || ct_value == 14)
	{
		$('case_type_color').selectedIndex = 0;
		$('case_type_color').set('disabled', true);
		$('cover_type').selectedIndex = 0;
		$('cover_type').set('disabled', true);
		$('cover_back').checked = false;
		$('cover_back').set('disabled', true);
	}
	else
	{
		$('case_type_color').set('disabled', false);
		$('cover_type').set('disabled', false);
		$('cover_back').set('disabled', false);
	}
}
