﻿function SearchFunction()
{
    var check_form = "";
    check_form+= TestRequiredInput("search_keywords");
    if(check_form != "")
	{
	    sfm_show_error_msg(check_form);
	}
	else
	{
	    var search_keywords = document.getElementById('search_keywords').value;
	    window.location="SearchResult.aspx?keyword="+escape(search_keywords);
	}
	
}

function ReceiveServerData(arg, context)
{
    var cmd_content = arg.split('`');
    if (cmd_content[0] == 'RenderFinish')
    {
        document.getElementById('div_result').innerHTML = cmd_content[1];
        document.getElementById('div_btn_enquiry').style.display = "block";
        document.getElementById('div_loading').style.display = "none";
	window.location="Page.aspx?id=52";


    }
    else if(cmd_content[0] == 'RenderFinishSignup')
    {
        document.getElementById('div_result').innerHTML = cmd_content[1];
        document.getElementById('div_signup_bt').style.display = "block";
        document.getElementById('div_loading').style.display = "none";
    }
    else if(cmd_content[0] == 'RenderAlert')
    {
        alert(cmd_content[1]);
    }
    
}
function SendSignUp()
{
    document.getElementById('div_signup_bt').style.display = "none";
    document.getElementById('div_loading').style.display = "block";
    document.getElementById('div_result').innerHTML = "";
    var check_form = "";
    check_form+= TestRequiredInput("txtName");
    check_form+= TestRequiredInput("txtEmail");
    check_form+= TestEmail("txtEmail");
    check_form+= TestRequiredInput("txtCell");
    if(check_form != "")
	{
	    sfm_show_error_msg(check_form);
	    document.getElementById('div_signup_bt').style.display = "block";
        document.getElementById('div_loading').style.display = "none";
	}
	else
	{
		var Name = document.getElementById('txtName').value;
		var Email = document.getElementById('txtEmail').value;
		var Cell = document.getElementById('txtCell').value;
		var NextCommand = 'SendSignUp' + '`' + Name + '`' +Email+ '`' +Cell;
        CallServer(NextCommand, '');
	}
}
function SendEnquiry()
{
    document.getElementById('div_btn_enquiry').style.display = "none";
    document.getElementById('div_loading').style.display = "block";
    document.getElementById('div_result').innerHTML = "";
    var check_form = "";
    check_form+= TestRequiredInput("txtFirstName");
    check_form+= TestRequiredInput("txtLastName");
    check_form+= TestRequiredInput("txtEmail");
    check_form+= TestEmail("txtEmail");
    check_form+= TestRequiredInput("txtCompany");
    check_form+= TestRequiredInput("txtCountry");
    check_form+= TestRequiredInput("txtTel");
    check_form+= TestSelectOneOptionValue("txtServices","Please Select One");
    check_form+= TestSelectOneOptionValue("txtTimeframe","Please Select One");
    /*
    check_form+= TestRequiredInput("txtIndustry");
    if(TestSelectOneCheckbox("ctl00_ContentPlaceHolder1_cblOthers")!= "")
    {
        check_form+= TestSelectOneCheckbox("cbl");
    }
    else
    {
        check_form+= TestRequiredInput("ctl00_ContentPlaceHolder1_txtInterestsOthers","Interests Others");
    }*/
    if(check_form != "")
	{
	    sfm_show_error_msg(check_form);
	    document.getElementById('div_btn_enquiry').style.display = "block";
        document.getElementById('div_loading').style.display = "none";
	}
	else
	{
		var FirstName = document.getElementById('txtFirstName').value;
		var LastName = document.getElementById('txtLastName').value;
		var Email = document.getElementById('txtEmail').value;
		var Company = document.getElementById('txtCompany').value;
		var Country = document.getElementById('txtCountry').value;
		var Tel = document.getElementById('txtTel').value;
		var Services = document.getElementById('txtServices').value;
		var Timeframe = document.getElementById('txtTimeframe').value;
		
		//var Department = document.getElementById('txtDepartment').value;
        //var ProductService = ReturnCheckBoxesValue('cbl',"|");
        //var Others = document.getElementById('txtInterestsOthers').value;
        var Remarks = document.getElementById('ctl00_ContentPlaceHolder1_txtComment').value;

        //var NextCommand = 'SendEnquiry' + '`' + FirstName + '`' +LastName+ '`' +Email+ '`' +Company+ '`' +Country+ '`' +Tel+ '`' +Industry+ '`' +Designation+ '`' +Department + '`' +ProductService + '`' + Others + '`' + Remarks;
        var NextCommand = 'SendEnquiry' + '`' + FirstName + '`' +LastName+ '`' +Email+ '`' +Company+ '`' +Country+ '`' +Tel+ '`' +Services+ '`' +Timeframe+ '`' + Remarks;
        
        //alert(NextCommand);
        
        CallServer(NextCommand, '');
        
        
        /*/
		var FirstName = document.getElementById('txtDesignation').value;
		var FirstName = document.getElementById('txtDesignation').value;
		var FirstName = document.getElementById('txtDesignation').value;
		var FirstName = document.getElementById('txtDesignation').value;*/
		
		
		
    }
    
}


function ReturnCheckBoxesValue(objValue,delimitter)
{
    var str = "";
    var objValue = document.getElementById(objValue);
    if(objValue!=null)
    {	
	    for(var i= 0; i < document.aspnetForm.elements.length; i ++)
        {
            if(document.aspnetForm.elements[i].id == objValue.id)
            {
                if(document.aspnetForm.elements[i].checked)
                {
                    str +=document.aspnetForm.elements[i].value + delimitter;
                }
            }
        }
    }
    return str;
}
