<?php 
/* 
* @author Nilay Medh
* Email : contact@oasissolutions.co.in
* URL : http://oasissolutions.co.in
* Description : Google Multi Module is a swiss knife for displaying several things Google on your website
*(c) Copyright: OASIS Technology Solutions
*(c) License: GNU / GPL 
***/
defined('_JEXEC') or die('Restricted access');
?>
<?php 
$vmodcss = $params->get('vmodcss');
$vtext = $params->get('vtext');
$vtextpos = $params->get('vtextpos');
$gtranslateshow = $params->get('gtranslateshow');
$pagelang = $params->get('pagelang');
$showtransliterate = $params->get('showtransliterate');
$showprofile = $params->get('showprofile');
$bloggerid = $params->get('bloggerid');
$showprofilename = $params->get('showprofilename');
$showblogs = $params->get('showblogs');
$showblogupdate = $params->get('showblogupdate');
$showblogwhat = $params->get('showblogwhat');
$showblogname = $params->get('showblogname');
$enablefeed = $params->get('enablefeed');
$showfeedwhat = $params->get('showfeedwhat');
$feedlist = $params->get('feedlist');
$feedposition = $params->get('feedposition');
$feedblocktitle = $params->get('feedblocktitle');
$numfeeditems = $params->get('numfeeditems');
$feeddisptime = $params->get('feeddisptime');
$feedsite = $params->get('feedsite');
$feedsiteword = $params->get('feedsiteword');
$feedblockwidth = $params->get('feedblockwidth');
$photodisptime = $params->get('photodisptime');
$phototransittime = $params->get('phototransittime');
$linkphoto = $params->get('linkphoto');
$photofeedurl = $params->get('photofeedurl');
$enableimagesearch = $params->get('enableimagesearch');
$showsearchcontrol = $params->get('showsearchcontrol');
$imagesearchphrase = $params->get('imagesearchphrase');
$sizerestrict = $params->get('sizerestrict');
$colorrestrict = $params->get('colorrestrict');
$imagetyperestrict = $params->get('imagetyperestrict');
$imagesiterestrict = $params->get('imagesiterestrict');
$enablelocalsearch = $params->get('enablelocalsearch');
$localsearchresult = $params->get('localsearchresult');
$localplace = $params->get('localplace');
$localsearchword = $params->get('localsearchword');
$locallatitude = $params->get('locallatitude');
$locallongitude = $params->get('locallongitude');
$localmapzoom = $params->get('localmapzoom');
$enablenewssearch = $params->get('enablenewssearch');
$newssearchtype = $params->get('newssearchtype');
$newssearchphrase = $params->get('newssearchphrase');
$newsorder = $params->get('newsorder');
$newsplace = $params->get('newsplace');
$newstopic = $params->get('newstopic');
$newsformat = $params->get('newsformat');
$newssearchtitle = $params->get('newssearchtitle');
$newsresultsize = $params->get('newsresultsize');
$newsdisplaytime = $params->get('newsdisplaytime');
$newstransittime = $params->get('newstransittime');
$newslinktarget = $params->get('newslinktarget');
$newsedition = $params->get('newsedition');
$enablewebsearch = $params->get('enablewebsearch');
$websearchphrase = $params->get('websearchphrase');
$websearchsite = $params->get('websearchsite');
$websiterestrict = $params->get('websiterestrict');
$websearchcse = $params->get('websearchcse');
$enableyoutube = $params->get('enableyoutube');
$videoid = $params->get('videoid');
$vwidth = $params->get('vwidth');
$vheight = $vwidth*295/480;
$loadmsg = $params->get('loadmsg');
$playersizes = $params->get('playersizes');
$defaultsize = $params->get('defaultsize');
$sizeincrementper = $params->get('sizeincrementper');
$playerinfo = $params->get('playerinfo');
$playerinfopos = $params->get('playerinfopos');
$vstate = $params->get('vstate');
$vtime = $params->get('vtime');
$vbytes = $params->get('vbytes');
$vchange = $params->get('vchange');
$vchangevideo = $params->get('vchangevideo');
$vchangetitle = $params->get('vchangetitle');
?>
<?php if($vmodcss != NULL) { ?><div style="<?php echo $vmodcss; ?>"><?php } ?>
	<?php if($vtextpos == 'Above') echo $vtext; ?>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>

<?php // online website translator
if($gtranslateshow == 'Yes') { ?>
	<div id="google_translate_element"></div>
	<script>
	function googleTranslateElementInit() {
		new google.translate.TranslateElement({
		pageLanguage: '<?php echo $pagelang; ?>'
		}, 'google_translate_element');
	}
	</script>
	<script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<?php } ?>

<?php // transliteration
if($showtransliterate == 'Yes') { ?>
	
    <script type="text/javascript">

      // Load the Google Transliteration API
      google.load("elements", "1", {
            packages: "transliteration"
          });

      var transliterationControl;
      function onLoad() {
        var options = {
            sourceLanguage: 'en',
            destinationLanguage: ['ar','bn','gu','hi','kn','ml','mr','ne','fa','pa','ta','te','ur'],
            transliterationEnabled: true,
            shortcutKey: 'ctrl+g'
        };
        // Create an instance on TransliterationControl with the required
        // options.
        transliterationControl =
          new google.elements.transliteration.TransliterationControl(options);

        // Enable transliteration in the textfields with the given ids.
        var ids = [ "transl1", "transl2" ];
        transliterationControl.makeTransliteratable(ids);

        // Add the STATE_CHANGED event handler to correcly maintain the state
        // of the checkbox.
        transliterationControl.addEventListener(
            google.elements.transliteration.TransliterationControl.EventType.STATE_CHANGED,
            transliterateStateChangeHandler);

        // Add the SERVER_UNREACHABLE event handler to display an error message
        // if unable to reach the server.
        transliterationControl.addEventListener(
            google.elements.transliteration.TransliterationControl.EventType.SERVER_UNREACHABLE,
            serverUnreachableHandler);

        // Add the SERVER_REACHABLE event handler to remove the error message
        // once the server becomes reachable.
        transliterationControl.addEventListener(
            google.elements.transliteration.TransliterationControl.EventType.SERVER_REACHABLE,
            serverReachableHandler);

        // Set the checkbox to the correct state.
        document.getElementById('checkboxId').checked =
          transliterationControl.isTransliterationEnabled();

        // Populate the language dropdown
        var destinationLanguage =
          transliterationControl.getLanguagePair().destinationLanguage;
        var languageSelect = document.getElementById('languageDropDown');
        var supportedDestinationLanguages =
          google.elements.transliteration.getDestinationLanguages(
            google.elements.transliteration.LanguageCode.ENGLISH);
        for (var lang in supportedDestinationLanguages) {
          var opt = document.createElement('option');
          opt.text = lang;
          opt.value = supportedDestinationLanguages[lang];
          if (destinationLanguage == opt.value) {
            opt.selected = true;
          }
          try {
            languageSelect.add(opt, null);
          } catch (ex) {
            languageSelect.add(opt);
          }
        }
      }

      // Handler for STATE_CHANGED event which makes sure checkbox status
      // reflects the transliteration enabled or disabled status.
      function transliterateStateChangeHandler(e) {
        document.getElementById('checkboxId').checked = e.transliterationEnabled;
      }

      // Handler for checkbox's click event.  Calls toggleTransliteration to toggle
      // the transliteration state.
      function checkboxClickHandler() {
        transliterationControl.toggleTransliteration();
      }

      // Handler for dropdown option change event.  Calls setLanguagePair to
      // set the new language.
      function languageChangeHandler() {
        var dropdown = document.getElementById('languageDropDown');
        transliterationControl.setLanguagePair(
            google.elements.transliteration.LanguageCode.ENGLISH,
            dropdown.options[dropdown.selectedIndex].value);
      }

      // SERVER_UNREACHABLE event handler which displays the error message.
      function serverUnreachableHandler(e) {
        document.getElementById("errorDiv").innerHTML =
            "Transliteration Server unreachable";
      }

      // SERVER_UNREACHABLE event handler which clears the error message.
      function serverReachableHandler(e) {
        document.getElementById("errorDiv").innerHTML = "";
      }
      google.setOnLoadCallback(onLoad);

    </script>

  <center>Type in Custom Languages</center>
    <div id='translControl'>
      <input type="checkbox" id="checkboxId" onclick="javascript:checkboxClickHandler()"></input>
      Type in <select id="languageDropDown" onchange="javascript:languageChangeHandler()"></select>
    </div>
    <br>Title : <input type='textbox' id="transl1"/>
    <br>Body<br><textarea id="transl2" style="width:600px;height:200px"></textarea>
    <br><div id="errorDiv"></div>
<?php } ?>

<?php // blogger api
if($showprofile == 'Yes') { 
if($showblogwhat == 'Blogs') { ?>

    <script type="text/javascript">
      google.load("gdata", "1.x", { packages : ["blogger"] });
    </script>
    <script type="text/javascript">
      function _run() {
        /*
        * Retrieve a list of blogs
        */
        
        // Obtain a reference to the 'content' div
        var content = document.getElementById('content');
        
        // Create the blogger service object
        var bloggerService =
            new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');
        
        // The default "metafeed" feed is used to retrieve a list of blogs for a
        // particular logged-in user.
        //
        // The ID included in this URI can be retrieved from the <link rel="me">
        // element in the Blog's HTML source
        var feedUri = 'http://www.blogger.com/feeds/<?php echo $bloggerid; ?>/blogs';
        
        // The callback method invoked when getBlogFeed() returns feed data
        var handleBlogFeed = function(blogFeedRoot) {
        
          // Display Blogger Profile data
          var author = blogFeedRoot.feed.getAuthors();
          var authorName = author[0].getName().getValue();
          var authorUri = author[0].getUri().getValue();
		  var html = '';	
          // This variable will buffer HTML output until execution is complete
		  <?php if($showprofilename == 'Yes') { ?>
          html += '<h2>Profile Information</h2>'
               + '<dl>'
               + '<dt>Profile Name:</dt>'
               + '<dd>' + authorName + '</dd>'
               + '<dt>Profile Link:</dt>'
               + '<dd><a href="' + authorUri + '">' + authorUri + '</a></dd>';
			<?php } ?>
          // Fetch blogs associated with this Blogger Profile
		  <?php if($showblogs == 'Yes') { ?>
          html += '<h2>Blog List</h2>';
          var blogEntries = blogFeedRoot.feed.getEntries();
        
          // Has the user created any blogs?
          if(!blogEntries.length) {
            html += '<p>First <a href="http://www.blogger.com" '
                  + 'target="_blank">create a blog</a>.</p>';
          } else {
            // Print list of blogs
			html += '<table rules="groups">'
                  + '<thead><tr>'
                  + '<th>Blog Name/Link</th><?php if($showblogupdate == 'Yes') { ?><th>Last Updated</th><?php } ?>'
                  + '</tr></thead>'
                  + '<tbody>';
        
            for (var i = 0, blogEntry; blogEntry = blogEntries[i]; i++) {
              var blogTitle = blogEntry.getTitle().getText();
              var blogURL = blogEntry.getHtmlLink().getHref();
              var blogUpdated = blogEntry.getUpdated().getValue().getDate();
              html += '<tr>'
                    + '<td><a href="' + blogURL + '" target="_blank">'
                    + blogTitle
                    + '</a></td>'
					<?php if($showblogupdate == 'Yes') { ?>
                    + '<td>' + blogUpdated + '</td>'
					<?php } ?>
                    + '</tr>';
            }
        
            html += '</tbody>'
                  + '</table>';
          };
		  <?php } ?>
		  
		// Output buffered HTML and clear 'Loading...' message
          content.innerHTML = html;
        };
        
        // Error handler called when getBlogFeed() produces an error
        var handleError = function(error) {
          content.innerHTML = '<pre>' + error + '</pre>';
        };
        
        // Submit the request using the blogger service object
        bloggerService.getBlogFeed(feedUri, handleBlogFeed, handleError);
		
        
      }
      google.setOnLoadCallback(_run);
    </script>
  
    <div id="content" style="width:100%;">Loading...</div>
<?php } ?>	
<?php // blog posts
if($showblogwhat == 'Posts') { ?>
		<script type="text/javascript">
      google.load("gdata", "1.x", { packages : ["blogger"] });
    </script>
    <script type="text/javascript">
      function _run() {
        /*
        * Retrieve a list of blog posts
        */
        
        // Obtain a reference to the 'content' div
        var content = document.getElementById('content');
        
        // Create the blogger service object
        var bloggerService =
            new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');
        
        // The feed for a single blog. (In this case, the Official Google Blog.)
        //
        // The ID included in this URI can be retrieved from the
        // <link rel="service.post"> element in the Blog's HTML source
        var feedUri = 'http://www.blogger.com/feeds/<?php echo $bloggerid; ?>/posts/default';
        
        // A callback method invoked getBlogPostFeed() returns data
        var handleBlogPostFeed = function(postsFeedRoot) {
          var posts = postsFeedRoot.feed.getEntries();
          
          // This variable will buffer HTML output until function completes
          var html = '';
          <?php if($showblogname == 'Yes') { ?>
          // Display blog's title
          html += '<dl>'
               + '<dt><strong>Blog:</strong> '
               + '<a href="'
               + postsFeedRoot.feed.getLink('alternate').getHref()
               + '">'
               + postsFeedRoot.feed.getTitle().getText()
               + '</a></dt>';
          <?php } ?>
          // Display blog posts
          html += '<dd><ul>';
          for (var i = 0, post; post = posts[i]; i++) {
            var postTitle = post.getTitle().getText();
            var postURL = post.getHtmlLink().getHref();
            html += '<li><a href="' + postURL + '" target="_blank">'
                      + postTitle
                      + '</a></li>';
          }
          html += '</ul></dd>';
          
          // Write out buffered HTML, and clear the "Loading..." message
          content.innerHTML = html;
        };
        
        var handleError = function(error) {
          content.innerHTML = '<pre>' + error + '</pre>';
        };
        
        bloggerService.getBlogPostFeed(feedUri, handleBlogPostFeed, handleError);
        
      }
      google.setOnLoadCallback(_run);
    </script>
  
  
    <div id="content" style="width:100%;">Loading...</div>
<?php } ?>
<?php // blog comments
if($showblogwhat == 'Comments') { ?>
	<script type="text/javascript">
      google.load("gdata", "1.x", { packages : ["blogger"] });
    </script>
    <script type="text/javascript">
      function _run() {
        /*
        * Retrieve a list of blog post comments
        */
        
        // Obtain a reference to the 'content' div
        var content = document.getElementById('content');
        
        // Create the blogger service object
        var bloggerService =
            new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');
        
        // The feed for a single blog. (In this case, Linus Torvalds' Blog.)
        //
        // The ID included in this URI can be retrieved from the <link rel="me">
        // element in the Blog's HTML source
        var feedUri = 'http://www.blogger.com/feeds/<?php echo $bloggerid; ?>/posts/default';
        
        // The callback method used when getBlogPostFeed() returns blog entries
        var handleBlogPostFeed = function(blogPostsFeed) {
          // Display blog's title and clear 'Loading...' message
		  content.innerHTML = ''
		  <?php if($showblogname == 'Yes') { ?>
          content.innerHTML += '<p><strong>Blog:</strong> '
                            + '<a href="'
                            + blogPostsFeed.feed.getLink('alternate').getHref()
                            + '">'
                            + blogPostsFeed.feed.getTitle().getText()
                            + '</a></p>';
          <?php } ?>
          var postEntry = blogPostsFeed.feed.getEntries()[0]; // only get first post  
          var commentsFeedUri = postEntry.getRepliesLink().getHref();
        
          bloggerService.getBlogCommentFeed(commentsFeedUri, handleCommentFeed, handleError);
        };
        
        // The callback method used when getBlogCommentFeed() returns comments
        var handleCommentFeed = function(commentsFeedRoot) {
          var commentEntries = commentsFeedRoot.feed.getEntries();
        
          // Buffer HTML until execution completes
          var html = '<p><strong>Recent Comments:</strong></p>';
          
          if (commentEntries.length > 0) {
            html += '<ul>';
            for(var i = 0, commentEntry; commentEntry = commentEntries[i]; i++) {
              var commentTitle = commentEntry.getTitle().getText();
              var commentLink = commentEntry.getLink('alternate').getHref();
              html += '<li>'
                   + '<a href="' + commentLink + '">'
                   + commentTitle + '</a></li>';
            }
            html += '</ul>';
          } else {
            html += '<p>No comments found for that post.</p>';
          }
          
          // Output buffered HTML and clear 'Loading...' message.
          content.innerHTML += html;
        };
        
        var handleError = function(error) {
          content.innerHTML = '<pre>' + error + '</pre>';
        };
        
        bloggerService.getBlogPostFeed(feedUri, handleBlogPostFeed, handleError);
        
      }
      google.setOnLoadCallback(_run);
    </script>
  
    <div id="content" style="width:100%;">Loading...</div>
<?php } ?>
<?php } ?>

<?php // feed
if($enablefeed == 'Yes') { 
$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::base().'/modules/mod_googlemultimod/css/gfeedcss.css');
if($showfeedwhat == 'feedurls') { ?>
<?php 

$feedseperate = explode(",", $feedlist);
$feednumcount = count($feedseperate);

?>
<!-- Dynamic Feed Control and Stylesheet -->
    <script src="http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js"
            type="text/javascript"></script>
    

    <script type="text/javascript">
    /*
    *  How to use the Dynamic Feed Control, which has pretty UI already made for you!
    *  Don't forget to check out the options:
    *  http://www.google.com/uds/solutions/dynamicfeed/reference.html
    */
    
    google.load('feeds', '1');
    <?php $feedshowcount = 0; ?>
    function OnLoad() {
      var feeds = [
	<?php while ($feedshowcount <= $feednumcount) { ?>  
        {
          title: "<?php echo $feedseperate[$feedshowcount]; ?>",
		  <?php $feedshowcount++; ?>
          url: "<?php echo $feedseperate[$feedshowcount]; ?>"
        },
    <?php $feedshowcount++; 
	} ?>    
      ];
    
      var options = {
        stacked : true,
        <?php echo $feedposition; ?> : true,
        title : "<?php echo $feedblocktitle; ?>",
		numResults : <?php echo $numfeeditems; ?>,
		displayTime : <?php echo $feeddisptime; ?>
      };
    
      new GFdynamicFeedControl(feeds, 'content', options);
      document.getElementById('content').style.width = "<?php echo $feedblockwidth; ?>";
    }
    
    google.setOnLoadCallback(OnLoad);
    </script>
  
  <div id="content">
    <span style="color:#676767;font-size:11px;margin:10px;padding:4px;">Loading...</span>
  </div>
<?php } ?>
<?php if($showfeedwhat == 'siteurl') { ?>
<script type="text/javascript">
    /*
    *  How to find a feed based on a query.
    */
    
    google.load("feeds", "1");
    
    function OnLoad() {
      // Query for president feeds on cnn.com
      var query = '<?php echo $feedsite; ?> <?php echo $feedsiteword; ?>';
      google.feeds.findFeeds(query, findDone);
    }
    
    function findDone(result) {
      // Make sure we didn't get an error.
      if (!result.error) {
        // Get content div
        var content = document.getElementById('content');
        var html = '';
    
        // Loop through the results and print out the title of the feed and link to
        // the url.
        for (var i = 0; i < result.entries.length; i++) {
          var entry = result.entries[i];
          html += '<p><a href="' + entry.url + '">' + entry.title + '</a></p>';
        }
        content.innerHTML = html;
      }
    }
    
    google.setOnLoadCallback(OnLoad);
    </script>
  
    <div id="content">Loading...</div>
<?php } ?>
<?php if($showfeedwhat == 'photofeed') { ?>
<script src="http://www.google.com/uds/solutions/slideshow/gfslideshow.js"
            type="text/javascript"></script>
    
    <script type="text/javascript">
    /*
    *  How to make a slideshow with a photo feed using our custom control.
    *  To see the options, go here or click the docs link in the titlebar:
    *  http://www.google.com/uds/solutions/slideshow/index.html
    */
    
    google.load("feeds", "1");
    
    function OnLoad() {
      var feed  = "<?php echo $photofeedurl; ?>";
      var options = {
        displayTime:<?php echo $photodisptime; ?>,
        transistionTime:<?php echo $phototransittime; ?>,
        scaleImages:true,
        fullControlPanel : true,
		<?php if($linkphoto == 'Yes') { ?>
		linkTarget : google.feeds.LINK_TARGET_BLANK
		<?php } ?>
      };
      var ss = new GFslideShow(feed, "slideshow", options);
    }
    
    google.setOnLoadCallback(OnLoad);
    </script>
  
  <div id="slideshow" class="gslideshow"><div class="feed-loading">Loading...</div></div>
<?php } ?>
<?php } ?>
<?php // image search
if($enableimagesearch == 'Yes') {
if($showsearchcontrol == 'No') { ?>
<script type="text/javascript">
    /*
    *  How to search for images and restrict them by size.
    *  This demo will also show how to use Raw Searchers, aka a searcher that is
    *  not attached to a SearchControl.  Thus, we will handle and draw the results
    *  manually.
    */
    
    google.load('search', '1');
    
    function searchComplete(searcher) {
      // Check that we got results
      if (searcher.results && searcher.results.length > 0) {
        // Grab our content div, clear it.
        var contentDiv = document.getElementById('content');
        contentDiv.innerHTML = '';
    
        // Loop through our results, printing them to the page.
        var results = searcher.results;
        for (var i = 0; i < results.length; i++) {
          // For each result write it's title and image to the screen
          var result = results[i];
          var imgContainer = document.createElement('div');
    
          var title = document.createElement('h2');
          // We use titleNoFormatting so that no HTML tags are left in the title
          title.innerHTML = result.titleNoFormatting;
    
          var newImg = document.createElement('img');
          // There is also a result.url property which has the escaped version
          newImg.src = result.tbUrl;
    
          imgContainer.appendChild(title);
          imgContainer.appendChild(newImg);
    
          // Put our title + image in the content
          contentDiv.appendChild(imgContainer);
        }
      }
    }
    
    function OnLoad() {
      // Our ImageSearch instance.
      var imageSearch = new google.search.ImageSearch();
      
      // Restrict to extra large images only
	  <?php if($sizerestrict != 'No') { ?>
      imageSearch.setRestriction(google.search.ImageSearch.RESTRICT_IMAGESIZE,
                                 google.search.ImageSearch.IMAGESIZE_<?php echo $sizerestrict; ?>);
		<?php } ?>
	  <?php if($colorrestrict != 'No') { ?>
	  imageSearch.setRestriction(google.search.ImageSearch.RESTRICT_COLORFILTER,
            google.search.ImageSearch.COLOR_<?php echo $colorrestrict; ?>);
      <?php } ?>
      <?php if($imagetyperestrict != 'No') { ?>
	  imageSearch.setRestriction(google.search.ImageSearch.RESTRICT_IMAGETYPE,
            google.search.ImageSearch.IMAGETYPE_<?php echo $imagetyperestrict; ?>);
      <?php } ?>
	  <?php if($imagesiterestrict != NULL) { ?>
	  imageSearch.setSiteRestriction('<?php echo $imagesiterestrict; ?>');
	  <?php } ?>
      // Here we set a callback so that anytime a search is executed, it will call
      // the searchComplete function and pass it our ImageSearch searcher.
      // When a search completes, our ImageSearch object is automatically
      // populated with the results.
      imageSearch.setSearchCompleteCallback(this, searchComplete, [imageSearch]);
    
      // Find me a beautiful car.
      imageSearch.execute("<?php echo $imagesearchphrase; ?>");
    }
    google.setOnLoadCallback(OnLoad);
    </script>
  
    <div id="content">Loading...</div>
<?php } ?>	
<?php if($showsearchcontrol == 'Yes') { ?>
<script type="text/javascript">
    /*
    *  How to search for images and restrict them by color.
    */
    
    google.load('search', '1');
    
    function OnLoad() {
      // Create a search control
      var searchControl = new google.search.SearchControl();
    
      // Create an ImageSearch
      var imageSearch = new google.search.ImageSearch();
    
      <?php if($sizerestrict != 'No') { ?>
      imageSearch.setRestriction(google.search.ImageSearch.RESTRICT_IMAGESIZE,
                                 google.search.ImageSearch.IMAGESIZE_<?php echo $sizerestrict; ?>);
		<?php } ?>
	  <?php if($colorrestrict != 'No') { ?>
	  imageSearch.setRestriction(google.search.ImageSearch.RESTRICT_COLORFILTER,
            google.search.ImageSearch.COLOR_<?php echo $colorrestrict; ?>);
      <?php } ?>
      <?php if($imagetyperestrict != 'No') { ?>
	  imageSearch.setRestriction(google.search.ImageSearch.RESTRICT_IMAGETYPE,
            google.search.ImageSearch.IMAGETYPE_<?php echo $imagetyperestrict; ?>);
      <?php } ?>
	  <?php if($imagesiterestrict != NULL) { ?>
	  imageSearch.setSiteRestriction('<?php echo $imagesiterestrict; ?>');
	  <?php } ?>
    
      // Add the searcher to the SearchControl
      searchControl.addSearcher(imageSearch);
    
      // tell the searcher to draw itself and tell it where to attach
      searchControl.draw(document.getElementById("content"));
    
      // Find me something fit for a fairytale
      searchControl.execute('<?php echo $imagesearchphrase; ?>');
    }
    
    google.setOnLoadCallback(OnLoad);
    </script>
  
    <div id="content">Loading...</div>
<?php } ?>
<?php } ?>
<?php // local search

if($enablelocalsearch == 'Yes') { 
$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::base().'/modules/mod_googlemultimod/css/glocalsearchtext.css'); ?>
<script type="text/javascript">
    google.load('search', '1');
    function OnLoad() {
      document.getElementById('content2');
    
      var center = "<?php echo $localplace; ?>";
      // create a search control
      var searchControl = new google.search.SearchControl();
    
      var ls = new google.search.LocalSearch();
      ls.setCenterPoint(center);
      var options = new google.search.SearcherOptions();
      options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
      options.setRoot(document.getElementById("searcherRoot"));
      searchControl.addSearcher(ls, options);
    
      // Start up the Searcher
      searchControl.draw(document.getElementById("searchControl"));
    
      // execute an inital search
      searchControl.execute("<?php echo $localsearchword; ?>");
    }
    google.setOnLoadCallback(OnLoad);
    
    </script>
  
    <div id="searchControl">Loading...</div>
    <div id="searcherRoot"></div>
<?php } ?>
<?php // news search
if($enablenewssearch == 'Yes') { 
if($newssearchtype == 'Normal') { ?>
<script type="text/javascript">
    /*
    *  How to restrict a news search to a geographic location.
    */
    
    google.load('search', '1');
    
    function OnLoad() {
      // Create a search control
      var searchControl = new google.search.SearchControl();
    
      // Create a NewsSearcher
      var newsSearch = new google.search.NewsSearch();
    
      // Set the geolocation to Australia
      var extendedArgs = google.search.Search.RESTRICT_EXTENDED_ARGS;
      newsSearch.setRestriction(extendedArgs, {'geo':'<?php echo $newsplace; ?>'});
    
      // Add the searcher to the SearchControl
      searchControl.addSearcher(newsSearch);
    
      // tell the searcher to draw itself and tell it where to attach
      searchControl.draw(document.getElementById("content"));
    
      // Australian for...
      searchControl.execute('<?php echo $newssearchphrase; ?>');
    }
    
    google.setOnLoadCallback(OnLoad);
    </script>
  
    <div id="content">Loading...</div>
<?php } ?>
<?php if($newssearchtype == 'NewsShow') { ?>
<script type="text/javascript">
    /*
     * The Google NewsShow embeds a news slideshow on your page, letting your users see headlines
     * and previews of Google News Search results, based on queries that you've selected.
     *
     * This sample will show how to change the size of the News Show.
     * http://code.google.com/apis/ajaxsearch/documentation/newsshow.html
    */
    
    google.load("elements", "1", {packages : ["newsshow"]});
    
    function onLoad() {
      // Change the News Show size format
      var options = {
        "format" : "<?php echo $newsformat; ?>",
		"displayTime" : <?php echo $newsdisplaytime; ?>,
		"transitionTime" : <?php echo $newstransittime; ?>,
		"linkTarget" : "<?php echo $newslinktarget; ?>",
		"queryList" : [
      {
        "title" : "<?php echo $newssearchtitle; ?>",
        "q" : "<?php echo $newssearchphrase; ?>",
		"topic" : "<?php echo $newstopic; ?>",
		"geo" : "<?php echo $newsplace; ?>",
		<?php if($newsorder == 'Date') { ?>"scoring" : "d",<?php } ?>
		<?php if($newsedition != 'None') { ?>"ned" : "<?php echo $newsedition; ?>",<?php } ?>
		"rsz" : "<?php echo $newsresultsize; ?>"
		
      }
		]
      
	  }
      var content = document.getElementById('content');
      var newsShow = new google.elements.NewsShow(content, options);
    }
    
    google.setOnLoadCallback(onLoad);
    </script>
  
    <div id="content"></div>
<?php } ?>
<?php } ?>
<?php if($enablewebsearch == 'Yes') { ?>
<script type="text/javascript">
    /*
    *  The Hello World of the AJAX Search API
    */
    
    google.load('search', '1');
    
    function OnLoad() {
      // Create a search control
      var searchControl = new google.search.SearchControl();
    
      // Add in a full set of searchers
      var webSearch = new google.search.WebSearch();
	  <?php if($websiterestrict == 'Site') { ?>webSearch.setSiteRestriction('<?php echo $websearchsite; ?>');<?php } ?>
	  <?php if($websiterestrict == 'CSE') { ?>webSearch.setSiteRestriction('<?php echo $websearchcse; ?>');<?php } ?>
      searchControl.addSearcher(webSearch);
      
    
      // tell the searcher to draw itself and tell it where to attach
      searchControl.draw(document.getElementById("content"));
    
      // execute an inital search
      searchControl.execute("<?php echo $websearchphrase; ?>");
    }
    
    google.setOnLoadCallback(OnLoad);
    
    </script>
  
    <div id="content">Loading...</div>
<?php } ?>
<?php if($enableyoutube == 'Yes') { ?>
<script type="text/javascript">
      google.load("swfobject", "2.1");
    </script>    
	<?php if($playersizes == 'Yes') { ?>
	<?php
	$sizeincrement = 1+$sizeincrementper/100;
	
	if ($defaultsize == 'Small') {
		$vwidths = $vwidth;
		$vheights = $vheight;
		$vwidthn = $vwidths*$sizeincrement;
		$vheightn = $vheights*$sizeincrement;
		$vwidthl = $vwidthn*$sizeincrement;
		$vheightl = $vheightn*$sizeincrement;
	}
	if ($defaultsize == 'Normal') {
		$vwidthn = $vwidth;
		$vheightn = $vheight;
		$vwidths = $vwidthn/$sizeincrement;
		$vheights = $vheightn/$sizeincrement;
		$vwidthl = $vwidthn*$sizeincrement;
		$vheightl = $vheightn*$sizeincrement;
	}
	if ($defaultsize == 'Large') {
		$vwidthl = $vwidth;
		$vheightl = $vheight;
		$vwidthn = $vwidthl/$sizeincrement;
		$vheightl = $vheightl/$sizeincrement;
		$vwidths = $vwidthn/$sizeincrement;
		$vheights = $vheightn/$sizeincrement;
	}
	} ?>
    <script type="text/javascript">
<?php if($playersizes == 'Yes') { ?>
	// Make the player small.
function smallPlayer() {
  resizePlayer(<?php echo $vwidths; ?>, <?php echo $vheights; ?>);
}

// Set the player back to normal.
function normalPlayer() {
  resizePlayer(<?php echo $vwidthn; ?>, <?php echo $vheightn; ?>);
}

// Make the player big.
function largePlayer() {
  resizePlayer(<?php echo $vwidthl; ?>, <?php echo $vheightl; ?>);
}

// Set the loaded player to a specific height and width.
function resizePlayer(width, height) {
  var playerObj = document.getElementById("ytPlayer");
  playerObj.height = height;
  playerObj.width = width;
}
<?php } ?>
<?php if($playerinfo == 'Yes') { ?>
/*
       * Polling the player for information
       */
      
      // Update a particular HTML element with a new value
      function updateHTML(elmId, value) {
        document.getElementById(elmId).innerHTML = value;
      }
      
      // This function is called when an error is thrown by the player
      function onPlayerError(errorCode) {
        alert("An error occured of type:" + errorCode);
      }
      
      // This function is called when the player changes state
      function onPlayerStateChange(newState) {
        updateHTML("playerState", newState);
      }
      
      // Display information about the current state of the player
      function updatePlayerInfo() {
        // Also check that at least one function exists since when IE unloads the
        // page, it will destroy the SWF before clearing the interval.
        if(ytplayer && ytplayer.getDuration) {
          updateHTML("videoDuration", ytplayer.getDuration());
          updateHTML("videoCurrentTime", ytplayer.getCurrentTime());
          updateHTML("bytesTotal", ytplayer.getVideoBytesTotal());
          updateHTML("startBytes", ytplayer.getVideoStartBytes());
          updateHTML("bytesLoaded", ytplayer.getVideoBytesLoaded());
        }
      }
      
      // This function is automatically called by the player once it loads
      function onYouTubePlayerReady(playerId) {
        ytplayer = document.getElementById("ytPlayer");
        // This causes the updatePlayerInfo function to be called every 250ms to
        // get fresh data from the player
        setInterval(updatePlayerInfo, 250);
        updatePlayerInfo();
        ytplayer.addEventListener("onStateChange", "onPlayerStateChange");
        ytplayer.addEventListener("onError", "onPlayerError");
      }
<?php } ?>
<?php if($vchange == 'Yes') { ?>
<?php 
$vchangevideos = explode(",", $vchangevideo);
$vchangetitles = explode(",", $vchangetitle);
$vchangecount = count($vchangevideos);
?>
/*
       * Change out the video that is playing
       */
      
      // Update a particular HTML element with a new value
      function updateHTML(elmId, value) {
        document.getElementById(elmId).innerHTML = value;
      }
      
      // Loads the selected video into the player.
      function loadVideo() {
        var selectBox = document.getElementById("videoSelection");
        var videoID = selectBox.options[selectBox.selectedIndex].value
        
        if(ytplayer) {
          ytplayer.loadVideoById(videoID);
        }
      }
      
      // This function is called when an error is thrown by the player
      function onPlayerError(errorCode) {
        alert("An error occured of type:" + errorCode);
      }
      
      // This function is automatically called by the player once it loads
      function onYouTubePlayerReady(playerId) {
        ytplayer = document.getElementById("ytPlayer");
        ytplayer.addEventListener("onError", "onPlayerError");
      }
<?php } ?>

      function loadPlayer() {
        /*
        * Simple player embed
        */
        
        // The video to load.
        var videoID = "<?php echo $videoid; ?>"
        // Lets Flash from another domain call JavaScript
        var params = { allowScriptAccess: "always" };
        // The element id of the Flash embed
        var atts = { id: "ytPlayer" };
        // All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
        swfobject.embedSWF("http://www.youtube.com/v/" + videoID + "&enablejsapi=1&playerapiid=player1",
                           "videoDiv", "<?php echo $vwidth; ?>", "<?php echo $vheight; ?>", "8", null, null, params, atts);
        
        
      }
	  function _run() {
        loadPlayer();
      }
      google.setOnLoadCallback(_run);
    </script>
  
    <table>
    <tr>
	<?php if($playerinfopos == 'Right' OR $playerinfopos == 'Bottom') { ?>
    <td><div id="videoDiv"><?php echo $loadmsg; ?></div>
	</td>
		<?php if ($playerinfopos == 'Bottom') echo '</tr><tr>' ?>
	<?php } ?>
    <td valign="top">
      <div id="videoInfo">
  <?php if($playersizes == 'Yes') { ?>	  
  <a href="javascript:smallPlayer()">Small Player</a>
  <a href="javascript:normalPlayer()">Normal Player</a>
  <a href="javascript:largePlayer()">Large Player</a>
  <?php } ?>
  <?php if($playerinfo == 'Yes') { ?>
	<?php if($vstate == 'Yes') { ?><p>Player state: <span id="playerState">--</span></p><?php } ?>
	<?php if($vtime == 'Yes') { ?><p>Current Time: <span id="videoCurrentTime">--:--</span> | Duration: <span id="videoDuration">--:--</span></p><?php } ?>
	<?php if($vbytes == 'Yes') { ?><p>Bytes Total: <span id="bytesTotal">--</span> | Start Bytes: <span id="startBytes">--</span> | Bytes Loaded: <span id="bytesLoaded">--</span></p><?php } ?>
  <?php } ?>
  <?php if($vchange == 'Yes') { ?>
    <p>Select a video to load:</p>
	<select id="videoSelection" onchange="loadVideo();">
	<?php $vselectcount = 0; 
	while ($vselectcount <= $vchangecount) { ?>
          <option value="<?php echo $vchangevideos[$vselectcount] ?>" <?php if($vchangevideos[$vselectcount] == $videoid) echo 'selected'; ?>><?php echo $vchangetitles[$vselectcount] ?></option>
          <?php $vselectcount++; 
		  } ?>
    </select>
  <?php } ?>
      </div>
    </td>
	<?php if($playerinfopos == 'Left' OR $playerinfopos == 'Top') { ?>
    <?php if ($playerinfopos == 'Top') echo '</tr><tr>' ?>
	<td><div id="videoDiv"><?php echo $loadmsg; ?></div>
	</td>
	<?php } ?></tr>
    </table>
<?php } ?>

<?php if($vtextpos == 'Below') echo $vtext; ?>
<?php if($vmodcss != NULL) { ?></div><?php } ?>