function OnCustomerValue(){
	if (document.getElementById('feedconsumer').value == "Consumer"){
		document.getElementById('feedrr').style.display = "";
	}else {
		document.getElementById('feedrr').style.display = "none";
	}
}

function startFeed(){
	   // document.getElementById('f1_upload_process').innerHTML = "<img src=http://localhost/cesc/image/ajax-loader.gif></img>" ;
  document.getElementById('feedresult').innerHTML = "Please wait, Your query is being forwarded to concerned authority for necessary action<br/><br/>"+"<img src=http://"+realurl+"/image/ajax-loader.gif></img>" ;
  //document.getElementById('fbform').style.display = "none";
  return true;
}

function stopFeed(success,obj){
    var result = '';
    if (success == 1){
       document.getElementById('feedresult').innerHTML = '<span class="msg">Your feedback submitted successfully!<\/span><br/><br/>'+obj;
    }
    else {
       document.getElementById('feedresult').innerHTML = 
         '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
    }
//    document.getElementById('f1_upload_process').innerHTML = obj;
//    document.getElementById('ntitles').value = "";
//    document.getElementById('myfile').value = "";
    
    
    document.getElementById('feedname').value = "";
    document.getElementById('feedadd').value = "";
    document.getElementById('feedphone').value = "";
    document.getElementById('feedemail').value = "";
    document.getElementById('feedconsumer').value = "Not a Consumer";
    document.getElementById('feedrrno').value = "";
    document.getElementById('feedrr').style.display = "none";
   // document.getElementById('feedsub').value = "";
    document.getElementById('feedcomplaint').value = "No Power Supply";
    document.getElementById('feednotes').value = "";
    return true;   
}

function startNewsUpdate(){
	
	document.getElementById('newsbriefstatus').innerHTML = "Please wait....." ;
	return true;
}

function stopNewsUpdate(success,obj){
	
	var result = '';
    if (success == 1){
       document.getElementById('newsbriefstatus').innerHTML = '<span class="msg">Latest News submitted successfully!<\/span><br/><br/>';
       document.getElementById('newsbriefdata').innerHTML = obj;
    }
    else {
       document.getElementById('newsbriefstatus').innerHTML = 
         '<span class="emsg">There was an error during update! Please contact CESC WebAdmin.<\/span><br/><br/>';
    }
//    document.getElementById('f1_upload_process').innerHTML = obj;
//    document.getElementById('ntitles').value = "";
//    document.getElementById('myfile').value = "";
    
    
    document.getElementById('latesttitle').value = "";
    document.getElementById('latestcontent').value = "";
   
    return true;  
	
}

function AddTotal(){
	 document.getElementById('TTlBill').value = Math.round( 
						parseFloat(document.getElementById('L4TU').value)
					  + parseFloat(document.getElementById('L6TU').value)
					  + parseFloat(document.getElementById('LTU').value)
					  + parseFloat(document.getElementById('CFL1TU').value)
					  + parseFloat(document.getElementById('CFL2TU').value)
					  + parseFloat(document.getElementById('TLTU').value)
					  + parseFloat(document.getElementById('ELITU').value)
					  + parseFloat(document.getElementById('IHTU').value)
					  + parseFloat(document.getElementById('WHTU').value)
					  + parseFloat(document.getElementById('TTU').value)
					  + parseFloat(document.getElementById('RFTU').value)
					  + parseFloat(document.getElementById('WACTU').value)
					  + parseFloat(document.getElementById('DCTU').value)
					  + parseFloat(document.getElementById('RCTU').value)
					  + parseFloat(document.getElementById('TFTU').value)
					  + parseFloat(document.getElementById('EFTU').value)
					  + parseFloat(document.getElementById('WMTU').value)
					  + parseFloat(document.getElementById('RTU').value)
					  + parseFloat(document.getElementById('TVTU').value)
					  + parseFloat(document.getElementById('MCGTU').value)
					  + parseFloat(document.getElementById('PCTU').value)
					  + parseFloat(document.getElementById('PM1TU').value)
					  + parseFloat(document.getElementById('PM2TU').value)
					  + parseFloat(document.getElementById('PM3TU').value));
}

function CalcUnit(objSel , objVal, objNo, objDisp ){
	
	if ( isNaN(parseFloat(objNo.value))  ){
		objDisp.value = 0;
		return;
		}
	else
	objDisp.value =
	(parseFloat(objNo.value) * 
	parseFloat( objSel.options[objSel.selectedIndex].value) * 
						parseFloat( objVal.value));
	objDisp.value = Math.round(objDisp.value);
        //document.getElementById('TTlBill').value = 100;
	//alert(document.getElementById('TTlBill').value);
	AddTotal();
}

var http_request = false;
function makePOSTRequestNew(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      if (url == 'http://'+realurl+'/update_page'){
    	  http_request.onreadystatechange = stopPageUpdate;
          http_request.open('POST', url, true);
          http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          http_request.setRequestHeader("Content-length", parameters.length);
          http_request.setRequestHeader("Connection", "close");
          http_request.send(parameters); 
    	  
      }else if (url == 'http://'+realurl+'/showlinks'){
    	  
    	  http_request.onreadystatechange = showLinxComplete;
          http_request.open('POST', url, true);
          http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          http_request.setRequestHeader("Content-length", parameters.length);
          http_request.setRequestHeader("Connection", "close");
          http_request.send(parameters); 
      }else if (url == 'http://'+realurl+'/showeditbox'){
    	  
    	  http_request.onreadystatechange = showBoxComplete;
          http_request.open('POST', url, true);
          http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          http_request.setRequestHeader("Content-length", parameters.length);
          http_request.setRequestHeader("Connection", "close");
          http_request.send(parameters); 
      }else if (url == 'http://'+realurl+'/telecorp'){
    	  
    	  http_request.onreadystatechange = telecorpComplete;
          http_request.open('POST', url, true);
          http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          http_request.setRequestHeader("Content-length", parameters.length);
          http_request.setRequestHeader("Connection", "close");
          http_request.send(parameters); 
          
      }else if (url == 'http://'+realurl+'/telecorpedt'){
    	  
    	  http_request.onreadystatechange = telecorpEdtComplete;
          http_request.open('POST', url, true);
          http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          http_request.setRequestHeader("Content-length", parameters.length);
          http_request.setRequestHeader("Connection", "close");
          http_request.send(parameters); 
          
      }else if (url == 'http://'+realurl+'/teleupdatepage'){
    	  
    	  http_request.onreadystatechange = stopTeleUpdate;
          http_request.open('POST', url, true);
          http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          http_request.setRequestHeader("Content-length", parameters.length);
          http_request.setRequestHeader("Connection", "close");
          http_request.send(parameters); 
      }else if (url == 'http://'+realurl+'/telelistextra'){
    	  
    	  http_request.onreadystatechange = teleExtraComplete;
          http_request.open('POST', url, true);
          http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          http_request.setRequestHeader("Content-length", parameters.length);
          http_request.setRequestHeader("Connection", "close");
          http_request.send(parameters); 
      }else if (url == 'http://'+realurl+'/teleextraedt'){
    	  
    	  http_request.onreadystatechange = teleExtraFinalComplete;
          http_request.open('POST', url, true);
          http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          http_request.setRequestHeader("Content-length", parameters.length);
          http_request.setRequestHeader("Connection", "close");
          http_request.send(parameters); 
      }
      
      
   }

function startPageUpdate(){
	var poststr = "empty=nil";
	document.getElementById('resultstatus').innerHTML = "<img src=http://"+realurl+"/image/ajax-loader.gif></img>";
	makePOSTRequestNew('http://'+realurl+'/update_page', poststr);
	
}

function stopPageUpdate(){
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        result = http_request.responseText; 
        document.getElementById('resultstatus').innerHTML = result; 
        } else {
           alert('There was a problem with the request.');
        }
     }
}


function showLinx(obj){
	
	
	var poststr = "data="+obj;
	//window.alert(obj);
	document.getElementById('linkx').innerHTML = "<img src=http://"+realurl+"/image/ajax-loader.gif></img>";
	document.getElementById('editx').innerHTML = "";
	makePOSTRequestNew('http://'+realurl+'/showlinks', poststr);
	
}

function showEditBox(obj){
	
	
	var poststr = "data="+obj;
	//window.alert(obj);
	
	document.getElementById('editx').innerHTML = "<img src=http://"+realurl+"/image/ajax-loader.gif></img>";
	makePOSTRequestNew('http://'+realurl+'/showeditbox', poststr);
	
}

function showLinxComplete(){
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        result = http_request.responseText; 
        document.getElementById('linkx').innerHTML = result; 
        } else {
           alert('There was a problem with the request.');
        }
     }
}

function showBoxComplete(){
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        result = http_request.responseText; 
        document.getElementById('editx').innerHTML = result; 
        } else {
           alert('There was a problem with the request.');
        }
     }
}

function showPopUp(){
	window.open("http://"+realurl+"/openhtmledit","Window1","menubar=no,width=750,height=900,toolbar=no");

}

function teleMainAdmin(obj){
	if (obj != "none"){
		var poststr = "data="+obj;
		//window.alert(obj);
		
		document.getElementById('tnext').innerHTML = "<img src=http://"+realurl+"/image/ajax-loader.gif></img>";
		makePOSTRequestNew('http://'+realurl+'/telecorp', poststr);
	}else{
		document.getElementById('tnext').innerHTML = "";
	}
}

function telecorpComplete(){
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        result = http_request.responseText; 
        document.getElementById('tnext').innerHTML = result; 
        } else {
           alert('There was a problem with the request.');
        }
     }
}

function teleCorpAdmin(obj,obj1){
	if (obj != "none"){
		
		var poststr = "data="+obj+"&iddata="+obj1;
		
		//window.alert("");
		
		document.getElementById('tnext1').innerHTML = "<img src=http://"+realurl+"/image/ajax-loader.gif></img>";
		makePOSTRequestNew('http://'+realurl+'/telecorpedt', poststr);
		
	}else{
		document.getElementById('tnext1').innerHTML = "";
	}
}

function telecorpEdtComplete(){
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        result = http_request.responseText; 
        document.getElementById('tnext1').innerHTML = result; 
        } else {
           alert('There was a problem with the request.');
        }
     }
}

function stopTeleUpdate(){
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        result = http_request.responseText; 
        document.getElementById('resultstatusa').innerHTML = result; 
        } else {
           alert('There was a problem with the request.');
        }
     }
}

function startTeleUpdates(){
	var poststr = "idx="+document.getElementById("idx").value+"&namesx="+document.getElementById("namesx").value+
	"&phonex="+document.getElementById("phonex").value+"&stdx="+document.getElementById("stdx").value+
	"&mobilex="+document.getElementById("mobilex").value+"&designationx="+document.getElementById("designationx").value+
	"&emailx="+document.getElementById("emailx").value+"&catx="+document.getElementById("catx").value+"&faxx="+document.getElementById("faxx").value;
	
	document.getElementById('resultstatusa').innerHTML = "<img src=http://"+realurl+"/image/ajax-loader.gif></img>";
	makePOSTRequestNew('http://'+realurl+'/teleupdatepage', poststr);
	
}

function teleExtraAdmin(obj){
	if (obj != "none"){
		
		var poststr = "data="+obj;
		
		//window.alert("");
		
		document.getElementById('tnext2').innerHTML = "<img src=http://"+realurl+"/image/ajax-loader.gif></img>";
		makePOSTRequestNew('http://'+realurl+'/telelistextra', poststr);
		
	}else{
		document.getElementById('tnext2').innerHTML = "";
	}
}

function teleExtraComplete(){
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        result = http_request.responseText; 
        document.getElementById('tnext2').innerHTML = result; 
        } else {
           alert('There was a problem with the request.');
        }
     }
}

function teleExtraFinal(obj,obj1){
	if (obj != "none"){
		
		var poststr = "data="+obj+"&iddata="+obj1;
		
		//window.alert("");
		
		document.getElementById('tnext4').innerHTML = "<img src=http://"+realurl+"/image/ajax-loader.gif></img>";
		makePOSTRequestNew('http://'+realurl+'/teleextraedt', poststr);
		
	}else{
		document.getElementById('tnext4').innerHTML = "";
	}
}

function teleExtraFinalComplete(){
	if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        result = http_request.responseText; 
        document.getElementById('tnext4').innerHTML = result; 
        } else {
           alert('There was a problem with the request.');
        }
     }
}


