
function my_strip_char ( chars , to_strip )
{
	var ret = '';
	for ( var i = 0; i < to_strip.length; i++ )
	{
		var to_use = 1;
		for ( var ii = 0; ii < chars.length; ii++ )
			if ( chars[ii] == to_strip[i] )
				to_use = 0;
		if ( to_use == 1 ) ret += to_strip[i];
	}
	return ret;
}

function my_png_fix ()
{
	if ( ! isIE6 ) return;

	$('*').each ( function () {
		if ( $(this).css ('background-image').match ( /\.png\b/i ) )
		{
			var img_matched = $(this).css ('background-image').match ( /\((.+?)\)/i );
			var img = my_strip_char ( [ "'", '""' ], img_matched[1] );

			$(this).css('background-image', 'none');
			$(this).css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + img + '",sizingMethod="scale")' );
		}
	});

}

function my_new_window_links ()
{
	$('a.link-in-new-window').each ( function () {
		$(this).click ( function () {
			window.open (this.href);
		});
	});
}

function my_document_ready ()
{
	isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
	my_png_fix ();
	my_new_window_links ();
}

var isIE6 = false;
$(document).ready ( my_document_ready );




/* Vector */

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
                return unescape(document.cookie.substring(c_start,c_end));
        }
     }
     return "";
}

function setCookie(c_name,value,expiredays)
{
                var exdate=new Date();
                exdate.setDate(exdate.getDate()+expiredays);
                document.cookie=c_name+ "=" +escape(value)+
                ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
            }

            function copyUserInfo()
            {
                var form = document.forms['userInfoForm'];
                if(!form)
                    return alert("Fatal error - form not found :/");

                if(form.copyValue.checked)
                {

                    // kopirovani obsahu
                    form.d_company.value    = form.company.value;
                    form.d_name.value       = form.name.value;
                    form.d_surname.value    = form.surname.value;
                    form.d_address.value    = form.address.value;
                    form.d_city.value       = form.city.value;
                    form.d_psc.value        = form.psc.value;

                    var index = form.new_country.selectedIndex;
                    form.new_country2.options[index].selected = 1;
                 }else
                 {
                    form.d_company.value    = "";
                    form.d_name.value       = "";
                    form.d_surname.value    = "";
                    form.d_address.value    = "";
                    form.d_city.value       = "";
                    form.d_psc.value        = "";
                    form.new_country2.options[0].selected = 1;
                 }
                return true;
            }

            function vatChange(what)
            {
                var index = what.selectedIndex;
                //if(index == 0)
                //    setCookie('vat',null,-3);
                var value = what.options[index].value;
                //var text  = what.options[index].text;

                setCookie('vat',value,3);
                window.location = "basket.php";

                return true;
            }

            function saveAndGo(form,whereto)
            {
                var targetForm = document.forms[form];
                if(!targetForm)
                   ; //return false;
               targetForm.action = targetForm.action+"&page2go="+whereto;

               targetForm.submit();


            }
/* //Vector */