Php Function Within Function Javascript Code