function samestr(str1,str2){
var len1=str1.length;
var len2= str2.length;
if(len1>len2){
longer=str1;
shorter=str2;
}else{
longer=str2;
shorter=str1;
}
for(var samelength=shorter.length;samelength>0;samelength--){
for(var i=0;i+samelength<=shorter.length;i++){
var samestring=shorter.substring(i,i+samelength)
if(longer.indexOf(samestring)>=0){
a=samestring
return a
}
}
}
}