Problem in changing texture using javascript

its working fine but i want to change signal texture on the button click using javascript its not working properly.

my javascript call is-

var u = new UnityObject2();
u.getUnity().SendMessage(“/MyTrafficLight/ID189”, “MyFunction”, “”);

I am changing signal texture color in unity as-

public class signal_change : MonoBehaviour {

int Counter=0;
int LastCounter=0;

void Start ()
{

}
void Awake()
{
//rend = gameObject.GetComponent(Renderer);
}
void Update ()
{
if (Input.GetKeyDown(KeyCode.U))
{
MyFunction(“”);
}

if (LastCounter != Counter) {

Counter=LastCounter;

Texture txt=null;
switch(Counter)
{
case 1:txt=Resources.Load(“caution-signal”, typeof(Texture2D)) as Texture;break;
case 2:txt=Resources.Load(“attention-signal”, typeof(Texture2D)) as Texture;break;
case 3:txt=Resources.Load(“proceed-signal”, typeof(Texture2D)) as Texture;break;
case 4:txt=Resources.Load(“stop-signal”, typeof(Texture2D)) as Texture;break;
}

renderer.material.mainTexture = txt;
}

}

public void MyFunction(string data)
{
LastCounter++;
if(LastCounter>4)
LastCounter=1;
//rend.material.mainTexture = txt;
Application.ExternalCall( “SayHello”, LastCounter.ToString() );
}

}

I’m going to put this in code tags so I can read it

public class signal_change : MonoBehaviour {

int Counter=0;
int LastCounter=0;

void Start () 
{

}
void Awake()
{
//rend = gameObject.GetComponent(Renderer);
}
void Update () 
{
if (Input.GetKeyDown(KeyCode.U))
{
MyFunction("");
} 

if (LastCounter != Counter) {

Counter=LastCounter;

Texture txt=null;
switch(Counter)
{
case 1:txt=Resources.Load("caution-signal", typeof(Texture2D)) as Texture;break;
case 2:txt=Resources.Load("attention-signal", typeof(Texture2D)) as Texture;break;
case 3:txt=Resources.Load("proceed-signal", typeof(Texture2D)) as Texture;break;
case 4:txt=Resources.Load("stop-signal", typeof(Texture2D)) as Texture;break;
}

renderer.material.mainTexture = txt;
}

}

public void MyFunction(string data)
{
LastCounter++;
if(LastCounter>4)
LastCounter=1;
//rend.material.mainTexture = txt;
Application.ExternalCall( "SayHello", LastCounter.ToString() );
}

}