function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch(e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}
/*********** Ajax Loader New *************/
function ProcessLoader()
{
    document.getElementById('dvprocessing').style.display = '';
}
/****************************************/


function disporderspinner(id, dir, url)
{   //alert(url);
	if(dir == 'up')
	{
       
		if(document.getElementById(id).value <= 1)
			return;
		document.getElementById(id).value = document.getElementById(id).value - 1;
		SendGridBindRequest(url,'gridbody','DO12');
	}
	else if(dir == 'down')
	{
       
		var order = document.getElementById(id).value;
		order++;
		document.getElementById(id).value = order;
		SendGridBindRequest(url,'gridbody','DO12');
	}
}


function CalculateTop(Height)
{
    var ScrollTop=document.body.scrollTop;
    if(ScrollTop==0)
    {
        if(window.pageYOffset)
            ScrollTop=window.pageYOffset;
        else
            ScrollTop=(document.body.parentElement)?document.body.parentElement.scrollTop:0;
    }

    var BodyHeight=document.body.clientHeight;

    if(BodyHeight==0)
    {
        BodyHeight=window.innerHeight;
    }
    if(BodyHeight==0)
    {
        BodyHeight=document.documentElement.clientHeight
    }

    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' )
    {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    }
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    var FinalTop=((myHeight-Height)/2)+ScrollTop;
    return FinalTop;
}


function hideIframe()
{
    if(ie)
    {
        var theIframe=document.getElementById("fadeboxiframe")
		
        if(theIframe!=null)
        {
            theIframe.style.display="none";
        }
    }
}

function SetBackground()
{
    document.getElementById('dvprocessing').style.display = '';
}
function UnsetBackground()
{
    document.getElementById('dimmer').style.width=0;
    document.getElementById('dimmer').style.height=0;
    document.getElementById('dimmer').style.visibility="";
    document.getElementById('dvprocessing').style.display = 'none';
}

function unhideIframe()
{
    if(ie)
    {
        var theIframe=document.getElementById("fadeboxiframe")
        var theDiv=document.getElementById("dvregisterfrm");
        theIframe.style.width=theDiv.offsetWidth+'px';
        theIframe.style.height=theDiv.offsetHeight+'px';
        theIframe.style.top=theDiv.offsetTop+'px';
        theIframe.style.left=theDiv.offsetLeft+'px';
        theIframe.style.display='';
    }
}


function rem_special_chars_js(string)
{
    string=string.replace(/\'/g, "&#39;");
    string=string.replace(/\"/g,"&quot;");
    
    return string;
}


function SendGridBindRequest(url,targetdiv,action,chkidfordelete,flgdisorder,flagvalue)
{
    xmlHttp = GetXmlHttpObject();
    if(xmlHttp != null)
    {
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState==1)
            {
                SetBackground();
            }
			
            if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
            {
                var str =  trim(xmlHttp.responseText);
                // alert(str);
                document.getElementById(targetdiv).innerHTML = '';
                document.getElementById(targetdiv).innerHTML = str;
                
                if(flagvalue!='' && (flagvalue=='uman' || flagvalue=='ser'))
                {
                    if(flagvalue=='uman')
                    {
                        var textareaid='main_description';
                        var boxwidth='1200';
                        var toolbartype='Default';
                    }
                    else
                    {
                        var textareaid='var_email_signature';
                        
                        if (CKEDITOR.instances['main_description'])
                        { 
                            CKEDITOR.remove(CKEDITOR.instances['main_description']); // with or without this line of code - rise an error }
                        }
                        var boxwidth='700';
                        var toolbartype='OnlyBasic';
                    }
                    
                    var editorInstance;
                    
                    if (CKEDITOR.instances[textareaid])
                    { 
                        CKEDITOR.remove(CKEDITOR.instances[textareaid]); // with or without this line of code - rise an error }
                    }
                    
                    
                    editorInstance = CKEDITOR.replace( textareaid,{

                        toolbar : toolbartype,
                        skin:'kama',
                        width:boxwidth,
                        filebrowserBrowseUrl : '../libraries/ckeditor/pdw_file_browser/index.php?editor=ckeditor',
                        filebrowserImageBrowseUrl : '../libraries/ckeditor/pdw_file_browser/index.php?editor=ckeditor&filter=image',
                        filebrowserFlashBrowseUrl : '../libraries/ckeditor/pdw_file_browser/index.php?editor=ckeditor&filter=flash'
                    });
                    
                    
                    
                    if(flagvalue=='uman')
                    {
                        if(document.getElementById('chr_maintenance').checked==true)
                        {
                            document.getElementById('ckeditordiv').style.display='';
                            document.getElementById('ckeditormaindiv').style.display='';
                        }
                        else
                        {
                            document.getElementById('ckeditordiv').style.display='none';
                            document.getElementById('ckeditormaindiv').style.display='none';
                        }
                    }
                }

                UnsetBackground();
				
                switch(action)
                {
                    case 'S': // to set the focus on the search text field
                        document.getElementById('searchtxt1').focus();
                        break;
					
                    case 'Gtop': // to set the focus on the go to page text field on top
                        document.getElementById('txtgotopagetop').focus();
                        break;
					
                    case 'Gbottom': // to set the focus on the go to page text field on bottom
                        document.getElementById('txtgotopagebottom').focus();
                        break;
					
                    case 'D': // This is when the delete button is clicked
                        alert("Congrats! The records have been deleted succesfully.");
                        break;
					
                    case 'none': // This is for delete ids directly passed
                        alert("No Records deleted .");
                        break;
					
                    case 'PS': //This is for for focusing display select box
                        var position = trim(document.getElementById('position').value);
                        document.getElementById('cmbdisplay'+position).focus();
                        break;
					
                    case 'FT':
                        document.getElementById('filterbytop').focus();
                        break;
						
                    case 'FB':
                        document.getElementById('filterbybottom').focus();
                        break;
                    case 'FS':
                        document.getElementById('filterbystatus').focus();
                        break;
						
                    case 'MT':
                        document.getElementById('cmbmodulestop').focus();
                        break;

                    case 'MB':
                        document.getElementById('cmbmodulesbottom').focus();
                        break;
                }
            }
        };
		
        var appendurl = '';
        
        switch(action)

               
        {
            case 'PStop':
				 
                var pagesize = trim(document.getElementById('cmbdisplaytop').value);
				 
                appendurl = '&pagesize='+pagesize;
                if (chkObjects('cmbmodulestop'))
                {
                    var filterby = trim(document.getElementById('cmbmodulestop').value);
                    appendurl = '&pagesize='+pagesize+'&view='+filterby;
                }
				 
                break;
            case 'PSbottom':

                var pagesize = trim(document.getElementById('cmbdisplaybottom').value);

                appendurl = '&pagesize='+pagesize;
				 
                if (chkObjects('cmbmodulesbottom'))
                {
                    var filterby = trim(document.getElementById('cmbmodulesbottom').value);
                    appendurl = '&pagesize='+pagesize+'&view='+filterby;
                }

                break;
			
            case 'S': // This is for search
                var searchtxt = trim(document.getElementById('searchtxt1').value);                
                var searchby = document.getElementById('searchby').value;
                
              
                appendurl = '&searchby='+searchby+'&searchtxt='+searchtxt;
                 
                break;
				
            case 'FCAT': // This is for filter
				
                var feature = trim(document.getElementById('feature').value);
                appendurl = '&feature='+feature;
                break;
				
            case 'FT': // This is for filter
				
                var filterby = trim(document.getElementById('filterbytop').value);
                appendurl = '&filterby='+filterby;
                break;
				
            case 'FB': // This is for filter
				
                var filterby = trim(document.getElementById('filterbybottom').value);
                appendurl = '&filterby='+filterby;

                break;
                
             case 'search_category_services':
                        var var_title1=document.getElementById('var_title1').value;
                        appendurl = '&categoryid='+var_title1
                        break;   
                
            case 'FS': // This is for filter
				
                var filterby = trim(document.getElementById('filterbystatus').value);
                appendurl = '&filterbystatus='+filterby;

                break;
                
            
            case 'MTC': // This is for filter
				
                var filterby = trim(document.getElementById('filterbystatus').value);
                appendurl = '&filterbystatus='+filterby;
                alert(appendurl);

                break;	
                        
            case 'MT': // This is for filter by modules in trash manager

                var filterby = trim(document.getElementById('cmbmodulestop').value);
                var tid = document.getElementById('h_view').value;
                document.getElementById('trname').value=document.getElementById('cmbmodulestop').value;
                var pagesize = trim(document.getElementById('cmbdisplaytop').value);


                $(function()
                {
                    var view=document.getElementById('trname').value;

                    var flagChange = false;
                    $("#searchby").change(function() {
                        flagChange = true;
                        var changeVal = $("#searchby option:selected").val();
                        $("#searchtxt1").autocomplete({
                            source: "index.php?auto=searchval&module=trashmanager&searchbyVal="+changeVal+"&view="+view,
                            term:'term',
                            minLength: 2,
                            select: function(event, ui) {
                                $('#searchtxt1').val(ui.item.id);
                            }
                        });
                    });
                    if(flagChange == false)
                    {
                        $('#searchtxt1').live('keypress', function() {
                            $(this).autocomplete({
                                source: "index.php?auto=searchval&module=trashmanager&searchbyVal="+$("#searchby option:selected").val()+"&view="+view,
                                term:'term',
                                minLength: 2,
                                select: function(event, ui) {
                                    $('#searchtxt1').val(ui.item.id);
                                }
                            });
                        });
                    }
                });
 
                appendurl = '&view='+filterby + '&pagesize='+pagesize;
                break;

            case "CT":

                var mastertype=$("#cbmmastertypetop option:selected").val();
                if(mastertype != undefined)
                    appendurl = appendurl+'&mastertype='+mastertype;
                else
                    appendurl = appendurl+'&mastertype=0';
                    
                var catrgorycode=$("#cmbcategorytop option:selected").val();
                //alert(catrgorycode);
                if(catrgorycode!=0)
                {
                    appendurl = appendurl+'&catrgorycode='+catrgorycode;
                }
                else
                {
                    appendurl = appendurl+'&catrgorycode=0';
                }
                break;

            case 'MR': // This is for filter by modules in trash manager
                appendurl="";

                    
                var modulecode=$("#cmbmodulestop option:selected").val();
                    
                if(modulecode!=0 && modulecode!=undefined)
                {
                    appendurl = appendurl+'&modulecode='+modulecode;
                }
                    
                var moduleglcode=$("#moduleglcode").val();

                if(moduleglcode!="" && moduleglcode!=undefined)
                {
                    appendurl = appendurl+'&moduleglcode='+moduleglcode;
                }
                    
                var formtype=$("#cmbformtypetop option:selected").val();

                if(formtype!=0 && formtype!=undefined)
                {
                    appendurl = appendurl+ '&formtype='+formtype;
                }

                var pagesize = trim(document.getElementById('cmbdisplaytop').value);
                appendurl += '&pagesize='+pagesize ;
                             
                break;
				
            case 'MB': // This is for filter by module
				
                var filterby = trim(document.getElementById('cmbmodulesbottom').value);
                var pagesize = trim(document.getElementById('cmbdisplaybottom').value);
                appendurl = '&view='+filterby + '&pagesize='+pagesize;
				
                break;

            case 'MDC': // This is for filter
				
                var mcombo = trim(document.getElementById('modulecombo').value);
                appendurl = '&mdnm='+mcombo;
                break; 
                
            case 'MDC1': // This is for filter
				
                var tcombo = trim(document.getElementById('typecombo').value);
                appendurl = '&tcmb='+tcombo;
                break;      
                
            case 'Gtop': // This is for go to page text field top
                
                var noofpages = trim(document.getElementById('hdnnoofpages').value);
                var enteredpageno = trim(document.getElementById('txtgotopagetop').value);
                if(enteredpageno == '' || enteredpageno == 0)
                {
                    alert("Please enter page number.");
                    document.getElementById('txtgotopagetop').focus();
                    return false;
                }
                else if(parseInt(enteredpageno) > parseInt(noofpages))
                {
                    alert("Please enter proper page number.");
                    document.getElementById('txtgotopagetop').focus();
                    return false;
                }
                appendurl = '&pagenumber='+enteredpageno;
                break;
				
            case 'Gbottom': // This is for go to page text field bottom
              
                var noofpages_2 = trim(document.getElementById('hdnnoofpages').value);
                var enteredpageno_2 = trim(document.getElementById('txtgotopagebottom').value);
                if(enteredpageno_2 == '' || enteredpageno_2 == 0)
                {
                    alert("Please enter page number.");
                    document.getElementById('txtgotopagebottom').focus();
                    return false;
                }
                else if(parseInt(enteredpageno_2) > parseInt(noofpages_2))
                {
                    alert("Please enter proper page number.");
                    document.getElementById('txtgotopagebottom').focus();
                    return false;
                }
                appendurl = '&pagenumber='+enteredpageno_2;
                break;
				
            case 'D': // This is for delete

                var chkelements = document.getElementsByName(chkidfordelete);
                var ids = "";
                var countChecked = 0;
                for(var i = 0; i < chkelements.length; i++)
                {
                    if(chkelements.item(i).checked == true)
                    {
                        countChecked++;
                        if(ids != "")
                            ids += ",";
                        ids += chkelements.item(i).value;
                    }
                }
                if(countChecked == 0)
                {
                    alert(" Please select atleast one record for delete.");
                    return false;
                }
                if(!confirm('Caution! The selected records will be deleted. Press OK to confirm.'))
                {
                    return false;
                }
				
                var totalpagerecords = document.getElementById('ptrecords').value;
                appendurl = '&action=delete&ptotalr='+totalpagerecords+'&dids='+ids;
                       
                break;
				
            case 'Delids': // This is for delete ids directly passed
			       
                var ids=chkidfordelete;
                var totalpagerecords = document.getElementById('ptrecords').value;
                appendurl = '&action=delete&ptotalr='+totalpagerecords+'&dids='+ids;
                break;

            case 'Delids': // This is for delete ids directly passed

                var ids=chkidfordelete;
                var totalpagerecords = document.getElementById('ptrecords').value;
                appendurl = '&action=delete&ptotalr='+totalpagerecords+'&dids='+ids;
                       
                break;
                
            case 'status':

                var status = document.getElementById('var_status').value;
                appendurl = '&status='+status;
                break;
				
            case 'typecmb':

                var type = document.getElementById('typecombo').value;
                appendurl = '&typecmb='+type;
                break;
            
            case 'packagetype':
                var optval = document.getElementById('var_packagetype').value;
                appendurl = '&optval='+optval;
                break;
           
           case 'position':
                var var_position = document.getElementById('var_position').value;
                appendurl = '&var_position='+var_position;
                break;
                
            case 'APP1':
                var chr_action = trim(document.getElementById('chr_action').value);
                appendurl = '&chr_action='+chr_action;
                break;    

            case 'AP': // This is for approve in grid
                appendurl = '&QT=4';
                break;
			
            case 'DISP': // This is for display in grid
                appendurl = '&action=display&QT=5';
                break;
			
            case 'CACHE': // This is for display in grid
                appendurl = '&action=cache&QT=5';
                break;
			
            case 'DEFAULT': // This is for display in grid
                appendurl = '&action=setdefault&QT=5';
                break;
			
            case 'QEDIT': // This is for quick edit in grid
                var quickfields = new Array();
                var varname = new Array();
                quickfields = chkidfordelete.split(',');
                for(i=0;i<quickfields.length;i++)
                {
                    varname[i] = document.getElementById(quickfields[i]).value;
                }
                appendurl = '&QT=6&varname='+varname+'';
                break;
			
            case 'APR': // This is for approve rating in grid
                appendurl = '&QT=7';
                break;
			
            case 'DO': // This is for bulk display order in grid
                     
                var totalrows = document.getElementById('ptrecords').value;
                var ids = "";
                var values = "";
                var oldvalues = "";
                var commonglcode = "";
					
                var elementforid = "";
                var elementforvalues = "";
                var elementforoldvalues = "";
                var elementforcommonglcodes = "";
					
                for(var i = 0; i < totalrows; i++)
                {
                    if(ids != "")
                        ids += ",";
							
                    if(values != "")
                        values += ",";
							
                    if(oldvalues != "")
                        oldvalues += ",";
						
                    elementforid = "hdnintglcode" + i;
                    elementforvalues = "displayorder" + i;
                    elementforoldvalues = "hdndisplayorder" + i;
						
                    if(document.getElementById(elementforvalues).value == "")
                    {
                        alert("Field(s) cannot be left blank.");
                        document.getElementById(elementforvalues).focus();
                        return;
                    }
                    if(document.getElementById(elementforvalues).value == 0)
                    {
                        alert("Sorry! The Display Order Value cannot be Zero.");
                        document.getElementById(elementforvalues).focus();
                        return;
                    }

                    if(trim(document.getElementById(elementforvalues).value) == "")//change by jshah to stop multiple spaces
                    {
                        alert("Field(s) can not be left blank.");
                        document.getElementById(elementforvalues).focus();
                        return;
                    }
						
                    ids += document.getElementById(elementforid).value;
                    values += document.getElementById(elementforvalues).value;
                    oldvalues += document.getElementById(elementforoldvalues).value;

                    if(flgdisorder)
                    {
                        if(commonglcode != "")
                            commonglcode += ",";
                        elementforcommonglcodes = "hdncommonglcode" + i;
                        commonglcode += document.getElementById(elementforcommonglcodes).value;
                    }
                }
                appendurl = '&task=orderupdate&uids='+ids+'&uvals='+values+'&uoldvals='+oldvalues+'&cmnglcode='+commonglcode;
                break;
                
                
                 case 'DO12': // This is for bulk display order in grid
                var totalrows = document.getElementById('ptrecords').value;
                var ids = "";
                var values = "";
                var oldvalues = "";
                var commonglcode = "";
					
                var elementforid = "";
                var elementforvalues = "";
                var elementforoldvalues = "";
                var elementforcommonglcodes = "";
				
                for(var i=0; i < totalrows; i++)
                {
                    if(ids != "")
                        ids += ",";
							
                    if(values != "")
                        values += ",";
							
                    if(oldvalues != "")
                        oldvalues += ",";
						
                    elementforid = "hdnintglcode" + i;
                    elementforvalues = "displayorder" + i;
                    elementforoldvalues = "hdndisplayorder" + i;
//                    alert(document.getElementById(elementforvalues).value);
//                    alert(trim(document.getElementById(elementforvalues).value));
                    if(trim(document.getElementById(elementforvalues).value) == "")
                    {
                        alert(FIELD_BLANK);
                        document.getElementById(elementforvalues).focus();
                        return;
                    }
                    if(trim(document.getElementById(elementforvalues).value) == "0")
                    {
                        alert(DISPLAY_ORDER_ZERO);
                        document.getElementById(elementforvalues).focus();
                        return;
                    }
						
                    ids += document.getElementById(elementforid).value;
                    values += document.getElementById(elementforvalues).value;
                    oldvalues += trim(document.getElementById(elementforoldvalues).value);

                    if(flgdisorder)
                    {
                        if(commonglcode != "")
                            commonglcode += ",";
						 
                        elementforcommonglcodes = "hdncommonglcode" + i;
                        commonglcode += document.getElementById(elementforcommonglcodes).value;
							
                    }
                }
                appendurl = '&action=orderupdate&uids='+ids+'&uvals='+values+'&uoldvals='+oldvalues+'&cmnglcode='+commonglcode;
                
                 break;
            case 'MUS': // This is for music in event category grid
                appendurl = '&QT=9';
					 
                break;
            case 'ORDSTATUS': // This is for Order Status Combo
                appendurl = '&QT=10&ordstatusglcode='+chkidfordelete;
                //alert(appendurl);
					 
                break;

            case 'SRCAT':
                var cate = document.getElementById('category').value;
                appendurl = '&category='+cate;
                break;
            
            case 'RECMD': // This is for Pinstripe Recommended Combo
                appendurl = '&QT=11';
					 
                break;
            case 'NEWSLET': // This is for Newsletter
                appendurl = '&QT=12';
                break;
            case 'CHSTATUS': // This is for Request CHANGE STATUS in magazine page in grid
                appendurl = '&QT=16';
                break;


            case 'MVF':
                var modval = document.getElementById('module').value;

                appendurl = '&modval='+modval;
                break;
            case ' JKL':
                var var_position = document.getElementById('var_position').value;

                appendurl = '&var_position='+var_position;
                break;
           
           
            case 'CTF':
                var cat_id = document.getElementById('categorytype').value;

                appendurl = '&categorytype='+cat_id;
                
                break;
                
                 case 'SNC':
                var short_id = document.getElementById('var_categoery').value;
                appendurl = '&categorytype='+short_id;
//                  alert(appendurl);
                  break;
          
          
          
           case 'SNC1':
                var short_id = document.getElementById('fk_category').value;
                appendurl = '&categorytype='+short_id;
//                  alert(appendurl);
                  break;
                  
           case 'SNC2':
                var short_id = document.getElementById('fk_des_category').value;
                appendurl = '&des_categorytype='+short_id;
//                  alert(appendurl);
                  break;
                  
            case 'ADP':
                var pos = document.getElementById('positiontype').value;
                appendurl = '&position='+pos;
                break;
            
            case 'CTF1':
                var cat_id = document.getElementById('fk_category').value;

                appendurl = '&fk_category='+cat_id;
                //                alert(appendurl);
                break;
                
            case 'WTC':
                var chr_garranty = document.getElementById('chr_garranty').value;

                appendurl = '&chr_garranty='+chr_garranty;
                break;
            case 'JKL':
                var var_position = document.getElementById('var_position').value;

                appendurl = '&var_position='+var_position;
                break;


            case 'R': // This is for bulk rating order in grid
                var totalrows = document.getElementById('ptrecords').value;
                var ids = "";
                var values = "";
                var oldvalues = "";
                var commonglcode = "";

                var elementforid = "";
                var elementforvalues = "";
                var elementforoldvalues = "";
                var elementforcommonglcodes = "";

                for(var i = 0; i < totalrows; i++)
                {
                    if(ids != "")
                        ids += ",";

                    if(values != "")
                        values += ",";

                    if(oldvalues != "")
                        oldvalues += ",";

                    elementforid = "hdnintglcode" + i;
                    elementforvalues = "int_rating" + i;
                    elementforoldvalues = "hdndisplayorder" + i;

                    if(trim(document.getElementById(elementforvalues).value) == "")
                    {
                        alert("Field(s) cannot be left blank.");
                        document.getElementById(elementforvalues).focus();
                        return;
                    }
                    if(document.getElementById(elementforvalues).value <= 0)
                    {
                        alert("Rating cannot be zero or less than zero");
                        document.getElementById(elementforvalues).focus();
                        return;
                    }

                    ids += document.getElementById(elementforid).value;
                    values += document.getElementById(elementforvalues).value;
                    oldvalues += document.getElementById(elementforoldvalues).value;

                    if(flgdisorder)
                    {
                        if(commonglcode != "")
                            commonglcode += ",";

                        elementforcommonglcodes = "hdncommonglcode" + i;
                        commonglcode += document.getElementById(elementforcommonglcodes).value;

                    }
                }
                appendurl = '&task=orderupdate&uids='+ids+'&uvals='+values+'&uoldvals='+oldvalues+'&cmnglcode='+commonglcode;
                break;
        }
        //alert(url + '&ajax=Y'+appendurl);
        xmlHttp.open('GET', url + '&ajax=Y'+appendurl, true);
        xmlHttp.send(null);
    }
    else
    {
        alert("Your browser does not support HTTP Request");
    }
    return true;
}

// Common function for updating a star
function UpdateStar(tablename, fieldname,intglcode)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }
	
    var path=document.getElementById('star-'+intglcode).src;
    var file_a= path.substring(path.lastIndexOf("/")+1,path.length);
    var value;
    if(file_a == 'gstar.png')
    {
        value = 'N';
    }
    else if(file_a == 'gstar-disable.png')
    {
        value = 'Y';
    }
	
    var url = "index.php?ajax=Y&tablename="+tablename+"&fieldname="+fieldname+"&value="+value+"&id="+intglcode;
    xmlHttp.onreadystatechange = function()
    {
        if(xmlHttp.readyState==1)
        {
            SetBackground();
        }
        if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
        {
            var result = xmlHttp.responseText;
			
            if(result == 1)
            {
                if(value == 'Y')
                {
                    document.getElementById('star-'+intglcode).src = 'html/images/gstar.png';
                    document.getElementById('star-'+intglcode).title='Starred';
                }
                else
                {
                    document.getElementById('star-'+intglcode).src = 'html/images/gstar-disable.png';
                    document.getElementById('star-'+intglcode).title='Not starred';
                }
            }
            else
            {
                alert("Sorry could not update...");
            }
			
            UnsetBackground();
		
        }
    };
	
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function UpdatePublish(tablename, fieldname,intglcode,othertable)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }
	
    var path=document.getElementById('tick-'+intglcode).src;
    var file_a= path.substring(path.lastIndexOf("/")+1,path.length);
    var value;
    if(file_a == 'tick.png')
    {
        value = 'N';
    }
    else if(file_a == 'tick_cross.png')
    {
        value = 'Y';
    }
    if(othertable == '')
        var url = "index.php?ajax=Y&tablename="+tablename+"&fieldname="+fieldname+"&value="+value+"&id="+intglcode;
    else
        var url = "index.php?ajax=Y&tablename="+tablename+"&fieldname="+fieldname+"&value="+value+"&id="+intglcode+"&othertablename="+othertable;

    xmlHttp.onreadystatechange = function()
    {
        if(xmlHttp.readyState==1)
        {
            //ProcessLoader();
            SetBackground();
        }
        if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
        {
            var result = xmlHttp.responseText;
			
            if(result == 1)
            {
                if(value == 'Y')
                {
                    document.getElementById('tick-'+intglcode).src = 'html/images/tick.png';
                    //document.getElementById('star-'+intglcode).onclick = function(){UpdateStar('pst_restaurant','chrstar','N',intglcode);};
                    if(tablename == 'ecl_special' || tablename == 'ecl_photoalbum'|| tablename == 'ecl_news' || tablename == 'ecl_package' || tablename == 'ecl_product')
                        {
                            document.getElementById('push_'+intglcode).innerHTML = '<img id="shar-'+intglcode+'" height="25" width="77" src="html/images/1-push.png" style="vertical-align:middle;cursor:pointer;<?= $display ?>" onclick="share('+intglcode+');">';
                        }
                    
                    if(document.getElementById('tick-'+intglcode).title=="UnSubscribed")
                        document.getElementById('tick-'+intglcode).title = 'Subscribed';
                    else
                        document.getElementById('tick-'+intglcode).title = 'Hide me';
                }
                else
                {
                    document.getElementById('tick-'+intglcode).src = 'html/images/tick_cross.png';
                    //document.getElementById('star-'+intglcode).onclick = function(){UpdateStar('pst_restaurant','chrstar','Y',intglcode);};
                    if(tablename == 'ecl_special' || tablename == 'ecl_photoalbum'|| tablename == 'ecl_news' || tablename == 'ecl_package' || tablename == 'ecl_product')
                        {
                            document.getElementById('push_'+intglcode).innerHTML = 'N/A';
                        }
                    
                    
                    if(document.getElementById('tick-'+intglcode).title=="Subscribed")
                        document.getElementById('tick-'+intglcode).title = 'UnSubscribed';
                    else
                        document.getElementById('tick-'+intglcode).title = 'Display me';
                }
            }
            else
            {
                alert("Sorry could not update...");
            }
			
            UnsetBackground();
		 
        }
    };
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function UpdatePublish_modulewise(tablename, fieldname,intglcode,othertable,module)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }
	
    var path=document.getElementById('tick-'+intglcode).src;
    var file_a= path.substring(path.lastIndexOf("/")+1,path.length);
    var value;
    if(file_a == 'tick.png')
    {
        value = 'N';
    }
    else if(file_a == 'tick_cross.png')
    {
        value = 'Y';
    }
    if(othertable == '')
        var url = "index.php?module="+module+"&action=updatepublish&tablename="+tablename+"&fieldname="+fieldname+"&value="+value+"&id="+intglcode;
    else
        var url = "index.php?module="+module+"&action=updatepublish&tablename="+tablename+"&fieldname="+fieldname+"&value="+value+"&id="+intglcode+"&othertablename="+othertable;

    xmlHttp.onreadystatechange = function()
    {
        if(xmlHttp.readyState==1)
        {
            //ProcessLoader();
            SetBackground();
        }
        if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
        {
            var result = xmlHttp.responseText;
			
            if(result == 1)
            {
                if(value == 'Y')
                {
                    document.getElementById('tick-'+intglcode).src = 'html/images/tick.png';
                    //document.getElementById('star-'+intglcode).onclick = function(){UpdateStar('pst_restaurant','chrstar','N',intglcode);};
                    if(tablename == 'ecl_special' || tablename == 'ecl_photoalbum'|| tablename == 'ecl_news' || tablename == 'ecl_package' || tablename == 'ecl_product')
                        {
                            document.getElementById('push_'+intglcode).innerHTML = '<img id="shar-'+intglcode+'" height="25" width="77" src="html/images/1-push.png" style="vertical-align:middle;cursor:pointer;<?= $display ?>" onclick="share('+intglcode+');">';
                        }
                    
                    if(document.getElementById('tick-'+intglcode).title=="UnSubscribed")
                        document.getElementById('tick-'+intglcode).title = 'Subscribed';
                    else
                        document.getElementById('tick-'+intglcode).title = 'Hide me';
                }
                else
                {
                    document.getElementById('tick-'+intglcode).src = 'html/images/tick_cross.png';
                    //document.getElementById('star-'+intglcode).onclick = function(){UpdateStar('pst_restaurant','chrstar','Y',intglcode);};
                    if(tablename == 'ecl_special' || tablename == 'ecl_photoalbum'|| tablename == 'ecl_news' || tablename == 'ecl_package' || tablename == 'ecl_product')
                        {
                            document.getElementById('push_'+intglcode).innerHTML = 'N/A';
                        }
                    
                    
                    if(document.getElementById('tick-'+intglcode).title=="Subscribed")
                        document.getElementById('tick-'+intglcode).title = 'UnSubscribed';
                    else
                        document.getElementById('tick-'+intglcode).title = 'Display me';
                }
            }
            else
            {
                alert("Sorry could not update...");
            }
			
            UnsetBackground();
		 
        }
    };
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}



// Common function for updating publish   //UpdateDefault
function UpdatePublish_pages(tablename, fieldname,intglcode,module)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }

    var path=document.getElementById('tick-'+intglcode).src;
    var file_a= path.substring(path.lastIndexOf("/")+1,path.length);
    var value;
    var flagconfirm ='Y';
    if(file_a == 'tick.png')
    {
        value = 'N';
    }
    else if(file_a == 'tick_cross.png')
    {
        value = 'Y';
    }
    if(value=='Y')
    {
        flagconfirm='Y';
    }
   
    //alert(flagconfirm);
    var url = "index.php?module="+module+"&action=updatepublish&ajax=Y&table="+tablename+"&field="+fieldname+"&value="+value+"&id="+intglcode+"&flagconfirm="+flagconfirm;
    

    xmlHttp.onreadystatechange = function()
    {
        if(xmlHttp.readyState==1)
        {
            //ProcessLoader();
            SetBackground();
        }
        if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
        {
            var str = xmlHttp.responseText;

            var result = str.split('$$$$$');
            if(result[1] == 1)
            {
                var recordid = result[2].split(',');
                var totalids = recordid.length;
				
                for(var i=0;i<totalids;i++)
                {
                    if(value == 'Y')
                    {
                        document.getElementById('tick-'+recordid[i]).src = 'html/images/tick.png';
                        //document.getElementById('star-'+intglcode).onclick = function(){UpdateStar('pst_restaurant','chrstar','N',intglcode);};
	
                        if(document.getElementById('tick-'+recordid[i]).title=="UnSubscribed")
                            document.getElementById('tick-'+recordid[i]).title = 'Subscribed';
                        else
                            document.getElementById('tick-'+recordid[i]).title = 'Hide me';
                    }
                    else
                    {
                        document.getElementById('tick-'+recordid[i]).src = 'html/images/tick_cross.png';
                        //document.getElementById('star-'+intglcode).onclick = function(){UpdateStar('pst_restaurant','chrstar','Y',intglcode);};
	
                        if(document.getElementById('tick-'+recordid[i]).title=="Subscribed")
                            document.getElementById('tick-'+recordid[i]).title = 'UnSubscribed';
                        else
                            document.getElementById('tick-'+recordid[i]).title = 'Display me';
                    }
                }
            }
            else
            {
                alert("Sorry could not update...");
            }
			
            UnsetBackground();
		
        }
    };
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}


// End Of Common function for updating publish

function updatereadstar(cmbid,tablename,chkidfordelete)
{
	
    if(document.getElementById(cmbid).value == '0')
        return false;
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }
    var chkelements = document.getElementsByName(chkidfordelete);
    
    var ids = "";
    var countChecked = 0;
    for(var i = 0; i < chkelements.length; i++)
    {
        if(chkelements.item(i).checked == true)
        {
            countChecked++;
            if(ids != "")
                ids += ",";
            ids += chkelements.item(i).value;
        }
    }
    if(countChecked == 0)
    {
        alert(" Please select atleast one record to be changed.");
        document.getElementById('cmbmoreactiontop').value = '0';
        return false;
    }
    
    var cmboption = document.getElementById(cmbid).value;
    var fieldname;
    var value;
    switch(cmboption)
    {
        case 'r': // To Mark As Read
            fieldname = 'chr_read';
            value = 'Y';
            break;
        case 'ur': // To Mark As UnRead
            fieldname = 'chr_read';
            value = 'N';
            break;
        case 'as': // Too Add Star
            fieldname = 'chr_star';
            value = 'Y';
            break;
        case 'rs': // Too Remove Star
            fieldname = 'chr_star';
            value = 'N';
            break;
        
    }
    var url = "index.php?ajax=Y&tablename="+tablename+"&fieldname="+fieldname+"&value="+value+"&id="+ids;
    //alert(url );
    xmlHttp.onreadystatechange = function(){
        if(xmlHttp.readyState==1)
        {
            //ProcessLoader();
            SetBackground();
        }
        if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
        {
            var result = xmlHttp.responseText;
            var idarray = ids.split(',');
            var classname ;
            var classarray ;
            var finalclassname;
            if(result == 1)
            {
                if(value == 'Y' && fieldname == 'chr_star')
                {
                    for ( var i=0, len=idarray.length; i<len; ++i ){
					   
                        document.getElementById('star-'+idarray[i]).src = 'html/images/gstar.png';
                        document.getElementById('star-'+idarray[i]).title ='Starred';
                    }
                }
                else if(value == 'N' && fieldname == 'chr_star')
                {
                    for ( var i=0, len=idarray.length; i<len; ++i ){
					
                        document.getElementById('star-'+idarray[i]).src = 'html/images/gstar-disable.png';
                        document.getElementById('star-'+idarray[i]).title ='Not starred';
                    }
                }
			
			
                if(value == 'Y' && fieldname == 'chr_read')
                {
                    for ( var i=0, len=idarray.length; i<len; ++i )
                    {
                        
                        document.getElementById('gtr-'+idarray[i]).className = 'grid-list-inner-table-text';
                        if(document.getElementById('imgStar-'+idarray[i]))
                        {                        
                            document.getElementById('star1-'+idarray[i]).style.display='none';
                            document.getElementById('imgStar-'+idarray[i]).src = '';
                        }
                        
                    }
                }
                if(value == 'N' && fieldname == 'chr_read')
                {
                    for ( var i=0, len=idarray.length; i<len; ++i )
                    {
                        
                        document.getElementById('gtr-'+idarray[i]).className = 'grid-list-inner-table-text-active';
                        
                        if(document.getElementById('imgStar-'+idarray[i]))
                        {                             
                            document.getElementById('star1-'+idarray[i]).style.display='';
                            document.getElementById('imgStar-'+idarray[i]).src = 'html/images/star_red.png';
                        }
                        
                       
                    }
                }
			
                document.getElementById(cmbid).value = '0';
            }
            else
            {
                alert("Sorry could not update...");
            }
		
            UnsetBackground();
        }
    };
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}


function expandCollapse(id)
{
    var cid = "collapse" + id;
    if(document.getElementById(id).style.display == "")
    {
        document.getElementById(id).style.display = "none";
        document.getElementById(cid).innerHTML = "+";
    }
    else
    {
        document.getElementById(id).style.display = "";
        document.getElementById(cid).innerHTML = "-";
    }
}


function expandcollapsepanel(panelid)
{

    if(document.getElementById(panelid).style.display == '')
    {
        document.getElementById(panelid).style.display = 'none';
    }
    else
    {
        document.getElementById(panelid).style.display = '';
    }

}
function KeycheckWithDecimal(e)
{
    var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    if(_dom==2){                     // for NN4
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }
    if(KeyID == 46)
    {
        return true;
    }
    if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
    {
        return false;
    }
    return true;
}
function KeycheckOnlyNumeric(e)
{
	
    var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    if(_dom==2){                     // for NN4
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }
    if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126) || (KeyID == 32))//changed by jshah for stopping spaces
    {
        return false;
    }
    return true;
}

function KeycheckOnlyPhonenumber(e)
{
   
    var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    if(_dom==2){                     // for NN4
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }
    if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 39) || (KeyID == 42 || KeyID == 44) || (KeyID >= 46 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
    {
        return false;
    }
	
    return true;
}


function checkemail(str)
{
    var testresults;
    
    var filter=/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i;

    if (filter.test(str))
        testresults=true
    else
        testresults=false

    return (testresults)
}


function checkall(id)
{
    if(document.getElementById('chkall').checked == true)
    {
        var chkelements = document.getElementsByName(id);

        for(var i = 0; i < chkelements.length; i++)
        {
            chkelements.item(i).checked = true;
        }
    }
    else
    {
        var chkelements = document.getElementsByName(id);

        for(var i = 0; i < chkelements.length; i++)
        {
            chkelements.item(i).checked = false;
        }
    }
}

function onkeydown_search(evt)
{
    var key = (evt.which) ? evt.which : event.keyCode

    if(key==13)
    { 
        document.getElementById('search').focus();
    }
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function stateChangeloginpopup()
{
    SetBackground();

    if(xmlHttp.readyState==1)
    {
        ProcessLoader();
    }

    if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {
        var popuph = 316;
        var popupw = 360;
        var popuph2 = popuph/2;
        var popupw2 = popupw/2;
        var winW = screen.width;
        var winH = screen.height;

        if (parseInt(navigator.appVersion)>3) {

            if (navigator.appName=="Netscape") {
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            }

            if (navigator.appName.indexOf("Microsoft")!=-1) {
                winW = document.body.clientWidth;
                winH = document.body.offsetHeight;
            }
        }

        var sh = winH;
        var sw = winW;
        var sh2 = sh/2;
        var sw2 = sw/2;
        var topf1 = sh2 - popuph;
        var leftf1 = sw2 - popupw2;

        document.getElementById('dvprocessing').style.display='none';
        document.getElementById('dvregisterfrm').style.display='';
        document.getElementById('dvregisterfrm').style.top=CalculateTop('211')+ "px";
        document.getElementById('dvregisterfrm').style.left=leftf1 + "px";
        document.getElementById("dvregisterfrm").innerHTML=xmlHttp.responseText;
    }
    

}


function showDiv(e, id1) {
	
    $('#'+id1).show();
}
function hidediv(id2) {
	
    $('#'+id2).hide();
}

function chkObjects(theVal)
{
    if (document.getElementById(theVal) != null)
    {
        return true;
    }
    else
    {
        return false;
    }
}

function limitText(limitField, limitNum)
{
    if (limitField.value.length > limitNum)
    {
        limitField.value = limitField.value.substring(0, limitNum);
    }

}

function makeLowercase (var_title,var_alias)
{
  
    if(typeof var_title=="undefined")
    {
        var_title="var_title";
    }
    if(typeof var_alias=="undefined")
    {
        var_alias="var_alias";
    }
    var str="";
    if($("#"+var_alias).val().length == 0)
        str= document.getElementById(var_title).value.toLowerCase();

    else
    sstr=$("#"+var_alias).val()
    str= str.toLowerCase();
    var temp = new String(str);
    temp =  temp.replace(/[^a-z A-Z 0-9 \-]+/g,'');
    temp=trim(temp);
         
    var strlength = temp.length;
    for(i=0;i<strlength;i++)
    {
        var alias = temp.split(' ').join('-');
    }
       
    document.getElementById(var_alias).value = alias;
}

function removeHTMLTags(value)
{
    var strInputCode = value;
    var str='';
 		
    str = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
        return (p1 == "lt")? "<" : ">";
    });

    str =str.replace(/<\/?[^>]+(>|$)/g, "");
    str = str.replace(/&quot;/g,"");
    str = str.replace(/&#39;/g,"");
    str = str.replace(/&nbsp;/g," ");
    str = str.replace(/\n/g," ");
    return str;
}

function checkvalidImage(file,filetypearray)
{
    allowSubmit = false;
    if (!file) return false;

    var extArray = filetypearray;

    while (file.indexOf("\\") != -1)
        file = file.slice(file.indexOf("\\") + 1);
    ext = file.slice(file.lastIndexOf(".")).toLowerCase();
    for (var i = 0; i < extArray.length; i++) {
        if (extArray[i] == ext) {
            allowSubmit = true;
            break;
        }
    }
    if (allowSubmit) return true;
    else
        return false;
}



function checkingAlias(Alias,table,eid,mode,module)
{

    var iChars = "!@#$%^&*()+=[]\\\';,./{}|\":<>?''";
    var alias = document.getElementById(Alias).value;
    if(alias=='')
    {
        alert('Please enter the alias.');
        $("#"+Alias).focus();
        return false;
    }
    
    else if(alias.length==1)
        {
             alert("Alias should be greater then one character.");
            $("#"+Alias).focus();
            return false;
        }
    
    else
    {

        for (var i = 0; i < document.getElementById("var_alias").value.length; i++) {
            if (iChars.indexOf(document.getElementById("var_alias").value.charAt(i)) != -1)
            {
                alert ("Alias is not valid.");
                document.getElementById('var_alias').focus();
                return false;
            }
        }
        if(trim(checkSameAlias(alias,table,eid,mode,module))==0)
        {
            $("#aliasmsg").removeClass("alias-valid");
            alert('Alias already exists. Please change the alias.');
            if($("#tabs").length>0)
                $( "#tabs" ).tabs({
                    selected: 0
                });
            $("#"+Alias).focus();
            return false;
        }
        else
        {
            $("#aliasmsg").addClass("alias-valid");
            return true;
        }
    }
}
function checkSameAlias(alias,table,eid,mode,module)
{
    return $.ajax({
        type: "GET",
        url: "index.php?module="+module+"&action=issameAlias",
        async: false,
        data: "&alias="+encodeURIComponent(alias)+"&table="+table+"&eid="+eid+"&mode="+mode
    }).responseText;
}


function KeycheckOnlyalias(e)
{
    var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    if(_dom==2){                     // for NN4
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }
    
    if((KeyID >= 33 && KeyID <= 41) || (KeyID >= 42 && KeyID <= 44) || (KeyID >= 46 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
    {
        return false;
    }

    return true;
}

function changeStatus(mark,id,mid,module)
{
    var actionurl="index.php?module="+module+"&action=approve&mark="+mark+"&eid="+id+"&mid="+mid;
    $.ajax({
        type: "GET",
        url: actionurl,
        async: true,
        success: function(data)
        {

            alert("Status has been changed successfully..!.");
            $("#changestatus").html(data);
        }
    });
}


function CountLeft(field, count, max) 
{
    if (field.value.length > max)
        field.value = field.value.substring(0, max);
    else
        count.value = max - field.value.length;
}

function openhidemodulecombo(id)
{
    if(id=="3")
    {
        document.getElementById('insurancecmbid').style.display='';
    }
    else
    {
        document.getElementById('insurancecmbid').style.display='none';
    }
}
