      // Load the Google Transliteration API
      google.load("elements", "1", {
          packages: "transliteration"
      });
      function onLoad() {
        var options = {
          sourceLanguage: 'en', // or google.elements.transliteration.LanguageCode.ENGLISH,
          destinationLanguage: ['fa'], // or [google.elements.transliteration.LanguageCode.PERSIAN],
          shortcutKey: 'ctrl+g',
          transliterationEnabled: true
        };
        // Create an instance on TransliterationControl with the required
        // options.
        var control =
            new google.elements.transliteration.TransliterationControl(options);

        // Enable transliteration in the textfields with the given ids.
        var ids = ["text1", "transl2" ];
        control.makeTransliteratable(ids);

      }
      google.setOnLoadCallback(onLoad);
	  
	  
	  
google.load("language", "1");
	srclan = "fa";
	deslan = "en";
    function pinglishInitialize() {
        var text = document.form1.transl2.value;
        google.language.detect(text, function(result) {
            if (!result.error) {
                var originaltext = document.form1.transl2.value;
                google.language.getBranding('googleBrandingdId');
                google.language.translate(originaltext, srclan, deslan, function(result) {
                    document.getElementById("farsitrans").innerHTML = (result.error) ? ("Error: " + result.error.message) : result.translation;
                });

            }
        });
    }
function perdicPinglish() {
	setTimeout("pinglishInitialize()", 200);
}


google.load("search", "1", {"language" : "fa"},  {"hl" : "fa"});
var searchControl;
webSearchfarsiName = 'Web';
imageSearchfarsiName = 'Images';
videoSearchfarsiName = 'Videos';
wikipediaSearchfarsiName = 'Wikipedia';

    function OnGoogleSearchLoad() {
      // Create a search control
      searchControl = new google.search.SearchControl();
	  
	  // attach "powered by Google" branding
	  GSearch.getBranding(document.getElementById("branding"));
	
      // Add in a full set of searchers
     // var localSearch = new google.search.LocalSearch();
     // searchControl.addSearcher(localSearch);
      
	  webSearch = new google.search.WebSearch();
	  webSearch.setUserDefinedLabel(webSearchfarsiName);

	  wikipediaSearch = new google.search.WebSearch();
	  wikipediaSearch.setUserDefinedLabel(wikipediaSearchfarsiName);
	  wikipediaSearch.setSiteRestriction("wikipedia.org");	  
	  
  	  imageSearch = new google.search.ImageSearch();
	  imageSearch.setUserDefinedLabel(imageSearchfarsiName);
	  
	  videoSearch = new google.search.VideoSearch();
	  videoSearch.setUserDefinedLabel(videoSearchfarsiName);
	  

	  
	  searchControl.addSearcher(webSearch);
      searchControl.addSearcher(wikipediaSearch);
      searchControl.addSearcher(imageSearch);
	  searchControl.addSearcher(videoSearch);
	  
	  // contains a list of searcher objects
	  searcherList = new Array();
	  searcherList[0] = webSearch;
	  searcherList[1] = wikipediaSearch;
	  searcherList[2] = imageSearch;
  	  searcherList[3] = videoSearch;
	  
	  // contains names of searchers
	  searcherNameList = new Array();
	  searcherNameList[0] = webSearchfarsiName;
	  searcherNameList[1] = wikipediaSearchfarsiName;
	  searcherNameList[2] = imageSearchfarsiName;
	  searcherNameList[3] = videoSearchfarsiName;

	  
  	  // bring back more results  
	  searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);

	  // create a drawOptions object
      var drawOptions = new GdrawOptions();
	  
	  // tell the searcher to draw itself in linear mode
       drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
    
      // Tell the searcher to draw itself and tell it where to attach
      searchControl.draw(document.getElementById("searchResults"), drawOptions);

	  searchControl.setNoResultsString('براي جستجوي شما نتيجه‌اي يافت نشد.<br><span style="font-family: arial,sans-serif; font-size: 11px; vertical-align: middle;">powered by<img src="http://www.google.com/uds/css/small-logo.png" style="padding-left: 1px; vertical-align: middle;" /></span>');
	  searchControl.clearAllResults();
	  searchControl.setSearchCompleteCallback(null, displayEndOfSearch);
      // Execute an inital search
      
		//searchControl.execute(searchString);
    }
    
	

	
function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}
	
	
	
	
	
	
	
	
	function displayEndOfSearch(passedSearchControl, passedSearcher)
{
	document.getElementById("searchStatus").innerHTML = '<table border=0 width="100%"><tr><td><span style="font-family: arial,sans-serif; font-size: 11px; vertical-align: middle;">powered by<img src="http://www.google.com/uds/css/small-logo.png" style="padding-left: 1px; vertical-align: middle;" /></span></td><td align=right>جستجوهاي مربوط به : <b>' + searchString + '</b></td></tr></table>';
	
	tabDivs = getElementsByClassName('gsc-tabHeader');
	
	for (var i=0; i<searcherList.length; i++ ) 
	{
		if (passedSearcher == searcherList[i])
		{
			if (passedSearcher.cursor == null)
			{
				tabDivs[i].innerHTML = searcherNameList[i] + ' (?)';
			}
			else
			{
				tabDivs[i].innerHTML = searcherNameList[i] +  ' (' + passedSearcher.cursor.estimatedResultCount + ')';
			}
		}
	}

	
}
function perdicPinglishSearch(){
	searchString = document.form1.text1.value;
	searchControl.execute(searchString);
}