function pageset(){
		if ( document.all['div_pg__body'] ) {
			headerheight = 0 ;
			footerheight = 0 ;
			titleheight  = 0 ;
			labelheight	 = 0 ;

			document.body.scroll = 'no';			
			
		
			if ( document.all['div_pg__header'].offsetHeight != null ) 
					headerheight = document.all['div_pg__header'].offsetHeight

			if ( document.all['div_pg__title'].offsetHeight != null ) {
					titleheight = document.all['div_pg__title'].offsetHeight
			}

			if ( document.all['div_pg__label'].offsetHeight != null ) 
					labelheight = document.all['div_pg__label'].offsetHeight

			
			if ( document.all['div_pg__footer'].offsetHeight != null ) 
					footerheight = document.all['div_pg__footer'].offsetHeight


				var nHeight = getDocumentHeight()-10;
				nHeight -=  headerheight + titleheight + labelheight + footerheight + 4;
				document.all['div_pg__body'].style.height = ( nHeight > 0 ? nHeight : 0);
				
			/*
			document.all['div_pg__header'].style.top = document.body.offsetTop ; 
			document.all['div_pg__title'].style.top = document.all['div_pg__header'].offsetTop + headerheight;
			document.all['div_pg__label'].style.top = document.all['div_pg__title'].offsetTop + titleheight;
			document.all['div_pg__body'].style.top = document.all['div_pg__label'].offsetTop + labelheight;
			document.all['div_pg__footer'].style.top = getDocumentHeight() - footerheight // document.all['div_pg__body'].offsetTop + document.all['div_pg__body'].offsetHeight;
*/
			document.all['div_pg__footer'].style.top =  getDocumentHeight() - footerheight;
			document.all['div_pg__body'].style.height =  getDocumentHeight() - footerheight - document.all['div_pg__body'].offsetTop;
			
			var docwidth = getDocumentWidth();
			document.all['div_pg__body'].style.width = Math.max( docwidth, 0 ); 
			document.all['div_pg__footer'].style.width = Math.max( docwidth, 0 ); 
			document.all['div_pg__label'].style.width = document.all['div_pg__body'].clientWidth
			
			labelscroll();
			hideInvisibleRows();
			

			window.onresize=pageset;
		//document.body.scroll = 'no';
			// this is newly added option to set height of sub div in body div
			if (document.all['div_pg__body_sub']){
				document.all['div_pg__body_sub'].style.height =  document.all['div_pg__body'].offsetHeight -30;
			}
			
		}
}

//	window.onload=pageset;

function delvalid( msg){
		if  (confirm(msg)==false){
			return false;
		}	
}

function showfile(filename){
	var f="d:\grasim2003\documents\1.htm";
	var w=window.open(f,"","height=500,width=500,resizable=no,maximize=no")
}

function scrollDiv()
{
	document.getElementById('div_pg__label').scrollLeft = document.getElementById('div_pg__body').scrollLeft;
}


function labelscroll(){
	for (var i=1; document.getElementById('pg_div__labcol'+ i ) != null; i++){
		var col = document.getElementById('pg_div__labcol'+i);
		var lab = document.getElementById('pg_div__lab'+i);
		if (lab != null ){
				lab.style.width = col.offsetWidth;
		}
	}
}

function getDocumentHeight()
{

	if (window.innerHeight)
		return window.innerHeight;
	else 
		return document.body.clientHeight;
}
function getDocumentWidth()
{
	if (window.innerWidth)
		return window.innerWidth ;
	else  
		return document.body.clientWidth;

}


function hideInvisibleRows()
{
	var div = document.getElementById("squeezeBox");
	if (div == null)
		return;
	var trs = div.getElementsByTagName("tr");

	
	var hiddenHeight = 0;
	for (var i=0; i < trs.length; i++)
	{
		
		if (trs[i].className == "pg_div_labelrow" && isValEmpty(trs[i].getAttribute("squeezeBox")) )
		{
			hiddenHeight += trs[i].offsetHeight + 1;
			trs[i].setAttribute("squeezeBox","T");
		}
	}
	if (hiddenHeight > 0)
	{
		div.style.overflow = "hidden";
		div.style.height = div.offsetHeight - hiddenHeight + 0 // (isIE ? 0 : 28);
	}
}

function isValEmpty(val,nam)
{
    if (val == null)
        return true;

    if (val.length == 0)
        return true;
    re = / /gi;
    val = val.replace(re,'');
    return (val.length == 0)
}

function utils_page_footer_show_page_title( divname ){
	if ( document.all[divname].style.display != "none" ) {
		document.all[divname].style.display =  "none" ;
		utilsfrm.utils_show_title.value = 0;
		utilsfrm_printall.utils_show_title.value = 0;
	}
	else{
		document.all[divname].style.display =  "block"  ;
		utilsfrm.utils_show_title.value = 1;
		utilsfrm_printall.utils_show_title.value = 1 ;
	}
	pageset()
}

function utils_printall( moption , memail ) {
	if ( moption == 'E' ){
		if (echeck(memail) == false) return;
		utilsfrm_printall.utils_email_sent_to.value = memail ; 
	}
	utilsfrm_printall.utils_page_mode.value = moption ; 
	utils_print_all = window.open("",'utils_print_all','height=200,top=130,left=30,width=250,top=10,left=10,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes');
	utilsfrm_printall.target = "utils_print_all"
	//utilsfrm_printall.target = "_blank"
	utilsfrm_printall.submit();
}

var bodyonlywidth = null;
var bodyonlyheight =null;

function onBeforePrint()
{
	var t = document.getElementById('div_pg__body');
	if (t != null)
	{
		t.style.width = null;
		t.style.height = null;
	}
	t = document.getElementById('div_pg__bodyonly');
	if (t != null)
	{
		bodyonlywidth = t.style.width;
		t.style.width = null;
		bodyonlyheight = t.style.height;
		t.style.height = null;
	}	
	document.body.scroll = 'auto';
}
function onAfterPrint()
{
	t = document.getElementById('div_pg__bodyonly');
	if (t != null)
	{
		t.style.width = bodyonlywidth;
		t.style.height = bodyonlyheight;
	}	
	pageset();
}
window.onbeforeprint = onBeforePrint;
window.onafterprint = onAfterPrint;


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
}


function select_all_company()
{
x = document.rptfrm.company_code.length ;
for(i=0;i<x;i++)
document.rptfrm.company_code.options[i].selected = 1;
}
function remove_all_company()
{
x = document.rptfrm.company_code.length ;
for(i=0;i<x;i++)
document.rptfrm.company_code.options[i].selected = 0;
}

function rev_all_company()
{
x = document.rptfrm.company_code.length ;
for(i=0;i<x;i++)
document.rptfrm.company_code.options[i].selected = document.rptfrm.company_code.options[i].selected?0:1
}

//For String Trim Function
String.prototype.trim = function() 
{
  return( this.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') ); 
}

function winopen(fl,tit,hgt, wid,opt) {
	var lft = (screen.width - wid) / 2 ;
	var tp = (screen.height-hgt) / 2;
	var feat = "height="+ hgt + ",width=" + wid + ",left="+ lft + ",top="+ tp + ",status=no,toolbar=no,menubar=no,location=no"
	if (opt){
		feat = feat  + ',' + opt;
	}
	var w = window.open(fl,tit,feat);
	//var w = window.open(fl,tit,"height="+ hgt + ",width=" + wid + ",status=no,toolbar=no,menubar=no,location=no,scrollbars=auto");
	w.focus();
}

	function hideElement(elmID,divname){
		var bodyele=document.body
		for (i = 0; i < bodyele.all.tags(elmID).length; i++){
			obj = bodyele.all.tags(elmID)[i];
			if (! obj || ! obj.offsetParent)
				continue;
			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
			objLeft   = obj.offsetLeft;
			objTop    = obj.offsetTop;
			objParent = obj.offsetParent;
			while (objParent.tagName.toUpperCase() != "BODY")
			{
				objLeft  += objParent.offsetLeft;
				objTop   += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}
			x=parseInt(bodyele.all[divname].style.left);
			y=parseInt(bodyele.all[divname].style.top);
			//alert('x:'+x +',objleft:'+objLeft +',objwidth' +obj.offsetWidth + ':' + bodyele.all[divname].offsetWidth +'\n;Top:' +objTop +';height:' + (y + bodyele.all[divname].offsetHeight) +';y:'+y +';objhght:'+obj.offsetHeight)
			if (x > (objLeft + obj.offsetWidth) || objLeft > (x + bodyele.all[divname].offsetWidth))
				;
			else if (objTop > (y+bodyele.all[divname].offsetHeight) || (objTop + obj.offsetHeight)< y)
				;
			else{
				obj.style.visibility = "hidden";
			}	
		}
	}

	function showElement(elmID)
	{
		var bodyele=document.body
		if ("object" == typeof(bodyele.all.tags(elmID)[0])) {
			for (i = 0; i < bodyele.all.tags(elmID).length; i++)
			{
				obj = bodyele.all.tags(elmID)[i];
				if (!obj){
					break;
				}
				else{
					obj.style.visibility = "";	
				}	
			}
		}	
	}	

	function showdiv(val,divname,obj){
			if (val==1){
			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
				objLeft   = obj.offsetLeft;
				objTop    = obj.offsetTop;
				objParent = obj.offsetParent;
				while (objParent.tagName.toUpperCase() != "BODY")
				{
					objLeft  += objParent.offsetLeft;
					objTop   += objParent.offsetTop;
					objParent = objParent.offsetParent;
				}
				document.all[divname].style.display='block';
				document.all[divname].style.top = objTop+15 ;
				var winwidth = getDocumentWidth();
				if ((objLeft + document.all[divname].offsetWidth) > winwidth) {
					document.all[divname].style.left = winwidth - document.all[divname].offsetWidth;
				}
				else{
					document.all[divname].style.left = objLeft ;
				}

				hideElement('SELECT',divname);
				
			}
			else{
				document.all[divname].style.display='none';
				showElement('SELECT',divname);
			}
	}	
	
	function setposdiv(){
		if (document.all["div_pg__bodyonly"]){
			var obj = document.all["div_pg__bodyonly"]
			//obj.style.height ='200px';
			//alert(document.all["div_pg__bodyonly"].offsetTop);
			var objTop    = obj.offsetTop;
			var objParent = obj.offsetParent;
				while (objParent.tagName.toUpperCase() != "BODY")
				{
					objTop   += objParent.offsetTop;
					objParent = objParent.offsetParent;
				}
			var footerheight =0;	
			if (document.all['div_pg__footer']){
				if ( document.all['div_pg__footer'].offsetHeight != null ) 
					footerheight = document.all['div_pg__footer'].offsetHeight;
			}
					
			obj.style.height = 	getDocumentHeight() - footerheight - objTop - 5;
		}
	}

	function candview_include(usercode)
	{
		var url = "cand_profile_new.asp?usercode=" + usercode
		var z = window.open(url,"Action","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=0,border=thin,top=0,left=0,width=700,height="+ eval(screen.height-60));
		z.focus();
	}

	function candview_include_monitor(usercode,reqfrom)
	{
		var url = "cand_profile_new.asp?usercode=" + usercode + "&rtype=" +reqfrom
		var z = window.open(url,"Action","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=0,border=thin,top=0,left=0,width=700,height="+ eval(screen.height-60));
		z.focus();
	}

	function tra_pageset(){

		if ( document.all['div_pg__body'] ) {
			headerheight = 0 ;
			footerheight = 0 ;
			titleheight  = 0 ;
			labelheight	 = 0 ;

			document.body.scroll = 'no';			
			
		

			if ( document.all['div_pg__title'].offsetHeight != null ) {
					titleheight = document.all['div_pg__title'].offsetHeight
			}

			
			if ( document.all['div_pg__footer'].offsetHeight != null ) 
					footerheight = document.all['div_pg__footer'].offsetHeight


				var nHeight = getDocumentHeight()-10;
				nHeight -=  headerheight + titleheight + labelheight + footerheight + 4;
				document.all['div_pg__body'].style.height = ( nHeight > 0 ? nHeight : 0);
				
			document.all['div_pg__footer'].style.top =  getDocumentHeight() - footerheight;
			document.all['div_pg__body'].style.height =  getDocumentHeight() - footerheight - document.all['div_pg__body'].offsetTop;
	
			var docwidth = getDocumentWidth();
			document.all['div_pg__body'].style.width = Math.max( docwidth, 0 ); 
			document.all['div_pg__footer'].style.width = Math.max( docwidth, 0 ); 
			
			window.onresize=tra_pageset;

			if (document.all['div_pg__body_sub']){
				document.all['div_pg__body_sub'].style.height =  document.all['div_pg__body'].offsetHeight -30;
			}
			
		}
}