// JavaScript Document
function CheckMail()
{
 var path="adminCheckMail.aspx";
  //window.open(path,'','','');
  window.open(path,"_self",'',false);
}
function OpenWin(path)
 {
   // window.location.reload();
      // window.close();
	 // var path="adminHome.aspx";
	 //alert("Done");
  window.open(path,'','','');
       return
 }
function BackWin(path)
 {
   // window.location.reload();
      // window.close();
	 // var path="adminHome.aspx";
	 alert("Done");
  window.open(path,"_self",'',true);
       return
 }
function ReloadWin()
 {
   // window.location.reload();
      // window.close();
	  var path="adminHome.aspx";
  window.open(path,"_self",'',true)
       return
 }
  function CloseWin1(toPath)
 {
   
	  var path=toPath; 
  	window.open(path,"_self",'',false);
	
 }
 function CloseWin(toPath)
 {
   // alert(toPath)
	if(toPath=="")
	{
		window.opener.location.reload();
        window.close();
        return
	}
	  var path=toPath+".aspx"; 
  	window.open(path,"_self",'',false);
	
 }
 function AddRecord()
 {
  var path=GlobalPath+"Add.aspx";
  //window.open(path,'','','');
  window.open(path,"_self",'',false);
 }
 
 /*function DeleteRecord(obj)
 {

	var CurRecordId=document.getElementById(obj).getAttribute("RecordId")
 var path=GlobalPath+"Del.aspx?RecordId="+CurRecordId
 window.open(path,"_self",'',true)
 //window.open(path,'','','');
 }*/
 function DeleteRecord(obj)
 {
  if(!confirm("Are you sure you want to remove the entry"))
    return;
  var CurRecordId=document.getElementById(obj).getAttribute("RecordId")
   if(IsSystemId(CurRecordId))
  {
    alert("Sorry this is the master Record and cannot be deleted")
    return
  }
 var path=GlobalPath+"Del.aspx?RecordId="+CurRecordId

//alert(path)
 window.open(path,"_self",'',false);

 }
 
 function EditRecord(obj)
 {
  var CurRecordId=document.getElementById(obj).getAttribute("RecordId")
 
 var path=GlobalPath+"Edit.aspx?RecordId="+CurRecordId

//window.open(path,'','','');
window.open(path,"_self",'',false);


 }
 
 function CreateRecords(tblId,totalCols,isEdit,isDel)
 {
 var colCount=0
 var rowCount=0
 if(DataRecords=="")
 return;
    
  var RowValues = DataRecords.split(Delimeter);
    
    TableObj=document.getElementById(tblId)
    //alert(RowValues.length)
    while(rowCount<RowValues.length-1)
    {
        colCount=0
        RowsObj=TableObj.insertRow(rowCount+1)
        //alert(RowValues.length+":"+rowCount+":"+RowValues[rowCount])
        ColValues=RowValues[rowCount++].split(InnerDelimeter)
    	
        CellsObj=RowsObj.insertCell(colCount)
            CellsObj.innerHTML=rowCount
        //alert(totalCols)
        for (i=1;i<=totalCols;i++)
        {
            CellsObj=RowsObj.insertCell(i)
            CellsObj.innerHTML=ColValues[i]
       }
      
      
       
        CellsObj=RowsObj.insertCell(totalCols+1)
        
		if(isEdit)
		{
			CellsObj.innerHTML="<input id=\"EditRecord"+rowCount+"\" type=\"button\" value=\"Edit\" style=\"width:50px\" onclick=\"EditRecord(this.id)\" />"
			SetId("EditRecord"+rowCount, ColValues[0])
		}
		else
		{
			CellsObj.innerHTML="&nbsp;";
		}
        
         CellsObj=RowsObj.insertCell(totalCols+2)
        if(isDel)
		{
			CellsObj.innerHTML="<input id=\"DeleteRecord"+rowCount+"\" type=\"button\" value=\"Delete\" style=\"width:50px\" onclick=\"DeleteRecord(this.id)\" />"
			SetId("DeleteRecord"+rowCount, ColValues[0])
		}
		else
		{
			CellsObj.innerHTML="&nbsp;";
		}
        //rowCount++
     }
 }
 
 function SetId(ObjId,ValueId)
 {
    document.getElementById(ObjId).setAttribute("RecordId", ValueId)
 }
 

function BuildSelect(objId,listArray)
 {
    var List=listArray.split(Delimeter)
    var obj=document.getElementById(objId)
    
    var count=0;
     var listno=0
      
     while(listno<(List.length-1))
     {
        
        var Item=List[listno++].split(InnerDelimeter)
        y=document.createElement('option');
        y.value=Item[0]
        y.text=Item[1]
        
        
        //alert(o)
        try
        {
            obj.add(y,null); // standards compliant
        }
        catch(ex)
        {
            obj.add(y); // IE only
        }
       
    }
 }

function BuildList(objId,listArray)
{
    //ClearForm();
    BuildSelect(objId,listArray)
   // BuildSelect("GroupType",GroupRecords)
   

}
 


