function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
  return obj_window;
}

function help(fieldname,body) {
	pagename = '?q=help,'+fieldname+','+body+'';
	newWindow (pagename, 'help', 500, 100, 1, 0, 0, 0, 0, 0, 0);
}

function rhino_bookmark(){
  url = document.location;
  title = document.title;
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function rhino_print () {
	var _url = document.location + "";
	var pos = _url.indexOf("?");
	if (pos >= 0) {
			url = document.location + '&print=1';		
	}
	else {
			url = document.location + '?print=1';
	}
	newWindow(url, 'Print', '800', '600', 1, 1, 1, 1, 1, 1, 0);
}

function rhino_tell () {
	var tellurl = 'modules/friend/';
	newWindow(tellurl, 'Print', '400', '300', 0, 0, 0, 0, 0, 0, 0);
}

function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
        	 IsNumber = false;
         }
      }
   return IsNumber;   
}

function checkData(Text, control){//for calculator
		if(IsNumeric(Text)){	
		//alert(num);
	}else{
		document.calculateFrm.elements[control].value = "";
		alert('Please use number for this field.');
	}	
}

function clear_all(){
	
	for(i = 0; i < document.calculateFrm.elements.length; i++)
    {
        text = ""+document.calculateFrm.elements[i].value+"";
		
		if(text != "Submit" && text != "Reset"){
			document.calculateFrm.elements[i].value = "";
		}
	}
}

function calcFormulas(){
	A = window.top.document.calculateFrm.elements['A'].value;
	B = window.top.document.calculateFrm.elements['B'].value;
	C = window.top.document.calculateFrm.elements['C'].value;
	
	window.top.document.calculateFrm.elements['D'].value = (A/B)*30;
	D = window.top.document.calculateFrm.elements['D'].value;
	
	E = (B*(D-14)/365*10.5)/100;
	F = (B*(C-2.5))/100;
	G = parseFloat(E)*12;
	H = parseFloat(F)*12;
	I = parseFloat(E)+parseFloat(F);
	J = parseFloat(H)+parseFloat(G);
	
	window.top.document.calculateFrm.elements['E'].value = E.toFixed(2);
	window.top.document.calculateFrm.elements['F'].value = F.toFixed(2);
	window.top.document.calculateFrm.elements['G'].value = G.toFixed(2);
	window.top.document.calculateFrm.elements['H'].value = H.toFixed(2);
	window.top.document.calculateFrm.elements['I'].value = I.toFixed(2);
	window.top.document.calculateFrm.elements['J'].value = J.toFixed(2);
	
	for(i = 4; i < window.top.document.calculateFrm.elements.length; i++)
    {
        nStr = ""+window.top.document.calculateFrm.elements[i].value+"";
		
		if(nStr != "Submit" && nStr != "Reset"){
			window.top.document.calculateFrm.elements[i].value = addCommas(nStr);
		}
	}
}
function addCommas(nStr){
	 nStr += '';
	 x = nStr.split('.');
	 x1 = x[0];
	 x2 = x.length > 1 ? '.' + x[1] : '';
	 var rgx = /(\d+)(\d{3})/;
	 while (rgx.test(x1)) {
	  x1 = x1.replace(rgx, '$1' + ',' + '$2');
	 }
	 return x1 + x2;
}

function IsNumeric(value, field_id)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
	var error = 0;
 
   for (i = 0; i < value.length && IsNumber == true; i++) 
      { 
      Char = value.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         	
			strLen = value.length;
			document.getElementById(field_id).value = value.slice(0,strLen-1);
			//return false;	
         }
      }

   
   }
function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
        	 IsNumber = false;
         }
      }
   return IsNumber;   
}

function SetCustomText (id, what, link) {
	var desc = new Array()
	desc["medical_practitioner_submit"]='<ul><li>Claim submission to all medical aids</li><li>Immediate processing against all scheme rules and patient benefits </li><li>Immediate response with unique claim reference number</li><li>Guaranteed proof of claim    delivery</li></ul>';
	desc["medical_practitioner_track"] ='<ul><li>Daily notification of action required for claims submitted</li><li>Daily SMS of amount claimed and amount requiring action</li><li>Online access to all claim responses in one place</li></ul>';
	desc["medical_practitioner_reconcile"] ='<ul><li>Automatic and accurate reconciliation directly into the PMA</li><li>Daily notification of action required for electronic remittance advices received</li><li>Online access to electronic remittance advices in one format in one place</li></ul>',
	desc["medical_practitioner_collect"] ='<ul><li>Simple, convenient and cost effective online and cellphone collection from patients</li><li>Low card transaction rates, that decrease as transaction volumes increase</li></ul>';
	desc["medical_practitioner_manage"] ='<ul><li>Simplified daily running of a practice for improved profitability</li></ul>';

	desc["pathologiest_submit"] = '<ul><li>Reduced claim rejections</li><li>Immediate processing against all scheme rules and patient benefits </li><li>Guaranteed proof of claim delivery</li><li>Immediate response with unique claim reference number</li></ul>';

	desc["radiologists_submit"] = '<ul><li>Reduced claim rejections</li><li>Immediate processing against all scheme rules and patient benefits </li><li>Guaranteed proof of claim delivery</li><li>Immediate response with unique claim reference number</li></ul>';
	desc["radiologists_track"] = '<ul><li>Daily notification of action required for claims submitted</li><li>Daily SMS of amount claimed and amount requiring action</li><li>Online access to all claim responses in one place</li></ul>';
	desc["radiologists_reconcile"] = '<ul><li>Automatic and accurate reconciliation directly into the PMA </li></ul>';
	desc["radiologists_manage"] = '<ul><li>Simplified daily running of a practice for improved profitability</li></ul>';

	desc["hospital_submit"] = '<ul><li>Efficient and fast hospital admission</li><li>Immediate processing against all scheme rules and patient benefits </li><li>Guaranteed proof of claim delivery </li></ul>';
	desc["hospital_track"] = desc["hospital_submit"];


	body=document.getElementById(id);
	if (body) {
		body.innerHTML  = desc[what];
	}

	// set the link
	body=document.getElementById('readmore');
	if (body) {
		body.innerHTML  = '<a href="' + link + '"><img width=85 height=21 src=upload/setup_files/readmore_x.gif /></a>&nbsp;';
	}
}

function EnableDisable(id) {
     body=document.getElementById(id);
     if (body) {
       if (body.style.display == 'none') {
         try {
           body.style.display='table-row';
         } catch(e) {
           body.style.display = 'block';
         }
       }
       else {
         body.style.display = 'none';
       }
     }
}