//////////////////////////////////////////////
// Kasseler CMS: Content Management System  //
// =========================================//
// Copyright (c)2007-2009 by Igor Ognichenko//
// http://www.kr-cms.net/                   //
//////////////////////////////////////////////

if(typeof HTMLElement!="undefined"&&!HTMLElement.prototype.insertAdjacentElement){HTMLElement.prototype.insertAdjacentElement=function(A,B){switch(A){case"beforeBegin":this.parentNode.insertBefore(B,this);break;case"afterBegin":this.insertBefore(B,this.firstChild);break;case"beforeEnd":this.appendChild(B);break;case"afterEnd":if(this.nextSibling){this.parentNode.insertBefore(B,this.nextSibling)}else{this.parentNode.appendChild(B)}break}};HTMLElement.prototype.insertAdjacentHTML=function(B,D){var C=this.ownerDocument.createRange();C.setStartBefore(this);var A=C.createContextualFragment(D);this.insertAdjacentElement(B,A)};HTMLElement.prototype.insertAdjacentText=function(B,C){var A=document.createTextNode(C);this.insertAdjacentElement(B,A)}}function allselect(){var A=document.getElementsByTagName("input");for(i=0;i<A.length;i++){if(A[i].type=="checkbox"){A[i].checked=true}}};
var lat2 = ["JO","SCH","ZH","CH","SH","JE","JU","JA","jo","sch","zh","ch","sh","je","ju","ja", "ya"];
var cyr2 = ["Ё", "Щ",  "Ж", "Ч", "Ш", "Э", "Ю", "Я", "ё", "щ", "ж", "ч", "ш",  "э", "ю", "я", "я"];
var lat = ["A", "B", "V", "G", "D", "E", "Z", "I", "J", "K", "L", "M", "N", "O", "P", "R", "S", "T", "U", "F", "H", "C", "``", "Y", "''", "a", "b", "v", "g", "d", "e", "z", "i", "j", "k", "l", "m", "n", "o", "p", "r", "s", "t", "u", "f", "h", "c", "`","y", "'"];
var cyr = ["А", "Б", "В", "Г", "Д", "Е", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т", "У", "Ф", "Х", "Ц", "Ъ", "Ы", "Ь", "а", "б", "в", "г", "д", "е", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ъ", "ы", "ь"];

var lat2_rewrite = ["JO","SCH","ZH","CH","SH","JE","JU","JA","jo","sch","zh","ch","sh","je","ju","ja", "ya", "_", "", "", "_", "_", "_", "", "", "", "", "_"];
var cyr2_rewrite = ["Ё", "Щ",  "Ж", "Ч", "Ш", "Э", "Ю", "Я", "ё", "щ", "ж", "ч", "ш",  "э", "ю", "я", "я", " ", "'", '"', '\\(', '\\)', '\\/', '\\\\', '\\[', '\\]', '\\{', '\\}', '\\-'];
var lat_rewrite = ["A", "B", "V", "G", "D", "E", "Z", "I", "J", "K", "L", "M", "N", "O", "P", "R", "S", "T", "U", "F", "H", "C", "", "Y", "", "a", "b", "v", "g", "d", "e", "z", "i", "j", "k", "l", "m", "n", "o", "p", "r", "s", "t", "u", "f", "h", "c", "","y", ""];
var cyr_rewrite = ["А", "Б", "В", "Г", "Д", "Е", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т", "У", "Ф", "Х", "Ц", "Ъ", "Ы", "Ь", "а", "б", "в", "г", "д", "е", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ъ", "ы", "ь"];

var upload1, small_load = "<img src='includes/images/loading/small.gif' alt='Loading...'>";

function displays(id, values){if($$(id)) $$(id).style.display = values;}
function addEvent(obj, name, handler){if (obj.attachEvent) obj.attachEvent('on' + name, handler); else obj.addEventListener(name, handler, false);}
function is_voted(table, id){var str = getCookie("rating"); return (str && str.indexOf(table+id+',') != -1 && str!='') ? 1 : 0;}
function datacase(d, m, y, start_year, l_d, l_m, l_y){addEvent(window, 'load', function(){create_datacase(d, m, y, start_year, l_d, l_m, l_y)});}
function switch_content(elm){if($$(elm).style.display == 'none') $$(elm).style.display = ''; else $$(elm).style.display = 'none';}
function id(elm){return (typeof elm === "string") ? $$(elm) : elm;}
function update_ajax(url, id, lang){if(confirm(lang)) ajaxed({action : url, animation : true, elm : id}, {}); else return false;}
function move_ajax(url, id){ajaxed({action : url, animation : true, elm : id}, {});}
function clear_ajax(url, id, lang){if(confirm(lang)) ajaxed({action : url, animation : true, elm : id}, {}); else return false;}
function captcha(){var time = new Date(); document.getElementById('imgseccode').src = 'includes/captcha.php?time='+time.getSeconds();}
function window_open(url, p1, p2){url = url.replace("&amp;", "&"); return window.open(url, p1, p2);}
function name2id(name){var e = document.getElementsByTagName('a'); for(var i=0; i<e.length; i++) if(e[i].name == name) return e[i]; return false;}
function translit(id, buf){for (i = 0; i < cyr2.length; i++) buf = buf.replace(eval('regexp = /'+cyr2[i]+'/g'), lat2[i]); for (i = 0; i < cyr.length; i++) buf = buf.replace(eval('regexp = /'+cyr[i]+'/g'), lat[i]);  if($$(id)) $$(id).value = buf;  return;}
function rewrite_key(id, buf){for (i = 0; i < cyr2_rewrite.length; i++) buf = buf.replace(eval('regexp = /'+cyr2_rewrite[i]+'/g'), lat2_rewrite[i]); for (i = 0; i < cyr_rewrite.length; i++) buf = buf.replace(eval('regexp = /'+cyr_rewrite[i]+'/g'), lat_rewrite[i]); if($$(id)) $$(id).value = buf; return;}
function ckeck_uncheck_all(){var chekeds = document.getElementsByTagName('input'); for(i=0; i<chekeds.length; i++) if(chekeds[i].type == 'checkbox' && chekeds[i].id!="checkbox_sel") chekeds[i].checked = (chekeds[i].checked) ? false : true;}
function set_avatar(file, directory){var dir = window.opener.$$('cat').value; if(window.opener.$$('avatar')) window.opener.$$('avatar').src = directory+dir+'/'+file; if(window.opener.$$('id_set_avatar')) window.opener.$$('id_set_avatar').value = dir+'/'+file;}
function hack_sel(){if(!$$('no_select')) var e = KR_AJAX.create.element('input', {id : 'no_select', disabled : true}, {'display' : 'none'}); else var e = $$('no_select'); try {e.focus()} catch(e) {}}
function elmPos(e){e = $$(e); var X = 0; var Y = 0; while(e != null){X += e.offsetLeft; Y += e.offsetTop; e = e.offsetParent;} return {left:X+'px', top:Y+'px'}}
function scroll2elm(Elm){Elm = $$(Elm); var selectedPosX = 0; var selectedPosY = 0; while(Elm != null){selectedPosX += Elm.offsetLeft; selectedPosY += Elm.offsetTop; Elm = Elm.offsetParent;} scroll(selectedPosX,selectedPosY);}
function add_comment(id, sort, rows, page){haja({elm : 'add_comment', action : $$('comment_form').action, animation : true}, {'id' : id, 'comment' : $$('comment').value, 'seccode' : (($$('seccode')) ? $$('seccode').value : ''), 'this_page' : page}, {onendload:function(){$$('comment').value=''}});}
function delete_comment(cid, id, table){if(confirm(window.js_lang.delcomm)){$$('comment_'+cid).style.display = 'none'; ajaxed({action : 'index.php?ajaxed=delete_comment', animation : false}, {'id' : id, 'cid' : cid, 'table' : table});}}
function set_rating(id, table, star, rating, voted, classes){ajaxed({action : 'index.php?ajaxed=rating'}, {'id' : id, 'table' : table, 'star' : star, 'rating' : rating, 'voted' : voted}); $$('rating'+id).innerHTML = '<ul class="'+classes+'"><li class="current-rating" style="width:'+((((((rating*voted)+star)/(voted+1))<1) ? star : (((rating*voted)+star)/(voted+1)))*17).toFixed(2)+'px;">'+((((((rating*voted)+star)/(voted+1))<1) ? star : (((rating*voted)+star)/(voted+1)))*17).toFixed(2)+'</li></ul>';}
function rating(id, table, rating, voted, types, classes){classes = (!classes) ? "unit-rating":classes; if(is_voted(table, id)==0 && types==1)  var html = "<div class='rating' id='rating"+id+"'><ul class='"+classes+"'><li class='current-rating' style='width:"+(rating*17).toFixed(2)+"px;'>"+(rating*17).toFixed(2)+"</li><li><a href='#' title='"+window.js_lang.r1+"' class='r1-unit' onclick=\"set_rating("+id+", '"+table+"', 1, "+rating+", "+voted+", '"+classes+"'); return false;\">1</a></li><li><a href='#' title='"+window.js_lang.r2+"' class='r2-unit' onclick=\"set_rating("+id+", '"+table+"', 2, "+rating+", "+voted+", '"+classes+"'); return false;\">2</a></li><li><a href='#' title='"+window.js_lang.r3+"' class='r3-unit' onclick=\"set_rating("+id+", '"+table+"', 3, "+rating+", "+voted+", '"+classes+"'); return false;\">3</a></li><li><a href='#' title='"+window.js_lang.r4+"' class='r4-unit' onclick=\"set_rating("+id+", '"+table+"', 4, "+rating+", "+voted+", '"+classes+"'); return false;\">4</a></li><li><a href='#' title='"+window.js_lang.r5+"' class='r5-unit' onclick=\"set_rating("+id+", '"+table+"', 5, "+rating+", "+voted+", '"+classes+"'); return false;\">5</a></li></ul></div>"; else var html = '<ul class="'+classes+'"><li class="current-rating" style="width:'+(rating*17).toFixed(2)+'px;">'+(rating*17).toFixed(2)+'</li></ul>';  KR_AJAX.addEvent(window, 'load', function(){if($$('r_'+id)) $$('r_'+id).innerHTML = html;});}
function set_language(lang){setCookie('lang', lang, '86400', '/');}
function switcher(elm){if(!$$(elm)) return false; if($$(elm).style.display == 'none')  $$(elm).style.display = ''; else $$(elm).style.display = 'none';}
function edit_comment(cid){var pos = elmPos($$('content_comment_'+cid)); if(!$$('layer_editcomment')) KR_AJAX.create.element('div', {id:'layer_editcomment', className:'comment_loading'}, {'display':'none'});  var heig = ($$('content_comment_'+cid).offsetHeight>=40) ? $$('content_comment_'+cid).offsetHeight : 40; KR_AJAX.set.style({display:'block', left:pos.left, top:pos.top, height:heig+'px', width:$$('content_comment_'+cid).offsetWidth+'px', position: 'absolute', zIndex: '80'}, $$('layer_editcomment')); haja({action:'index.php?ajaxed=edit_comment', elm:'content_comment_'+cid, animation:false}, {id:cid, height:heig}, {onendload:function(){$$('layer_editcomment').style.display='none'}});}
function cancel_edit_comment(cid){$$('content_conteiner_'+cid).style.display = ''; $$('edit_conteiner_'+cid).style.display = 'none'; return false;}
function apply_edit_comment(cid){haja({elm:'content_comment_'+cid, animation:false, action:'index.php?ajaxed=apply_edit_comment'}, {id:cid, comment:$$('edit_comment_area_'+cid).value}, {}); return false;}
function select_add_options(id, action, value, sel){if(!window.sels) sels = []; haja({action:action.replace('amp;', ''), animation:false},{value:value}, {onstartload:function(){sels = []; for(y=0;y<$$(id).options.length;y++) $$(id).options[y] = null; $$(id).options[0] = new Option(window.js_lang.loading, "");}, onendload:function(){eval(KR_AJAX.result); for(y=0;y<$$(id).options.length;y++) $$(id).options[y] = null; if(sels.length>0){for(i=0;i<sels.length;i++){$$(id).options[i] = new Option(sels[i][1], sels[i][0]); if(sel==sels[i][0]) $$(id).options[i].selected=true;}} else $$(id).options[0] = new Option(window.js_lang.casemodule, "");}});}
function set_them(them){setCookie('them', them.value, '86400', '/'); location.href='http://'+location.host+'/';}
function showuploadereffect(obj){if(!obj){if($$('up_table')) obj = $$('up_table'); else obj = $$('upl_up');} var pos = elmPos(obj); if(!$$('layer_svfuploader')) KR_AJAX.create.element('div', {id:'layer_svfuploader'}, {'display':'none'}); $$('layer_svfuploader').className = 'up_process_update'; KR_AJAX.set.style({display:'block', position:'absolute', zIndex:'80', left:(parseInt(pos.left)-1)+'px', top:pos.top, height:obj.offsetHeight+'px', width:obj.offsetWidth+'px'}, $$('layer_svfuploader'));}
function delete_attach(url, lang){if(confirm(lang)){showuploadereffect(); haja({elm:'upl_up', action:url.replace('&amp;', '&'), animation:false}, {'options':$$('update_upload_options').value}, {onendload:function(){if($$('layer_svfuploader')) $$('layer_svfuploader').style.display = 'none'}})} else return false;}
function create_dir(){if($$('uploaddir')){showuploadereffect(); haja({elm:'upl_up', action:'index.php?ajaxed=mkdir', animation:false}, {'dir':$$('uploaddir').value}, {onendload:function(){if($$('layer_svfuploader')) $$('layer_svfuploader').style.display = 'none'}})} return false; }
function rename(dir, file){var dialog = prompt(window.js_lang['new_name'], ''); if (dialog && dialog!=file){ showuploadereffect(); haja({elm:'upl_up', action:'index.php?ajaxed=rename', animation:false}, {'dir':dir, 'file':file, 'new_name':dialog, 'options':$$('update_upload_options').value}, {onendload:function(){if($$('layer_svfuploader')) $$('layer_svfuploader').style.display = 'none'}});}}
function update_upload(dir){$$('uploaddir').value = dir; showuploadereffect(); haja({elm:'upl_up', action:'index.php?ajaxed=update_upload', animation:false}, {'dir':dir,'options':$$('update_upload_options').value}, {onendload:function(){if($$('layer_svfuploader')) $$('layer_svfuploader').style.display = 'none'}});}
function corect_code(id){KR_AJAX.addEvent(window, 'load', function(){$$(id).style.width = parseInt($$(id).parentNode.offsetWidth)+'px';})        }
function quickreply_box(el, bol){switch_content(el, bol);}
function dialog(lang, func){if(confirm(lang)){return true; if(func) func();} else return false;}
function sendpost(url){haja({action: url, animation: true, elm: 'post_table', add: true}, {'message':document.getElementById('message').value, 'last_post':document.getElementById('last_post').value, 'count_post':document.getElementById('count_post').value, 'pages':document.getElementById('pages').value, 'num':document.getElementById('num').value, 'page':document.getElementById('page').value}, {});}
function name_user_set(user){if($$('message')){$$('message').value = $$('message').value + '[b]'+user+'[/b], '; $$('quickreply').style.display = ''; scroll(0, 999999); try {$$('message').focus()} catch(e) {} return false;}}
function check_inputs(){var inp=document.getElementsByTagName('input'); for(var i=0; i<inp.length; i++) if(inp[i].type=='text') if((inp[i].type=='text' || inp[i].type=='password') && $$(inp[i].id+'_hk') && inp[i].value!=$$(inp[i].id+'_hk').value) inp[i].value=$$(inp[i].id+'_hk').value;}
function set_vote(e, langparam){var varvote = 0; var elements = KR_AJAX.document.getElementsByTagName('INPUT', e); for(var i=0; i<elements.length; i++) {if(elements[i].type=='radio' && elements[i].checked == true) {varvote = elements[i].value; break;}} if(varvote!=0) haja({elm:'voting_result', action:e.action, animation:false}, {'var':varvote, 'voteblock':true}, {onstartload:function(){for(var i=0; i<elements.length; i++) {if(elements[i].type=='submit') elements[i].disabled = true;}}}); else alert(langparam);}
function load_module(){if(!window.ajaxload || window.ajaxload!=true) return false; var a=document.getElementsByTagName('a'), class_link=(window.classes)?window.classes:[], ch=false, cl=0; for(var i=0; i<a.length; i++){ for(cl=0;cl<class_link.length;cl++) if(a[i].className==class_link[cl] && a[i].href!='#' && a[i].href.indexOf('logout')==-1) ch = true; if(ch){a[i].onclick = function(){if (KR_AJAX.isReady){haja({elm:'ajax_content', action:this.href, history:true}, {'module':KR_AJAX.this_module,load_module:'true'}, {onendload : function(){scroll(0, 0); load_module()}}); return false;} else return true;}} ch = false;}}
function addinput(id, name, clas){var arr_inputs = document.getElementsByTagName('input'); var values_array = []; for(var i=0;i<arr_inputs.length-1;i++) if(arr_inputs[i].type=='text') values_array[i] = arr_inputs[i].value; cl = (clas) ? " class='"+clas+"'" : "";  $$(id).innerHTML+= "<table width='100%' cellspacing='0' cellpadding='0' style='margin-top: 2px;'><tr><td><input"+cl+" type='text' name='"+name+"[]' value='' /></td></tr></table>"; arr_inputs = document.getElementsByTagName('input'); for(var i=0;i<arr_inputs.length-1;i++) if(arr_inputs[i].type=='text') {if(arr_inputs[i].type=='text') {arr_inputs[i].value = (values_array[i]!='undefined' && values_array[i]!='') ? values_array[i] : ''; if(arr_inputs[i].value=='undefined') arr_inputs[i].value='';}}}
function set_favorite(id, el, module, lang, cl){$$(el).className = ($$(el).className==(cl+'favorite_off')) ? cl+'favorite_on' : cl+'favorite_off'; $$(el).title = ($$(el).title==lang[0]) ? lang[1] : lang[0]; ajaxed({action:'index.php?ajaxed=favorite', animation:false, history:false}, {'id' : id, 'module' : module});}
function add_tag(e){if(e.value.length>2){haja({action:'index.php?ajaxed=add_tag_insession', animation:false, elm:'tag_list'}, {'value':e.value}, {onstartload:function(){e.value = ''; $$('tag_loader').style.display = '';}, onendload:function(){$$('tag_loader').style.display = 'none'; if(KR_AJAX.result) $$('tag_list').style.display = '';}});}}
function remove_tag(text){haja({action:'index.php?ajaxed=remove_tag_insession', animation:false, elm:'tag_list'}, {'text':text}, {onstartload:function(){showuploadereffect($$('tag_list'));}, onendload:function(){if($$('layer_svfuploader')) $$('layer_svfuploader').style.display = 'none'; if(!KR_AJAX.result) $$('tag_list').style.display = 'none';}});}
function getchecked(id, sp){var ins = KR_AJAX.document.getElementsByTagName('INPUT', $$('cont_frame_'+id).contentWindow.document); var string = ''; for(var i=0;i<ins.length;i++) if(ins[i].type=='checkbox' && ins[i].checked == true) string += ins[i].value+sp; return string.substring(0, string.length-1)}
function case_tags(module, title){KR_AJAX.kr_window.init('case_tags', 350, 500, null, null, {title : title, close : true, fone:true, iframe:'index.php?module='+module+'&do=case_tag', mooved:true, resize:false, buttons:{button1:{title:'OK', options:{onclick:'KR_AJAX.kr_window.close("case_tags", true); haja({action:"index.php?ajaxed=add_tag_insession", animation:false, elm:"tag_list"},{"tags":getchecked("case_tags", "|")},{onstartload:function(){showuploadereffect($$("tag_list"))}, onendload:function(){if($$("layer_svfuploader")) $$("layer_svfuploader").style.display = "none"; if(KR_AJAX.result) $$("tag_list").style.display = "";}}); return false;'}}, button2:{title:window.js_lang.cancel, options:{onclick:'KR_AJAX.kr_window.close("case_tags", true); return false;'}}}});}
function case_authors(module, title){KR_AJAX.kr_window.init('case_authors', 350, 500, null, null, {title : title, close : true, fone:true, iframe:'index.php?module='+module+'&do=case_author', mooved:true, resize:false, buttons:{button1:{title:'OK', options:{onclick:'KR_AJAX.kr_window.close("case_authors", true); $$("authors").value = getchecked("case_authors", ","); return false;'}}, button2:{title:window.js_lang.cancel, options:{onclick:'KR_AJAX.kr_window.close("case_authors", true); return false;'}}}});}
function add_goods(id, type){if(type=='+') $$(id).value = parseInt($$(id).value)+1; else if(parseInt($$(id).value)>1) $$(id).value = parseInt($$(id).value) - 1; return false;}
function delete_product(id){haja({animation: false, action:'index.php?module=shop&do=delete_shopping_cart'}, {'id':id}, {onstartload:function(){KR_AJAX.document.getElementsByClassName('shopping_cart_loading', document, 'img', function(e){e.style.display = '';});},onendload:onendload}); return false;}
function clear_shoped(){haja({animation: false, action:'index.php?module=shop&do=clear_shoped'}, {}, {onstartload:function(){KR_AJAX.document.getElementsByClassName('shopping_cart_loading', document, 'img', function(e){e.style.display = '';});}, onendload:onendload}); return false;}
function shoped(id, count, type){if(!count) count = $$('shop_count_'+id).value; if(!type) type = ''; haja({animation: false, action:'index.php?module=shop&do=add_shopping_cart'}, {'id':id, 'count':count, 'type':type}, {onstartload:function(){if($$('shop_count_'+id)) $$('shop_count_'+id).value = '1'; KR_AJAX.document.getElementsByClassName('shopping_cart_loading', document, 'img', function(e){e.style.display = '';});}, onendload:onendload}); return false;}
function scrollTop(scroller, px, e){if(px!='auto') $$(scroller).scrollTop = parseInt($$(scroller).scrollTop)-px; else $$(scroller).scrollTop = parseInt($$(scroller).scrollTop)-KR_AJAX.document.getElementsByClassName(e, document)[0].offsetHeight; return false;}
function scrollBottom(scroller, px, e){if(px!='auto') $$(scroller).scrollTop = parseInt($$(scroller).scrollTop)+px; else $$(scroller).scrollTop = parseInt($$(scroller).scrollTop)+KR_AJAX.document.getElementsByClassName(e, document)[0].offsetHeight; return false;}

function send_form(form, elm){
    var form = $$(form), array_tags=['select', 'input', 'textarea']; KR_AJAX.options.elm = elm; KR_AJAX.options.action = form.action; KR_AJAX.options.method = form.method;
    for(var ta=0; ta<array_tags.length; ta++){var e = form.getElementsByTagName(array_tags[ta]); for(var i=0; i<e.length; i++) if(e[i].name){ if(e[i].type == 'checkbox' && e[i].checked==false) continue; KR_AJAX.set_var(e[i].name, e[i].value);}}
    KR_AJAX.processResponse();
}

function create_preview(el, img){
    if(!$$('showpic')) KR_AJAX.create.element('div', {id:'showpic', className:'showpic', innerHTML:"<img id='showimg' src='includes/images/pixel.gif' style='display:none; margin:2px;' alt='' /><img id='loading_pic_img' src='includes/images/loading/mini_loading.gif' style='margin:30px;' alt='Loading...' />"}, {display:'none', position:'absolute', zIndex:'200'});
    KR_AJAX.set.atrib({onload:function(){$$('loading_pic_img').style.display="none"; this.style.display="";}, src:img}, $$('showimg'));
    $$('showpic').style.display="block"; 
    document.onmousemove = function(e){
        var ps = (typeof e != "undefined") ? {x:e.pageX+15, y:e.pageY+15}:{x:event.clientX+15, y:event.clientY+15};
        KR_AJAX.set.style({left:((KR_AJAX.window.docwidth()-ps.x+KR_AJAX.window.scrollX() < $$('showpic').offsetWidth) ? ps.x + KR_AJAX.window.scrollX() - ($$('showpic').offsetWidth + ps.x - KR_AJAX.window.docwidth() - 4) : ps.x)+'px', top:((KR_AJAX.window.height()-ps.y+KR_AJAX.window.scrollY() < $$('showpic').offsetHeight) ? ps.y + KR_AJAX.window.scrollY() - ($$('showpic').offsetHeight + ps.y - KR_AJAX.window.height() + 4) : ps.y)+'px'}, $$('showpic'));
    }
    el.onmouseout = function(){document.onmousemove = function(){}; $$('showpic').style.display="none"; $$('showimg').style.display="none"; $$('loading_pic_img').style.display="";  document.getElementById('showimg').src='includes/images/pixel.gif';} 
}

var cacheuserinfo = [];
function show_userinfo(el, id){
    if(!$$('showinfo')) KR_AJAX.create.element('div', {id:'showinfo', className:'showuserinfo'}, {display:'none', position:'absolute', zIndex:'200'});                            
    if(!cacheuserinfo[id]) haja({elm:'showinfo', action:'index.php?ajaxed=userinfo', animation:false}, {id:id}, {onstartload:function(){$$('showinfo').innerHTML="<img id='loading_pic_img' src='includes/images/loading/mini_loading.gif' style='margin:30px;' alt='Loading...' />"}, onendload:function(){cacheuserinfo[id]=KR_AJAX.result}});
    else $$('showinfo').innerHTML = cacheuserinfo[id];
    $$('showinfo').style.display="block"; 
    document.onmousemove = function(e){
        var ps = (typeof e != "undefined") ? {x:e.pageX+15, y:e.pageY+15}:{x:event.clientX+15, y:event.clientY+15};
        t = (!KR_AJAX.browser.msie) ? ((KR_AJAX.window.height()-ps.y+KR_AJAX.window.scrollY() < $$('showinfo').offsetHeight) ? ps.y + KR_AJAX.window.scrollY() - ($$('showinfo').offsetHeight + ps.y - KR_AJAX.window.height() + 4) : ps.y) : ps.y+KR_AJAX.window.scrollY();
        KR_AJAX.set.style({
            left:((KR_AJAX.window.docwidth()-ps.x+KR_AJAX.window.scrollX() < $$('showinfo').offsetWidth) ? ps.x + KR_AJAX.window.scrollX() - ($$('showinfo').offsetWidth + ps.x - KR_AJAX.window.docwidth() - 4) : ps.x)+'px', 
            top:t+'px'
        }, $$('showinfo'));
    }        
    
    el.onmouseout = function(){document.onmousemove = function(){}; $$('showinfo').style.display="none";} 
}

function add_goods_update(id, type, pay, symbol_rate){
    var i, sum=0, box, hide, el, sum_arr=[];
    clearTimeout(shop_timeout);
    if(type=='+') KR_AJAX.document.getElementsByClassName('cart_count_'+id, document, 'input', function(e){e.value = parseInt(e.value)+1});
    else KR_AJAX.document.getElementsByClassName('cart_count_'+id, document, 'input', function(e){if(parseInt(e.value)>0) e.value = parseInt(e.value)-1;});    
    KR_AJAX.document.getElementsByClassName('sum_product_'+id, document, 'b', function(e){
            el = KR_AJAX.document.getElementsByClassName('cart_count_'+id, document, 'input');        
            e.innerHTML = (parseInt(el[0].value)*pay).toFixed(2)+' '+symbol_rate;
        }
    );
    box = KR_AJAX.document.getElementsByClassName('cart_count_.*', document, 'input');
    for(i = 0; i < box.length; ++i){
        hide = KR_AJAX.document.getElementsByClassName('hidden_pay_'+box[i].name.replace('cart_count_', ''), document, 'input');
        sum += hide[0].value*parseInt(box[i].value);
    }    
    box = KR_AJAX.document.getElementsByClassName('cart_count_'+id, document, 'input');
    sum = sum/box.length;
    KR_AJAX.document.getElementsByClassName('orders_pay', document, 'div', function(e){e.innerHTML = '<h2 class="price">'+sum.toFixed(2)+' '+symbol_rate+"</h2>";});        
    shop_timeout = setTimeout("set_count_shop()", 1000);    
    return false;
}

function set_count_shop(id, count){
    var ids = [];
    box = KR_AJAX.document.getElementsByClassName('cart_count_.*', document, 'input');
    for(i=0; i<box.length; i++) ids[ids.length] = box[i].name.replace('cart_count_', '')+"|"+box[i].value;
    haja({animation: false, action:'index.php?module=shop&do=set_count_shop'}, {'id':ids}, {
        onstartload:function(){KR_AJAX.document.getElementsByClassName('shopping_cart_loading', document, 'img', function(e){e.style.display = '';});},
        onendload:onendload
    });
    return false;
}

function load_image(obj){
    
    
}

var shop_timeout;
var onendload = function(){
    KR_AJAX.document.getElementsByClassName('shopping_cart_loading', document, 'img', function(e){e.style.display = 'none';});
    KR_AJAX.document.getElementsByClassName('cart_count_.*', document, 'input', function(e){e.className = '';});
    KR_AJAX.document.getElementsByClassName('shopping_cart', document, 'div', function(e){if(KR_AJAX.result) e.innerHTML = KR_AJAX.result;});
}

addEvent(window, 'load', function(){load_module()});
KR_AJAX.addEvent(window, 'load', KR_AJAX.init);
KR_AJAX.addEvent(window, 'load', function(){
    KR_AJAX.include.script("includes/javascript/kr_window.js");
    hack_opera();
});
KR_AJAX.include.style("includes/javascript/highslide/highslide.css");
KR_AJAX.include.style("includes/css/kr_window.css");
//if(KR_AJAX.browser.msie) KR_AJAX.include.script("includes/javascript/pngfix.js");

var upload1; 
function upload_swf_func(upload_url, session_id, user_name, size, mask_types, types_desc, limit, tpl){
    window.upload1 = new SWFUpload({
        upload_url: upload_url,
        post_params: {'PHPSESSID':session_id, 'uname':user_name},
        file_size_limit : size,
        file_types : mask_types,
        file_types_description : types_desc,
        file_upload_limit : limit,
        file_queue_limit : '0',

        file_dialog_start_handler : fileDialogStart,
        file_queued_handler : fileQueued,
        file_queue_error_handler : fileQueueError,
        file_dialog_complete_handler : fileDialogComplete,

        upload_start_handler : uploadStart,
        upload_progress_handler : uploadProgress,
        upload_error_handler : uploadError,
        upload_success_handler : uploadSuccess,
        upload_complete_handler : uploadComplete,

        button_image_url : 'templates/'+tpl+'/images/uplods.png',
        button_placeholder_id : 'spanButtonPlaceholder1',
        button_width: 108,
        button_height: 33,

        flash_url : 'includes/javascript/swfupload/swfupload.swf',
        custom_settings : {progressTarget : 'upload_progress', cancelButtonId : 'cancel'}
    });
}
