﻿function SwitchMenu(menuId, submenuId, animationId) {
	var de = document.documentElement;
	var largura = screen.width;
	var larguraCorpo = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
	var i;
	var m, s;
	var menu = document.getElementById(menuId);
	var submenu = document.getElementById(submenuId);

	for (i = 0; i < 20; i++) {
		m = document.getElementById('subMenuHome_' + i);
		s = document.getElementById('subMenuHomeTable_' + i);
		if (m != null) {
			if (m.id != menuId) {
				m.style.display = "none";
				m.style.height = "0px";
				m.style.width = "900px";
				if (s != null) {
					s.style.height = "0px";
					s.style.display = "none";
				}
			}
		}
	}

	if (menu != null) {
		if (menu.style.display == "none") {
			if (largura > 900) {
				menu.style.left = ((largura / 2) - (900 / 2)) + "px";
			}
			objAnimation = $find(animationId).get_OnClickBehavior().get_animation();
			objAnimation.play();
		}
		else {
			menu.style.display = "none";
			menu.style.height = "0px";
			menu.style.width = "900px";
			if (submenu != null) {
				submenu.style.height = "0px";
				submenu.style.display = "none";
			}
		}
	}
	return false;
}

function BtnClick(validationGrp,borderColor) {
    var val = Page_ClientValidate(validationGrp);
    var obj;
    var sty;
    var ctl = "";
    if (!val) {
        var i = 0;
        for (; i < Page_Validators.length; i++) {
            obj = document.getElementById(Page_Validators[i].controltovalidate);
			if(Page_Validators[i].validationGroup==validationGrp)
			{
				if (!Page_Validators[i].isvalid) {
					sty = "1px solid red";
				}
				else {
					if (Page_Validators[i].controltovalidate != ctl) {
						sty = "1px solid " + borderColor;
					}
				}
	
				obj.style.border = sty;
				ctl = Page_Validators[i].controltovalidate;
			}
        }
    }
    return val;
}

function SelectAll(textbox) {
    var txt = document.getElementById(textbox);

    txt.focus();
    txt.select();
}

