function pic(p)
{
	if(p==4)
			location="http://www.transkom-n.ru"
	else	
		location="/produkt"
}
function f(p)
{
	//alert(p)
	//return false;
	if(p==1)	
		location="/filial/novosibirsk"
		
	if(p==5)	
		location="/filial/krasnoyarsk"
	if(p==4)	
		location="/filial/habarovsk"
	if(p==6)	
		location="/filial/irkutsk"
	if(p==3)	
		location="/filial/omsk"
	if(p==2)	
		location="/filial/novokuzneck"
	if(p==7)
		location="/filial/rostov"
	if(p==8)
		location="/filial/ekaterinburg"
	if(p==9)
		location="/filial/barnaul"

	if(p==10)	
		location="/"
		

}
function menuicon(id, f)
{
	// 
	//alert(document.getElementById(id+"j").src)
	if(document.getElementById(id+"j").src.indexOf("__")!=-1)
	{
		//alert(f)//
		//document.getElementById(id+"j").src="/img/icon_sel_2.png"
		document.getElementById(id+"j").src=document.getElementById(id+"j").src.replace("__", "_sel_")
	}
	else
		if(document.getElementById(id+"k").className!="menu_sel")
			document.getElementById(id+"j").src=document.getElementById(id+"j").src.replace("_sel_", "__")
}
function menuicon2(id, obj)
{
	
	if(obj.className!="menu_sel")
	{
	//	alert("ok")
		if(document.getElementById(id+"j").src.indexOf("__")!=-1)
			document.getElementById(id+"j").src=document.getElementById(id+"j").src.replace("__", "_sel_")
		else
			document.getElementById(id+"j").src=document.getElementById(id+"j").src.replace("_sel_", "__")
	}
}
		
function isIt(input, it)
{
	if(it=="empty")
	{
		check= new Array(" ",  "	");	
		if(input=="")
			return true
	}	
	if(it=="digit")
		check= new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0);	
	if(it=="charOrDigit")
 		check= new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, "q", "w", "e",  "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m");

for (var i = 0; i < input.length; i++)
  {
    var chr = input.charAt(i);
    var found = false
    for (var j = 0; j < check.length; j++) 
      if (chr == check[j]) found = true
    if (!found) return found
   }
   return found
}
function showdv(what, callback)
{
//	alert(document.getElementById("v"+what).style.display="block")
//		return
/*
	if(document.getElementById("v"+what).style.display=="block")
		document.getElementById("v"+what).style.display="none"
	else
		document.getElementById("v"+what).style.display="block"
	*/
   callback = callback || function() {};
   $("#v" + what).slideToggle(1000, callback);
}

function changeLinkText() {
	var id = $(this).attr('id').replace(/v(.*)-1/, "$1");
	$("#v" + id + "-2").text(($(this).css('display') == 'none' ? "����������� �� ��������" : "������� �����"));
}

function changeLinkTextTender() {
	var id = $(this).attr('id').replace(/v(.*)-1/, "$1");
	$("#v" + id + "-2").text(($(this).css('display') == 'none' ? "����������� �� ������" : "������� �����"));
}


function show(what, vis)
{
	document.getElementById(what).style.display=vis
}
function showgoods(id)
{
	window.open('/show.php?id='+id,'_blank','left='+((document.body.clientWidth-850)/2)+', top=200, width=850px,height=560px,location=no,toolbar=no,status=no,scrollbars=yes'); 

}
function bigphoto(obj)
{
	var str=obj.src.toString()
	document.getElementById('mainphoto').src=str.replace('/1/', '/3/')
}

function Kariera(id) {
	var self = this;
	$('#v' + id + '-1').ajaxForm({
		beforeSubmit: function (a, f, o) {
			var errorText = '����������, ��������� ��� ���� �����!';
			var elems = Array('fio', 'experience', 'age', 'email', 'phone');
			for (i in elems) {
				var el = f.find('[name=' + elems[i] + ']');
				if (el.val() == '') {
					alert(errorText);
					el.focus();
					return false;
				}
			}
		},
		url: "/kariera?t=ajax",
		dataType: 'json',
		success: function (data) {
			if (data.status == 'ok') {
				$('#v' + id + '-2').remove();
				$('#v' + id + '-1').replaceWith("<div style='color: red;'>" + data.message + "</div>");
			} else {
				alert(data.message);
			}
		}
	});
}
function Tender(link) {
	var self = this;
	$.fn.ajaxSubmit.debug = true;
	$('#vt-1').ajaxForm({
		beforeSubmit: function (a, f, o) {
			var ret = true;
			$("input.required").each(function () {
				if ($.trim($(this).val()) == '') {
					alert('��������� ���� "' + $("span.f-" + $(this).attr('name')).text() + '"');
					$(this).focus();
					ret = false;
					return false;
				}
			});
			return ret;
		},
		url: "/tenders/" + link + "?t=ajax",
		dataType: 'json',
		iframe: true,
		error: function (XMLHttpRequest) {
			alert('error');
		},
		success: function (data) {
			if (data.status == 'ok') {
				$('#vt-2').remove();
				$('#vt-1').replaceWith(data.message);
			} else {
				alert(data.message);
			}
		}
	});
	
}

