help me in awk

could any one tell me why the following code is not running when i m using
shell as interpreter but is running when i m using awk as interpreter

  1 \#!/bin/sh
  2
  3 awk '
  4
  5 \{
  6     if\(\(index\($1,"@"\) > 0\)\)
  7     \{
  8
  9       i = index\($1,"@"\);
 10       printf\("username is :  %s\\n",substr\($1,1,i-1\)\);
 11       printf\("site name is :  %s\\n",substr\($1,i\+1,length\($1\)\)\);
 12
 13     \}
 14
 15
 16 \}
 17
 18 '

~
~
~
but it is working when using
#!/bin/awk -f

1 #!/bin/sh
2
3 awk '
4
5 {
6 if((index($1,"@") > 0))
7 {
8
9 i = index($1,"@");
10 printf("username is : %s\n",substr($1,1,i-1));
11 printf("site name is : %s\n",substr($1,i+1,length($1)));
12
13 }
14
15
16 }
17
18 '

--------------------
If you are using shell as interpreter.
U should use awk and then code
awk ' { if((index($1,"@") > 0))
ur code

}
'
filename

if ur keeping code in the file
code.awk should have
' { if((index($1,"@") > 0))
ur code
'
in shell u have to use
awk -f code.awk filename.txt

but why the above code is not working