// JavaScript Document

/* Print page - Function*/
function printPage(){
	if (!window.print)
	{
		alert("You need NS4.x to use this print button!")
		return
	}
	window.print()
}

/* Add to favorites - Function*/
function addFavorite(){
	window.external.AddFavorite('http://www.padmashalisamaj.com','Padmashali Samaja Seva Sangh');
}

/* Status bar message - Function*/
function statusMsg(message){
window.status = message;
return true;
}

/* Global File include Function*/
document.include = function (url){
	if ('undefined' == typeof(url)) return false;
	var p,rnd;
	if (document.all)
	{
	   // For IE, create an ActiveX Object instance
	   p = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else 
	{
	   // For mozilla, create an instance of XMLHttpRequest.
	   p = new XMLHttpRequest();
	}
	// Prevent browsers from caching the included page
	// by appending a random  number
	rnd = Math.random().toString().substring(2);
	url = url.indexOf('?')>-1 ? url+'&rnd='+rnd : url+'?rnd='+rnd;
	// Open the url and write out the response
	p.open("GET",url,false);
	p.send(null);
	document.write( p.responseText );
}

function openWindow(w,h,url,scrl){  	
  	var leftPos = (screen.width/2) - (w/2);
	var topPos = (screen.height/2) - (h/2);
	
	winStats='width='+w+',height='+h+',top='+topPos+',left='+leftPos+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrl+'';
	window.open(url,"pop",winStats).focus();
}

/*Dynamic Font Size*/
function changeFont(divID, dynFtSize){
document.getElementById(divID).className=dynFtSize;
}

/*Dynamic Add / Delete rows starts*/
function addDetailsRow(tblObj){
	var tbl=document.getElementById(tblObj);
	var lastRow=tbl.rows.length;
	var iteration=lastRow;//if there's no header row in the table, then iteration = lastRow + 1
	var newRow=tbl.insertRow(lastRow);
	
	//first cell
	var oCell0	= newRow.insertCell(0);
	var textNode = document.createTextNode(iteration);
	oCell0.appendChild(textNode);
	
	//second cell
	var oCell1 = newRow.insertCell(1);
	var elName = document.createElement('input');
			elName.type = 'text';
			elName.name = 'cName' + iteration;
			elName.id = 'cName' + iteration;
			elName.className = 'txtFieldX';
	oCell1.appendChild(elName);
	
	//third cell
	var oCell2 = newRow.insertCell(2);
	var elAge = document.createElement('input');
			elAge.type = 'text';
			elAge.name = 'cAge' + iteration;
			elAge.id = 'cAge' + iteration;
			elAge.className = 'txtFieldX';
	oCell2.appendChild(elAge);
	
	//fourth cell
	var oCell3 = newRow.insertCell(3);
	var elOccp = document.createElement('input');
			elOccp.type = 'text';
			elOccp.name = 'cQual' + iteration;
			elOccp.id = 'cQual' + iteration;
			elOccp.className = 'txtFieldX';
	oCell3.appendChild(elOccp);
	
	//fifth cell
	var oCell4	= newRow.insertCell(4);
	var elDel = document.createElement('input');
			elDel.type = 'button';
			elDel.name = 'cDel' + iteration;
			elDel.id = 'cDel' + iteration;
			elDel.value = 'Delete'
			elDel.className = 'butGreen';
			elDel.onclick = function() { delDetailsRow(); return false; }
	oCell4.appendChild(elDel);	
}
function delDetailsRow(){
	var tbl = document.getElementById('addDetailstbl');
	var lastRow = tbl.rows.length;
	if(lastRow>2){
	tbl.deleteRow(lastRow-1)
	}
}
/*Dynamic Add / Delete rows ends*/