/*
	This file is part of the hatatitla.biz
	Copyright (C) 2002-2007 Hatatitla
	All Rights Reserved

±¿¼æ¶³ó
*/

function ht_chk_all(ids)
{
	var a = ids.split(";");
	for (var i=0; i<a.length; ++i)
	{
		var o = mwl_obj(a[i]);
		if (o) o.checked = true;
	}
}

function ht_uchk_all(ids)
{
	var a = ids.split(";");
	for (var i=0; i<a.length; ++i)
	{
		var o = mwl_obj(a[i]);
		if (o) o.checked = false;
	}
}

function show_chat()
{
	window.open("chat.php", "chat_window", "toolbar=no,scrollbars=no,resizable=no,width=620,height=420");
}

function show_gallery(id)
{
	var s, w, h;
	if (window.screen)
	{
		w = 0.7 * screen.availWidth;
		h = 0.9 * screen.availHeight;
	}
	else
	{
		w = 620;
		h = 420;
	}
	s = "toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h;
	window.open("gallery-auto.php?id=" + id, "gallery_window", s);
}

function open_email_office()
{
	location.href = "mai"+"lt"+"o:b"+"iur"+"o@"+"hatati"+"tla.b"+"iz";
}

function open_email_marketing()
{
	location.href = "mai"+"lt"+"o:ma"+"rke"+"t"+"ing"+"@"+"hatati"+"tla.b"+"iz";
}

function show_tip(msg)
{
	var height = msg.length < 200 ? 240 : 300;
	window.open("tip.php?msg=" + msg, "tip_window", "toolbar=no,scrollbars=yes,resizable=yes,width=240,height=" + height);
}

function show_help(href)
{
	window.open(href, "help_window", "toolbar=no,scrollbars=yes,resizable=yes,width=400,height=350");
}

/* Common 2 */
function ht_smh_put(id, s1, s2)
{
	var o = mwl_obj(id);
	o.value += s1 + s2;
	o.focus();
}

function ht_smh_put_itemize(id)
{
	var o = mwl_obj(id);
	o.value += "\n* ";
	o.focus();
}

var ht_smh_enabled = 0;
var ht_smh_interval;
var ht_smh_limit = 0;

function ht_smh_chk_ok(id, limit)
{
	ht_smh_enabled = 1;
	ht_smh_limit = limit;
	ht_smh_interval = setInterval('ht_smh_check_form(\'' + id + '\');', 300);
}

function ht_smh_chk_off()
{
	ht_smh_enabled = 0;
	ht_smh_limit = 0;
	clearInterval(ht_smh_interval);
}

function ht_smh_check_form(id)
{
	var st = mwl_obj('smart_status_' + id);
	var rest = ht_smh_limit - mwl_obj(id).value.length;
	if (rest>=0)
		st.innerHTML = rest;
	else
		st.innerHTML = "0 (przekroczono limit)";
}

/* Common 3*/
function ht_submit(formId, ctrlId, par)
{
	var f = document.forms[formId];
	var ctrl = f['ht_ctrl'];
	if (ctrl!=null)
		ctrl.value = ctrlId;
	var p = f['ht_params'];
	if (p!=null)
		p.value = par;
	f.submit();
}

function ht_submit_conf(formId, ctrlId, par, quest)
{
	if (confirm(quest))
		ht_submit(formId, ctrlId, par);
}

function show_popup_window(sURL, width, height)
{
	var s = "toolbar=no,location=no,scrollbars=yes,resizable=yes,width="+width+",height="+height;
	window.open(sURL, "_blank", s);
}

/* Common 4 */
function shop_prod_mouse(o, ov)
{
	o.style.borderColor = ov ? '#80C0FF' : '#C0C0C0';
	o.style.borderStyle = ov ? 'solid' : 'dotted';
	o.style.backgroundColor = ov ? '#F8F8F8' : '#F0F0F0';
}

function shop_prod_show(id)
{
	window.location.href = 'shop-more.php?id=' + id;
}

function shop_prod_show2(id, category)
{
	window.location.href = 'shop-more.php?id=' + id + '&category=' + category;
}

function ht_rep_chk_all(prefix, ids)
{
	var a = ids.split(';');
	if (a.length > 0)
	{
		var found0 = false;
		for (var i=0; i<a.length; ++i)
		{
			var o = mwl_obj(prefix + a[i]);
			if (o)
			{
				if (false == o.checked)
					found0 = true;
			}
		}
		var newState = true;
		if (false == found0)
			newState = false;
		for (var i=0; i<a.length; ++i)
		{
			var o = mwl_obj(prefix + a[i]);
			if (o)
				o.checked = newState;
		}
	}
}

function home_seg_mouse(o, color)
{
	o.style.backgroundColor = color;
}

function home_seg_mouse_out(o)
{
	o.style.backgroundColor = '';
}

function em35_dec3(enc)
{
	var em = '';
	for (var i=0; i<enc.length; i += 2)
	{
		var c = enc.substr(i+1, 1) + enc.substr(i, 1);
		var nCode = parseInt(c, 16);
		nCode = (nCode - 7) % 0x100;
		em = em + String.fromCharCode(nCode);
	}
	return em;
}

function em35_draw3(container, enc)
{
	var o = mwl_obj(container);
	if (null != o)
		o.innerHTML = em35_dec3(enc);
}

function em35_link3(enc, subject)
{
	var s = 'm'+'ai'+'lt'+'o'+':'+em35_dec3(enc);
	if ('' != subject)
		s += '?su'+'bj'+'ect='+em35_dec3(subject);
	parent.location = s;
}

function ht_vo_ref_selector_clear_obj_cf(field, previewId, clearBtn) {
	if (confirm('Czy chcesz usunac powiazanie?')) {
		$('#'+field).val('0');
		$('#'+previewId).html('(brak)');
		$('#'+clearBtn).empty();
		$('#'+clearBtn).removeClass('a59');
		$('#'+clearBtn).addClass('a60');
	}
}

/*function ht_search_clear_sb(o)
{
	o.value = '';
}*/
