// JavaScript Document
   function popup_new_page() 
   { 
     var kk;
	 w=screen.width;
	 h=screen.width;
     kk=window.open("comingsoon.php", "View", "fullscreen=yes,location=1,menubar=1,scrollbars=1,status=1,toolbar=1,resizable=1,HEIGHT="+h+",WIDTH="+w+",left=0,top=0"); 
	 kk.focus();
   } 

function send_java_email(id,domain)
{
	window.location.href='mail'+'to'+':'+id+'@'+domain;
	
}
function popup_email_to_friend(fpath)
{
   var kkk;
   kkk=window.open("_emailtofriend.php?fpath="+fpath, "Email","resizable=0,HEIGHT=500,WIDTH=520,left=200,top=100,replace,scrollbars"); 
   kkk.focus();
}

function gotomypage(val)
{
		if(val!='') 
		{ 

				 window.location='documents.php?wd='+val;
		}	
}
function printpage()
{
	if(confirmmsg('Would you like to continue printing this page?'))
	{
	 window.print();	
	}
}
 function add2fav()
 {
  if (document.all) 
  { 
  window.external.AddFavorite(location.href, document.title); 
  } 
  else if (window.sidebar) 
  { 
  window.sidebar.addPanel(document.title, location.href, ""); 
  }
 else
  { 
   alert("Sorry! Your browser doesn't support this function.");
  }
  return false; 
  } 
function set_txtbox_value(id,str)
{
	document.getElementById(id).value=str;
}
function remove_space_all(str)
{

var str=str;
return (str.replace(/ /g, ""));
}

function clear_msg()
{
//
return;
document.getElementById('msgmsg').innerHTML = "";
}

function submitform(form_name,action_file_name)
{
	
	var doc=form_name;
	doc.action=action_file_name;
	doc.submit();
}


<!--
// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}
//-->


function roundNumber(pnumber,decimals){
	if (isNaN(pnumber)) { return 0};
	if (pnumber=='') { return 0};
	
	var snum = new String(pnumber);
	var sec = snum.split('.');
	var whole = parseFloat(sec[0]);
	var result = '';
	
	if(sec.length > 1){
		var dec = new String(sec[1]);
		dec = String(parseFloat(sec[1])/Math.pow(10,(dec.length - decimals)));
		dec = String(whole + Math.round(parseFloat(dec))/Math.pow(10,decimals));
		var dot = dec.indexOf('.');
		if(dot == -1){
			dec += '.'; 
			dot = dec.indexOf('.');
		}
		while(dec.length <= dot + decimals) { dec += '0'; }
		result = dec;
	} else{
		var dot;
		var dec = new String(whole);
		dec += '.';
		dot = dec.indexOf('.');		
		while(dec.length <= dot + decimals) { dec += '0'; }
		result = dec;
	}	
	return result;
}

function roundNumber_old(number,decimal_points) 
{
//
	if(!decimal_points) return Math.round(number);
	if(number == 0) {
		var decimals = "";
		for(var i=0;i<decimal_points;i++) decimals += "0";
		return "0."+decimals;
	}

	var exponent = Math.pow(10,decimal_points);
	var num = Math.round((number * exponent)).toString();
	
	return num.slice(0,-1*decimal_points) + "." + num.slice(-1*decimal_points)
}

function abh_blank(value,return_msg)
{
    if(ISBLANK(value))
    {
        _hide_progress_();
        alert(return_msg);
        return false;
    }
}
function abh_email(value,return_msg,is_compulsory)
{
    if(ISBLANK(value)) 
    {
        if(is_compulsory==true)
        {
            _hide_progress_();
            alert(return_msg);
            return false;
        }
    }
    if(!ISBLANK(value)) 
    {
        if(checkemail(x.email.value)==false)
        {
            _hide_progress_();
            alert(return_msg);
            return false;
        }
    }
}
function abh_numeric(value,return_msg,is_compulsory)
{
    if(ISBLANK(value)) 
    {
        if(is_compulsory==true)
        {
            _hide_progress_();
            alert(return_msg);
            return false;
        }
    }
    if(!ISBLANK(value)) 
    {
        if(isNaN(value))
        {
            _hide_progress_();
            alert(return_msg);
            return false;
        }
    }
}
 
 

function show_edit(rowid)
{
var x;
var rowid=rowid;
// table-row or none
if(document.getElementById(rowid).style.display=="none")
{
   try
   {
   document.getElementById(rowid).style.display="table-row";
   }
   catch(e)
   {
      document.getElementById(rowid).style.display="block";
   }
}
else
{
document.getElementById(rowid).style.display="none";
}
}

function confirmmsg(msg)
{
 var go = confirm(msg);
 if (go == true) {
   return true;
 }
 else {
  return false;
 }
}
/// delete confir
function create() 
{
 var go = confirm("Are you sure to DELETE this record?");
 if (go == true) {
   return true;
 }
 else {
  return false;
 }
}


/// check is it blank
function ISBLANK(xx)
{ 
        var cc=0,tt;
		for(tt=0; tt<xx.length; tt++)
		{
		     if (xx.charAt(tt)==' ')
			 {
			 	cc=cc+1; // count blank character
			 }
		}
		if (cc==xx.length)
		{
			return true;  //// means it is BLANK
		}
	     return false;	//// means it is NOT BLANK
}
// Isvalidexcel .xls
function Isvalidexcel(xx) 
	{   
	    var str=xx;
		
		var dotpos=str.lastIndexOf('.');
		var rr=(str.charAt(dotpos+1)+str.charAt(dotpos+2)+str.charAt(dotpos+3)+str.charAt(dotpos+4));
		
		if (rr.toLowerCase()=="xls" )
		{
			return true;
		}
		else
		{
			return false;
		}
    }

// is valid brochure file : pdf/jpeg
function Isvalidbrochure(xx) 
	{   
	    var str=xx;
		
		var dotpos=str.lastIndexOf('.');
		var rr=(str.charAt(dotpos+1)+str.charAt(dotpos+2)+str.charAt(dotpos+3)+str.charAt(dotpos+4));
		
		if (rr.toLowerCase()=="pdf")
		{
			return true;
		}
		else
		{
			return false;
		}
    }
	
// is valid image file jpg/jpeg/gif
function IsValidimage(xx) 
	{   
	    var str=xx;
		
		var dotpos=str.lastIndexOf('.');
		var rr=(str.charAt(dotpos+1)+str.charAt(dotpos+2)+str.charAt(dotpos+3)+str.charAt(dotpos+4));
		
		if (rr.toLowerCase()=="jpg" || rr.toLowerCase()=="gif" || rr.toLowerCase()=="jpeg")
		{
			return true;
		}
		else
		{
			return false;
		}
    }


///////// RADIO BUTTON VALIDATION ////////

/*
/// how to call in main function
function CheckAll(x)
{
if(!is_radio_button_selected(x.radiobutton_name))
{
  alert ("Please select radio button !!");
  return false;
}
}
*///


function is_radio_button_selected(fieldnm)
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < fieldnm.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (fieldnm[counter].checked)
radio_choice = true; 
}

if (!radio_choice)
{
return (false); /// means not selected
}
return (true); /// means selected
}

///
function is_checkbox_button_selected(fieldnm)
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < fieldnm.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (fieldnm[counter].checked)
radio_choice = true; 
}

if (!radio_choice)
{
return (false); /// means not selected
}
return (true); /// means selected
}

///

function checkemail(myemail)
{
var str=myemail;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
{
testresults=true
}
else
{
testresults=false
}
return (testresults)
}
function readlistboxtext(listbox_id)
{

var k=document.getElementById(listbox_id);
var j=k.selectedIndex;
if(j==0)
{
return "";
}
return  document.getElementById(listbox_id).options[j].text;
}
///
function lastselect(oSelect)
{
	
oSelect.selectedIndex = oSelect.options.length-1;	
}

///
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

///

function setblanklistbox(document_listbox)
{
	document_listbox.options.length=0;
}

function addvalue_in_listbox(document_listbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
document_listbox.options.add(optn);

}

