﻿// JScript File

function popup(url) 
{
 var width  = 500;
 var height = 300;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';
 params +- ', titlebar=no';
 newwin=window.open(url,'windowname5', params);
 if (window.focus) {newwin.focus()}
 return false;
}


function box_flip(boxid)
{
        var box_id = boxid;  
        //var but_id = "btn_" + boxid.substring(4);
	    if (document.getElementById (box_id).style.display == 'none') 
	    {
		    //document.getElementById (but_id).value = "-";		
			box_open (box_id);
	    } 
	    else 
	    {
	        //document.getElementById (but_id).value = "+";
		    box_close (box_id);
	    }
}

function box_open(b_id)
{
	document.getElementById (b_id).style.display = 'block';
}

function box_close(b_id)
{
	document.getElementById (b_id).style.display = 'none';
}

var list = [];
var list1 = [];
var list2 = [];
	
function fixhome1(input,name)
{
var fields = document.forms[0][input].value.split("|");
			
list.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
		list[el.id] = el.name;
		converthome1(el,name);
	}
}
}

function converthome1(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function reverthome1()
{
 
for(var prop in list)
{
      
	var el = document.getElementById(prop);
	if (el)
	{
		converthome1(el,list[prop]);
	}     
}
 
return true;
}

function fixhome2(input,name)
{

var fields = document.forms[0][input].value.split("|");

list1.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
	    
		list1[el.id] = el.name;
		converthome2(el,name);
	}
}
}

function converthome2(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function reverthome2()
{
 
for(var prop in list1)

{
      
	var el = document.getElementById(prop);
	if (el)
	{
		converthome2(el,list1[prop]);
	}     
}
 
return true;
}


function fixhome3(input,name)
{

var fields = document.forms[0][input].value.split("|");

list2.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
	    
		list2[el.id] = el.name;
		converthome3(el,name);
	}
}
}


function converthome3(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);

radio.checked = checked;
}

function reverthome3()
{
 
for(var prop in list2)

{
      
	var el = document.getElementById(prop);
	if (el)
	{
		converthome3(el,list2[prop]);
	}     
}
 
return true;
}




var list3 = [];
var list4 = [];
var list5 = [];

function fixwork1(input,name)
{
var fields = document.forms[0][input].value.split("|");
			
list3.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
		list3[el.id] = el.name;
		convertwork1(el,name);
	}
}
}

function convertwork1(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function revertwork1()
{
 
for(var prop in list3)
{
      
	var el = document.getElementById(prop);
	if (el)
	{
		convertwork1(el,list3[prop]);
	}     
}
 
return true;
}

function fixwork2(input,name)
{

var fields = document.forms[0][input].value.split("|");

list4.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
	    
		list4[el.id] = el.name;
		convertwork2(el,name);
	}
}
}

function convertwork2(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function revertwork2()
{
 
for(var prop in list4)

{
      
	var el = document.getElementById(prop);
	if (el)
	{
		convertwork2(el,list4[prop]);
	}     
}
 
return true;
}


function fixwork3(input,name)
{

var fields = document.forms[0][input].value.split("|");

list5.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
	    
		list5[el.id] = el.name;
		convertwork3(el,name);
	}
}
}


function convertwork3(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function revertwork3()
{
 
for(var prop in list5)

{
      
	var el = document.getElementById(prop);
	if (el)
	{
		convertwork3(el,list5[prop]);
	}     
}
 
return true;
}








var list6 = [];
var list7 = [];
var list8 = [];

function fixprivate1(input,name)
{
var fields = document.forms[0][input].value.split("|");
			
list6.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
		list6[el.id] = el.name;
		convertprivate1(el,name);
	}
}
}

function convertprivate1(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function revertprivate1()
{
 
for(var prop in list6)
{
      
	var el = document.getElementById(prop);
	if (el)
	{
		convertprivate1(el,list6[prop]);
	}     
}
 
return true;
}

function fixprivate2(input,name)
{

var fields = document.forms[0][input].value.split("|");

list7.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
	    
		list7[el.id] = el.name;
		convertprivate2(el,name);
	}
}
}

function convertprivate2(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function revertprivate2()
{
 
for(var prop in list7)

{
      
	var el = document.getElementById(prop);
	if (el)
	{
		convertprivate2(el,list7[prop]);
	}     
}
 
return true;
}


function fixprivate3(input,name)
{

var fields = document.forms[0][input].value.split("|");

list8.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
	    
		list8[el.id] = el.name;
		convertprivate3(el,name);
	}
}
}


function convertprivate3(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function revertprivate3()
{
 
for(var prop in list8)

{
      
	var el = document.getElementById(prop);
	if (el)
	{
		convertprivate3(el,list8[prop]);
	}     
}
 
return true;
}


var list9 = [];
	
function fixpayment(input,name)
{
var fields = document.forms[0][input].value.split("|");

list9.length = 0;
for(var i=0;i<fields.length;i++)
{
      
	var el = document.getElementById(fields[i]);
	if (el)
	{
		list9[el.id] = el.name;
		convertpayment(el,name);
	}
}
}


function convertpayment(el,group)
{
var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function revertpayment()
{
 
for(var prop in list9)

{
      
	var el = document.getElementById(prop);
	if (el)
	{
		convertpayment(el,list9[prop]);
	}     
}
 
return true;
}

var list10 = [];

function fixorg(input,name)
{
	   
var fields = document.forms[0][input].value.split("|");

list10.length = 0;


for(var i=0;i<fields.length;i++)
{

	var el = document.getElementById(fields[i]);
	
	if (el)
	{
	    
	    list10[el.id] = el.name;
		convertorg(el,name);
	}
}
}


function convertorg(el,group)
{

var radio = null;
if (document.all)
{
	radio = document.createElement("<INPUT TYPE='RADIO' NAME='" + group + "' ID='" + el.id + "' VALUE='" + el.value + "'>");
}
else
{
	radio = document.createElement("input");
	radio.type = "radio";
	radio.name = group;
	radio.id = el.id;
	radio.value = el.value;
}
var checked = el.checked;
el.parentNode.replaceChild(radio,el);
radio.checked = checked;
}

function revertorg()
{
 
for(var prop in list10)

{
	var el = document.getElementById(prop);
	if (el)
	{
		convertorg(el,list10[prop]);
	}     
}
 
return true;
}


function validateAddress(val1,val2,val3,val4)
{
                 
    CompulsoryTxtFlds = Array(val1,val2,val3,val4);
    FriendlyNames = Array("Street Address","Area","Mobile No.");

    for(i=0;i<CompulsoryTxtFlds.length;i++)
    {   
        
        myfld = eval(document.getElementById(CompulsoryTxtFlds[i]))
		if(i==3)
		{
		var my=myfld.value;
        var attherate=my.indexOf("@");
        var lastattherate = my.lastIndexOf("@")
        var dotpos=my.lastIndexOf(".");
        var posspace = my.indexOf(" ");
        var totallen = my.length;

            if (attherate<=0 || dotpos<=0 || attherate > dotpos || (dotpos-attherate)<=1 || (dotpos == totallen-1) || posspace > -1 || attherate!=lastattherate)
	        {
		        alert("Inavalid Email.");
		        myfld.select();
                myfld.focus();
		        return false;
	        }
       
		}
        else
            {
                if(myfld.value.split(" ").join("") == "")
                    {
                            alert(FriendlyNames[i]+" can not be blank.");
                            myfld.select();
                            myfld.focus();
                            return false;
                    }
            }
    }
    return true;
}
function validateQualification(val1,val2,val3,val4,val5,val6,val7)
{
                 
    CompulsoryTxtFlds = Array(val1,val2,val3,val4,val5,val6,val7);
    FriendlyNames = Array("Degree","Course","Graduation Date","Course Duration","University","Phone","Email");

    for(i=0;i<CompulsoryTxtFlds.length;i++)
    {   
        
        myfld = eval(document.getElementById(CompulsoryTxtFlds[i]))
		if(i==6)
		{
		var my=myfld.value;
        var attherate=my.indexOf("@");
        var lastattherate = my.lastIndexOf("@")
        var dotpos=my.lastIndexOf(".");
        var posspace = my.indexOf(" ");
        var totallen = my.length;

            if (attherate<=0 || dotpos<=0 || attherate > dotpos || (dotpos-attherate)<=1 || (dotpos == totallen-1) || posspace > -1 || attherate!=lastattherate)
	        {
		        alert("Inavalid Email.");
		        myfld.select();
                myfld.focus();
		        return false;
	        }
       
		}
        else
            {
                if(myfld.value.split(" ").join("") == "")
                    {
                            alert(FriendlyNames[i]+" can not be blank.");
                            myfld.select();
                            myfld.focus();
                            return false;
                    }
            }
    }
    return true;
}
function validatePostQualification(val1,val2,val3,val4,val5)
{
                 
    CompulsoryTxtFlds = Array(val1,val2,val3,val4,val5);
    FriendlyNames = Array("Qualification","Exact Letters","Date Obtained","Years","Place");

    for(i=0;i<CompulsoryTxtFlds.length;i++)
    {   
        
        myfld = eval(document.getElementById(CompulsoryTxtFlds[i]))
		
                if(myfld.value.split(" ").join("") == "")
                    {
                            alert(FriendlyNames[i]+" can not be blank.");
                            myfld.select();
                            myfld.focus();
                            return false;
                    }
    }
    return true;
}

function validateNotes(val1,val2,val3,val4)
{
                 
    CompulsoryTxtFlds = Array(val1,val2,val3,val4);
    FriendlyNames = Array("Name","Email","Title","Description");

    for(i=0;i<CompulsoryTxtFlds.length;i++)
    {   
        
        myfld = eval(document.getElementById(CompulsoryTxtFlds[i]))
		if(i==1)
		{
		var my=myfld.value;
        var attherate=my.indexOf("@");
        var lastattherate = my.lastIndexOf("@")
        var dotpos=my.lastIndexOf(".");
        var posspace = my.indexOf(" ");
        var totallen = my.length;

            if (attherate<=0 || dotpos<=0 || attherate > dotpos || (dotpos-attherate)<=1 || (dotpos == totallen-1) || posspace > -1 || attherate!=lastattherate)
	        {
		        alert("Inavalid Email.");
		        myfld.select();
                myfld.focus();
		        return false;
	        }
       
		}
        else
            {
                if(myfld.value.split(" ").join("") == "")
                    {
                            alert(FriendlyNames[i]+" can not be blank.");
                            myfld.select();
                            myfld.focus();
                            return false;
                    }
            }
    }
    return true;
}	
    
