function recomp(txt){
	var chr=txt.charAt(0);
	if("\""===chr){
		txt=txt.substr(1,txt.length-2);
	}else{
		chr=chr.toLowerCase();
		if(chr!="f"&&chr!="h"){
			var	reComp=/(https?|ttps?|tps?|ps?|s?):\/\//i;
			if(reComp.test(txt)){
				var scheme=txt.substr(0,4);
				var colon=txt.indexOf(":");
				if(-1!=scheme.indexOf("s")){
					txt="https"+txt.substr(colon);
				}else{
					txt="http"+txt.substr(colon);
				}
			}
		}
	}
	return txt;
}
function open(txt,flags,pos){
	var tab=App.CmdExec("go",txt,pos,flags|0x1);
	if(pos<0){
		// get tab index
		pos = App.tabIndex(tab.id);
	}
	return pos;
}
(function(){
	var txt=App.clipboard.getData("TEXT");
	if(txt&&txt.length){
		var	flags=Context.tabFlags;
		var	pos=Context.NewTabPosition;
		var	reComp=/(https?|ttps?|tps?|ps?|s?):\/\//i;
		var	re=/((((http|https|ftp|file|javascript|res|mailto):\/\/)|about:)[.\/]+\b)|((https?|ttps?|tps?|ps?|s?):\/\/(.+\/){0,1}[A-z0-9$-_.+!*'(),\;\/?:@&=%~#]*)|(\"[^\r\n]+\")/gi;
		while(true){
			var ret=re.exec(txt);
			if(ret){
				pos=open(recomp(ret[0]),flags,pos);
			}
			else{
				break;
			}
			flags&=~0x2;
			flags|=0x4;
			++pos;
		}
	}
})();