
    var windowDiscussionInfo = null;
	var curPopupWindow = null;
		
    /*function ShowDiscussions(project_id, project_title) {
        var h = 250;
        var w = 250
        var wint = (screen.height-h)/2;
        var winl = (screen.width-w)/2;
        var settings ='height=' + h + ',';
        settings +='width=' + w + ',';
        settings +='top=' + wint + ',';
        settings +='left=' + winl + ',';
    	windowDiscussionInfo = window.open('http://www.hellobrain.com/collab/discussion.asp' + '?pid=' + project_id + '&ptitle=' + project_title,'Discussions',settings);
    }
    
    function sendDiscussionInfo(group_id) {
    	window_onfocus();
      window.location.href="http://www.hellobrain.com/collab/msgframes.asp?dgid=" + group_id;
    }
            
    function window_onfocus() {
    	// Make sure the "Discussions" window is closed.
    	if ( windowDiscussionInfo ) {
    		if ( !windowDiscussionInfo.closed ) {
    			windowDiscussionInfo.close();
    		}
    		windowDiscussionInfo = null;
    	}
    }


	function MM_openBrWindow(theURL,winName,features) { //v2.0
	 window.open(theURL,winName,features);
	}
*/ 
	var	selected = new Array();
	var	hilited = new Array(4);
	hilited[0] = -1;
	hilited[1] = -1;
	hilited[2] = -1;
	hilited[3] = -1;
	var	timer = null;

	var	docObj = "document.";
	var	styleObj = "";
	if (document.all) {
		docObj = "document.all.";
		styleObj = ".style";
	}
	function setClearTime() {
		if (timer) clearTimeout(timer);
		timer = null;
		timer = setTimeout("clearMenus()",600);
	}
	function cancelClearTime() {
		if (timer) clearTimeout(timer);
		timer = null;
	}
	function clearMenus() {
		var	i,e;
		for (i = 0; i < selected.length; i++) {
			e = selected[i];
			if (e != "undefined") {
				elempt = eval(docObj+"sO" + e + styleObj);
				if (elempt != null) {
					elempt.visibility = "hidden";
					showFormFields(e);
				}
			}
		}
		selected.length = 0;
	}
	
	function clearMenus1(j) {
		var	i,e;
		styleObj = ".style";
		//styleObj =" ";
		//for (i = 0; i < selected.length; i++) {
			e = j;
			if (e != "undefined") {
				elempt = eval(docObj+"sO" + e + styleObj);
				if (elempt != null) {
					elempt.visibility = "hidden";
					//showFormFields(e);
				}
			}
		//}
		//selected.length = 0;
	}
	
	function doIMouseClick(i) {
		document.location = "stylePage.asp?RN="+i;
		return true;
	}
	function doIMouseOut(cdiv) {
		setClearTime();
	}
	function clearOtherMenus(lev) {
		if (selected.length > lev) {
			e = selected[lev];
			if (e != "undefined") {
				elempt = eval(docObj+"sO" + e + styleObj);
				if (elempt != null) {
					elempt.visibility = "hidden";
					showFormFields(e);
				}
			}
			for (k = lev+1; k < selected.length; k++) {
				e = selected[k];
				if (e != "undefined") {
					elempt = eval(docObj+"sO" + e + styleObj);
					if (elempt != null) {
						elempt.visibility = "hidden";
						showFormFields(e);
					}
				}
			}
			selected.length = lev;
		}
		for (k = lev+1; k < 4; k++) {
			if (hilited[k] != -1) {
				elempt = eval(docObj+"cell" + hilited[k] + styleObj);
				if ((elempt != null)&&(elempt.type != "undefined")) {
					elempt.background = "#FFFFCC";
				hilited[k] = -1;
				}
			}
		}
	}
	function doTMouseOver(lev,cdiv,src) {
		var	elempt;
		if (cdiv != "undefined") {
			if (hilited[lev] != cdiv) {
				if (hilited[lev] != -1) {
					elempt = eval(docObj+"cell" + hilited[lev] + styleObj);
					if ((elempt != null)&&(elempt.type != "undefined")) {
						elempt.background = "#FFFFCC";				
					}
				}
				elempt = eval(docObj+"cell" + cdiv + styleObj);
				if ((elempt != null)&&(elempt.type != "undefined")) {
					elempt.background = "LIGHTGREY";
					hilited[lev] = cdiv;
				}
			}
		}
		clearOtherMenus(lev);

		cancelClearTime();
	}

	function doIMouseOver(i,lev,ccc,src) {
		var	k,e;
		var	elempt;
		var	OK = false;
		if (i == -1) clearOtherMenus(lev);
		else {
		if (ccc == -1) OK = true;
		else {
			elempt = eval(docObj+"sO" + src + styleObj);
			OK = (elempt.visibility == "visible");
		}
		clearOtherMenus(lev);
		hideFormFields(i);
		if (hilited[lev] != ccc) {
			if (hilited[lev] != -1) {
				elempt = eval(docObj+"cell" + hilited[lev] + styleObj);
				if ((elempt != null)&&(elempt.type != "undefined")) {
					elempt.background = "#FFFF66";
					hilited[lev] = -1;
				}
			}
		}
		if (ccc == "undefined") ccc = -1;
		if (ccc != -1) {
			elempt = eval(docObj+"cell" + ccc + styleObj);
			if (elempt != null) {
				elempt.background = "#FFFFCC";
				hilited[lev] = ccc;
			}
		}
		if (OK) {
			if (i != "undefined") {
				elempt = eval(docObj+"sO" + i + styleObj);
				if ((elempt != null)&&(elempt.type != "undefined")) elempt.visibility = "visible";
				selected[lev] = i;
			}
			cancelClearTime();
		}
		}
	}
	
	function doIMouseOver1(i,lev,ccc,src) {
		var	k,e;
		var	elempt;
		var	OK = false;
		//if (i == -1) clearOtherMenus(lev);
		//else
		 {
		if (ccc == -1) OK = true;
		else {
			elempt = eval(docObj+"sO" + src + styleObj);
			OK = (elempt.visibility == "visible");
		}
		//clearOtherMenus(lev);
		hideFormFields(i);
		if (hilited[lev] != ccc) {
			if (hilited[lev] != -1) {
				elempt = eval(docObj+"cell" + hilited[lev] + styleObj);
				if ((elempt != null)&&(elempt.type != "undefined")) {
					elempt.background = "#FFFF66";
					hilited[lev] = -1;
				}
			}
		}
		if (ccc == "undefined") ccc = -1;
		if (ccc != -1) {
			elempt = eval(docObj+"cell" + ccc + styleObj);
			if (elempt != null) {
				elempt.background = "#FFFFCC";
				hilited[lev] = ccc;
			}
		}
		if (OK) {
			if (i != "undefined") {
				elempt = eval(docObj+"sO" + i + styleObj);
				if ((elempt != null)&&(elempt.type != "undefined")) elempt.visibility = "visible";
				selected[lev] = i;
			}
			cancelClearTime();
		}
		}
	}

	function hideFormFields(i) {
		maskFields(i, "SELECT",   "hidden");
		//maskFields(i, "INPUT",    "hidden");
		//maskFields(i, "TEXTAREA", "hidden");
	}

	function showFormFields(i) {
		maskFields(i, "SELECT",   "");
		//maskFields(i, "INPUT",    "");
		//maskFields(i, "TEXTAREA", "");
	}

	function maskFields(i, fieldType, mask) {
		if (!document.all) return;
		divObj = document.all["sO" + i];
		x = divObj.offsetLeft;
		y = divObj.offsetTop;

		for (i = 0; i < document.all.tags(fieldType).length; i++) {

			obj = document.all.tags(fieldType)[i];
			if (! obj || ! obj.offsetParent)
				continue;

			fy = obj.offsetTop;
			if (fy > 300)
				continue;	//triage
			fx = obj.offsetLeft;
			objParent = obj.offsetParent;
			while (objParent.tagName.toUpperCase() != "BODY") {
				fx += objParent.offsetLeft;
				fy += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}

			if (!((x > fx + obj.offsetWidth) || (x + divObj.offsetWidth < fx) || 
			      (y > fy + obj.offsetHeight) || (y + divObj.offsetHeight < fy)))
				obj.style.visibility = mask;
		}
	}

	function showFields(fieldType) {
		if (!document.all) return;
		for (i = 0; i < document.all.tags(fieldType).length; i++) {
			obj = document.all.tags(fieldType)[i];
			if (! obj || ! obj.offsetParent)
				continue;
			obj.style.visibility = "";
		}
	}
	
	function mOvr(src,clrOver){ 
		if (!src.contains(event.fromElement)){ 
			src.style.cursor = 'hand'; 
			src.bgColor = clrOver; 
			//alert(clrOver);
		} 
	} 
function mOut(src,clrIn){ 
		if (!src.contains(event.toElement)){ 
			src.style.cursor = 'default'; 
			src.bgColor = clrIn; 
		} 
	} 
function mClk(src){ 
	if(event.srcElement.tagName=='TD')
		src.children.tags('A')[0].click();
	}
function helpWin(p_helpfile)
	{
		if (arguments.length == 0)
			p_helpfile="help.htm"
		w = window.open(p_helpfile,"answerWindow","scrollbars =1,width=600,height=400,resizable=1")
	} 
	//formName,parentEditElementName,display
function lookupPick2(str,str1) {
	if (str1=="case")
		str1 = "case1";
	var temp_var = "document.form1."+str1;
	alert("Temp Value-->"+temp_var);
	eval(temp_var + ".value = " + "\"" + str +"\"");    
	//alert(eval(temp_var + ".value = " + "\"" + str +"\""));
		
}	
	
function lookupPick1(str,str1,str2) {
	//var temp_var = "document.form1."+str1;
	//alert("Temp Value-->"+temp_var);
	alert("The L String-->"+str2)
	//str2.document.close());
	top.close();
	alert("The String-->"+str)
	document.account1.account.value=str;
	//eval(temp_var + ".value = " + "\"" + str +"\"");    
	
		
}	
		
function chkTime(obj1)
{	
	var str;
	var len;
	var pos;
	str = obj1;
	if ((str!="00.00")&&(str != "") &&(str != "0")&&(str != "00"))
	{
		len = str.length;
		pos=str.indexOf(".");
		if ( pos != "-1" )
		{
			var m_hr=str.substring( 0,pos );
			var m_min=str.substring( pos+1,5);
		}
			
		else 
		{
			var m_hr = str;
			var m_min = "0";
		}
	
		if ( (isInt(m_hr)) || (isInt(m_min)) )
		{
			
			if ( (m_hr!="") && (m_hr >= 1) && (m_hr <= 12)&& (m_min >= 0) && (m_min <= 59 ))
				{
					//concat()
					//alert("Valid Time");
				return false ;	
				}
			else
				{
					//alert("Invalid Time");
					//document.form1.m_appt1.focus();
				return true;	
				}
		}
	
	}//end of if (str!="")
}	//end of chkTime function

function isInt(obj){

	var newValue = obj;
	var newLength = newValue.length;
	for(var i = 0; i<newLength;i++){
		aChar =  newValue.substring(i,i+1);
		if(aChar <"0" || aChar > "9"  ){
			
			return false;
		}	
	}
	return true;
}

function get_value(t_value,t_table,t_media){
			
	m_href= "listdata.asp?m_value=" + escapeUTF(t_value) +"&m_table="+t_table+"&m_media="+t_media
	curPopupWindow  = window.open(m_href,"myWindow1","scrollbars=0,titlebar=1,toolbar=0,top=210,left=175,height=220,width=400",true)
	
	}

function get_value1(t_value,t_table,t_media){
			
	m_href= "listdata2.asp?m_value=" + escapeUTF(t_value) +"&m_table="+t_table+"&m_media="+t_media
	curPopupWindow  = window.open(m_href,"myWindow1","scrollbars=0,titlebar=1,toolbar=0,top=210,left=175,height=220,width=400",true)
	
	}

function get_connection(t_value,t_table){
			
	m_href= "chk_conn.asp?m_value=" + escapeUTF(t_value) +"&m_table="+t_table
	curPopupWindow  = window.open(m_href,"myWindow1","scrollbars=0,titlebar=1,toolbar=0,top=210,left=175,height=220,width=400",true)
	
	}
	
function get_query(t_value,t_table,t_conn){
			
	m_href= "chk_sql.asp?m_value=" + escapeUTF(t_value) +"&m_table="+t_table+"&m_conn="+t_conn
	curPopupWindow  = window.open(m_href,"myWindow1","scrollbars=0,titlebar=1,toolbar=0,top=210,left=175,height=220,width=400",true)
	
	}

function get_description(t_value,t_table){
			
	m_href= "prj_desc.asp?m_value=" + escapeUTF(t_value) +"&m_table="+t_table
	curPopupWindow  = window.open(m_href,"myWindow1","scrollbars=0,titlebar=1,toolbar=0,top=210,left=175,height=220,width=400",true)
	
	}

//function get_value1(t_value,t_table,t_media,t_field){
    //alert("Field->"+t_field);
//	m_href= "listdata1.asp?m_value=" + escapeUTF(t_value) +"&m_table="+t_table+"&m_media="+t_media+"&m_field="+t_field
//	curPopupWindow  = window.open(m_href,"myWindow1","scrollbars=0,titlebar=1,toolbar=0,top=210,left=410,height=220,width=280",false)
//	}
	
	
function lookupPick(str,str1) {
	
	var temp_var ="top.window.opener.document.form1."+str1;
	eval(temp_var + ".value = " + "\"" + str +"\"");    
	//eval(temp_var + ".focus()");    
		
}
			
function lookupPickk(m_value,str,str1) {
	
	var temp_var ="top.window.opener.document.form1."+str1;
	eval(temp_var + ".value = m_value + " + "\"" + str +"\"");    
	//eval(temp_var + ".focus()");    
}
function closePopup() {
	if (curPopupWindow != null) {
	   
		if (!curPopupWindow.closed) {
			curPopupWindow.close();
		}
		curPopupWindow = null;
	}
}
function lookupPickA(str,str1) {
	var temp_var = "document.form1."+str1;
	alert("Temp Value-->"+temp_var);
	eval(temp_var + ".value = " + "\"" + str +"\"");    
	//alert(eval(temp_var + ".value = " + "\"" + str +"\""));
		
}	
function closePopup() {
	if (curPopupWindow != null) {
	   
		if (!curPopupWindow.closed) {
			curPopupWindow.close();
		}
		curPopupWindow = null;
	}
}

function escapeUTF(src) {
	var ret = "";
	for (i = 0; i < src.length; i++) {
		var ch = src.charCodeAt(i);
		if (ch <= 0x7F) {
			ret += escape(src.charAt(i));
		} else if (ch <= 0x07FF) {
			ret += '%' + ((ch >> 6) | 0xC0).toString(16) + '%' + ((ch & 0x3F) | 0x80).toString(16);
		} else if (ch >= 0x0800) {
			ret += '%' + ((ch >> 12) | 0xE0).toString(16) +
				   '%' + (((ch >> 6) & 0x3F) | 0x80).toString(16) + '%' + ((ch & 0x3F) | 0x80).toString(16);
		}
	}
	return ret;
}

function isValidEmail(emailad) {
	if (emailad !="")
	{
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,3}$/;

		if(((emailad.search(exclude) != -1) ||
		    (emailad.search(check)) == -1) ||
		    (emailad.search(checkend) == -1)){
		   return false;
		} else {
		   return true;
		}
   }
   else 
	return true;
}

function chkIsbn(isbno){
	
    isbno = replaceChar(isbno,' ' ,'');

	if(isbno!="")
	 
	 {
	 var a2str="";
	 var  numAry = new Array(9);
	 var  numAry2 = new Array();
	 isn_len = isbno.length;
	 t_count=0;
	 var p_val = 11;
	 var chk_val;
	 var total = 0;

	for(i=0;i<isn_len;i++){
		if ( !(isNaN(isbno.charAt(i)) ) )
		{
			p_val = p_val-1;
			t_count = t_count +1;
			numAry[i] = isbno.charAt(i);
			
			if (t_count<10){
				total  = total + ( numAry[i]* p_val );
			}
			
			if (t_count>9){
			j = t_count-10;
			//alert("Val j-->"+j);
			numAry2[j] = isbno.charAt(i);
			a2str = a2str + isbno.charAt(i);
			j = j + 1;
			}
		}
		
	}
	//alert("String of 2 Array-->"+a2str);
	dd = isn_len-1;
	if ( (isbno.charAt(dd)== "X") || ( isbno.charAt(dd)== "x" ) )
			t_count = t_count  + 1 ;
	chk_val = 11 - (total % 11);
	
	if ( chk_val == 11 )
		chk_val = 0;
	if (chk_val == 10)
		chk_val ="X";
			
	if ( chk_val != isbno.charAt(isn_len-1) ){
//	if ( (chk_val != a2str) || (chk_val != isbno.charAt(isn_len-1)) ){

		alert("Not a Valid ISBN Number.");
//		document.form1.m_isbn.focus();
		return false;
		}
	else if (t_count < 10){
		alert("Not a Valid ISBN Number.");
//		document.form1.m_isbn.focus();
		return false;
		}
	else if (t_count > 10){
		alert("Not a Valid ISBN Number.");
//		document.form1.m_isbn.focus();
		return false;
		}
	else 	
		return true;	 
	
	}
	
}

// 22.06.01 

function replaceChar(s, oldchar, newchar) {
	var retval = '';
	for (i = 0; i < s.length; i++) {
		
		if (s.charAt(i) == oldchar) {
			retval = retval + newchar;
		} else {
			retval = retval + s.charAt(i);
		}
	}	
	return retval;
}

function isValidDate(indate){
if((indate) !="" )		
		{
		f_date = indate;
		t_date = new Date();

		var f_day;
		var f_mon;
		var f_year;
		temp = 1;
		arr_days = new Array(11)
		arr_days[0] = 31;
		arr_days[1] = 29;
		arr_days[2] = 31;
		arr_days[3] = 30;
		arr_days[4] = 31;
		arr_days[5] = 30;
		arr_days[6] = 31;
		arr_days[7] = 31;
		arr_days[8] = 30;
		arr_days[9] = 31;
		arr_days[10] = 30;
		arr_days[11] = 31;

		//if (f_date != "") {
			f_day = f_date.substring(0,2);
			f_mon = f_date.substring(3,5);
			f_year = f_date.substring(6,10);

			if (isNaN(f_day))
				f_day = 0;
			
			if (isNaN(f_mon) || f_mon >12 )
				f_mon = 0;

			if (isNaN(f_year)) 
				f_year = 0;

			if ((f_year >= 0) && (f_year <= 57)) {
				if (f_year == "") 
					f_year = t_date.getYear()
				else
					f_year = parseInt(f_year) + parseInt(2000);
					//alert (f_year);}
			}
			else if ((f_year >= 58) && (f_year <= 99)) 
				f_year = parseInt(f_year) + parseInt(1900);
			else if ((f_year >= 100) && (f_year <= 999)) 
				f_year = parseInt(f_year) + parseInt(1000);

			if ((f_year%4) == 0)
				arr_days[1] = 29;
			else
				arr_days[1] = 28;
				
			if (f_day > arr_days[f_mon-1]) 
				f_day = 0
			
		if ((f_day ==0) || (f_mon == 0) || (f_year == 0)) {
			alert ("invalid date");
			document.form1.m_po_date.focus();
			return false;
			}	
	else 
		return 	true;		
  }
}  


function showAll(t_value){
			
	m_href= "listdata2.asp?m_value=" + escapeUTF(t_value) 
	//curPopupWindow  = window.open(m_href,"myWindow1","scrollbars=0,titlebar=1,toolbar=0,top=210,left=410,height=220,width=280",false)
	
	}

