var RND=parseInt(Math.random()*100000);




function addTR(begin) {

colls=4; // кол-во столбцов

if (begin=='1') { 
		beginTD++;
		if (beginTD==1) document.write('<tr valign=top1>');
	}
	
else {	

		if (beginTD==colls) {
			document.write('</tr><tr height=20><td colspan=4>&nbsp;</td></tr>');
			beginTD=0;
		}

	}


}


function addzakaznumber(){
var time = new Date()
var day1 = time.getSeconds()  
var day2 = time.getMinutes()
var day3 = time.getHours()
var day4 = time.getDate();
var day5 = time.getMonth();
var day6 = time.getFullYear();

addate=day3+'.'+day2+'.'+day1+'-'+day4+'.'+day5+'.'+day6
order.number.value=addate;

}


function ShowBigFoto(img){
 
	var title = "Большое изображение ";
	var width=800; 
	var height=510; 
	
	 
	var p_top=0;
	var p_left=0;
	var imgnwin=window.open("","imgswin","resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height+",top="+p_top+",left="+p_left);
	imgnwin.document.write("<html><title>"+title+"</title><body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0><center><img id=mypic src='"+img+"' border=0 onclick='javascript:self.close();' onload='window.resizeTo(mypic.width+40, mypic.height+70);'><br></center><script></script></body></html>")
	imgnwin.focus();

}





function show_img(title,width,height,s_url){
	var imgnwin=window.open("","imgswin","resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height);
	imgnwin.document.write("<html><title>"+title+"</title><body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0><center><img src='"+s_url+"' border=0></center></body></html>")
}

function show_win(width,height,s_url){
	var p_top=(window.screen.height-height)/2, p_left=(window.screen.width-width)/2;
	var imgnwin=window.open(s_url,"imgswin","resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height+",top="+p_top+",left="+p_left);
	imgnwin.focus();
}

function active_win(surl){
	window.opener.document.location=surl;
}

function set_check(p,v){ if (p!=null && p.value==v) p.checked=true; }

function set_selected(p,v){
	for (i=0; i < p.options.length; i++) {
		if (p.options[i].value==v) { p.options[i].selected=true; break; }
	}
}

function check_forum(){
	if (document.forum.gbsubj!=null && document.forum.gbsubj.value=='') document.forum.gbsubj.value=check_field(document.forum.gbmess.value,false);
	if (document.forum.gbmess.value=='') { alert("Необходимо ввести текст вопроса!"); return false; }
	document.forum.gbname.value=check_field(document.forum.gbname.value,true);
	document.forum.gbemail.value=check_field(document.forum.gbemail.value,true);
	//document.forum.gbwww.value=check_field(document.forum.gbwww.value,true);
	document.forum.gbmess.value=check_field(document.forum.gbmess.value,false);
	return true;
}

function check_field(v,flag_aps){
	var ch,ret='';
	for(var i=0; i<v.length; i++) {
		ch=v.substring(i,i+1);
		if (ch=='<' || ch=='>') continue;
		if (flag_aps && ch=='\'') continue;
		ret+=ch;
	}
	return ret;
}

function ejob(){
document.write("<a href='mailto:rabota@osg.ru?subject=Job'>e-mail с пометкой Job в поле Subject</a>")
}

function show_div(id_cur){
    var div_set=null;
    div_set=document.getElementById(id_cur);
    if (div_set!=null) {
        if (div_set.style.display=="block") div_set.style.display="none";
        else div_set.style.display="block";
    }
}

function set_selected(p,v){
	for (i=0; i < p.options.length; i++) {
		if (p.options[i].value==v) { p.options[i].selected=true; break; }
	}
}

function set_radio(p,v){
	for (i=0; i < p.length; i++) {
		if (p[i].value==v) { p[i].checked=true; break; }
	}
}

function set_checked(p,v){
	if (p.value==v) p.checked=true; 
}

function CreateCookie(name,value,ex_date){
	var today=new Date();
	today.setDate(today.getDate()+ex_date);
	document.cookie=name+"="+value+"; expires="+today.toGMTString()+"; path=/;";
}

function CreateTmpCookie(name,value){
	document.cookie=name+"="+value+"; path=/;";
}

function RemoveCookie(name){
	CreateCookie(name,"",-1);
}

function SetCompare(obj,id_goods){
	if (!obj.checked) RemoveCookie("idg"+id_goods); else CreateTmpCookie("idg"+id_goods,id_goods);
}

function SpellCompare(obj){
	var str="";
	var start_IDG=0;
	var end_IDG=-1;
	var break_point=0;
	var flag;
	while (start_IDG!=-1){
		start_IDG=document.cookie.indexOf("idg",start_IDG);
		end_IDG=document.cookie.indexOf("=",start_IDG);
		if (start_IDG==-1 || end_IDG==-1) break;
		idg=unescape(document.cookie.substring(start_IDG+3,end_IDG));
		start_IDG=end_IDG;
		flag=false;
		//alert("idg="+idg+" , obj.idg.length="+obj.idg.length);
		if (isNaN(obj.idg.length)) { 
			if (obj.idg.value==idg) { obj.idg.checked=true; flag=true; }
		}
		else {
			for (i=0;i<obj.idg.length;i++) {
				if (obj.idg[i].value==idg) { obj.idg[i].checked=true; flag=true; break; }
			}
		}
		//alert("flag="+flag);
		if (!flag) { 
			//alert("!!! idg="+idg);
			str+="<input type=hidden name=idg value="+idg+">"
		}
		break_point++; if (break_point>10) break;
	}
	return str;
}

function normalize(price)
{	var pr, str;
	pr=parseInt(Math.round(price*100));
	str = new String(pr);
	pr="";
	if (str.length>2)
		pr += str.substring(0, str.length-2);
	else
		pr += "0";
	return pr;
}


flag_row=0;
function s_tr(){
	var strTR;
	if (flag_row==1)	{ strTR="<tr bgcolor=#E7E7E7 align=center>"; flag_row=0; } 
	else							{ strTR="<tr align=center>"; flag_row=1; }
	document.write(strTR);
}

s_td_flag=1;
function s_td(n_class)
{	
	if (n_class=="e_name") {
		if (!s_td_flag) s_td_flag=1; 
		else s_td_flag=0;
	}
	document.write("<td class='" + n_class + s_td_flag + "'>");
}

function logoff(file_templ,idc,stype,page,idr,idt,idn,idg){
	RemoveCookie("login");
	RemoveCookie("pass");
	RemoveCookie("userid");
	document.location='/'+ file_templ +'?idc='+idc +'&stype='+stype +'&page='+page +'&idr='+idr +'&idt='+idt +'&idn='+idn +'&idg='+idg +'&r='+RND;
	//location.reload();
}

function w_send(){
	document.write('<input type=hidden name=s_ch value=\"'+s_ch+'\"><input type=hidden name=s_cf value=\"'+s_cf+'\">');
}