/**
 * Beginning of Transliteration Tool
 * @authors: Junaid P V ([[user:Junaidpv]])

 */
function importScript( page ) {
	// TODO: might want to introduce a utility function to match wfUrlencode() in PHP
	var uri = wgScript + '?title=' +
		encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') +
		'&action=raw&ctype=text/javascript';
	return importScriptURI( uri );
}

var loadedScripts = {}; // included-scripts tracker
function importScriptURI( url ) {
	if ( loadedScripts[url] ) {
		return null;
	}
	loadedScripts[url] = true;
	var s = document.createElement( 'script' );
	s.setAttribute( 'src', url );
	s.setAttribute( 'type', 'text/javascript' );
	document.getElementsByTagName('head')[0].appendChild( s );
	return s;
}
function addCheckBoxToSimpleSearch() {
	//To add "देवनागरी" transliteration tool
	//********************* देवनागरी **********************************
	var firstone =document.getElementById('p-search');
	if(firstone!= null) {
	try
	{
	var nextone=document.getElementById('h5');
	 
	var chkboxelement = document.createElement("input");
	chkboxelement.setAttribute("type","checkbox");
	chkboxelement.setAttribute("id","searchInputcb");
	chkboxelement.style.position ="relative";
	chkboxelement.style.left=".5em";
	chkboxelement.style.top="-4em";
	chkboxelement.value = 'searchInput'; // specifying curresponding input filed.
	chkboxelement.checked =true;
	 
	if (chkboxelement.addEventListener) 
	chkboxelement.addEventListener("click", transOptionOnClick, false);
	else if (chkboxelement.attachEvent) 
	chkboxelement.attachEvent("onclick", transOptionOnClick);
	 
	var chkboxlabel = document.createElement('chkboxlabel');
	chkboxlabel.style.fontSize = '.75em';
	chkboxlabel.style.fontWeight = 'bold';
	chkboxlabel.style.position ="relative";
	chkboxlabel.style.left="1em";
	chkboxlabel.style.top="-4.5em"
	 
	var linktohelp = document.createElement ('a')
        linktohelp.href= "http://hi.wikipedia.org/wiki/विकिपीडिया:देवनागरी_में_कैसे_टाइप_करें";
        linktohelp.title= "Phonetic Roman-to-Devanagari: Ctrl + M";
        linktohelp.appendChild( document.createTextNode('देवनागरी') );
	chkboxlabel.appendChild(linktohelp);
	chkboxlabel.appendChild(document.createElement('br'));
	firstone.insertBefore(chkboxelement,nextone);
	firstone.insertBefore(chkboxlabel,nextone);
	firstone.style.position ="relative";
	//firstone.style.top="-1.6em";
	}
	catch(ex)
	{
	//finished script written by junaid and sajid from malayalam wiki(thanks to them)
	}
	 
	}
	//************************* end of script ****************************
}

$j(document).ready( function() {
	transliterate('searchInput', 'wpTextbox1', 'wpSummary', 'wpFilterDescription', 'wpFilterTags', 'wpFilterRules', 'wpFilterNotes', 'wikieditor-toolbar-reference-text', 'mw-upload-form', 'wpDestFile', 'wpUploadDescription', 'emailuser', 'wpSubject', 'searchText', 'powerSearchText', 'wpNewTitle', 'wpReason', 'nsfrom', 'username', 'mwProtect-reason', 'nsto','wpText');
	//CHECKBOX_TEXT = "देवनागरी (Ctrl+M)";
	//addTransliterationOption( 'wpSummary', 'searchText', 'powerSearchText', 'wpFilterDescription', 'wpFilterTags', 'wpFilterRules', 'wpFilterNotes', 'wikieditor-toolbar-reference-text', 'mw-upload-form', 'wpDestFile', 'wpUploadDescription', 'emailuser', 'wpSubject', 'wpNewTitle', 'wpReason', 'nsfrom', 'username', 'mwProtect-reason', 'nsto','wpText');
	TO_POSITION = "before";
	//addTransliterationOption( 'wpTextbox1');
	//addCheckBoxToSimpleSearch();
	//translitStateSynWithCookie('searchInput', 'wpTextbox1', 'wpSummary', 'wpFilterDescription', 'wpFilterTags', 'wpFilterRules', 'wpFilterNotes', 'wikieditor-toolbar-reference-text', 'mw-upload-form', 'wpDestFile', 'wpUploadDescription', 'emailuser', 'wpSubject', 'searchText', 'powerSearchText', 'wpNewTitle', 'wpReason', 'nsfrom', 'username', 'mwProtect-reason', 'nsto','wpText');
});
/* End of Transliteration Tool */