var idSelectedRight='';
var openedTMobject;
var openedTYPEobject;

function opencloseTM(a) {
    if (openedTMobject) openedTMobject.className = 'hid';
    a.className = 'vis';
    openedTMobject = a;
}

function opencloseTYPE(a) {
    if (openedTYPEobject) openedTYPEobject.className = 'hid';
    a.className = 'vis';
    openedTYPEobject = a;
}

function product_div_switch(object,objectmenu) {
    if (document.all.prod_menu_descr) document.all.prod_menu_descr.className = 'prod';
    if (document.all.prod_menu_effect) document.all.prod_menu_effect.className = 'prod';
    if (document.all.prod_menu_using) document.all.prod_menu_using.className = 'prod';

    if (document.all.prod_descr)
	if (document.all.prod_descr.className=='vis') document.all.prod_descr.className = 'hid';
    if (document.all.prod_effect) 
	if (document.all.prod_effect.className=='vis') document.all.prod_effect.className = 'hid';
    if (document.all.prod_using) 
	if (document.all.prod_using.className=='vis') document.all.prod_using.className = 'hid';

    object.className='vis';
    objectmenu.className='prod_sel';
}

function submitViaEnter(evt,a) {
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13 || charCode == 3) {
            do_search(a);
    }
}

function do_search(a) {
	if (document.all.str.value!='') {
		document.all.search_str.value=document.all.str.value;
		document.forms['searchform'].submit();
	} else alert(a);
}

function IsDigit( e )
{
	if ( !e )
		e = event ;

	var iCode = ( e.keyCode || e.charCode ) ;
	
	return (
			( iCode >= 48 && iCode <= 57 )		// Numbers
			|| (iCode >= 37 && iCode <= 40)		// Arrows
			|| iCode == 8				// Backspace
			|| iCode == 46				// Delete
	) ;
}

function change_left(menu_object,object,cl,left,top)
{
/*    if (cl=='vis') {
	if (menu_object.style.background=='#f0f0f0') idSelectedRight=menu_object.id;
	menu_object.style.background='#f9f9f9';
    } else {
	if (idSelectedRight==menu_object.id) menu_object.style.background='#F0F0F0';
	else menu_object.style.background='#FFFFFF';
    }
*/
    var offsetTrail = menu_object;
    var offsetLeft = left;
    var offsetTop = top;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    object.style.left=offsetLeft;
    object.style.top=offsetTop+19;
    object.className=cl;
}


function change(t,menu_object,object,cl)
{
    var offsetTrail = menu_object;
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    object.style.left=offsetLeft;
    object.style.top=offsetTop+19;
    object.style.width=screen.availWidth-220;
    object.className=cl;
    if (cl=='vis') t.style.background='#f0f0f0';
    else t.style.background='#ffffff';
}

function hide_visible(object)
{
	if (object.className=='vis') object.className='hid'; else object.className='vis'; 
}

function openOrder(){
	var width = 650;
	var height = 550;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
	window.open("","order","top="+top+",left="+left+",width="+width+",height="+height+",menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=no",true);
}

function checkform_order() {
	if (document.all.fio.value=="") {alert("Âû íå çàïîëíèëè ïîëå ÊÎÍÒÀÊÒÍÎÅ ËÈÖÎ");return false;}
	else if (document.all.tel.value=="") {alert("Âû íå çàïîëíèëè ïîëå ÒÅËÅÔÎÍ"); return false;}
	else if (document.all.email.value=="") {alert("Âû íå çàïîëíèëè ïîëå ÝËÅÊÒÐÎÍÍÛÉ ÀÄÐÅÑ"); return false;}
	else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.all.email.value)) { return true } 
	else {
		alert('Íåâåðíûé àäðåñ ïî÷òû.\nÏîïðîáóéòå åùå ðàç.'); document.all.email.select();
		return false;
	}
	return true;
}

