function replace_str(find_str,replace_str){
var temp_str = this
replace_location=temp_str.indexOf(find_str)
	while(replace_location!=-1){
			left_str=temp_str.substring(0,replace_location)
			right_str=temp_str.substring(replace_location+find_str.length)
			temp_str=left_str+replace_str+right_str
			start_location=replace_location+replace_str.length
			replace_location=temp_str.indexOf(find_str,start_location)
	}
	return temp_str
}
String.prototype.replace=replace_str

var new_window=Array();
function window_img(img_name,w,h){
var s_w=screen.availWidth;
var s_h=screen.availHeight;

if (w>s_w) w=s_w
if (h>s_h-50) h=s_h-50
w=w*1+17;
h=h*1+4;
w_left=(s_w-w)/2
w_top=(s_h-h)/2
	name=img_name.replace('.','')
	name=name.replace('/','')

window_size="scrollbars=1, height="+h+",width="+w+",left="+w_left+",top="+w_top
	if (!new_window[name]){
		new_window[name] = window.open("/tpl/i.htm?"+img_name,"i"+name,window_size)
	}
	if (new_window[name].closed){
		new_window[name] = window.open("/tpl/i.htm?"+img_name,"i"+name,window_size)
	}
new_window[name].focus()
}

var type_e="id_good[]";
function count_checked(name_form){
check_box=false
cost=0
  for (var i=0; i<name_form.elements.length; i++) {
    e=name_form.elements[i];
    	if (e.name == type_e){
			if(e.checked==true){
				check_box=true
			}
			tr = e;
			while (tr.tagName != 'TR') tr = tr.parentNode;
			thisInputs = tr.getElementsByTagName('input');
			thisTDs = tr.getElementsByTagName('td');
			num_goods=thisInputs[1].value
			if(num_goods>=0 && num_goods<=99){
				}else{
				num_goods=1
				thisInputs[1].value=1
			}
			cost_this=thisTDs[3].innerHTML
			cost_sum=parseInt(cost_this)*parseInt(num_goods)
			thisTDs[5].innerHTML='<div>'+cost_sum+'</div>'
				cost+=cost_sum
    	}
  }

if(check_box==true){
name_form.del.disabled=false
	}else{
	name_form.del.disabled=true
	}
document.getElementById("all_sum").innerHTML=cost+' <span style="font-size:12px">'+currency+'</span>'
}
function check_uncheck_all(name_form,regim){
  for (var i=0; i<name_form.elements.length; i++) {
    e=name_form.elements[i];
    	if (e.name == type_e){
    		if(regim==false){
      			e.checked=false
				} else { e.checked=true}
    	}
  }
count_checked(name_form)
}

function check_email(email){
	var reg_email=/^(([a-z]{1})|([a-z]{1}[0-9a-z_-]{0,18}[0-9a-z]{1}))+@([0-9a-z_-]+\.){1,3}[a-z]{2,4}$/i
	if (reg_email.test(email)){
		return true;   
	}
}
