// JavaScript Document
function GEId(H){try{return document.getElementById(H);}catch(e){}}
/////////////////////////////////////////
function confirmSubmit()
{
var agree=confirm("Are you sure you want to Delete ?");
if (agree)
	return true ;
else
{
	return false ;
}
}
//////////////////////////////////////
function confirmPaySubmit()
{
var agree=confirm("Are you sure you want to complete ?");
if (agree)
	return true ;
else
{
	return false ;
}
}
//////////////////////////////////////

function CheckAll(oF) {
	for(i=0; i<oF.length; i++) {
		e = oF.elements[i];
		if(e.type == 'checkbox' && e.name != 'allbox') {
			if(oF.allbox.checked)
				e.checked = true;
			else
				e.checked = false;
		}
	}
}


  var news = new Array();
if (window.XMLHttpRequest) { 
    xmlHttp = new XMLHttpRequest();
} else if (window.ActiveXObject) { 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
var MyContainer;
function callServer(url,txtSearch,ContainerName)
{
	MyContainer = ContainerName;
	document.getElementById(MyContainer).style.visibility = "visible";  //or "visible"
	url = url + '?id=' + txtSearch;
	xmlHttp.open("POST", url, true);
	xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
	window.setTimeout( "", 2500 )

	//alert (txtSearch);
}
function updatePage() {
  if (xmlHttp.readyState == 4) 
  {
  	if (xmlHttp.status == 200)
  	{
	    var response = xmlHttp.responseText;
	    document.getElementById(MyContainer).innerHTML = response;
	    //setTimeout("callServer(" + url + ")",2500);
	    //document.recalc();
    }
  }
  else
	{
		document.getElementById(MyContainer).innerHTML = '<img src="../images/wait.gif">';
	}
}

function loading(){
document.getElementById("page").className = 'load';
}
function unloading(){
document.getElementById("page").className = '';
}




///////////////////////
function submitButton(action){
    
		 document.forms[0].operation.value = action; 
		// alert(form1.operation.value);
		 document.forms[0].submit();		 	   
}
/////////////////////////
function deleteItem(itemId){
	 document.forms[0].selected_item.value=itemId;	 
	if(confirmSubmit()){
	submitButton("delete");		
	}
}
///////////////
function deleteItems(itemId,id){
	 document.forms[0].selected_items.value=itemId;
     document.forms[0].selected_id.value=id;
	 
	if(confirmSubmit()){
	submitButton("deleteapp");		
	}
}
///////////////
function Delete() {
			if(confirm('Are you sure you want to delete ?')){
				document.forms[0].operation.value = "delete";
				document.forms[0].submit();
				document.forms[0].onsubmit = null;
				}
				
			}
			
			

///////////////
function Deletes() {
			if(confirm('Are you sure you want to delete ?')){
				document.forms[0].operation.value = "deletes";
				document.forms[0].submit();
				document.forms[0].onsubmit = null;
				}
				
			}
////////////////////
function addRow()
{
var oTable= document.getElementById("ansTable");
var len= oTable.rows.length;
var newRow= oTable.insertRow();
    newRow.id = newRow.uniqueID;
        
        // declare cell variable
var newCell

        newCell = newRow.insertCell(0);

		newCell.align="left";

        newCell = newRow.insertCell(1);

        newCell.innerHTML = "<input type='text' size='20' name='ans"+(len-2)+"' id='ans"+(len-2)+"' />";

}
///////////////////

function delRow()
{
var oTable= document.getElementById("ansTable");
var len= oTable.rows.length;
var newRow= oTable.deleteRow();
}
/////////////////////
function cont()
{
var oTable= document.getElementById("ansTable");
var len= oTable.rows.length;
document.forms[0].hh.value=len-2;
}
////////////////////////////
function showHid(idd)
{
if(document.getElementById(idd).style.display=='none')
{
	document.getElementById('img'+idd).innerHTML="<img src='../images/collapse.gif'>";
	document.getElementById(idd).style.display='block';
}
else
{
	document.getElementById('img'+idd).innerHTML="<img src='../images/expand.gif'>";
	document.getElementById(idd).style.display='none';
}
//alert(idd);
}
/////////////////////////////
function isMain() {
			if(confirm('Are you sure you want to set this news in index page ?')){
				document.forms[0].operation.value = "ismain";
				document.forms[0].submit();
				document.forms[0].onsubmit = null;
				}
				
			}
////////////////////////////
function viewsub(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="subTpe.php?typeid="+str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
/////////////////////////////////////////
function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
if(document.forms[0].itmid.value != '')
{
document.getElementById("hid").innerHTML="";
document.getElementById("txt").innerHTML=xmlHttp.responseText;
}
else
{
document.getElementById("txt").innerHTML=xmlHttp.responseText;
}
}
}
///////////////////////////////
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
///////////////////////////////////////////
function checkFinance(str)
{
if(str==0)
{
alert("All Payment Process Completed");
return false;
}
}
////////////////////////////////////////////
function enabledisable()
{
if(document.forms[0].type[0].checked)
{
//document.forms[0].idate.disabled=true;
document.forms[0].idate.value="";
document.forms[0].idate.readOnly=true;
document.forms[0].idate.style.backgroundColor="#CCCCCC";
}
else
{
//form1.i.disabled=false;
document.forms[0].idate.readOnly=false;
document.forms[0].idate.style.backgroundColor="#FFFFFF";
}
}
//////////////////////////////////////////////
function TrimInputSpaces(zb){try{zb.value=Trim(zb.value);}catch(e){}}
function IsEmpty(s){return s==""?true:false;}
///////////////////////////////////////////////
function singleValidator(oI, eType){
    var sEI="";
	
    try {
        if(eType=='String') {            
			oI.style.border="1px solid #3f87cf";            
			TrimInputSpaces(oI);
            if(IsEmpty(oI.value)) {
                return HdlErr(false,oI);
            }
        }else if(eType=='Integer'){       
	    oI.style.border="1px solid #3f87cf";
        TrimInputSpaces(oI);
        if(IsEmpty(oI.value)) {
            return HdlErr(false,oI);
        }else if (!isInteger(oI.value)){
        return HdlErr(false,oI);
    }	
}
} catch(e){return false;}
return true;
}
   
function HdlErr(Ib,Jb){
	  try{
        if(Ib)return false;
    	 SetErr(false,true,Jb);
        } catch(e){}
        return false;
 }
var g_fFocusSet;
function SetErr(Ab,Bb,Cb){       
	if(Ab)return;
      if(Bb){		  
       	Cb.style.border="1px solid red";
          if(!g_fFocusSet){				
             g_fFocusSet=true;
               Cb.focus();
               if(Cb.type=="text"||Cb.type=="password")Cb.select();
            }
        } else Cb.style.border="1px solid #3f87cf";
 }
 ///////////////////////////////////////
 function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {  
      var c = s.charAt(i);
      if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}
/////////////////////////////////////
function paymentsValidator(val,pay,total)
{
var nBorder = parseInt(val);
if(val == "")
{
window.alert("Payment value is required");
document.forms[0].ammount.value="";
document.forms[0].ammount.focus();
return false;	
}
else if(isNaN(val))
{
window.alert("Payment Must be number");
document.forms[0].ammount.value="";
document.forms[0].ammount.focus();
return false;
}
else if(val < 0)
{
window.alert("Payment Must be greater than zero");
document.forms[0].ammount.value="";
document.forms[0].ammount.focus();
return false;	
}
else if((parseFloat(val)+parseFloat(pay)) > parseFloat(total))
{
window.alert("Payment ammount greater than total needed ammount");
document.forms[0].ammount.value="";
document.forms[0].ammount.focus();
return false;	
}
else if(!confirmPaySubmit())
{
 return false;
	
}

}
//////////////////////////////////
function paymentsBlurValidator(val,pay,total)
{
if((parseFloat(val)+parseFloat(pay)) == parseFloat(total))
{
document.forms[0].idate.value="";
document.forms[0].idate.disabled=true;
document.forms[0].idate.style.backgroundColor="#CCCCCC";
return false;	
}
else
{
document.forms[0].idate.disabled=false;
document.forms[0].idate.style.backgroundColor="#FFFFFF";
return true;
}
}
/////////////////////////////////
function activate() {
			if(confirm('Are you sure you want to show this Job Application ?')){
				job.operation.value = "activate";
				job.submit();
				job.onsubmit = null;
				}
				
			}
function Freeze() {
			if(confirm('Are you sure you want to hide this Job Application ?')){
				job.operation.value = "Freeze";
				job.submit();
				job.onsubmit = null;
				}
				
			}
/////////////////////////////
