/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/* userportal.jsp Scripts */

var feedbackemail="cbfeedback@supplierbid.com";

function showHide(_myObj,_action,name)
{
    var _myTableObj = document.getElementById((_myObj.parentNode.id).substring(0,(_myObj.parentNode.id).indexOf('_')));

    if (_action == 'show')
    {
        _myTableObj.style.display = 'block';
        _myObj.parentNode.innerHTML = '<a style="cursor:pointer" onclick="showHide(this,\'hide\',\''+name+'\');">'+name+'</a>';
    }

    if (_action == 'hide')
    {
        _myTableObj.style.display = 'none';
        _myObj.parentNode.innerHTML = '<a style="cursor:pointer" onclick="showHide(this,\'show\',\''+name+'\');">'+name+'</a>';
    }
}

var http_request = false;

function makePOSTRequest(url, parameters)
{
    //alert('h1');
    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;
    }

    http_request.onreadystatechange = alertContents
    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(null);
}

function alertContents()
{
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('sortdatatable').innerHTML = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }
}

function get(obj)
{
    //alert('herer ...');
    var poststr = '';
    makePOSTRequest('load_tabledata.htm', poststr);
}

function get_searchingtable(obj)
{
    //alert('herer ...');
    var poststr = '';
    makePOSTRequest('find_load_table.htm', poststr);
}

function load_table(obj)
{
    var poststr='';
    //alert('page name === ');
    makePOSTRequest('more_category_load_table.htm', poststr);
}

function submit_search()
{
    //alert('name === ');
    var poststr = '';
// makePOSTRequest(name, poststr);
}

var http_request = false;
function makePOSTRequest1(url, parameters)
{
    //alert('h1');
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = function()
    {
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('sortdatatable').innerHTML = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }
    else
    {
        eval('document.getElementById(\'sortdatatable\').innerHTML = r ;');
    }
};
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

function makePOSTRequest1b(url, parameters)
{
    //alert('h1');
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = function()
    {
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('bsortdatatable').innerHTML = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }
    else
    {
        eval('document.getElementById(\'bsortdatatable\').innerHTML = r ;');
    }
};
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

function alertContents1()
{
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('sortdatatable').innerHTML = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }
    else
    {
        eval('document.getElementById(\"'+id+'\").innerHTML = r ;');
    }
}

function makePOSTRequest_id(id,url, parameters)
{
    //alert('h1');
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = function()
    {
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById(id).innerHTML = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }
    else
    {
        eval('document.getElementById('+id+').innerHTML = r ;');
    }
};
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

function makePOSTRequest_bid(id,url, parameters)
{
    //alert('h1');
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = function()
    {
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById(id).innerHTML = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }
    else
    {
        eval('document.getElementById('+id+').innerHTML = r ;');
    }
};
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

function makePOSTRequest_encrypt(id, url, parameters)
{
    //alert('h1');
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = function()
    {

    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            id.value = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }

};
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

var http_request = false;
function makePOSTRequest2(url, parameters)
{
    //alert('h1');
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = alertContents2;
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

function alertContents2()
{
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('sortdatatable5').innerHTML = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }
    else
    {
        eval('document.getElementById(\'sortdatatable5\').innerHTML = r ;');
    }
}

function edit_user(obj,user_id)
{
    var poststr= 'user_id='+user_id;
    send_data(obj,'userprofile/edit_user.htm',poststr);
}

function edit_user_level(obj,user_id,page,param)
{
    //alert('Editing User information ....'+user_id);
    var poststr= 'user_id='+user_id+'&page='+page+'&param='+param;
    send_data(obj,'edit_user_level.htm',poststr);
}

function delete_user(obj,user_id,page)
{
//    alert('Deleting User...'+user_id);
    var poststr= 'user_id='+user_id+'&page='+page;
    if(window.confirm('Are you sure to delete this User ?'))
        send_data(obj,'userprofile/delete_user.htm',poststr);
}

function delete_bid(obj,bid_id,param)
{

    //alert('here ...'+bid_id);
    var poststr = 'bid_id='+bid_id;

    if( (param == 'main') && (window.confirm('Are you sure to delete this Bid ?')) )
        makePOSTRequest1('delete_bid.htm', poststr);
    else if( (param == 'other1') &&(window.confirm('Are you sure to delete this Bid ?')))
    {	
        poststr += '&page=proposals_bid';
        makePOSTRequest4('delete_bid_another.htm', poststr);
    }
    else if((param == 'other2')&&(window.confirm('Are you sure to delete this Bid ?')))
    {	
        poststr += '&page=show_bid_details';
        makePOSTRequest3('delete_bid_another.htm', poststr);
    }
    else if((obj=='sortdatatable7') && (window.confirm('Are you sure to delete this Part from log?')))
        {	
			poststr+= '&page=listing_desc_table&level_id='+param;
			send_data(obj,'delete_bid_another.htm',poststr);
		}
    else if( ((param!='main')&&(param!='other1')&&(param!='other2'))
        && (window.confirm('Are you sure to delete this Part ?')))
        {	
//        alert('level_id === '+param);
        poststr+= '&page=listing_mgmt_table&level_id='+param;
        
        if(document.getElementById('part_details'))
            document.getElementById('part_details').style.display='none';
        
        send_data(obj,'delete_bid_another.htm',poststr);
    }
}

function moreInfo_bid(obj,bid_id,param)
{
    //alert('here ...'+bid_id);
    var poststr = 'bid_id='+bid_id;
    send_data(obj,'BidMoreInfo.htm',poststr);
}


function pagging_prev_next(obj,pageno)
{
    //alert('calling pagging_prev_next ...');
    var poststr = 'iPageNo='+pageno+'&cPageNo='+pageno;
    makePOSTRequest1('load_tabledata.htm', poststr);
}

function pagging_current(obj,pageno)
{
    //alert('calling pagging_current ....');
    var poststr = 'iPageNo='+pageno;
    makePOSTRequest1('load_tabledata.htm', poststr);
}

function search_pagging_prev_next(obj,pageno,page)
{
    //alert('calling pagging_prev_next ...');
    //alert('page == '+page);
    var poststr = 'iPageNo='+pageno+'&cPageNo='+pageno;
    makePOSTRequest1(page, poststr);
}

function search_pagging_current(obj,pageno,page)
{
    //alert('calling pagging_current ....');
    //alert('page == '+page);
    var poststr = 'iPageNo='+pageno;
    makePOSTRequest1(page, poststr);
}
function page_submit(form)
{
    //alert('Find Product Content '+document.getElementById('find_prod').value);
    //alert('Here,,,');
    //alert(document.getElementById('find_prod'));
    if(document.getElementById('find_prod').value != '')
    {
        form.submit();
    }
    else
    {
        alert('Please Enter any Product Name');
        return false;
    }
}

function page_submit_supplier(form)
{
    //alert('Find Product Content '+document.getElementById('find_prod').value);
//    alert('Here,,,');
    //alert(document.getElementById('find_prod'));
    if(document.getElementById('find_supp').value != '')
    {
        form.submit();
    }
    else
    {
        alert('Please Enter any Value For Searching');
        return false;
    }
}

function page_submit_user(form)
{
    //alert('Find Product Content '+document.getElementById('find_prod').value);
//    alert('Here,,,');
    //alert(document.getElementById('find_prod'));
    if(document.getElementById('find_user').value != '')
    {
        form.submit();
    }
    else
    {
        alert('Please Enter any Value For Searching');
        return false;
    }
}

function searchKeyTest(event,form)
{
    if(event.keyCode == 13)
    {
		searchMe();
		return false;		
    }
}

function testKey(event,form)
{
    if(event.keyCode == 13)
    {

        if(document.getElementById('find_prod'))
        {
            if(document.getElementById('find_prod').value != '')
            {
                form.action = 'search.htm';
                form.submit();
            }
            else
            {
                alert('Please Enter any Product Name');
                return false;
            }
        }
        else if(document.getElementById('find_supp'))
        {
            if(document.getElementById('find_supp').value != '')
            {
                form.action = 'suuplier_search.htm';
                form.submit();
            }
            else
            {
                alert('Please Enter any Value For Searching');
                return false;
            }
        }
        else if(document.getElementById('find_user'))
        {
            if(document.getElementById('find_user').value != '')
            {
                form.action = 'user_search.htm';
                form.submit();
            }
            else
            {
                alert('Please Enter any Value For Searching');
                return false;
            }
        }

    }
}

function sort_data(name,part_id,level_id)
{
    //alert('sort_data function '+name+'==='+part_id+' === '+level_id);
    var poststr = 'lvl='+level_id+'&part_id='+part_id+'&name='+name;
    var page='sort_data.htm';
    var id_name='filter_data_'+name;
    var propValueID = document.getElementById(id_name).value;
	var index = document.getElementById(id_name).selectedIndex;
    var value = document.getElementById(id_name).options[index].value;
    //alert(document.getElementById(id_name).selectedIndex);
    //alert('Value == '+value);
    poststr = poststr + '&value='+value+'&propValueID='+propValueID;
    makePOSTRequest1(page, poststr);
}

function sort_data_hem(part_id,level_id)
{
    //alert('sort_data function '+name+'==='+part_id+' === '+level_id);
	
	var totalProperty=document.getElementById("totalProperty").value;
	var propValueID="";
	for(var i=0;i<=totalProperty;i++)
	{
		propValueID+=document.getElementById("filter_data_"+i).value+",";
	}
	propValueID+="-1";
	
    var poststr = 'lvl='+level_id;
    var page='sort_data_hem.htm';

	//var index = document.getElementById(id_name).selectedIndex;
    //var value = document.getElementById(id_name).options[index].value;
    poststr = poststr +'&propValueID='+propValueID;
    makePOSTRequest1(page, poststr);
}

function addRow(id)
{
    
    var numi = document.getElementById('theValue'); // Get the hidden parameter
    var num = (document.getElementById("theValue").value -1)+ 2;
    numi.value = num;
    var textname='cust_property'+num;
    var desc = 'cust_prop_desc'+num;

    var RowIdName = "my"+num+"Row"; // create name of the id of newly added row
    var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0]; // get the table body
    var row = document.createElement("TR"); // create new <TR> in the table
    row.setAttribute("id", RowIdName); // set row's id attribute
    row.setAttribute("class", "datawhite");
    row.setAttribute("onmouseover", "this.className='dataover'");
    row.setAttribute("onclick", "this.className='datadown'");
    row.setAttribute("onmouseout", "this.className='datawhite'");

    var td1 = document.createElement("TD"); // create new <TD> element in the table
    td1.setAttribute("align", "center");
    td1.setAttribute("style", "padding:2px 5px 2px 5px");
    td1.innerHTML="&nbsp;";

    //td1.appendChild(document.createTextNode("column 1")); // set the text in the <td>
    //num = num + 1;

    var td2 = document.createElement("TD"); // create new <TD> element in the table
    td2.setAttribute("align", "left");
    td2.setAttribute("valign", "middle");
    td2.setAttribute("style", "padding:2px 5px 2px 5px");
    td2.innerHTML="<input type='text' name='"+textname+"' id='"+textname+"' value='' maxlength='50'>";
   

    var td3 = document.createElement("TD");
    td3.setAttribute("align", "left");
    td3.setAttribute("valign", "middle");
    td3.setAttribute("style", "padding:2px 5px 2px 5px");
    td3.innerHTML="<input type='text' name='"+desc+"' id='"+desc+"'  style=\"width:300px\" value='' maxlength='50'>";

    var td4 = document.createElement("TD"); // create new <TD> element in the table
    td4.setAttribute("align", "center");
    td4.setAttribute("style", "padding:2px 5px 2px 5px");
    td4.innerHTML="<a href=\"javascript:;\" onclick=\"addRow(\'"+id+"\');\"><img src='images/add-page-green.gif'></img></a>"; // set the innerHTML of the <TD>

    var td5 = document.createElement("TD"); // create new <TD> element in the table
    td5.setAttribute("align", "center");
    td5.setAttribute("style", "padding:2px 5px 2px 5px");
    td5.innerHTML="<a href=\"javascript:;\" onclick=\"removeRow(\'"+RowIdName+"\',\'"+id+"\')\"><img src='images/delete_icon.gif'></img></a>"; // set the innerHTML of the <TD>

    row.appendChild(td1);
    row.appendChild(td2);   
    row.appendChild(td3);
    row.appendChild(td4);
    row.appendChild(td5);
    tbody.appendChild(row);
}

function removeRow(row_id,table_id)
{
	//Hemant[31_10_2009][B'date of Sardar Patel (India)]
    //alert('Remove RowId '+row_id);
    var tbody = document.getElementById(table_id).getElementsByTagName('tbody')[0];
    var oldtr = document.getElementById(row_id);
    var rownum = parseInt(document.getElementById('theValue').value);
    var theValue = document.getElementById('theValue');
	//hemant
	////alert('Before theValue == '+rownum);
    //rownum = rownum - 1;
    //theValue.value = rownum; // setting the hidden parameter value
    ////alert('after theValue == '+rownum);
    //tbody.removeChild(oldtr);	
	document.getElementById(row_id).style.display="none";	
	//hemant	
}
function addFrndRow(id)
{

    var numi = document.getElementById('theValue'); // Get the hidden parameter
    var num = (document.getElementById("theValue").value -1)+ 2;
    numi.value = num;
    var textname='cust_property'+num;
    var desc = 'cust_prop_desc'+num;

    var RowIdName = "my"+num+"Row"; // create name of the id of newly added row
    var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0]; // get the table body
    var row = document.createElement("TR"); // create new <TR> in the table
    row.setAttribute("id", RowIdName); // set row's id attribute
    row.setAttribute("class", "datawhite");
    row.setAttribute("onmouseover", "this.className='dataover'");
    row.setAttribute("onclick", "this.className='datadown'");
    row.setAttribute("onmouseout", "this.className='datawhite'");

    var td1 = document.createElement("TD"); // create new <TD> element in the table
    td1.setAttribute("align", "center");
    td1.setAttribute("style", "padding:2px 5px 2px 5px");
    td1.innerHTML="&nbsp;";

    //td1.appendChild(document.createTextNode("column 1")); // set the text in the <td>
    //num = num + 1;

    var td2 = document.createElement("TD"); // create new <TD> element in the table
    td2.setAttribute("align", "left");
    td2.setAttribute("valign", "middle");
    td2.setAttribute("style", "padding:2px 5px 2px 5px");
    td2.innerHTML=" <strong><label>Friend "+num+" :</label></strong>";


    var td3 = document.createElement("TD");
    td3.setAttribute("align", "left");
    td3.setAttribute("valign", "middle");
    td3.setAttribute("style", "padding:2px 5px 2px 5px");
    td3.innerHTML="<input type='text' name='"+desc+"' id='"+desc+"'  style=\"width:300px\" value='' maxlength='50'>";

    var td4 = document.createElement("TD"); // create new <TD> element in the table
    td4.setAttribute("align", "center");
    td4.setAttribute("style", "padding:2px 5px 2px 5px");
    td4.innerHTML="<a href=\"javascript:;\" onclick=\"addFrndRow(\'"+id+"\');\"><img src='images/add-page-green.gif'></img></a>"; // set the innerHTML of the <TD>

    var td5 = document.createElement("TD"); // create new <TD> element in the table
    td5.setAttribute("align", "center");
    td5.setAttribute("style", "padding:2px 5px 2px 5px");
    td5.innerHTML="<a href=\"javascript:;\" onclick=\"removeRow(\'"+RowIdName+"\',\'"+id+"\')\"><img src='images/delete_icon.gif'></img></a>"; // set the innerHTML of the <TD>

    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    row.appendChild(td4);
    row.appendChild(td5);
    tbody.appendChild(row);
}

function addColleagueRow(id)
{

    var numi = document.getElementById('theValue'); // Get the hidden parameter
    var num = (document.getElementById("theValue").value -1)+ 2;
    numi.value = num;
    var textname='cust_property'+num;
    var desc = 'cust_prop_desc'+num;

    var RowIdName = "my"+num+"Row"; // create name of the id of newly added row
    var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0]; // get the table body
    var row = document.createElement("TR"); // create new <TR> in the table
    row.setAttribute("id", RowIdName); // set row's id attribute
    row.setAttribute("class", "datawhite");
    row.setAttribute("onmouseover", "this.className='dataover'");
    row.setAttribute("onclick", "this.className='datadown'");
    row.setAttribute("onmouseout", "this.className='datawhite'");

    var td1 = document.createElement("TD"); // create new <TD> element in the table
    td1.setAttribute("align", "center");
    td1.setAttribute("style", "padding:2px 5px 2px 5px");
    td1.innerHTML="&nbsp;";

    //td1.appendChild(document.createTextNode("column 1")); // set the text in the <td>
    //num = num + 1;

    var td2 = document.createElement("TD"); // create new <TD> element in the table
    td2.setAttribute("align", "left");
    td2.setAttribute("valign", "middle");
    td2.setAttribute("style", "padding:2px 5px 2px 5px");
    td2.innerHTML=" <strong><label>Colleague "+num+" :</label></strong>";


    var td3 = document.createElement("TD");
    td3.setAttribute("align", "left");
    td3.setAttribute("valign", "middle");
    td3.setAttribute("style", "padding:2px 5px 2px 5px");
    td3.innerHTML="<input type='text' name='"+desc+"' id='"+desc+"'  style=\"width:300px\" value='' maxlength='50'>";

    var td4 = document.createElement("TD"); // create new <TD> element in the table
    td4.setAttribute("align", "center");
    td4.setAttribute("style", "padding:2px 5px 2px 5px");
    td4.innerHTML="<a href=\"javascript:;\" onclick=\"addColleagueRow(\'"+id+"\');\"><img src='images/add-page-green.gif'></img></a>"; // set the innerHTML of the <TD>

    var td5 = document.createElement("TD"); // create new <TD> element in the table
    td5.setAttribute("align", "center");
    td5.setAttribute("style", "padding:2px 5px 2px 5px");
    td5.innerHTML="<a href=\"javascript:;\" onclick=\"removeRow(\'"+RowIdName+"\',\'"+id+"\')\"><img src='images/delete_icon.gif'></img></a>"; // set the innerHTML of the <TD>

    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    row.appendChild(td4);
    row.appendChild(td5);
    tbody.appendChild(row);
}


function addRow_partAdd(id)
{
 
   var num = eval(document.getElementById("addtheValue").value)+ 1;
 
    var textname='addproperty'+num;
    var desc = 'addprop_desc'+num;

    var RowIdName = "addmy"+num+"Row"; // create name of the id of newly added row
    var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0]; // get the table body
    var row = document.createElement("TR"); // create new <TR> in the table
    row.setAttribute("id", RowIdName); // set row's id attribute
    row.setAttribute("class", "datawhite");
    row.setAttribute("onmouseover", "this.className='dataover'");
    row.setAttribute("onclick", "this.className='datadown'");
    row.setAttribute("onmouseout", "this.className='datawhite'");

    var td1 = document.createElement("TD"); // create new <TD> element in the table
    td1.setAttribute("align", "center");
    td1.setAttribute("style", "padding:2px 5px 2px 5px");
    td1.innerHTML="&nbsp;";

    //td1.appendChild(document.createTextNode("column 1")); // set the text in the <td>
    //num = num + 1;

    var td2 = document.createElement("TD"); // create new <TD> element in the table
    td2.setAttribute("align", "left");
    td2.setAttribute("valign", "middle");
    td2.setAttribute("style", "padding:2px 5px 2px 5px");
    td2.innerHTML="<input type='text' name='"+textname+"' id='"+textname+"' value=''>";


    var td3 = document.createElement("TD");
    td3.setAttribute("align", "left");
    td3.setAttribute("valign", "middle");
    td3.setAttribute("style", "padding:2px 5px 2px 5px");
    td3.innerHTML="<input type='text' name='"+desc+"' id='"+desc+"' style=\"width:300px\" value=''>";

    var td4 = document.createElement("TD"); // create new <TD> element in the table
    td4.setAttribute("align", "center");
    td4.setAttribute("style", "padding:2px 5px 2px 5px");
    td4.innerHTML="<a href=\"javascript:\" onclick=\"addRow_partAdd(\'"+id+"\');\"><img src='images/add-page-green.gif'></img></a>"; // set the innerHTML of the <TD>

    var td5 = document.createElement("TD"); // create new <TD> element in the table
    td5.setAttribute("align", "center");
    td5.setAttribute("style", "padding:2px 5px 2px 5px");
    td5.innerHTML="<a href=\"javascript:\" onclick=\"removeRow_partRemove(\'"+RowIdName+"\',\'"+id+"\')\"><img src='images/delete_icon.gif'></img></a>"; // set the innerHTML of the <TD>

    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    row.appendChild(td4);
    row.appendChild(td5);
    tbody.appendChild(row);
    document.getElementById("addtheValue").value=num;
}

function removeRow_partRemove(row_id,table_id)
{

    var tbody = document.getElementById(table_id).getElementsByTagName('tbody')[0];
    var oldtr = document.getElementById(row_id);
    var rownum = eval(document.getElementById('addtheValue').value);
    var theValue = document.getElementById('addtheValue');
    rownum = rownum - 1;
    theValue.value = rownum; 
    tbody.removeChild(oldtr);
	//document.getElementById(row_id).style.display="none";
  //document.getElementById("addtheValue").value= eval(document.getElementById("addtheValue").value)-1;

	
	
}
function editRow_partAdd(id)
{
    var num = eval(document.getElementById("editTheValue").value)+ 1;
    
    var textname='editproperty'+num;
    var desc = 'editprop_desc'+num;

    var RowIdName = "editmy"+num+"Row"; // create name of the id of newly added row
    var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0]; // get the table body
    var row = document.createElement("TR"); // create new <TR> in the table
    row.setAttribute("id", RowIdName); // set row's id attribute
    row.setAttribute("class", "datawhite");
    row.setAttribute("onmouseover", "this.className='dataover'");
    row.setAttribute("onclick", "this.className='datadown'");
    row.setAttribute("onmouseout", "this.className='datawhite'");
	//row.setAttribute("style", "display:block");

    var td1 = document.createElement("TD"); // create new <TD> element in the table
    td1.setAttribute("align", "center");
    td1.setAttribute("style", "padding:2px 5px 2px 5px");
    td1.innerHTML="&nbsp;";

    //td1.appendChild(document.createTextNode("column 1")); // set the text in the <td>
    //num = num + 1;

    var td2 = document.createElement("TD"); // create new <TD> element in the table
    td2.setAttribute("align", "left");
    td2.setAttribute("valign", "middle");
    td2.setAttribute("style", "padding:2px 5px 2px 5px");
    td2.innerHTML="<input type='text' name='"+textname+"' id='"+textname+"' value=''>";


    var td3 = document.createElement("TD");
    td3.setAttribute("align", "left");
    td3.setAttribute("valign", "middle");
    td3.setAttribute("style", "padding:2px 5px 2px 5px");
    td3.innerHTML="<input type='text' name='"+desc+"' id='"+desc+"' style=\"width:300px\" value=''>";

    var td4 = document.createElement("TD"); // create new <TD> element in the table
    td4.setAttribute("align", "center");
    td4.setAttribute("style", "padding:2px 5px 2px 5px");
    td4.innerHTML="<a href=\"javascript:;\" onclick=\"editRow_partAdd(\'"+id+"\');\"><img src='images/add-page-green.gif'></img></a>"; // set the innerHTML of the <TD>

    var td5 = document.createElement("TD"); // create new <TD> element in the table
    td5.setAttribute("align", "center");
    td5.setAttribute("style", "padding:2px 5px 2px 5px");
    td5.innerHTML="<a href=\"javascript:;\" onclick=\"editremoveRow_partRemove(\'"+RowIdName+"\',\'"+id+"\')\"><img src='images/delete_icon.gif'></img></a>"; // set the innerHTML of the <TD>

    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    row.appendChild(td4);
    row.appendChild(td5);
    tbody.appendChild(row);
    document.getElementById("editTheValue").value=num;
}

function editremoveRow_partRemove(row_id,table_id)
{
    
    var tbody = document.getElementById(table_id).getElementsByTagName('tbody')[0];
    var oldtr = document.getElementById(row_id);
    var rownum = eval(document.getElementById('editTheValue').value);
    var theValue = document.getElementById('editTheValue');
    alert(rownum);
    rownum = rownum - 1;
    theValue.value = rownum;
    tbody.removeChild(oldtr);
}

/*function hide_row(id,table_id)
{
    var tbody = document.getElementById(table_id).getElementsByTagName('tbody')[0];
    var oldtr = document.getElementById(id);
    var rownum = parseInt(document.getElementById('theValue').value);
    var theValue = document.getElementById('theValue');
    alert('TR === '+document.getElementById('my3Row'));
    alert('tbody === '+tbody);
    document.getElementById(oldtr).style.display='none';
    rownum = rownum - 1;
    theValue.value = rownum; // setting the hidden parameter value
    
}*/

function addRow_bid(id)
{
    var numi = document.getElementById('theValue'); // Get the hidden parameter
    var num = (document.getElementById("theValue").value -1)+ 2;
    numi.value = num;

    var eau='EAU'+num;
    var price = 'PRICE'+num;
    var eau_id = 'eau'+num;
    var price_id = 'price'+num;
    var RowIdName = "my"+num+"Row_1"; // create name of the id of newly added row
    var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0]; // get the table body
    var row = document.createElement("TR"); // create new <TR> in the table
    row.setAttribute("id", RowIdName); // set row's id attribute
    row.setAttribute("class", "datawhite");
    row.setAttribute("onmouseover", "this.className='dataover'");
    row.setAttribute("onclick", "this.className='datadown'");
    row.setAttribute("onmouseout", "this.className='datawhite'");

    var td1 = document.createElement("TD"); // create new <TD> element in the table
    td1.setAttribute("align", "center");
    td1.setAttribute("style", "padding:2px 5px 2px 5px");
    td1.innerHTML="&nbsp;";

    var td2 = document.createElement("TD"); // create new <TD> element in the table
    td2.setAttribute("align", "center");
    td2.setAttribute("style", "padding:2px 5px 2px 5px");
    td2.innerHTML="<input type='text' name='"+eau+"' id='"+eau_id+"' value=''>";

    var td3 = document.createElement("TD");
    td3.setAttribute("align", "center");
    td3.setAttribute("style", "padding:2px 5px 2px 5px");
    td3.innerHTML="<input type='text' name='"+price+"' id='"+price_id+"' value=''>";

    var td4 = document.createElement("TD"); // create new <TD> element in the table
    td4.setAttribute("align", "center");
    td4.setAttribute("style", "padding:2px 5px 2px 5px");
    td4.innerHTML="&nbsp;";
    
    var td5 = document.createElement("TD"); // create new <TD> element in the table
    td5.setAttribute("align", "center");
    td5.setAttribute("style", "padding:2px 5px 2px 5px");
    td5.innerHTML="<a href=\"javascript:;\" onclick=\"addRow_bid(\'"+id+"\');\"><img src='images/add-page-green.gif'></img></a>"; // set the innerHTML of the <TD>

    var td6 = document.createElement("TD"); // create new <TD> element in the table
    td6.setAttribute("align", "center");
    td6.setAttribute("style", "padding:2px 5px 2px 5px");
    td6.innerHTML="<a href=\"javascript:;\" onclick=\"removeRow_bid(\'"+RowIdName+"\',\'"+id+"\')\"><img src='images/delete_icon.gif'></img></a>"; // set the innerHTML of the <TD>

    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    row.appendChild(td4);
    row.appendChild(td5);
    row.appendChild(td6);
    tbody.appendChild(row);
}

function removeRow_bid(row_id,table_id)
{
    //alert('Remove RowId '+row_id);
    var tbody = document.getElementById(table_id).getElementsByTagName('tbody')[0];
    var oldtr = document.getElementById(row_id);
    var rownum = parseInt(document.getElementById('theValue').value);
    var theValue = document.getElementById('theValue');
    //alert('Before theValue == '+rownum);
    rownum = rownum - 1;
    theValue.value = rownum; // setting the hidden parameter value
    //alert('after theValue == '+rownum);
    tbody.removeChild(oldtr);
}

function fill_combo(combo_id,page)
{
  // alert('fill Combo....nsmrta');
    var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;
     
    var poststr = 'MastLevelId='+value;
    makePOSTRequest1(page, poststr);
}

function fill_bcombo(combo_id,page)
{
  // alert('fill Combo....nsmrta');
    var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;

    var poststr = 'bMastLevelId='+value;
    makePOSTRequest1b(page, poststr);
}

function fill_combo_id(id,combo_id,page)
{
 
    var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;
    var text=document.getElementById(combo_id).options[index].text;

    document.getElementById("cat_id").value=value;
    if(text!='All'){
    var poststr = 'MastLevelId='+value;
    makePOSTRequest_id(id,page, poststr);
    }
}

function fill_bcombo_id(id,combo_id,page)
{

    var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;
    var text=document.getElementById(combo_id).options[index].text;

    document.getElementById("bcat_id").value=value;
    if(text!='All'){
    var poststr = 'bMastLevelId='+value;
    makePOSTRequest_bid(id,page, poststr);
    }
}
function fill_combo3(combo_id,page)
{
   // alert('fill Combo....'+combo_id);
    var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;
    //alert('Selected Value === '+value);
    var poststr = 'MastLevelId='+value;
    
    makePOSTRequest2(page, poststr);
}


function fill_property(combo_id,page)
{
    var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;
    //alert('Selected Value === '+value);
    var poststr = 'LevelId='+value;
    makePOSTRequest2(page, poststr);
    document.getElementById('show_chk').style.display = "";
}



//Start:call from load_property.jsp and edit_part.jsp
var prop_value_index=0;
function fill_property_value(index)
{
	prop_value_index=index;
	var property_id_arr=document.getElementById("prop_val"+prop_value_index).value.split(",");
	if(property_id_arr.length>=2){
		var property_id=property_id_arr[1];
		
		getPropertyValue('4Process',property_id);
	}
	else
	{

		document.getElementById("propdesc"+prop_value_index).innerHTML="<option value=\"none\">---- Select Property ---</option>";
	}
}
function getPropertyValue(id,property_id)
{
	
	var post_str = 'property_id='+property_id;
	document.getElementById(id).style.display="block";	
	document.getElementById(id).style.height=100;
	document.getElementById(id).style.width=100;
	send_data_hem(id,'fill_property_value.htm',post_str,resultGetPropertyValue);
}		   
function resultGetPropertyValue(result){
	var tempCmb="";
	document.getElementById("4Process").style.display="none";
	tempCmb="<select name=\"propdesc"+prop_value_index+"\" id=\"propdesc"+prop_value_index+"\" style=\"width:200px;\">"
	tempCmb+=result;
	tempCmb+="</select>"
	document.getElementById("tdPropdesc"+prop_value_index).innerHTML=tempCmb;
}	
//End:call from load_property.jsp and edit_part.jsp


function fill_property1(combo_id,page)
{
    
	var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;
//    alert('Selected Value === '+combo_id);
    var poststr = 'LevelId='+value;
    if(combo_id == 'edit_part')
        poststr+='&lvl=1';
    makePOSTRequest2(page, poststr);
//    document.getElementById('show_chk').style.display = "";
}

function fill_combo1(combo_id,page)
{
    //alert('fill Combo....'+combo_id);
    var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;
    //alert('Selected Value === '+value);
    var poststr = 'MastLevelId='+value;
    send_data('part_combo',page, poststr);
}

function fill_property2(id,combo_id,page)
{
    if(document.getElementById('load_part_property_table'))
        document.getElementById('load_part_property_table').style.display='';
//    alert('Selected Value === '+document.getElementById(combo_id).selectedIndex);
    var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;
//    alert('Selected Value === '+combo_id);
    var poststr = 'LevelId='+value;
    if(id == 'load_part_property_table'){
        poststr+='&lvl='+document.getElementById('edit_subcat').options[document.getElementById('edit_subcat').selectedIndex].value+'&mode=edit';
//        alert('poststr === '+poststr);
    }
    else if(id=='del_load_part_property_table')
    {
        poststr+='&del_lvl='+document.getElementById('del_subcat').options[document.getElementById('del_subcat').selectedIndex].value+'&mode=del';
//        alert(' poststr ==== '+poststr);
    }
    send_data(id,page, poststr);
//    document.getElementById('show_chk').style.display = "";
}

function fill_combo2(id,combo_id,page)
{
//    alert('fill Combo....'+combo_id);
    var index = document.getElementById(combo_id).selectedIndex;
    var value = document.getElementById(combo_id).options[index].value;
//    alert('Selected Value === '+id);
    if(document.getElementById('load_part_property_table'))
        document.getElementById('load_part_property_table').style.display='none';
    var poststr = 'MastLevelId='+value;
    send_data(id,page,poststr);
}

var http_request = false;
function makePOSTRequest3(url, parameters)
{
    //alert('h1');
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = alertContents3;
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

function alertContents3()
{
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('sortdatatable3').innerHTML = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }
    else
    {
        eval('document.getElementById(\'sortdatatable3\').innerHTML = r ;');
    }
}

var http_request = false;
function makePOSTRequest4(url, parameters)
{
    //alert('h1');
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = alertContents4;
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

function alertContents4()
{
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200)
        {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('sortdatatable4').innerHTML = result;
        }
        else
        {
            alert('There was a problem with the request or You Forgot to Sign in');
        }
    }
    else
    {
        eval('document.getElementById(\'sortdatatable4\').innerHTML = r ;');
    }
}

function bid_history()
{
    var poststr='';
    //alert('History_bid Page');
    makePOSTRequest3('History_bid.htm', poststr);
}



function proposal_history()
{
    var poststr='';
    //alert('Proposals_bid Page');
    makePOSTRequest4('proposals_bid.htm', poststr);
}

function existing_users(id,srcString)
{
    var post_str = 'srcString='+srcString;

    send_data(id,'existing_users.htm',post_str);
}

function new_users(id,srcString)
{
    var post_str = 'srcString='+srcString;
    send_data(id,'new_users.htm',post_str);
}

function new_companies(id,srcString)
{
    var post_str = 'srcString='+srcString;
    send_data(id,'new_companies.htm',post_str);
}

function existing_companies(id,srcString)
{
    var post_str = 'srcString='+srcString;
    send_data(id,'existing_companies.htm',post_str);
}

function existing_message(id,srcString)
{
    var post_str = 'srcString='+srcString;
    send_data(id,'existing_message.htm',post_str);
}

function search_messages(id,srcString,key)
{
    var post_str = 'srcString='+srcString+'&key='+key;
    send_data(id,'search_messages.htm',post_str);
}

function viewexisting_message(id,srcString)
{
    var post_str = 'msgid='+srcString;
    send_data(id,'viewmessage.htm',post_str);
}

function makeNewWindow(value)
{
    var poststr = 'param='+value;
    makePOSTRequest4('contact_detail.htm', poststr);
}
//Hemant
function makeNewWindowBid(value)
{
    var poststr = 'param='+value;
    makePOSTRequest4('BidMoreInfoMore.htm', poststr);
}

//Hemant


var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos,param)
{
    if(pos=="random")
    {
        LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
        TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }

    if(pos=="center")
    {
        LeftPosition=(screen.width)?(screen.width-w)/2:100;
        TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else if((pos!="center" && pos!="random") || pos==null)
    {
        LeftPosition=0;
        TopPosition=20
    }

    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win=window.open(mypage,myname,settings);
    win.document.write('<input type=text name=abc value='+param+'>');
    win.document.close();
}

function openModalMoreExample()
{

    window.showModalDialog('LearnMoreExample.html','','dialogwidth: 680px; dialogheight: 450px; dialogleft: 0px; dialogtop: 0px; resizable: yes');
}


function openModal(value)
{
    var param = new Array;
    param[0] = 1;
    param[1] = 4;
    window.showModalDialog('contact.htm',value,'dialogwidth: 525px; dialogheight: 230px; dialogleft: 0px; dialogtop: 0px; resizable: yes');
}

//Hemant
function openModalBid(value)
{
    var param = new Array;
    param[0] = 1;
    param[1] = 4;
    window.showModalDialog('BidMoreInfo.htm',value,'dialogwidth: 525px; dialogheight: 300px; dialogleft: 0px; dialogtop: 0px; resizable: yes');
}
//Hemant

function send_data(id,url,parameters)
{
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
    
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = function(){
       
        if (http_request.readyState == 4)
        {
            if (http_request.status == 200)
            {
                result = http_request.responseText;
                eval('document.getElementById(\"'+id+'\").innerHTML=result');
            }
            else
            {
                alert('There was a problem with the request or You Forgot to Sign in');
            }
        }
        else
        {
            eval('document.getElementById(\"'+id+'\").innerHTML = r ;');
        }
    }
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

function send_data_page(id,url,parameters)
{
    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';

    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;
    }
    //alert('h2');
    http_request.onreadystatechange = function(){

        if (http_request.readyState == 4)
        {
            if (http_request.status == 200)
            {
                //alert(http_request.responseText);
//                result = http_request.responseText;
//                eval('document.getElementById(\"'+id+'\").innerHTML=result');
            }
            else
            {
                alert('There was a problem with the request or You Forgot to Sign in');
            }
        }
        else
        {
//            eval('document.getElementById(\"'+id+'\").innerHTML = r ;');
        }
    }
    http_request.open('POST', url, false);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

function send_data_sync(id,url,parameters)
{
//    var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';

    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;
    }
    //alert('h2');
    http_request.onreadystatechange = function(){

        if (http_request.readyState == 4)
        {
            if (http_request.status == 200)
            {
                //alert(http_request.responseText);
                result = http_request.responseText;
                eval('document.getElementById(\"'+id+'\").innerHTML=result');
            }
            else
            {
                alert('There was a problem with the request or You Forgot to Sign in');
            }
        }
        else
        {
//            eval('document.getElementById(\"'+id+'\").innerHTML = r ;');
        }
    }
    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");
    //alert('parameter == '+parameters);
    http_request.send(parameters);
}

var global_id='',global_trid='',global_part_id;
function show_partdetail(id,level_id)
{
    var poststr='level_id='+level_id;
    //alert('Calling show_partdetail....');
    document.getElementById(id).style.display="";
    send_data(id,'listing_part_detail.htm',poststr);
}

function show_partdetail_new(id,trid,level_id)
{
    var poststr='level_id='+level_id;
    //alert('Calling show_partdetail....');
    //alert('global_id === '+global_id);
    if((global_id != '') && (global_trid!=''))
    {
        if(document.getElementById(global_id) && document.getElementById(global_trid))
        {
            document.getElementById(global_id).style.display="none";
            document.getElementById(global_trid).style.display="none";
        }
        document.getElementById(id).style.display="";
        document.getElementById(trid).style.display="";
        global_id = id;
        global_trid = trid;
    }
    else 
    {
        global_id = id;
        global_trid = trid;
        document.getElementById(id).style.display="";
        document.getElementById(trid).style.display="";
    }
    send_data(id,'listing_part_detail.htm',poststr);
}
function show_bid_details(id,trid,level_id,totAccBid)
{
    var poststr='level_id='+level_id;
    global_part_id = level_id;
    //alert('Calling show_partdetail....');
	if(totAccBid>0)
	{
		if((global_id != '') && (global_trid!=''))
		{
			if(document.getElementById(global_id) && document.getElementById(global_trid))
			{
				document.getElementById(global_id).style.display="none";
				document.getElementById(global_trid).style.display="none";
			}
			document.getElementById(id).style.display="";
			document.getElementById(trid).style.display="";
			global_id = id;
			global_trid = trid;
		}
		else
		{
			global_id = id;
			global_trid = trid;
			document.getElementById(id).style.display="";
			document.getElementById(trid).style.display="";
		}
		send_data(id,'show_bid_details.htm',poststr);
	}
	else
	{
		alert("No accepted bid found");
	}
}


function common_pagging_prev_next(id,url,pageno,ex_param)
{
    //alert('calling pagging_prev_next ...'+id);
    var poststr = 'iPageNo='+pageno+'&cPageNo='+pageno;
    if((ex_param == '1') || (ex_param == '2'))
    {
      if((global_id != '') && (global_trid!='')){
        document.getElementById(global_id).style.display="none";
        document.getElementById(global_trid).style.display="none";}
//        document.getElementById(id).style.display="none";
    }

    if(id=='global_id'){
        id=global_id;
//        alert(' global_id === '+id);
        document.getElementById(global_id).style.display="";
        document.getElementById(global_trid).style.display="";
        poststr+='&level_id='+global_part_id;
    }
    send_data(id,url, poststr);
}

function common_pagging_current(id,url,pageno,ex_param)
{

  //alert('calling pagging_current ....'+id);
    var poststr = 'iPageNo='+pageno;
    if((ex_param == '1') || (ex_param == '2'))
    {
      if((global_id != '') && (global_trid!='')){
        document.getElementById(global_id).style.display="none";
        document.getElementById(global_trid).style.display="none";
      }
    }

    if(id=='global_id'){
        id=global_id;
//        alert(' global_id === '+id);
        document.getElementById(global_id).style.display="";
        document.getElementById(global_trid).style.display="";
        poststr+='&level_id='+global_part_id;
    }
    send_data(id,url,poststr);
}

function edit_bid(bid_id)
{
    //alert('bid_id == '+bid_id);
    document.cookie="bid_id="+bid_id;
    document.forms[0].action='edit_bid.htm';
    document.forms[0].submit();
}

function status_bid(id,status,url,param,partName)
{
//    alert('Status == '+status);
//    alert('Pararm == '+param);
    var poststr = 'status='+status+'&bid_id='+param+'&partName='+partName;
    var msg = 'Are you sure for '+status+' this Proposal ?';
//    if((window.confirm(msg)))
    send_data(id,url,poststr);
}

function edit_permission(id,status,param)
{
    var poststr = 'permission='+param+'&userid='+status;
	if(param=="disallow") //delete
	{
		if(confirm("Do you want to delete user?"))
			send_data(id,'edit_permission.htm',poststr);
	}
	else
	{
		send_data(id,'edit_permission.htm',poststr);
	}
}

function edit_company_permission(id,status,param)
{
    //alert('Here ...'+param+status);
    var poststr = 'permission='+param+'&company_id='+status;
	if(param=="disallow") //delete
	{
		if(confirm("Do you want to delete user?"))
			send_data(id,'edit_company_permission.htm',poststr);
	}
	else
	{
		send_data(id,'edit_company_permission.htm',poststr);
	}	
}
        
function show_company(id,value)
{
    //alert('Show Company');
    if(value == 'JEC')
    {
        document.getElementById('new_company').style.display="none";
        document.getElementById(id).style.display="";
    }
    else if(value == 'NOR')
    {
        document.getElementById('new_company').style.display="none";
        document.getElementById('company').style.display="none";
    }
    else if(value=='RNC')
    {
        document.getElementById('company').style.display="none";
        document.getElementById(id).style.display="";
    }
}

function checkCompany(id,param)
{
    var error="";
//    alert('Here ...'+id);
    if ((id == 'JEC') && (param==''))
    {
//        alert('JEC 2');
        error = 'Please Enter the Company Code';
        document.getElementById('company_id1').innerHTML=error;
    }
    else if((id =='RNC'))
    {
        error +=checkCompanyName(param.cname.value);
        error +=checkCompanyAddress(param.caddress.value);
        error +=checkCompanyPhone(param.cphone.value);
        error +=checkCompanyCity(param.ccity.value);
        error +=checkCompanyState(param.cstate.value);
        error +=checkCompanyCountry(param.ccountry.selectedIndex);
    }

    return error;
}

function checkCompanyName(strng)
{
    //alert('Check Username');
    var error = "";
    if (strng == "") {
        error = "You didn't enter a Company Name.\n";
    }

    var illegalChars = /\W/;
    // allow only letters, numbers, and underscores
    if (illegalChars.test(strng)) {
        error = "The username contains illegal characters.\n";
    }

    document.getElementById('company1name').innerHTML=error;
    return error;
}

function checkCompanyAddress(strng)
{
    var error = "";
    if(strng == ""){
        error = "Please Enter the Company Address.\n";
    }
    document.getElementById('company1address').innerHTML = error;
    return error;
}

function checkCompanyPhone(strng)
{
//    alert('Check Phone ');
    var error = "";
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
    //strip out acceptable non-numeric characters

    if(strng == "")
    {
        error="Please Enter Company Phone Number";
    }else if ( (strng != "") && (isNaN(parseInt(stripped))) )
    {
        error = "The phone number contains illegal characters.";
    }else if ( (strng != "") && (!(stripped.length == 10)) )
    {
        error = "The phone number is the wrong length.Make sure you included an area code.\n";
    }

    try
    {
        document.getElementById('company1phone').innerHTML=error;
    }
    catch(err)
    {
        return error;
    }
    return error;
}

function checkCompanyCity(strng)
{
    var error = "";
    if (strng == "") {
        error = "You didn't enter a City of the Company.\n";
    }

    document.getElementById('company1city').innerHTML=error;
    return error;
}

function checkCompanyState(strng)
{
    var error = "";
    if (strng == "") {
        error = "You didn't enter a State of the Company.\n";
    }

    document.getElementById('company1state').innerHTML=error;
    return error;
}

function checkCompanyCountry(choice)
{
    //alert('Check Nationality ');
    var error = "";
    if (choice == 0)
    {
        error = "You didn't choose an option from the drop-down list.\n";
    }
    document.getElementById('company1country').innerHTML = error;
    return error;
//return error;
}

function delete_property(divId,commonpropertyId,part_id,subcat_id,mode)
{
/*    alert('commonpropertyId === '+commonpropertyId);
    alert('part_id ==== '+part_id);
    alert('subcat_id === '+subcat_id);
    return false;*/
//    alert('mode === '+mode);
    var poststr = 'property_id='+commonpropertyId+'&part_id='+part_id+'&subcat_id='+subcat_id+'&mode='+mode;
    send_data(divId,'delete_commonproperty.htm',poststr);
}

function supplier_preference(divid,id,supp_id,page)
{
    var isChecked ;
    if(document.getElementById(id))
    {
        if(document.getElementById(id).checked)
            isChecked = 'Y';
        else
            isChecked='N';
    }
    
    var poststr = 'supp_id='+supp_id+'&isChecked='+isChecked;
    if(page == 'supplier_preference')
    {
        poststr+='&mode=add';
    }
    else
    {
        poststr+='&mode=edit';
    }

    send_data_page('mainSupp','add_supp_preference.htm',poststr);
}


function validateFields()
{
    var val = document.getElementById('upload').value;
    //alert(val);
}

function checkWholeForm(theForm)
{
    //document.getElementById('email_id1').innerHTML='abc';
    //alert('Here ..');
    var why = "";
    why += checkUsername(theForm.uname.value);
	
    if(theForm.upassword.value != '')
    {
        why += checkPassword(theForm.upassword.value);
        why+=comparePassword(theForm.upassword.value,theForm.ucnfpass.value);
    }

	document.getElementById('JEC').disabled=false;
	document.getElementById('RNC').disabled=false;
	document.getElementById('NOR').disabled=false;
	
	
    why+=checkAddress(theForm.uaddress.value);
    why+=checkPhone(theForm.uphone.value);
    why+=checkmail(theForm.uemailid.value);
    why+=checkCity(theForm.ucity.value);
    why+=checkState(theForm.ustate.value);
    why+=checkDropdown(theForm.ucountry.selectedIndex);
    //alert(theForm.cname+" == "+theForm.cname.value);
    if(document.getElementById('JEC').checked){
        why+=checkCompany('JEC',theForm.company_id.value);
    }
    else if(document.getElementById('RNC').checked)
    {
       // alert('Here...');
        why+=checkCompanyName(theForm.cname.value);
       // alert('1');
        why+=checkCompanyAddress(theForm.caddress.value);
       // alert('2');
        why+=checkCompanyPhone(theForm.cphone.value);
       // alert('3');
        why+=checkCompanyCity(theForm.ccity.value);
       // alert('4');
        why+=checkCompanyState(theForm.cstate.value);
       // alert('5');
        why+=checkCompanyCountry(theForm.ccountry.selectedIndex);
    }

    if (why != "")
    {
        //alert("Final == "+why);
        return false;
    }
    return true;
}

function checkUsername (strng)
{
    //alert('Check Username');
    var error = "";
    if (strng == "") {
        error = "You didn't enter a username.\n";
    }

    var illegalChars = /\W/;
    // allow only letters, numbers, and underscores
    if (illegalChars.test(strng)) {
        error = "The username contains illegal characters.\n";
    }

    document.getElementById('user1name').innerHTML=error;
    return error;
}

function checkPassword (strng)
{
    //alert('Check Password');
    var error = "";
    if (strng == "")
    {
        error = "You didn't enter a password.\n";
    }

    var illegalChars = /[\W_]/; // allow only letters and numbers

    if ((strng != "") && ((strng.length < 4) || (strng.length > 8)) )
    {
        error = "The password is the wrong length. It must be greater than 4 characters and less than 8 characters.\n";
    }
    else if ( (strng != "") && (illegalChars.test(strng)) )
    {
        error = "The password contains illegal characters.\n";
    }
   /* else if ( (strng != "") && (!((strng.search(/[a-z]+/) > -1)&& (strng.search(/[A-Z]+/) > -1)&& (strng.search(/[0-9]+/) > -1))) )
    {
        error = "The password must contain at least one uppercase letter, one lowercase letter,and one numeral.\n";
    }*/

    document.getElementById('user1pass').innerHTML=error;
    return error;
}

function checkAddress(strng)
{
    //alert('Check Address');
    var error = "";
    if( strng == "")
        error = "Please Enter your Address ";

    document.getElementById('user1address').innerHTML=error;
    return error;
}

function comparePassword(pass1,pass2)
{
    //alert('Check Retype Password');
    var error = '';
    if(pass2 == '')
    {
        error = 'Please Enter the Password For Confirmation';
    }
    else if( (pass2 != '') && (pass1!=pass2))
    {
        error = "Both Passwords are not matched ";
    }
    document.getElementById('user1repass').innerHTML=error;
    return error;
}
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
function checkmail(e)
{
    var error = "";
    var returnval=emailfilter.test(e);
    if (returnval==false){;
        alert("Please enter a valid email address.");
        error = "Please enter a valid email address.";
    }
    document.getElementById('user1emailid').innerHTML = error;
    return error;

}


function checkPhone(strng)
{
    //alert('Check Phone ');
    var error = "";
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
    //strip out acceptable non-numeric characters

    if(strng == "")
    {
        error="Please Enter your Phone Number";
    }else if ( (strng != "") && (isNaN(parseInt(stripped))) )
    {
        error = "The phone number contains illegal characters.";
    }else if ( (strng != "") && (!(stripped.length <= 18)) )
    {
        error = "The phone number is 18 digits.Make sure you included an area code.\n";
    }

    try{
        document.getElementById('user1phone').innerHTML=error;
    }
    catch(err)
    {
        return error;
    }
    return error;
}

function checkCity(strng)
{
    var error = "";
    if (strng == "") {
        error = "You didn't enter a City.\n";
    }

    document.getElementById('user1city').innerHTML=error;
    return error;
}

function checkState(strng)
{
    var error = "";
    if (strng == "") {
        error = "You didn't enter a State .\n";
    }

    document.getElementById('user1state').innerHTML=error;
    return error;
}

function checkDropdown(choice)
{
    //alert('Check Nationality ');
    var error = "";
    if (choice == 0)
    {
        error = "You didn't choose an option from the drop-down list.\n";
    }
    document.getElementById('user1country').innerHTML = error;
    return error;
    //return error;
}

function checkCompany(id,param)
{
    var error="";
    //alert('Here ...'+id);
    if ((id == 'JEC') && (param==''))
    {
        alert('JEC 2');
        error = 'Please Enter the Company Code';
        document.getElementById('company1_id').innerHTML=error;
    }
    else if((id =='RNC'))
    {
        error +=checkCompanyName(param.cname.value);
        error +=checkCompanyAddress(param.caddress.value);
        error +=checkCompanyPhone(param.cphone.value);
        error +=checkCompanyCity(param.ccity.value);
        error +=checkCompanyState(param.cstate.value);
        error +=checkCompanyCountry(param.ccountry.selectedIndex);
    }

    return error;
}

function checkCompanyName(strng)
{
    //alert('Check Username');
    var error = "";
    if (strng == "") {
        error = "You didn't enter a Company Name.\n";
    }

    var illegalChars = /\W\s/;
    // allow only letters, numbers, and underscores
    if (illegalChars.test(strng)) {
        error = "The Companyname contains illegal characters.\n";
    }

    document.getElementById('company1name').innerHTML=error;
    return error;
}

function checkCompanyAddress(strng)
{
    var error = "";
    if(strng == ""){
        error = "Please Enter the Company Address.\n";
    }
    document.getElementById('company1address').innerHTML = error;
    return error;
}

function checkCompanyPhone(strng)
{
    //alert('Check Phone ');
    var error = "";
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
    //strip out acceptable non-numeric characters

    if(strng == "")
    {
        error="Please Enter your Phone Number";
    }else if ( (strng != "") && (isNaN(parseInt(stripped))) )
    {
        error = "The phone number contains illegal characters.";
    }else if ( (strng != "") && (!(stripped.length <= 18)) )
    {
        error = "The phone number is 18 digits.Make sure you included an area code.\n";
    }

    try
    {
      document.getElementById('company1phone').innerHTML=error;
    }
    catch(err)
    {
        return error;
    }
    return error;
}

function checkCompanyCity(strng)
{
    var error = "";
    if (strng == "") {
        error = "You didn't enter a City of the Company.\n";
    }

    document.getElementById('company1city').innerHTML=error;
    return error;
}

function checkCompanyState(strng)
{
    var error = "";
    if (strng == "") {
        error = "You didn't enter a State of the Company.\n";
    }

    document.getElementById('company1state').innerHTML=error;
    return error;
}

function checkCompanyCountry(choice)
{
    //alert('Check Nationality ');
    var error = "";
    if (choice == 0)
    {
        error = "You didn't choose an option from the drop-down list.\n";
    }
    document.getElementById('company1country').innerHTML = error;
    return error;
    //return error;
}

function send_data_hem(id,url,parameters,resFun)
{

 var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';
   
    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;
    }
    //alert('h2');
    http_request.onreadystatechange = function(){
       
        if (http_request.readyState == 4)
        {
            if (http_request.status == 200)
            {
                //alert(http_request.responseText);
                result = http_request.responseText;
				resFun(result);
                                delete self.http_request;

            }
            else
            {
                //alert('There was a problem with the request or You Forgot to Sign in');
                alert('Please Wait');
            }
        }
        else
        {
            eval('document.getElementById(\"'+id+'\").innerHTML = r ;');
        }
    }
    http_request.open('GET', 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 send_data_nam(id,url,parameters,resFun)
{
   
    //alert("parameter:::"+parameters);
 var r = '<center><img align=middle src = \"images/loading.gif\" width="50" height="50"><br/>Loading...</center>';

    var http_request1 = false;
    if (window.XMLHttpRequest)
    { // Mozilla, Safari,...
        http_request1 = new XMLHttpRequest();
        if (http_request1.overrideMimeType)
        {
            // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request1.overrideMimeType('text/html');
        }
    }
    else if (window.ActiveXObject)
    { // IE
        try
        {
            http_request1 = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                http_request1 = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {}
        }
    }
    if (!http_request1)
    {
        alert('Cannot create XMLHTTP instance');
        return false;
    }
    //alert('h2');
    http_request1.onreadystatechange = function(){

        if (http_request1.readyState == 4)
        {
            if (http_request1.status == 200)
            {
                //alert(http_request.responseText);
                result = http_request1.responseText;
				resFun(result);
                               // delete self.http_request1;

            }
            else
            {
                //alert('There was a problem with the request or You Forgot to Sign in');
                alert('Please Wait');
            }
        }
        else
        {
            eval('document.getElementById(\"'+id+'\").innerHTML = r ;');
        }
    }
    http_request1.open('GET', url, true);
    http_request1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request1.setRequestHeader("Content-length", parameters.length);
    http_request1.setRequestHeader("Connection", "close");
    //alert('parameter == '+parameters);
    http_request1.send(parameters);
}

function findPos(obj){
	var LT=new Array();
	var curleft=0;
	var curtop=0;
	while (obj!=null) {
		//LT[0] += obj.offsetLeft;
		//LT[1] += obj.offsetTop;
		curleft += obj.offsetLeft;
		curtop += obj.offsetTop;
		obj = obj.offsetParent;
	} 
	//curleft += obj.offsetLeft;
	//curtop += obj.offsetTop;
	// && obj.nodeName != 'HTML'
	LT[0]=curleft;
	LT[1]=curtop;
	return LT;
}

function showDivInCenter(Xwidth,Yheight,divid) {
	// First, determine how much the visitor has scrolled
	
	var scrolledX, scrolledY;
	if( self.pageYOffset ) {
		scrolledX = self.pageXOffset;
		scrolledY = self.pageYOffset;
	} else if( document.documentElement && document.documentElement.scrollTop ) {
		scrolledX = document.documentElement.scrollLeft;
		scrolledY = document.documentElement.scrollTop;
	} else if( document.body ) {
		scrolledX = document.body.scrollLeft;
		scrolledY = document.body.scrollTop;
	}
	
	// Next, determine the coordinates of the center of browser's window
	
	var centerX, centerY;
	if( self.innerHeight ) {
		centerX = self.innerWidth;
		centerY = self.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
		centerX = document.documentElement.clientWidth;
		centerY = document.documentElement.clientHeight;
	} else if( document.body ) {
		centerX = document.body.clientWidth;
		centerY = document.body.clientHeight;
	}
	
	// Xwidth is the width of the div, Yheight is the height of the
	// div passed as arguments to the function:
	var leftOffset = scrolledX + (centerX - Xwidth) / 2;
	var topOffset = scrolledY + (centerY - Yheight) / 2;
	// The initial width and height of the div can be set in the
	// style sheet with display:none; divid is passed as an argument to // the function
	var o=document.getElementById(divid);
	var r=o.style;
	r.position='absolute';
	r.top = topOffset + 'px';
	r.left = leftOffset + 'px';
	r.display = "block";
}  

function removeHTMLCode(obj){
	var strInputCode =obj.value;
	strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
		return (p1 == "lt")? "<" : ">";
	});
	var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
	//alert("Input code:\n" + strInputCode + "\n\nOutput text:\n" + strTagStrippedText);	
	obj.value=strTagStrippedText;
}

function isNumberKey(evt)
{//return false/true is for direct call this method from control. But I also attach this event. So return is not work. So I put "event.returnValue=false"

 var obj = (evt.target) ? evt.target : evt.srcElement;
 var charCode = (evt.which) ? evt.which : evt.keyCode;
 if(charCode==46) // 46="."
 {
	   if(obj.value.indexOf(".")==-1)
		return true;
	   else
		return false;
 }
 else if (charCode > 40  && ( charCode < 48 || charCode > 57  ) )
 {
		return false;
 }

 return true;
}
