Umesh

Untitled Document

Monday, 1 April 2013

android.os.NetworkOnMainThreadException or Unable to load Images From Twitter on android 4.0 Emulator or Device


Hello guys, after spending whole day, I got nice solution for my own  problem. Actualy I am feeding twitter data in my android application.  I am parsing user_name, created_at(means tweet time) and profile image url. When I parse these from twitter JSON, all data will shown in my listview properly. These is no any problem with my android 2.2,2.3.. emulator and device, but when I run this same code for my android 4.0 or up emulator and device , Image does not loads.


But finally I got my solution : Please fallow steps to resolve your problem..

Write below code into your Main Activity where your are showing listview just below

setContentView(R.layout.main_activity);

code:

if (android.os.Build.VERSION.SDK_INT > 9)
 {
     StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
     StrictMode.setThreadPolicy(policy);
 }

The above if condition is execute if your device api version is > 9 and if your device api version is less than 9 then your code is completely work without any error. Now my code works fine with all v ersion of devices properly.

And import below statement into your activity

import android.os.StrictMode

Friday, 22 March 2013

Finishes all the intents in stack which are on the top of any other activity


Let suppose if you want to log-out from last activity and come on to front activity. It removes all intents from stack which are on the top of front activity. It's nice search for me.This is the nice code. It finishes all the activities which are on the top of MagicMap--By Umesh


Intent intent = new Intent(getApplicationContext(), MagicMap.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

Thursday, 21 March 2013

Design your own check box in android


Hello guys, if you want to design your own check box for your android app then just go through fallowing steps : 


 Step 1 : Add these four images in your drawable folder 


checkbox_on_background_focus_yellow.png

checkbox_off_background.png

checkbox_on_background.png

checkbox_off_background_focus_yellow.png



Step 2 : Also add following chk.xml in your drawable folder 


chk.xml : 


<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/checkbox_on_background_focus_yellow" android:state_checked="true" android:state_focused="true"/>
    <item android:drawable="@drawable/checkbox_off_background_focus_yellow" android:state_checked="false" android:state_focused="true"/>
    <item android:drawable="@drawable/checkbox_off_background" android:state_checked="false"/>
    <item android:drawable="@drawable/checkbox_on_background" android:state_checked="true"/>

</selector>


Step 3 : write following code in check box property in your main layout 


android:background="@drawable/chk"


Selector for different button states in android


Change button on focus, on-clicked and active mode. Here is a simple and nice code. Add three different buttons of same size in your drawable folder. There is no need to code in your java file.


File : res/drawable/new_button.xml


<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_pressed_yellow"
android:state_pressed="true" />
<item android:drawable="@drawable/button_focused_orange"
android:state_focused="true" />
<item android:drawable="@drawable/button_normal_green" />
</selector>

File : res/layout/main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<Button
android:id="@+id/imageButtonSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/new_button" />

</LinearLayout>


Android : XMLParser class to parse xml online with example


Step 1 : Hello guys, here is simple XMLParser class which is used to parse almost all xml files. Just keep this file in your project and pass xml url in it.

XMLParser.java :


package com.umesh.xmlparsing;

import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import android.util.Log;

public class XMLParser {

// constructor
 public XMLParser() {
 }

 // Getting XML from URL making HTTP request param url string

 public String getXmlFromUrl(String url) {
  String xml = null;
  try {
   // defaultHttpClient
   DefaultHttpClient httpClient = new DefaultHttpClient();
   HttpPost httpPost = new HttpPost(url);
   HttpResponse httpResponse = httpClient.execute(httpPost);
   HttpEntity httpEntity = httpResponse.getEntity();
   xml = EntityUtils.toString(httpEntity);
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  } catch (ClientProtocolException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
  // return XML
  return xml;
 }

 // Getting XML DOM element param XML string
 
 public Document getDomElement(String xml){
  Document doc = null;
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  try {
   DocumentBuilder db = dbf.newDocumentBuilder();
   InputSource is = new InputSource();
          is.setCharacterStream(new StringReader(xml));
          doc = db.parse(is);
   } catch (ParserConfigurationException e) {
    Log.e("Error: ", e.getMessage());
    return null;
   } catch (SAXException e) {
    Log.e("Error: ", e.getMessage());
             return null;
   } catch (IOException e) {
    Log.e("Error: ", e.getMessage());
    return null;
   }
         return doc;
 }

 // Getting node value param elem element
 
  public final String getElementValue( Node elem ) {
      Node child;
      if( elem != null){
          if (elem.hasChildNodes()){
              for( child = elem.getFirstChild(); child != null; child = child.getNextSibling() ){
                  if( child.getNodeType() == Node.TEXT_NODE  ){
                      return child.getNodeValue();
                  }
              }
          }
      }
      return "";
  }
 
//  Getting node value param Element node param key string
 
  public String getValue(Element item, String str) {
   NodeList n = item.getElementsByTagName(str);
   return this.getElementValue(n.item(0));
  }
}

Step 2 :This will be any class to parse xml.

AndroidXMLParsingActivity.java


package com.umesh.xmlparsing;

import java.util.ArrayList;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class AndroidXMLParsingActivity extends ListActivity {

 // All static variables
 static final String URL = "http://api.androidhive.info/pizza/?format=xml";

 // XML node keys
 static final String KEY_ITEM = "item"; // parent node
 static final String KEY_ID = "id";
 static final String KEY_NAME = "name";
 static final String KEY_COST = "cost";
 static final String KEY_DESC = "description";

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);  //we can comment this line, because we are extending ListActivity

  ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
  XMLParser parser = new XMLParser();
  String xml = parser.getXmlFromUrl(URL); // getting XML
  Document doc = parser.getDomElement(xml); // getting DOM element
  NodeList nl = doc.getElementsByTagName(KEY_ITEM);
  // looping through all item nodes <item>
  for (int i = 0; i < nl.getLength(); i++) {
   // creating new HashMap
   HashMap<String, String> map = new HashMap<String, String>();
   Element e = (Element) nl.item(i);
   // adding each child node to HashMap key => value
   map.put(KEY_ID, parser.getValue(e, KEY_ID));
   map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
   map.put(KEY_COST, "Rs." + parser.getValue(e, KEY_COST));
   map.put(KEY_DESC, parser.getValue(e, KEY_DESC));
   // adding HashList to ArrayList
   menuItems.add(map);
  }
  // Adding menuItems to ListView
  ListAdapter adapter = new SimpleAdapter(this, menuItems,
    R.layout.list_item,
    new String[] { KEY_NAME, KEY_DESC, KEY_COST }, new int[] {
      R.id.name, R.id.desciption, R.id.cost });
  setListAdapter(adapter);
 }
}

In the above code, the line setContentView(R.layout.main) is no longer needed, because we are extends activiy as ListActivity.

Step 3 : Here is simple list_item.xml file.

list_item.xml :


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"> 
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
  <!-- Name Label -->
        <TextView
            android:id="@+id/name"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#dc6800"
            android:textSize="16sp"
            android:textStyle="bold"
            android:paddingTop="6dip"
            android:paddingBottom="2dip" />
  <!-- Description label -->
        <TextView
            android:id="@+id/desciption"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#acacac"
            android:paddingBottom="2dip">
        </TextView>
        <!-- Linear layout for cost and price Cost: Rs.100 -->
        <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <!-- Cost Label -->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#5d5d5d"
            android:gravity="left"
            android:textStyle="bold"
            android:text="Cost: " >
        </TextView>
        <!-- Price Label -->
        <TextView
            android:id="@+id/cost"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#acacac"
            android:textStyle="bold"
            android:gravity="left">
        </TextView>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

Android : JSONParser class with simple JSON parsing example


Step 1  : Simple JSON format :


{

  "contacts": [
        {
                "id": "c200",
                "name": "Ravi Tamada",
                "email": "
umesh@gmail.com",
                "address": "xx-xx-xxxx,x - street, x - country",
                "gender" : "male",
                "phone": {
                    "mobile": "+91 0000000000",
                    "home": "00 000000",
                    "office": "00 000000"
                }
        },
        {
                "id": "c201",
                "name": "Johnny Depp",
                "email": "
suryawanshi@gmail.com",
                "address": "xx-xx-xxxx,x - street, x - country",
                "gender" : "male",
                "phone": {
                    "mobile": "+91 0000000000",
                    "home": "00 000000",
                    "office": "00 000000"
                }
        },

/
/
/
/
so on...


Step 2 : Hello guys, this is comman JSONParser class.  Use this code and parse any    JSON.  Just put this java file in your package.



package com.umesh.jsonparse;import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import android.util.Log;

public class JSONParser {

    static InputStream is = null;
    static JSONObject jObj = null;
    static String json = "";

    // constructor
    public JSONParser() {

    }

    public JSONObject getJSONFromUrl(String url) {

        // Making HTTP request
        try {
            // defaultHttpClient
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost(url);

            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();
            is = httpEntity.getContent();          

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            json = sb.toString();
        } catch (Exception e) {
            Log.e("Buffer Error", "Error converting result " + e.toString());
        }

        // try parse the string to a JSON object
        try {
            jObj = new JSONObject(json);
        } catch (JSONException e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
        }

        // return JSON String        return jObj;

    }
}




Step 3 : This is simple  class which parse JSON and show values in listiview.


Main.java :

import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Menu;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class Main extends ListActivity {
 private static String url="http://api.androidhive.info/contacts/";
 ArrayList<HashMap<String, String>> contactList;
 JSONArray contacts=null;

 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  //setContentView(R.layout.main);

  contactList=new ArrayList<HashMap<String,String>>();
  JSONParser jparse=new JSONParser();
  JSONObject jobject=jparse.getJSONFromUrl(url);

  try
  {
   contacts=jobject.getJSONArray("contacts");
 
   for(int i=0;i<contacts.length();i++)
   {
    HashMap<String,String> map=new HashMap<String, String>();
  
    JSONObject c=contacts.getJSONObject(i);
  
    map.put("id",c.getString("id"));
    map.put("name",c.getString("name"));
    map.put("email",c.getString("email"));
  
    JSONObject phone=c.getJSONObject("phone");
    map.put("phone",phone.getString("mobile"));
    contactList.add(map);
  
  
   }
  }
  catch(Exception e)
  {
   e.printStackTrace();
  }

  ListAdapter adapter=new SimpleAdapter(this,contactList,R.layout.listitems,new String[]{"name","email","phone"},new int []{R.id.tv_name,R.id.tv_email,R.id.tv_mobile});
  setListAdapter(adapter);

 }
}


Step 4 : As we are extending ListActivity, no need to use main layout with list view. Just define listitems. Following is the simple listitem layout




listitems.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    tools:context=".Main" >
    <TextView
        android:id="@+id/tv_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Name"
        android:textSize="16dp"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    <TextView
        android:id="@+id/tv_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/tv_name"
        android:text="email id"
        android:textSize="14dp"
        android:textAppearance="?android:attr/textAppearanceMedium" />
    <TextView
        android:id="@+id/tv_mobile"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/tv_email"
        android:text="Mobile : "
        android:textSize="14dp"
        android:textAppearance="?android:attr/textAppearanceMedium" />
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/tv_mobile"
        android:src="@drawable/ic_launcher" />
</RelativeLayout>

 


Friday, 15 March 2013

Get MD5 fingerprint from Java's keytool, not only SHA-1?


With JDK 1.7 installed, keytool always outputs by default SHA1 fingerprint, not MD5. You can get the MD5 Certificate by adding -v option.


use the following code :-

1.  keytool -v -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android

or you can simply use following short command also. It will also outputs same Certificate

2. keytool -v -list -keystore debug.keystore

It will output MD5 Certificate as well. 

Monday, 25 February 2013

Check whether your app is running on Android Emulator or Android Mobile


Hello guys, following is simple code which check's whether your android app is running on emulator or Mobile device

           
  if("google_sdk".equals(Build.MODEL))
{
// Emulator
}
else
{
//Mobile
}

Thursday, 7 February 2013

Android Emulator lost internet connection after some time and show an error on reset "Adb connection Error:An existing connection was forcibly closed by the remote host"


Step 1 : 

Before doing anything, add your "jdk\bin" path and  "android-sdk-windows\platforms\android-4\tools" in your environment variables. 

Example : I have added following paths in my environment variables at a time separated with semicolon 

D:\Android\android-sdk-windows\tools;D:\Android\android-sdk-windows\platforms\android-4\tools;C:\Java\jdk1.7.0_05\bin;C:\Users\admin\.android;C:\openjdk-7-b146-windows-i586-20_jun_2011\java-se-7-ri\bin

Step 2 :

Open cmd and type :

adb kill-server
adb start-server

It assigns new port and then internet will be starts on your emulator.

Wednesday, 6 February 2013

Android : Copy your database from assets folder to device


This is a sample class which will help you quickly copy your database from assets folder to the android device. Simply make a new class in your project named as DataBaseHelper



       public class DataBaseHelper {

    // The system path of your application database.
       private static String DATABASE_PATH;


    // Your database name
       private static final String DATABASE_NAME = "kbc_t8.sqlite";

    // Your database version
       private static final int DATABASE_VERSION = 1;
    // defining table name so that you don't have to change the table name
    // everywhere if your table name    
    // changes. Just change it here

    private static final String TABLE_NAME = "table";


 // Columns
    private static final String QUESTIONS_COLUMN_ID = "_id";
    private static final String QUESTIONS_COLUMN_LEVEL = "level";

    private static final String[] questions_columns =

{ QUESTIONS_COLUMN_ID, QUESTIONS_COLUMN_LEVEL,};

// to store the context of the class that is calling the database
    private Context contextSql;

    private SQLiteDatabase dbObj;
    private SqliteOpenHelper helperObj;

     //constructor of database class
       DataBaseHelper(Context context) {
       contextSql = context;


    //making your path more adjustable so you don't have to change the package name it will take by default
        DATABASE_PATH = "/data/data/" + context.getPackageName()
                + "/databases/";
    }

    public void open() throws SQLException
   {
        helperObj = new SqliteOpenHelper(contextSql);
        dbObj = helperObj.getWritableDatabase();
    }

    public void close()
{
        if (dbObj != null)
            dbObj.close();

        helperObj.close();
    }

    public class SqliteOpenHelper extends SQLiteOpenHelper {

            public SqliteOpenHelper(Context context)
       {
               super(context, DATABASE_NAME, null, DATABASE_VERSION);
            // TODO Auto-generated constructor stub

          
        }

        @Override
        public void onCreate(SQLiteDatabase db)
       {
            // TODO Auto-generated method stub

            try
            {
                    copyDataBase();
            }
           catch (IOException e)
            {
                // throw new Error("Error copying database");
                   Log.e("copy_db", "Error copying database");
            }         
        }

            //Copies your database from your local assets-folder to the empty database

               private void copyDataBase() throws IOException {

            // Open your db as input stream
                InputStream inputStream = contextSql.getAssets().open(DATABASE_NAME);

            // Path to new db
               String outFileName = DATABASE_PATH + DATABASE_NAME;

            // Open new db of device
               OutputStream outputStream = new FileOutputStream(outFileName);

            // transfer bytes from the inputfile to the outputfile
               byte[] data = new byte[1024];
               int length;
               while ((length = inputStream.read(data)) > 0) {
               outputStream.write(data, 0, length);
            }

            // Close what you have opened
               outputStream.flush();
               outputStream.close();
               inputStream.close();

        }

             @Override
             public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO Auto-generated method stub

            db.execSQL("DROP TABLE IF EXISTS " + TABLE_QUESTIONS);
            onCreate(db);

        }

    }

Wednesday, 2 January 2013

HTML : Add style to mouse cursor (like layered text)


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->


<script language="javascript">

// ENTER TEXT BELOW. CAN *NOT* INCLUDE NORMAL HTML CODE.
var text='UMESH SURYAWANSHI.......';

var delay=40; // SPEED OF TRAIL
var Xoff=0; // PIXEL COUNT FROM THE LEFT OF THE CURSOR (- VALUES GO TO LEFT)
var Yoff=-30; // PIXEL COUNT FROM THE TOP OF THE CURSOR (- VALUES GO UP)
var txtw=14; // AMOUNT OF PIXEL SPACE EACH CHARACTER OCCUPIES
var beghtml='<font color="#00436e"><b>'; // OPTIONAL HTML CODE THAT EFFECTS WHOLE TEXT STRING SUCH AS FONT COLOR, SIZE, ETC.
var endhtml='</b></font>'; // END HTML CODE. MOSTLY USED IF ABOVE SETTING IS USED.

//********** NO NEED TO EDIT BELOW HERE **********\\

ns4 = (navigator.appName.indexOf("Netscape")>=0 && document.layers)? true : false;
ie4 = (document.all && !document.getElementById)? true : false;
ie5 = (document.all && document.getElementById)? true : false;
ns6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var txtA=new Array();
text=text.split('');
var x1=0;
var y1=-1000;
var t='';

for(i=1;i<=text.length;i++){
t+=(ns4)? '<layer left="0" top="-100" width="'+txtw+'" name="txt'+i+'" height="1">' : '<div id="txt'+i+'" style="position:absolute; top:-100px; left:0px; height:1px; width:'+txtw+'; visibility:visible;">';
t+=beghtml+text[i-1]+endhtml;
t+=(ns4)? '</layer>' : '</div>';
}
document.write(t);

function moveid(id,x,y){
if(ns4)id.moveTo(x,y);
else{
id.style.left=x+'px';
id.style.top=y+'px';
}}

function animate(evt){
x1=Xoff+((ie4||ie5)?event.clientX+document.body.scrollLeft:evt.pageX);
y1=Yoff+((ie4||ie5)?event.clientY+document.body.scrollTop:evt.pageY);
}

function getidleft(id){
if(ns4)return id.left;
else return parseInt(id.style.left);
}

function getidtop(id){
if(ns4)return id.top;
else return parseInt(id.style.top);
}

function getwindowwidth(){
if(ie4||ie5)return document.body.clientWidth+document.body.scrollLeft;
else return window.innerWidth+pageXOffset;
}

function movetxts(){
for(i=text.length;i>1;i=i-1){
if(getidleft(txtA[i-1])+txtw*2>=getwindowwidth()){
moveid(txtA[i-1],0,-1000);
moveid(txtA[i],0,-1000);
}else moveid(txtA[i], getidleft(txtA[i-1])+txtw, getidtop(txtA[i-1]));
}
moveid(txtA[1],x1,y1);
}

window.onload=function(){
for(i=1;i<=text.length;i++)txtA[i]=(ns4)?document.layers['txt'+i]:(ie4)?document.all['txt'+i]:document.getElementById('txt'+i);
if(ns4)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=animate;
setInterval('movetxts()',delay);
}
</script>

</head>

<body>

</body>
</html>