//hide all and display one
function ToggleDisplayAllOne(arrElements, dIndex) {

	var visEl=document.getElementById(arrElements[dIndex]);
	for (i = 0; i < arrElements.length; i++) {
	    document.getElementById(arrElements[i]).style.display = "none";
	}
	visEl.style.display = "block";

	//if (ie || ns)
	//	document.getElementById(arrElements[i]).style.display="none";
	//else
    //	document.getElementById(arrElements[i]).display="none";

	//if (ie || ns)
	//    visEl.style.display = "block";
	//else 
    //    visEl.display = "block";
}
//hide or display one
function ToggleDisplayStyle(elemId)
{
	var El=document.getElementById(elemId);	
	if (!El) return;
	if (ie || ns)
		if (El.style.display == "none") El.style.display = "block"; else El.style.display = "none";
	else
		if (El.style.display == "none") El.display = "block"; else El.display = "none";
}
function OpenDialog(url,width,height,resizable)
{
	var mv = window.open(url,"_blank","height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable="+resizable); 
	centerWindow(width,height,mv);
	if (mv)mv.focus();		
}
function storeCaret(textEl) {if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();}
function CheckBoxValidator(check, boxid)
{	
	var helperbox = document.getElementById (boxid);
	if (check.checked)
		helperbox.value = "on";
	else
		helperbox.value = "";
}
function Redirect(url){window.location=url;}
function Popup(query_string, action, redirect_url)
{	
	if (query_string != undefined) query_string = query_string + '&';

	var mv = window.open("/Popup.aspx?" + query_string + "action=" + action, "_blank", "height=200,width=300,left=300,top=250,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,fullscreen=no,channelmode=no,resizable=no"); 
	centerWindow(300,200,mv);
	mv.focus();
	if (redirect_url != undefined) window.location.href = redirect_url;
}
function NewWindow(url, params)
{	
	var mv = window.open(url, "_blank", params);	
	mv.focus();
	return true;
}
function centerWindow( nWidth, nHeight, wind)
{
    var nPosX;
    var nPosY;
    
    nPosX = Math.ceil( (screen.width - nWidth ) / 2 );
    nPosY = Math.ceil( (screen.height - nHeight ) / 2 );
    
    if(wind != null) wind.moveTo( nPosX, nPosY );
}
function getCookie (name) {
	var dc = document.cookie;
	var cname = name + "=";
	var clen = dc.length;
	var cbegin = 0;

	while (cbegin < clen) { 
	var vbegin = cbegin + cname.length;

	if (dc.substring(cbegin, vbegin) == cname) { 
		var vend = dc.indexOf (";", vbegin);
		if (vend == -1) vend = clen;

		return unescape(dc.substring(vbegin, vend));
	}
	cbegin = dc.indexOf(" ", cbegin) + 1;
	if (cbegin== 0) break;
	}
	return null;
}
function setCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName + "=''";
 document.cookie = cookieName + "=" + escape(cookieValue) + ";path=/;expires=" + expire.toGMTString();
}
function encodeMyHtml(source) {
     encodedHtml = escape(source);
     encodedHtml = encodedHtml.replace(/\//g,"%2F");
     encodedHtml = encodedHtml.replace(/\?/g,"%3F");
     encodedHtml = encodedHtml.replace(/=/g,"%3D");
     encodedHtml = encodedHtml.replace(/&/g,"%26");
     encodedHtml = encodedHtml.replace(/@/g,"%40");
     return encodedHtml;
   } 

/*function SetSelectedCount(table,count)
{
	var tableid = table.id;	
	var box =  document.getElementById(tableid.substring(0,tableid.indexOf("Control")) + "SubControl" + tableid.substring(tableid.indexOf("Control")+7, tableid.length));
			
	var j=0;
	for (var i=0; i<count; i++)
	{
		var input = document.getElementById(tableid + '_' + i);
		if (input.checked)
			j++;	
	}
	(j==0)? box.value='' : box.value="checked";
	window.status=box.value;
}
function SetComment(labelname,value)
{document.getElementById(labelname).value = value;}  */      
                     
//get browser name
var ie = false;
var op = false;
var ns = false;
if (navigator.appVersion.charAt(0) >= "4")
{
	if (navigator.userAgent.indexOf("Opera") > -1)   
		op = true;		
	if (navigator.userAgent.indexOf("Netscape")> -1)
		ns = true;
	if (navigator.userAgent.indexOf("MSIE") > -1)
		ie = true;
}
