// ************************common Javascript Library   ***************************////////
///// Developed By   : Trilochan Nayak                   ///////////////////////



///*******Read the java script tutorial at http://www.netspade.com/articles/javascript   *****////////

<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
				window.open(theURL,winName,features);
}
function open_popup(theURL,winName,features) { //v2.0
				window.open(theURL,winName,features);


}

var pop;
function show_win()
{
				pop.focus();
}

function hide_win(what)
{
				pop.blur();
}


/*
function for returning the form *object* that
has a give named element
*/


function  get_form (elemname) {
				for(var i=0;i<document.forms.length;i++)
				{
								for(var x=0;x<document.forms[i].length;x++)
								{
												if(document.forms[i].elements[x].name==elemname)
												{
																return document.forms[i].elements[x].form;
												}
								}
				}
}



/**
 * Read the JavaScript cookies tutorial at:
 *   http://www.netspade.com/articles/javascript/cookies.xml
 */

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

//-->



//This function toggles visibility of any object
//To use just pass id of the element as parameter and
//It will become visible if it was not vice versa

function toggle_view(object)
{
 if (document.getElementById) {
    if (document.getElementById(object).style.visibility == 'visible')
      document.getElementById(object).style.visibility = 'hidden';
    else
      document.getElementById(object).style.visibility = 'visible';
  }

  else if (document.layers && document.layers[object] != null) {
    if (document.layers[object].visibility == 'visible' ||
        document.layers[object].visibility == 'show' )
      document.layers[object].visibility = 'hidden';
    else
      document.layers[object].visibility = 'visible';
  }

  else if (document.all) {
    if (document.all[object].style.visibility == 'visible')
      document.all[object].style.visibility = 'hidden';
    else
      document.all[object].style.visibility = 'visible';
  }

  return false;
}


//This function is supposed to be called on click even of a checkbox to highlight its row
function style_chkbx(obj,color)
{
				obj.checked==true ?bg=color : bg='';
				do
				{
								obj=obj.parentNode;
				}while(obj.nodeName!='TR')
				var bg;
				obj.style.backgroundColor=bg;
}


function style_form(obj,color)
{
        do
        {
                obj=obj.parentNode;
        }while(obj.nodeName!='TR')
        obj.style.backgroundColor=color;
}


function getselectedradio(buttonGroup){
if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   return -1;
}

function getselectedradiovalue(buttonGroup) {
   var i = getselectedradio(buttonGroup);
   if (i == -1) {
      return false;
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
}


function dropdownvalue(obj){
return obj.options[obj.selectedIndex].value;
}

function dropdowntext(obj){
return obj.options[obj.selectedIndex].text;
}

function resetradios(obj){
				var ar=document.getElementsByTagName("input");
				for(var i=0;i<ar.length;i++){
								if(ar[i].type=='radio'){
												if(obj){
																if(ar[i].name==obj){
																				ar[i].checked=false;
																}
												}else{

																ar[i].checked=false;
												}
								}
				}
}



function selectfirstfield(){
var ar=document.getElementsByTagName("input");
        for(var i=0;i<ar.length;i++){
                if(ar[i].type=='text'){
                        ar[i].focus();break;
												alert(ar[i].name);
                }
        }

}

function bullet(color){
document.write("<table cellspacing=0 cellpadding=0 border=0 style='font-size:8px'><tr bgcolor='"+color+"'><td>&nbsp;&nbsp;</td></tr></table>");
}

function bullet1(color){
document.write("<table cellspacing='0' cellpadding='0' align='left'><tr><td bgcolor='#000000'><table cellspacing=1 cellpadding=0 border=0 style='font-size:8px'><tr bgcolor='"+color+"'><td>&nbsp;&nbsp;</td></tr></table></td></tr></table>");
}

function bullet2(bgcolor,fcolor,text){
document.write("<table cellspacing='0' cellpadding='0' align='left'><tr><td bgcolor='#000000'><table cellspacing=1 cellpadding=0 border=0 style='font-size:8px'><tr bgcolor='"+bgcolor+"'><td style='"+fcolor+"'>"+text+"</td></tr></table></td></tr></table>");
}


// This function can be used, to take user confirmation when he clicks on link 

function confirm_click(msg,url){
				if(confirm(msg)){
								window.location=url;
				}
}

