<?xml version="1.0" encoding="UTF-8" ?>
<Module>
 <ModulePrefs height="500" 
title="Our Pic Of The Day"
title_url="http://www.meteo-si.com/"
description="Displays the POD based on your own choice. You may choose the exact picture (just write the web address of the picture, e.g. http://www.meteo-si.com/pic/images/laz.jpg  or folder, e.g. http://www.meteo-si.com/pic/images/ to get all pictures from that folder. Use your imagination to get pictures of cars, nature, art, babes, holidays, friends and family. Use your own pictures, just copy them into the web directory. A fresh picture with every refresh. Use your or your friends pictures or find the public directory with appropriate images. Navigation between pictures (move mouse over the top right corner shows the navigator). Thumbnail view and full screen view - click the maximize button in the upper right hand corner to view the full screen canvas. Share the gadget and its content with your friends, who are able to view and/or edit your setup, e.g. upload holiday pictures and share them with friends." 
author="AdaptA d.o.o." 
author_email="info@adapta.si"
author_location="Ljubljana, Slovenia, EU"
author_affiliation="AdaptA"
author_photo="http://www.meteo-si.com/adapta-sign.png"
author_aboutme="We develop for you gadgets and gadget ads!"  
author_link="http://www.adapta-solutions.com/solutions/gadgets.html" 
author_quote="Simplify!" 
screenshot="http://www.meteo-si.com/pic/our-picoftheday/our-picoftheday280.png" 
thumbnail="http://www.meteo-si.com/pic/our-picoftheday/our-picoftheday_120.png" 
category="lifestyle"
category2="funandgames"
>
<Require feature="analytics" />
<Require feature="views" />
<Require feature="dynamic-height"/>
<Require feature="setprefs"/>
<Require feature="minimessage"/>
<optional feature="shareable-prefs"/>
 </ModulePrefs>
 <UserPref name="myphoto" display_name="Photo/Directory" default_value="http://www.meteo-si.com/pic/images/"/>
 <UserPref name="lastphoto" display_name="Last viewed" datatype="hidden" default_value=""/>
 <UserPref name="random" display_name="Choose images at random?" datatype="bool" default_value="false"/>
 <UserPref name="thumbnails" display_name="Show thumbnails?" datatype="bool" default_value="true"/>
 <UserPref name="jpg" display_name="Show jpg images?" datatype="bool" default_value="true"/>
 <UserPref name="gif" display_name="Show gif images?" datatype="bool" default_value="false"/>
 <UserPref name="png" display_name="Show png images?" datatype="bool" default_value="false"/>
 <UserPref name="xlarge" display_name="Show Extra Large images?" datatype="bool" default_value="true"/>
 <UserPref name="large" display_name="Show Large images?" datatype="bool" default_value="true"/>
 <UserPref name="medium" display_name="Show Medium images?" datatype="bool" default_value="true"/>
 <UserPref name="small" display_name="Show Small images?" datatype="bool" default_value="false"/>
 <UserPref name="today" datatype="hidden" default_value="" />
<Content type="html" view="home">
<![CDATA[

<style>
div.markerTooltip, div.markerDetail {
    color: black;
    font-weight: bold;
    background-color: white;
    white-space: nowrap;
    margin: 0;
    padding: 2px 4px;
    border: 1px solid black;
}
.regular,h1 {
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
color: #000000;
margin-bottom:0;
margin-top:0;
}
a:link {color: #0000FF; text-decoration:none}
a:visited {color: #0000FF; text-decoration:none}
a:hover {color: #0000FF; text-decoration:underline}
</style>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<SCRIPT language="JavaScript">
<!--
pic1= new Image(100,25); 
pic1.src="http://www.meteo-si.com/pic/our-picoftheday/left.gif";
pic2= new Image(100,25);
pic2.src="http://www.meteo-si.com/pic/our-picoftheday/left-shadow.gif";
pic3= new Image(100,25);
pic3.src="http://www.meteo-si.com/pic/our-picoftheday/right.gif";
pic4= new Image(100,25);
pic4.src="http://www.meteo-si.com/pic/our-picoftheday/right-shadow.gif";
//-->
</SCRIPT>
</head>
<body onload="start()">

   <script type="text/javascript">

	var linx = new Array();
        var curLink = 0;
	var t;
	var iVal, ival1, tmpImg, rIval;
	var docWidth= document.body.clientWidth;
	var prefs = new _IG_Prefs();
	var movingLeft = false;
	var lastImage = 500;
	var nResults = null;

	var CanvasExists = false;
	var supported_views = gadgets.views.getSupportedViews();
	for (var v in supported_views) {
		if (supported_views[v].getName() == "canvas") CanvasExists = true;
	} 

        var mIdx = Math.round(13*Math.random());
	messageTexts = new Array(14);

	messageTexts[0] = new Array(2);
	messageTexts[0][0]='http://www.google.com/ig/adde?hl=en&moduleurl=http://www.meteo-si.com/pic/our-picoftheday.xml&source=imag';
	messageTexts[0][1]='Check our new fully customizable sharing and canvas view/thumbnailed PictureOfTheDay Gadget!';

	messageTexts[1] = new Array(2);
   	messageTexts[1][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/moon/moon.xml&source=imag';
	messageTexts[1][1]='Is the Earth weather boring? Check the Moon Live Weather Gadget!';

	messageTexts[2] = new Array(2);
	messageTexts[2][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/meteo-USA.xml&source=imag';
  	messageTexts[2][1]='Check the USA Live Weather Gadget!';

	messageTexts[3] = new Array(2);
	messageTexts[3][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/meteo-CA.xml&source=imag';
	messageTexts[3][1]='Check the Canada Live Weather Gadget!';

	messageTexts[4] = new Array(2);
   	messageTexts[4][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/sun.xml&source=imag';
   	messageTexts[4][1]='Is the Earth weather boring? Check the Sun Live Weather Gadget!';

	messageTexts[5] = new Array(2);
   	messageTexts[5][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/mercury.xml&source=imag';
   	messageTexts[5][1]='Is the Earth weather boring? Check the Mercury Live Weather Gadget!';

	messageTexts[6] = new Array(2);
   	messageTexts[6][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/venus.xml&source=imag';
   	messageTexts[6][1]='Is the Earth weather boring? Check the Venus Live Weather Gadget!';

	messageTexts[7] = new Array(2);
   	messageTexts[7][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/mars.xml&source=imag';
   	messageTexts[7][1]='Is the Earth weather boring? Check the Mars Live Weather Gadget!';

	messageTexts[8] = new Array(2);
   	messageTexts[8][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/jupiter.xml&source=imag';
	messageTexts[8][1]='Is the Earth weather boring? Check the Jupiter Live Weather Gadget!';

	messageTexts[9] = new Array(2);
   	messageTexts[9][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/saturn.xml&source=imag';
   	messageTexts[9][1]='Is the Earth weather boring? Check the Saturn Live Weather Gadget!';

	messageTexts[10] = new Array(2);
   	messageTexts[10][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/uranus.xml&source=imag';
  	messageTexts[10][1]='Is the Earth weather boring? Check the Uranus Live Weather Gadget!';

	messageTexts[11] = new Array(2);
   	messageTexts[11][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/neptune.xml&source=imag';
   	messageTexts[11][1]='Is the Earth weather boring? Check the Neptune Live Weather Gadget!';

	messageTexts[12] = new Array(2);
   	messageTexts[12][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/dreamachine/dreamachine.xml&source=imag';
   	messageTexts[12][1]='Use our new Dreamachine-of-the-day Gadget!';

	messageTexts[13] = new Array(2);
   	messageTexts[13][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/meteo-USA.xml&source=imag';
   	messageTexts[13][1]='Check the USA Live Weather Gadget!';

   	var msg = new _IG_MiniMessage(__MODULE_ID__);
	var someMsg = msg.createStaticMessage("<p class='regular' align='center'><a href='"+messageTexts[mIdx][0]+"' target='_blank'><span style='font-size: 11px; font-weight: bold;'>"+messageTexts[mIdx][1]+"</span></a></p>");
	someMsg.style.backgroundColor = "#EEEEEE";







	function getGoogleImage(){
	  var query = prefs.getString('myphoto');
	  var start = Math.floor(Math.random()*lastImage);
	  var url = 'http://images.google.com/images?q=' + _esc(query) + '&start=' + start + '&safe=on&imgsz=large&imgtype=photo';

	  _IG_FetchContent(url, function (responseText) {

	    if(nResults == null) {
	       var numstr = responseText.match(/of about <b>([^<]+)/);
	       if(numstr) {
	          nResults = parseInt(numstr[1].replace(/,/g,''));
        	  if (nResults>970) lastImage=970;
		  else lastImage = nResults;
	       }
	    }

	    var image = responseText.match(/imgurl=[^>]*/);
	    if(!image) {
	       if(lastImage == 0) noImage();
	       else {
	         lastImage = Math.floor(max_images / 2);
	         return getGoogleImage();
	       }
	    }

	        linx[0]='"'+image[0].match(/imgurl=([^&]*)/)[1]+'"';
		curLink=0;
		displayImage(2);

	  });
	}









        function findPos(obj){
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
		}
		return [curleft,curtop];
	}

	function rectangle(w,h,x,y,bg,bCol,name) 
	{ 
		 var rect = document.createElement("div"); 
 		 rect.setAttribute('id',name);
		 var style = rect.style; 
		 style.width = w + "px"; 
		 style.height = h + "px"; 
		 style.left = x + "px"; 
		 style.top = y +"px"; 
		 style.backgroundColor = bg; 
		 style.borderColor = bCol; 
		 style.position = "absolute"; 
		 style.borderStyle = "solid" 
		 style.borderWidth = 1+"px"; 
		 return rect 
	}
	
	function createDiv(x,y,name){
		 var elem = document.createElement("div"); 
 		 elem.setAttribute('id',name);
		 var style = elem.style; 
		 style.top=y;
		 style.left=x;
		 style.position = "absolute"; 
		 return elem
	}

	function createImage(loc,name){
		 var elem = document.createElement("img"); 
 		 elem.setAttribute('id',name);
		 elem.src=loc;
		 var style = elem.style; 
		 style.position = "absolute";
		 style.cursor = "pointer"; 
		 return elem
	}

	function movedOffImage(e){
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY){
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY){
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
		var temp=document.getElementById('navRect');
		var rL= parseInt(temp.style.left.substring(0,temp.style.left.length-2));
		var rT=parseInt(temp.style.top.substring(0,temp.style.top.length-2));
		var rW=parseInt(temp.style.width.substring(0,temp.style.width.length-2));
		var rH=parseInt(temp.style.height.substring(0,temp.style.height.length-2));
		if (posx>rL+rW || posy<rT){	
			document.body.removeChild(temp);
			removeNavElements();
		}
		
	}


	function removeNavElements(){
				if (temp=document.getElementById('navRect')){
					document.body.removeChild(temp);
				}
				if (itemL=document.getElementById('navLeft')){
			                if (temp1=document.getElementById('prev')){
						itemL.removeChild(temp1);
					}
					document.body.removeChild(itemL);
				}
				if (item1=document.getElementById('navRight')){
			                if (temp2=document.getElementById('next')){
						item1.removeChild(temp2);
					}
					document.body.removeChild(item1);
				}

	}

        function removeNavigation(e){
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY){
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY){
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}

                if (temp=document.getElementById('navRect')){
			var rL= parseInt(temp.style.left.substring(0,temp.style.left.length-2));
			var rT=parseInt(temp.style.top.substring(0,temp.style.top.length-2));
			var rW=parseInt(temp.style.width.substring(0,temp.style.width.length-2));
			var rH=parseInt(temp.style.height.substring(0,temp.style.height.length-2));
			if (!(posx>=rL && posx<rL+rW+3 && posy>rT && posy<=rT+rH+2)){	
		                document.body.removeChild(temp);
				removeNavElements();
			}
		}
	}

	function nextImage(){
		movingLeft=false;
                var tImg=document.getElementById('next');
		tImg.src="http://www.meteo-si.com/pic/our-picoftheday/right.gif";
		iVal1=setInterval("nextImage1()",300);
	}	

	function nextImage1(){
		if (document.getElementById('next').complete){
			clearInterval(iVal1);
			if (prefs.getBool("google") == true){
				getGoogleImage();
				removeNavElements();
			}
			else if (prefs.getBool("random") == true){
				displayImage(2);
				removeNavElements();
			}		
			else if (curLink<linx.length-1){
				curLink++;
				displayImage(2);
				removeNavElements();
			}
			else fitNavigation();
		}
	}

	function prevImage(){
                var tImg=document.getElementById('prev');
		tImg.src="http://www.meteo-si.com/pic/our-picoftheday/left.gif";
		iVal1=setInterval("prevImage1()",300);
	}	

	function prevImage1(){
		if (document.getElementById('prev').complete){
			clearInterval(iVal1);
			if (prefs.getBool("google") == true){
				getGoogleImage();
				removeNavElements();
			}
			else if (prefs.getBool("random") == true){
				displayImage(2);
				removeNavElements();
			}		
			else if (curLink>0){
				movingLeft=true;
				curLink--;
				displayImage(2);
				removeNavElements();
			}
			else fitNavigation();
		}
	}

	function fitNavigation(){
		var item=document.getElementById('timg');


                if (temp=document.getElementById('navRect')){
			document.body.removeChild(temp);
		}
		var T=document.getElementById('T1');
		var offsets = findPos(T);

		removeNavElements();

		var rect = rectangle(5,5,100,5,"#EEEEEE","#CCCCCC","navRect");
		var itemL = createDiv(5,5,"navLeft");
		var item1 = createDiv(5,5,"navRight");
		
		var imgLeft = createImage("http://www.meteo-si.com/pic/our-picoftheday/left-shadow.gif",'prev');
		imgLeft.onclick=function(){
			prevImage();
		}
		var imgRight = createImage("http://www.meteo-si.com/pic/our-picoftheday/right-shadow.gif",'next');
		imgRight.onclick=function(){
			nextImage();
		}

                offsets[0]+=T.width-8-item.width;
		offsets[1]+=6;
                calc = offsets[0]+item.width-imgRight.width-5;
		item1.style.left=calc+"px";
		calc = offsets[1]+3;
		item1.style.top =calc+"px";
		calc = offsets[0]+item.width-imgRight.width-imgLeft.width-5;
		itemL.style.left=calc+"px"
		calc = offsets[1]+3;
		itemL.style.top =calc+"px";
		calc=imgRight.width+imgLeft.width+11;
		rect.style.width=calc+"px";
		calc=imgRight.height+4;
		rect.style.height=calc+"px";
		calc=offsets[0]+item.width-imgRight.width-imgLeft.width-12;
		rect.style.left=calc+"px";	
		calc=offsets[1]+1;
		rect.style.top=calc+"px";


		document.body.appendChild(rect);
		itemL.appendChild(imgLeft);
		item1.appendChild(imgRight);
		document.body.appendChild(itemL);
		document.body.appendChild(item1);
	}


	function removeI(j){
		if ((curLink>j-1)&&(curLink>0)) curLink--;
		for (i=j;i<linx.length-1;i++) linx[i]=linx[i+1];
		linx.length=linx.length-1;
		if (curLink>(linx.length-1)) curLink--;
	}


	function removeDuplicates(){
		var i=0;
		var j=1;
		while (i<linx.length-1){
			if (linx[i]==linx[j]) removeI(j);
			else j++;
			if (j>linx.length-1) {
				i++;
				j=i+1;
			}
		}
		displayImage(2);
	}


	function parseDir(responseText) {
//		alert("parse "+responseText);
		var nLinx = -1;        
		var sLink = 0;
		var eLink = 0;
		var temp = "";
		var normal = 0;
		var iMode = 0;
		var found=false;

     		while (responseText!=''){		
			sLink = responseText.search(/src=|href=/i);	
			if ((responseText.charAt(sLink)=="h")||(responseText.charAt(sLink)=="H")) iMode=1
			else iMode=0;
			if ((responseText.substr(sLink+4+iMode,1)=="'")||(responseText.substr(sLink+4+iMode,1)=='"')){
				normal=1;
			}
			else normal=0;
	        	responseText=responseText.substr(sLink+4+iMode+normal);
			if (sLink>-1){
				if (normal==1) {
					eLink = responseText.search(/"|'/i);
				}
				else eLink = responseText.search(/ /i);
				temp = responseText.substring(0,eLink+1);
	        		if (((temp.search(/.jpg/i)>-1)&&(prefs.getBool("jpg")==true))||((temp.search(/.gif/i)>-1)&&(prefs.getBool("gif")==true))||((temp.search(/.png/i)>-1)&&(prefs.getBool("png")==true))) {
					nLinx++;
					linx[nLinx] = '"'+responseText.substring(0,eLink)+'"';
					if ("__UP_lastphoto__"==linx[nLinx].substring(linx[nLinx].indexOf('"')+1,linx[nLinx].lastIndexOf('"'))) { if (found==false){ curLink=nLinx; found=true;}}
				}
	        		responseText=responseText.substr(eLink+1);
			}
			else{
				responseText='';
			}
		}
//		alert(linx);
		if (linx.length>0){
			if (tSec=parseInt(prefs.getString("rndtimer"))){
				if (tSec>0) rIval= window.setInterval("displayImage(2)",(tSec*1000*60));
			}
			 removeDuplicates();
		}
		else noImage();
	}


	function noImage(){
		var html='<table id="T1" align="center" width='+(docWidth-5)+' style="border-width:5px; border-style:solid; border-color:#CCCCCC; background-color:#EEEEEE">';
		html+='<tr>';
		html+='<td align="center"><b><font color="#FFFFFF" size="+2">no images found</b></font></td>';
		html+='</tr>';
		html+='</table>';
		document.getElementById('imidz1').innerHTML = html;
		_IG_AdjustIFrameHeight();
	}

	function shiftItems(objNum){
		for (i=curLink;i<linx.length-1;i++) linx[i]=linx[i+1];
		linx.length=linx.length-1;
		if ((curLink>(linx.length-1))||((curLink>0)&&(movingLeft==true))) curLink--;
		if (linx.length==0) { alert("SI"); noImage(); }
		else displayImage(2);
	}

	function restrictions(obj){
		var accepted=true;
		if ((obj.width<=0) || (obj.height<=0)) accepted=false;
		else{
			var size = obj.width * obj.height;
			if ((size>0)&&(size<=20000)&&(prefs.getBool("small") == false)) accepted=false;
			else if ((size>20000)&&(size<=200000)&&(prefs.getBool("medium") == false)) accepted=false;
			else if ((size>200000)&&(size<=1000000)&&(prefs.getBool("large") == false)) accepted=false;
			else if ((size>1000000)&&(prefs.getBool("xlarge") == false)) accepted=false;
		}
		return accepted;
	}


	function badImage(e){
		if (!e)
		  {
		   window.clearInterval(iVal);
		   if (prefs.getBool("google")==true) getGoogleImage();
		   else shiftItems(curLink);
		  }
	}


        function displayImage(mode){
		var rnd = Math.round((linx.length-1)*Math.random());
		if ((prefs.getBool("random") == true)&&(prefs.getBool("google") != true)){
			while ((rnd==curLink)&&(linx.length-1>0)) rnd = Math.round((linx.length-1)*Math.random());
			curLink=rnd;
		}
		tmpImg = document.createElement('img');
		tmpImg.onerror=badImage;
		if (mode==1) tmpImg.src = "__UP_myphoto__";
		else{	
			if (linx[curLink].substr(1,7)=='http://') tmpImg.src = linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
			else{
				var s=prefs.getString("myphoto");					
				if (linx[curLink].charAt(1)=='/'){
					s=s.substr(7);
					if (s.indexOf("/")>-1) tmpImg.src = 'http://'+s.substr(0,s.indexOf("/"))+linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
					else tmpImg.src = 'http://'+s+linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
				}
				else{
					s=s.substr(7);
					if (s.indexOf("/")>-1) tmpImg.src = 'http://'+s.substr(0,s.lastIndexOf("/")+1)+linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
					else tmpImg.src = 'http://'+s+'/'+linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
				}
			}
		}
		iVal=window.setInterval("imageLoaded("+mode+")",1000);
	}

	function imageLoaded(mode){
	     if (mode==2) prefs.set("lastphoto",linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"')));
	     if (tmpImg.complete){
	       window.clearInterval(iVal);
	       if (restrictions(tmpImg)==false){
		   if (prefs.getBool("google")==true) getGoogleImage();
		   else shiftItems(curLink);
	       }else{
		var html = '';
		if (mode==2){
			html='<table id="T1" align="center" onmouseover="fitNavigation()" onmouseout="removeNavigation(event)" width='+(docWidth-5)+' style="border-width:5px; border-style:solid; border-color:#CCCCCC; background-color:#EEEEEE">';
			html+='<tr>';
			if (tmpImg.height<40) html+='<td width='+(docWidth-18)+' height=40 align="center" bgcolor="EEEEEE" style="border-width:1px; border-style:solid; border-color:#CCCCCC; background-color:#EEEEEE">';
			else html+='<td align="center" width='+(docWidth-18)+' style="border-width:1px; border-style:solid; border-color:#CCCCCC; background-color:#EEEEEE">';
        	        html += '<img id="timg" onclick="goToCanvas();" src="'+tmpImg.src+'"';
			if (tmpImg.width>docWidth-25){
				html += ' width=' + (docWidth-25);
			}
			html+='>';
			html+='</td>';
			html+='</tr>';
			html+='</table>';
		}
		else {
			html='<table id="T1" align="center" width='+(docWidth-5)+' border="5" borderColor="#CCCCCC">';
			html+='<tr>';
			html+='<td width='+(docWidth-18)+' align="center" style="border-width:1px; border-style:solid; border-color:#CCCCCC; background-color:#EEEEEE">';
			html+='<IMG onclick="goToCanvas();" SRC="__UP_myphoto__"';
			if (tmpImg.width>docWidth-30){
				html += ' width=' + (docWidth-30);
			}
			html+='>';
			html+='</td>';
			html+='</tr>';
			html+='</table>';
		}
		document.getElementById('imidz1').innerHTML = html;
		_IG_AdjustIFrameHeight();
	       }
	     }
	}

	function showhelp(){
        	var h = document.getElementById('helpdiv');
		var helpstr = '';
        	helpstr = '<p class="regular" align="left">Picture Of The Day;<br />';
		helpstr += '<br />';
	        helpstr += '<br /><a onclick="hidehelp();" style="cursor:pointer">Close help</a></p>';
	        h.innerHTML = helpstr;
        	var hm = document.getElementById('midtd');
	        hm.innerHTML = '<a onclick="hidehelp();" style="cursor:pointer">Close help</a>';
        	_IG_AdjustIFrameHeight();
	}

	function hidehelp(){
        	var h = document.getElementById('helpdiv');
	        h.innerHTML = '';
        	var hm = document.getElementById('midtd');
	        hm.innerHTML = '<a onclick="showhelp();" style="cursor:pointer">Help</a>';
        	_IG_AdjustIFrameHeight();
	}


	function canvasViewAdjustment(){
		if (CanvasExists==false){
			var table = document.getElementById('oTable');
			table.removeChild(table.lastChild);
		}
	}

	function start(){
//		alert("381");
		canvasViewAdjustment();
		var temp = "__UP_myphoto__";
		var lead = temp.substr(0,7);
		if ((lead!='http://')&&(lead!='HTTP://')&&(prefs.getBool("google")!=true)){
			 temp='http://'+temp;
			 prefs.set('myphoto',temp);
		}
//		if (prefs.getBool("post") == true) _IG_FetchContent("http://www.meteo-si.com/potd/test.php?link="+prefs.getString("myphoto"), _IG_Callback(checkID), { refreshInterval: 1} );
//		if ((prefs.getBool("post") == true)&&(prefs.getBool("google")!=true)) _IG_FetchContent("http://www.meteo-si.com/potd/test.php?link="+prefs.getString("myphoto")+"&fake="+Math.random(), _IG_Callback(checkID));
		if (prefs.getBool("post") == true) _IG_FetchContent("http://www.meteo-si.com/potd/test.php?link="+prefs.getString("myphoto")+"&google="+(prefs.getBool("google") == true)?"1":"0"+"&fake="+Math.random(), _IG_Callback(checkID));
//		else alert("not supposed to post");
		else _IG_FetchContent("http://www.meteo-si.com/potd/hit.php?link="+prefs.getString("myphoto")+"&google="+((prefs.getBool("google") == true)?"1":"0")+"&fake="+Math.random(), _IG_Callback(getID));
//		alert("http://www.meteo-si.com/potd/hit.php?link="+prefs.getString("myphoto")+"&google="+((prefs.getBool("google") == true)?"1":"0")+"&fake="+Math.random());
		var tip = temp.substr(temp.lastIndexOf(".")+1,3);
		if (prefs.getBool("google")==true){
			if (tSec=parseInt(prefs.getString("rndtimer"))){
				if (tSec>0) rIval= window.setInterval("getGoogleImage()",(tSec*1000*60));
			}
			 getGoogleImage();
		}
		else if ((tip=="jpg")||(tip=="gif")||(tip=="png")){
			 displayImage(1);
		}
		else {						
			_IG_FetchContent(temp, _IG_Callback(parseDir));
//			_IG_FetchContent(temp, _IG_Callback(parseDir), { refreshInterval: 1 });
//			alert("Fetching "+temp);
		}
	}


    function goToCanvas() {
      goToView('canvas');
    }

    function goToView(dest) {
      var supported_views = gadgets.views.getSupportedViews();
      gadgets.views.requestNavigateTo(supported_views[dest]);
    }

	function checkID(responseText){
		if (responseText=="") postToDB();
		else{
			prefs.set('post',false);
			prefs.set('id',responseText);
		}
	}

    function postToDB(){
	alert("setting up");
	document.getElementById('form1').link.value=prefs.getString("myphoto");
//	alert("myphoto ="+prefs.getString("myphoto")+"   link="+document.getElementById('form1').link.value);
	document.getElementById('form1').category.value=prefs.getString("imagetype");
	document.getElementById('form1').description.value=prefs.getString("description");
	document.getElementById('form1').google.value=(prefs.getBool("google") == true)?"1":"0";
	document.getElementById('form1').jpg.value=(prefs.getBool("jpg") == true)?"1":"0";
	document.getElementById('form1').gif.value=(prefs.getBool("gif") == true)?"1":"0";
	document.getElementById('form1').png.value=(prefs.getBool("png") == true)?"1":"0";
//	alert("posting "+document.getElementById('form1').jpg.value+"  "+ document.getElementById('form1').gif.value+"  "+document.getElementById('form1').png.value);
	document.getElementById('form1').submit();
	prefs.set('post',false);	
	_IG_FetchContent("http://www.meteo-si.com/potd/test.php?link="+prefs.getString("myphoto"), _IG_Callback(getID)+"&fake="+Math.random());
//	_IG_FetchContent("http://www.meteo-si.com/potd/test.php?link="+prefs.getString("myphoto"), _IG_Callback(getID), { refreshInterval: 1 } );
//	alert("done");
    }

	function getID(responseText){
		prefs.set('id',responseText);
	}

   </script>

<div id="helpdiv"></div>
<table cellspacing="0" cellpadding="0" width="100%" bgcolor="white" class="regular">
<tr id="oTable">
  <td>
    <a href="http://www.adapta-solutions.com/solutions/gadgets.html" target="_blank" onmouseover="document.m1.src ='http://www.meteo-si.com/images/kroglice2.gif';" onmouseout="document.m1.src ='http://www.meteo-si.com/images/kroglice.gif';"><img border="0" src="http://www.meteo-si.com/images/kroglice.gif" name="m1"> More gadgets</a>
  </td>
  <td id="midtd" align="right"><a onclick="showhelp();" style="cursor:pointer">Help</a></td>
  <td id="righttd" align="right">
    <a onclick="goToCanvas();" style="cursor:pointer">More options</a>
  </td>
</tr>
</table>

   <div id="imidz1"></div>

<div id="post" style="display:none">
<form name="form1" id="form1" method="post" action="http://www.meteo-si.com/potd/post.php" target="blackhole">
     <input type="text" size=400 name="link" id="link">
     <input type="text" size=400 name="description" id="description">
     <input type="text" size=400 name="category" id="category">
     <input type="checkbox" name="google" id="google" value="0" checked>
     <input type="checkbox" name="jpg" id="jpg" value="0" checked>
     <input type="checkbox" name="gif" id="gif" value="0" checked>
     <input type="checkbox" name="png" id="png" value="0" checked>
     <input type=submit value="Submit Post">
</form> 
</div>

<iframe name="blackhole" width=0 height=0 style="visibility:hidden"></iframe>

<script type="text/javascript">
// Get a reference to user preferences
var prefs = new _IG_Prefs();
// Get the user's current date/time
var now = new Date();
// Create a date string of the form yyyy-m-d
var today = (now.getFullYear?now.getFullYear():now.getYear())+'-'+(now.getMonth()+1)+'-'+now.getDate();
// Get the stored value of the "today" user preference.
var prefs_today = prefs.getString('today');

// If the "today" user preference is blank, then the user has never loaded
// this gadget. They must have just added it!
if (prefs_today=='') {
    _IG_Analytics("UA-6660391-1", "/novigadget/pic/our-picoftheday");
}
// If the generated date string doesn't match the one stored in the
// preferences, then this is the first time the user has loaded the
// gadget today. Record a hit and change the preferernce to be
// today's date string so it won't get recorded again.
if (prefs_today!=today) {
    prefs.set('today',today);
    _IG_Analytics("UA-6660391-1", "/gadget/pic/our-picoftheday");
}
</script>


</body>
</html>
]]>
</Content>
<Content type="html" view="canvas">
<![CDATA[

<style>
div.markerTooltip, div.markerDetail {
    color: black;
    font-weight: bold;
    background-color: white;
    white-space: nowrap;
    margin: 0;
    padding: 2px 4px;
    border: 1px solid black;
}
.regular,h1 {
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
color: #000000;
margin-bottom:0;
margin-top:0;
}
a:link {color: #0000FF; text-decoration:none}
a:visited {color: #0000FF; text-decoration:none}
a:hover {color: #0000FF; text-decoration:underline}
</style>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<SCRIPT language="JavaScript">
<!--
//-->
</SCRIPT>
</head>
<body bgcolor="#EEEEEE" onload="start()">

   <script type="text/javascript">

	var linx = new Array();
	var tmpImg;
	var imgs = new Array();
	var imgLinx = new Array();
        var firstLink = 0;
	var curLink = 0;
	var t = new Array();
	var docWidth= document.body.clientWidth-170;
	var line = Math.round((docWidth-10)/100);
	var lineBup = Math.round((docWidth-10)/100);
	var iVal, iVal1, iVal2, iDone, rIval = "";
	var prefs = new _IG_Prefs();
	var imgCount;
        var duplicating=false;
	var counter=0;
	var curImg=0;
	var boxes=0;

	var lastImage = 500;
	var nResults = null;

        var mIdx = Math.round(13*Math.random());
	messageTexts = new Array(14);

	messageTexts[0] = new Array(2);
	messageTexts[0][0]='http://www.google.com/ig/adde?hl=en&moduleurl=http://www.meteo-si.com/pic/our-picoftheday.xml&source=imag';
	messageTexts[0][1]='Check our new fully customizable sharing and canvas view/thumbnailed PictureOfTheDay Gadget!';

	messageTexts[1] = new Array(2);
   	messageTexts[1][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/moon/moon.xml&source=imag';
	messageTexts[1][1]='Is the Earth weather boring? Check the Moon Live Weather Gadget!';

	messageTexts[2] = new Array(2);
	messageTexts[2][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/meteo-USA.xml&source=imag';
  	messageTexts[2][1]='Check the USA Live Weather Gadget!';

	messageTexts[3] = new Array(2);
	messageTexts[3][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/meteo-CA.xml&source=imag';
	messageTexts[3][1]='Check the Canada Live Weather Gadget!';

	messageTexts[4] = new Array(2);
   	messageTexts[4][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/sun.xml&source=imag';
   	messageTexts[4][1]='Is the Earth weather boring? Check the Sun Live Weather Gadget!';

	messageTexts[5] = new Array(2);
   	messageTexts[5][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/mercury.xml&source=imag';
   	messageTexts[5][1]='Is the Earth weather boring? Check the Mercury Live Weather Gadget!';

	messageTexts[6] = new Array(2);
   	messageTexts[6][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/venus.xml&source=imag';
   	messageTexts[6][1]='Is the Earth weather boring? Check the Venus Live Weather Gadget!';

	messageTexts[7] = new Array(2);
   	messageTexts[7][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/mars.xml&source=imag';
   	messageTexts[7][1]='Is the Earth weather boring? Check the Mars Live Weather Gadget!';

	messageTexts[8] = new Array(2);
   	messageTexts[8][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/jupiter.xml&source=imag';
	messageTexts[8][1]='Is the Earth weather boring? Check the Jupiter Live Weather Gadget!';

	messageTexts[9] = new Array(2);
   	messageTexts[9][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/saturn.xml&source=imag';
   	messageTexts[9][1]='Is the Earth weather boring? Check the Saturn Live Weather Gadget!';

	messageTexts[10] = new Array(2);
   	messageTexts[10][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/uranus.xml&source=imag';
  	messageTexts[10][1]='Is the Earth weather boring? Check the Uranus Live Weather Gadget!';

	messageTexts[11] = new Array(2);
   	messageTexts[11][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/space/neptune.xml&source=imag';
   	messageTexts[11][1]='Is the Earth weather boring? Check the Neptune Live Weather Gadget!';

	messageTexts[12] = new Array(2);
   	messageTexts[12][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/dreamachine/dreamachine.xml&source=imag';
   	messageTexts[12][1]='Use our new Dreamachine-of-the-day Gadget!';

	messageTexts[13] = new Array(2);
   	messageTexts[13][0]='http://www.google.com/ig/adde?moduleurl=http://www.meteo-si.com/meteo-USA.xml&source=imag';
   	messageTexts[13][1]='Check the USA Live Weather Gadget!';

   	var msg = new _IG_MiniMessage(__MODULE_ID__);
	var someMsg = msg.createStaticMessage("<p class='regular' align='center'><a href='"+messageTexts[mIdx][0]+"' target='_blank'><span style='font-size: 11px; font-weight: bold;'>"+messageTexts[mIdx][1]+"</span></a></p>");
	someMsg.style.backgroundColor = "#EEEEEE";



	function crop(img_id, crop_id, x, y, width, height) {

		var style = img_id.style; 
                var styleC = crop_id.style;
		var scale_x = img_id.width / width;
		var scale_y = img_id.height / height;

		styleC.position = 'relative';
		styleC.overflow = 'hidden';

		style.position = "absolute"; 
		style.display = "block";
		style.left = (-x * scale_x) + 'px';
    		style.top = (-y * scale_y) + 'px';
		style.width = (img_id.width * scale_x) + 'px';
		style.height = (img_id.height * scale_y) + 'px';
		style.border = "#FFFFFF";
		style.borderWidth = "8px"

		crop_id.appendChild(img_id);

	}

	function removeI(j){
		if ((curLink>j-1)&&(curLink>0)) curLink--;
		for (i=j;i<linx.length-1;i++) linx[i]=linx[i+1];
		linx.length=linx.length-1;
		if (j>(linx.length-1)) curImg--;
	}

	function removeDuplicates(){
		duplicating=true;
		var i=0;
		var j=1;
		while (i<linx.length-1){
			if (linx[i]==linx[j]) removeI(j);
			else j++;
			if (j>linx.length-1) {
				i++;
				j=i+1;
			}
		}
		duplicating=false;
	//	displayImage(2);
		displayLinx();
	}









	function getGoogleImage(){
	  var query = prefs.getString('myphoto');
	  var start = Math.floor(Math.random()*lastImage);
	  var url = 'http://images.google.com/images?q=' + _esc(query) + '&start=' + start + '&safe=on&imgsz=large&imgtype=photo';

	  _IG_FetchContent(url, function (responseText) {

	    if(nResults == null) {
	       var numstr = responseText.match(/of about <b>([^<]+)/);
	       if(numstr) {
	          nResults = parseInt(numstr[1].replace(/,/g,''));
        	  if (nResults>970) lastImage=970;
		  else lastImage = nResults;
	       }
	    }

	    var image = responseText.match(/imgurl=[^>]*/);
	    if(!image) {
	       if(lastImage == 0) return noImage();
	       else {
	         lastImage = Math.floor(max_images / 2);
	         return getGoogleImage();
	       }
	    }

	        linx[curLink]='"'+image[0].match(/imgurl=([^&]*)/)[1]+'"';
//		alert(linx[curLink]);
		curLink++;
		if ((curLink<lastImage)&&(curLink<line)) return getGoogleImage();
		else {
			curLink=0;
			removeDuplicates();
		}

	  });
	}










	function parseDir(responseText) {
		var nLinx = -1;        
		var sLink = 0;
		var eLink = 0;
		var temp = "";
		var normal = 0;
		var iMode = 0;
		var found=false;

     		while (responseText!=''){		
			sLink = responseText.search(/src=|href=/i);	
			if ((responseText.charAt(sLink)=="h")||(responseText.charAt(sLink)=="H")) iMode=1
			else iMode=0;
			if ((responseText.substr(sLink+4+iMode,1)=="'")||(responseText.substr(sLink+4+iMode,1)=='"')){
				normal=1;
			}
			else normal=0;
	        	responseText=responseText.substr(sLink+4+iMode+normal);
			if (sLink>-1){
				if (normal==1) {
					eLink = responseText.search(/"|'/i);
				}
				else eLink = responseText.search(/ /i);
				temp = responseText.substring(0,eLink+1);
	        		if (((temp.search(/.jpg/i)>-1)&&(prefs.getBool("jpg")==true))||((temp.search(/.gif/i)>-1)&&(prefs.getBool("gif")==true))||((temp.search(/.png/i)>-1)&&(prefs.getBool("png")==true))) {
					nLinx++;
					linx[nLinx] = '"'+responseText.substring(0,eLink)+'"';
					if ("__UP_lastphoto__"==linx[nLinx].substring(linx[nLinx].indexOf('"')+1,linx[nLinx].lastIndexOf('"'))) { if (found==false){ curLink=nLinx; found=true;}}
				}
	        		responseText=responseText.substr(eLink+1);
			}
			else{
				responseText='';
			}
		}
		if (linx.length>0){
			if (tSec=parseInt(prefs.getString("rndtimer"))){
				if (tSec>0) rIval= window.setInterval("displayImage(2)",(tSec*1000*60));
			}
			 removeDuplicates();
		}
		else noImage();
	}


	function waitForUpdate(){
		if (imgs[curLink].complete){
				showImage(curLink);
				window.clearInterval(iVal1);
		}
	}


	function nextImage(obj){
                var tImg=document.getElementById('next'+obj);
		tImg.src="http://www.meteo-si.com/pic/our-picoftheday/right.gif";
		iVal1=window.setInterval("nextImage1("+obj+")",300);
	}	

	function nextImage1(obj){
		if (document.getElementById('next'+obj).complete){
			window.clearInterval(iVal1);
			if (prefs.getBool("random") == true){
				displayImage(2);
			}		
			else if (curLink<linx.length-1){
				curLink++;
				displayImage(2);
			}
			else document.getElementById('next'+obj).src="http://www.meteo-si.com/pic/our-picoftheday/right-shadow.gif"
		}
	}

	function prevImage(obj){
                var tImg=document.getElementById('prev'+obj);
		tImg.src="http://www.meteo-si.com/pic/our-picoftheday/left.gif";
		iVal1=window.setInterval("prevImage1("+obj+")",300);
	}	

	function prevImage1(obj){
		if (document.getElementById('prev'+obj).complete){
			window.clearInterval(iVal1);
			if (prefs.getBool("random") == true){
				displayImage(2);
			}		
			else if (curLink>0){
				curLink--;
				displayImage(2);
			}
			else document.getElementById('prev'+obj).src="http://www.meteo-si.com/pic/our-picoftheday/left-shadow.gif"
		}
	}


	function ImageDone(imgID){
		var im=document.getElementById(imgID);
		if (im.complete){
			window.clearInterval(iDone);
			_IG_AdjustIFrameHeight();
		}
	}

        function mainNavigation(){	
		var html='<table align ="left" width='+docWidth+' style="border-width:2px; border-style:inset; border-color:#CCCCCC; background-color:#CCCCCC">';
		html+='<td width=100 align="left" onclick="prevImage(0)">';
		html+='<img id="prev0" src="http://www.meteo-si.com/pic/our-picoftheday/left-shadow.gif">';
		html+='</td>';
		if (prefs.getBool("google")==true) html+='<td width='+(document.width-210)+' align="center"></td>';
		else html+='<td width='+(document.width-210)+' align="center"><b><font color="#FFFFFF" size="+2">('+(curLink+1)+' of '+linx.length+')</b></font></td>';
		html+='<td width=100 align="right" onclick="nextImage(0)">';
		html+='<img id="next0" src="http://www.meteo-si.com/pic/our-picoftheday/right-shadow.gif">';
		html+='</td>';
		html+='</table>';
		var html1='<table align ="left" width='+docWidth+' style="border-width:2px; border-style:inset; border-color:#CCCCCC; background-color:#CCCCCC">';
		html1+='<td width=100 align="left" onclick="prevImage(1)">';
		html1+='<img id="prev1" src="http://www.meteo-si.com/pic/our-picoftheday/left-shadow.gif">';
		html1+='</td>';
		if (prefs.getBool("google")==true) html1+='<td width='+(document.width-210)+' align="center"></td>';
		else html1+='<td width='+(document.width-210)+' align="center"><b><font color="#FFFFFF" size="+2">('+(curLink+1)+' of '+linx.length+')</b></font></td>';
		html1+='<td width=100 align="right" onclick="nextImage(1)">';
		html1+='<img id="next1" src="http://www.meteo-si.com/pic/our-picoftheday/right-shadow.gif">';
		html1+='</td>';
		html1+='</table>';
		document.getElementById('navigation').innerHTML = html;
		document.getElementById('navigation2').innerHTML = html1;
		iDone=window.setInterval("ImageDone('timg')",200);
	}

	function noImage(){
		var html='<table align ="left" width='+docWidth+' style="border-width:2px; border-style:inset; border-color:#CCCCCC; background-color:#CCCCCC">';
		html+='<td align="center"><b><font color="#FFFFFF" size="+2">no images found</b></font></td>';
		html+='</table>';
//		document.getElementById('navigation').innerHTML = html;
//		document.getElementById('navigation2').innerHTML = html;
		document.getElementById('navigation2').innerHTML = "";
		html='<table width='+docWidth+' border="5" borderColor="#CCCCCC">';
		html+='<tr>';
		html+='<td align="center"  style="border-width:1px; border-style:solid; border-color:#CCCCCC; background-color:#EEEEEE"><b><font color="#FFFFFF" size="+2">no images found</b></font></td></tr>';
		document.getElementById('imidz').innerHTML = html;
		if (prefs.getBool("thumbnails") == true) document.getElementById('thumbs').innerHTML = "";
		_IG_AdjustIFrameHeight();
	}

        function showImage(item){
		window.clearInterval(iVal);
		curLink=item+firstLink;		
		tmpImg = document.createElement('img');
		tmpImg.src=imgs[item].src;
		iVal=window.setInterval("imageLoaded(2)",200);
	}


        function displayImage(mode){
		var rnd = Math.floor((linx.length-1)*Math.random());
		if (prefs.getBool("random") == true){
			while ((rnd==curLink)&&(linx.length-1>0)){
				 rnd = Math.floor((linx.length)*Math.random());
			}
			curLink=rnd;
		}
		tmpImg = document.createElement('img');
		if (mode==1) tmpImg.src = "__UP_myphoto__";
		else{
			if (linx[curLink].substr(1,7)=='http://') tmpImg.src = linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
			else{
				var s=prefs.getString("myphoto");					
				if (linx[curLink].charAt(1)=='/'){
					s=s.substr(7);
					if (s.indexOf("/")>-1) tmpImg.src = 'http://'+s.substr(0,s.indexOf("/"))+linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
					else tmpImg.src = 'http://'+s+linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
				}
				else{
					s=s.substr(7);
					if (s.indexOf("/")>-1) tmpImg.src = 'http://'+s.substr(0,s.lastIndexOf("/")+1)+linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
					else tmpImg.src = 'http://'+s+'/'+linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"'));
				}
			}
		}
		window.clearInterval(iVal);
		iVal=window.setInterval("imageLoaded("+mode+")",1000);
	}

	function imageLoaded(mode){
	     if (mode==2) prefs.set("lastphoto",linx[curLink].substring(linx[curLink].indexOf('"')+1,linx[curLink].lastIndexOf('"')));
	     if (tmpImg.complete){
	       window.clearInterval(iVal);
	       if (restrictions(tmpImg)==false){
			curLink=0;
			displayImage(2);
	       }else{
		var html = '';
		if (mode==2){
			html='<table width='+docWidth+' border="5" borderColor="#CCCCCC">';
			html+='<tr>';
			html+='<td align="center"  style="border-width:1px; border-style:solid; border-color:#CCCCCC; background-color:#EEEEEE">';
        	        html += '<img id="timg" onclick="popitup('+"'"+tmpImg.src+"'"+');" src="'+tmpImg.src+'"';
			if (tmpImg.width>docWidth){
				html += ' WIDTH=' + (docWidth-30);
			}
			html+='>';
			html+='</td>';
			html+='</tr>';
			html+='</table>';
		}
		else {
			html='<table width='+docWidth+' border="5" borderColor="#CCCCCC">';
			html+='<tr>';
			html+='<td align="center"  style="border-width:1px; border-style:solid; border-color:#CCCCCC; background-color:#EEEEEE">';
			html+='<IMG  onclick="popitup('+"'"+"__UP_myphoto__"+"'"+');" SRC="__UP_myphoto__"';
			if (tmpImg.width>docWidth){
				html += ' WIDTH=' + (docWidth-30);
			}
			html+= '>';
			html+='</td>';
			html+='</tr>';
			html+='</table>';
		}
	        document.getElementById('imidz').innerHTML = html;
	        if (mode==2) mainNavigation();
	       }
	     }
	}

	function shiftItems(objNum){
		if (firstLink+objNum==curLink) curLink=0;
		removeI(firstLink+objNum);
		if (linx.length==0) noImage();
		else if ((objNum>0) && (firstLink+objNum<linx.length)){
			//displayImage(2);
			if (prefs.getBool("google")==true) {curLink=objNum; getGoogleImage();}
			else fixLinx();
		}
		else displayLinx();
	}

	function restrictions(obj){
		var accepted=true;
		if ((obj.width<=0) || (obj.height<=0)) accepted=false;
		else if (prefs.getBool("google")!=true) {
			var size = obj.width * obj.height;
			if ((size>0)&&(size<=20000)&&(prefs.getBool("small") == false)) accepted=false;
			else if ((size>20000)&&(size<=200000)&&(prefs.getBool("medium") == false)) accepted=false;
			else if ((size>200000)&&(size<=1000000)&&(prefs.getBool("large") == false)) accepted=false;
			else if ((size>1000000)&&(prefs.getBool("xlarge") == false)) accepted=false;
		}
		return accepted;
	}

	function checkImage(objNum){
		if (imgs[objNum].complete){
		   window.clearInterval(t[objNum]);
		   if (restrictions(imgs[objNum])==false){
//			if (prefs.getBool("google")==true) getGoogleImage();
			shiftItems(objNum);
		   }
		   else{
			if (imgs[objNum].width>imgs[objNum].height){
				var fact=imgs[objNum].height/75;
				var x=((imgs[objNum].width/fact)-75)*(fact/2);
				crop(imgs[objNum], document.getElementById("crop"+objNum), x, 1, imgs[objNum].width*fact, imgs[objNum].height*fact);
			}
			else{
				var fact=imgs[objNum].width/75;
				var y=((imgs[objNum].height/fact)-75)*(fact/2);
				crop(imgs[objNum], document.getElementById("crop"+objNum), 1, y, imgs[objNum].width*fact, imgs[objNum].height*fact);
			}
			if (objNum<imgCount){				
				objNum++;
				curImg=objNum;
				imgs[objNum].src=imgLinx[objNum];
				 t[objNum]=window.setInterval("checkImage("+objNum+")",200);
			}
			else displayImage(2);
		   }
		}
	}

	function badImage(e){
		var targ;
		var objNum=curImg;
		if (!e)
		  {
		   window.clearInterval(t[objNum]);
		   //if (prefs.getBool("google")==true) {curLink=curImg; getGoogleImage();}
		   shiftItems(objNum);
		  }
	}


	function deleteBoxes(){
		var table = document.getElementById('T1');
		var fix=false;
		for (i=imgCount;i<=boxes;i++){
			fix=true;
			table.removeChild(table.lastChild);
		}
		if (fix==true) {
			var el = document.createElement('TD');
			table.appendChild(el);	
		}
		boxes=imgCount;
	}

	function fixLinx(){
		for (j=firstLink+curImg,i=curImg;((j<linx.length)&&(j<firstLink+line));j++,i++){
			if (linx[j].substr(1,7)=='http://') imgLinx[i] = linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
			else{
				var s=prefs.getString("myphoto");					
				if (linx[j].charAt(1)=='/'){
					s=s.substr(7);
					if (s.indexOf("/")>-1) imgLinx[i] = 'http://'+s.substr(0,s.indexOf("/"))+linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
					else imgLinx[i] = 'http://'+s+linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
				}
				else{
					s=s.substr(7);
					if (s.indexOf("/")>-1) imgLinx[i] = 'http://'+s.substr(0,s.lastIndexOf("/")+1)+linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
					else imgLinx[i] = 'http://'+s+'/'+linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
				}
			}
			imgCount=i;
		}		
		if (imgCount<boxes) deleteBoxes();
		imgs[curImg] = document.createElement('img');
		imgs[curImg].onerror = badImage;
		imgs[curImg].setAttribute('id','img'+i);
		imgs[curImg].src=imgLinx[curImg];
		t[curImg]=window.setInterval("checkImage("+curImg+")",200);
	}

	function displayLinx(){
		var html='<table width="'+docWidth+'" bgcolor="#EEEEEE" align="left" style="border:1px solid #CCCCCC">';
		html+='<tr id="T1">';
		if (firstLink>0){
			line=lineBup+0;
			html+='<td border="0" onclick="moveLeft()" width="'+Math.round((docWidth-(line*90))/2)+'">';
			html+='<img id="NL" style="cursor:pointer;" src="http://www.meteo-si.com/pic/our-picoftheday/double-left-shaddow.gif">';
			html+='</td>';
		}
		else line=lineBup+1;

		while (firstLink>=linx.length) firstLink--;
		for (j=firstLink,i=0;((j<linx.length)&&(j<firstLink+line));j++,i++){
			html+='<td border="0" width=85 onmouseover="changeBorder('+i+')" onmouseout="changeBorderBack('+i+')">'; 
			html += '<div id="crop'+i+'" onclick="showImage('+i+')" style="cursor:pointer; width:75px; height:75px; border-width:4px; border-style:inset; border-color:#FFFFFF;"></div>';
			imgs[i] = document.createElement('img');
			imgs[i].onerror = badImage;
			imgs[i].setAttribute('id','img'+i);
			if (linx[j].substr(1,7)=='http://') imgLinx[i] = linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
			else{
				var s=prefs.getString("myphoto");					
				if (linx[j].charAt(1)=='/'){
					s=s.substr(7);
					if (s.indexOf("/")>-1) imgLinx[i] = 'http://'+s.substr(0,s.indexOf("/"))+linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
					else imgLinx[i] = 'http://'+s+linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
				}
				else{
					s=s.substr(7);
					if (s.indexOf("/")>-1) imgLinx[i] = 'http://'+s.substr(0,s.lastIndexOf("/")+1)+linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
					else imgLinx[i] = 'http://'+s+'/'+linx[j].substring(linx[j].indexOf('"')+1,linx[j].lastIndexOf('"'));
				}
			}
			html+='</td>';
			imgCount=i;
		}
		boxes=imgCount;
		curImg=0;
		imgs[0].src=imgLinx[0];
		t[0]=window.setInterval("checkImage(0)",200);
		

		if ((firstLink+line<linx.length)||((lastImage>line)&&(prefs.getBool("google")==true))){
			html+='<td border="0" align="right" onclick="moveRight()">';
			html+='<img id="NR" style="cursor:pointer;" src="http://www.meteo-si.com/pic/our-picoftheday/double-right-shaddow.gif">';
			html+='</td>';
		}
		else html+='<td></td>';
		html+='</tr>'
		html+='</table>';
	        if (prefs.getBool("thumbnails") == true) document.getElementById('thumbs').innerHTML = html;
	}

	function changeBorder(objNum){
		var style = document.getElementById('crop'+objNum).style;
		style.borderColor="#FF0000";
	}

	function changeBorderBack(objNum){
		var style = document.getElementById('crop'+objNum).style;
		style.borderColor="#FFFFFF";
	}


	function moveLeft(){
		window.clearInterval(t[curImg]);
                var tImg=document.getElementById('NL');
		tImg.src="http://www.meteo-si.com/pic/our-picoftheday/double-left.gif";
		iVal2=window.setInterval("moveLeft1()",300);
	}

	function moveLeft1(){
		if (document.getElementById('NL').complete){
			window.clearInterval(iVal2);
			if (firstLink>0){
				firstLink-=line;
				if (firstLink==1) firstLink=0;
				displayLinx();
			}
		}	
	}

	function moveRight(){
		window.clearInterval(t[curImg]);
                var tImg=document.getElementById('NR');
		tImg.src="http://www.meteo-si.com/pic/our-picoftheday/double-right.gif";
		iVal2=window.setInterval("moveRight1()",300);
	}

	function moveRight1(){
		if (document.getElementById('NR').complete){
			window.clearInterval(iVal2);
			if (prefs.getBool("google")==true){
				curLink=0;
				getGoogleImage();
			}
			else if (firstLink+line<linx.length){				
				firstLink+=line;
				displayLinx();
			}
		}
	}


	function showhelp(){
        	var h = document.getElementById('helpdiv');
		var helpstr = '';
        	helpstr = '<p class="regular" align="left">Picture Of The Day;<br />';
		helpstr += '<br />';
	        helpstr += '<br /><a onclick="hidehelp();" style="cursor:pointer">Close help</a></p>';
	        h.innerHTML = helpstr;
        	var hm = document.getElementById('menuhelpdiv');
	        hm.innerHTML = '<a onclick="hidehelp();" style="cursor:pointer">Close help</a>';
        	_IG_AdjustIFrameHeight();
	}

	function hidehelp(){
        	var h = document.getElementById('helpdiv');
	        h.innerHTML = '';
        	var hm = document.getElementById('menuhelpdiv');
	        hm.innerHTML = '<a onclick="showhelp();" style="cursor:pointer">Help</a>';
        	_IG_AdjustIFrameHeight();
	}


	function popitup(s) {
		newwindow=window.open(s,'m','scrollbars=yes,resizable=yes');
		if (window.focus) {newwindow.focus()}
	}

	function start(){
//		alert("100");
		var temp = "__UP_myphoto__";
		var lead = temp.substr(0,7);
		if ((lead!='http://')&&(lead!='HTTP://')&&(prefs.getBool("google")!=true)){
			 temp='http://'+temp;
			 prefs.set('myphoto',temp);
		}
		var tip = temp.substr(temp.lastIndexOf(".")+1,3);
		if (prefs.getBool("google")==true){
			if (tSec=parseInt(prefs.getString("rndtimer"))){
				if (tSec>0) rIval= window.setInterval("displayImage(2)",(tSec*1000*60));
			}
			 getGoogleImage();
		}
		else if ((tip=="jpg")||(tip=="gif")||(tip=="png")){
			 displayImage(1);
		}
//		else _IG_FetchContent(temp, _IG_Callback(parseDir), { refreshInterval: 1 });
		else _IG_FetchContent(temp, _IG_Callback(parseDir));
 
	}

//http://ankitchaturvedi.blogspot.com/2008/04/reuters-top-photos.html

   </script>

<div id="helpdiv"></div>
<table cellspacing="0" cellpadding="0" width="100%" bgcolor="white" border=1 class="regular">
<tr><td>
  <table cellspacing="0" cellpadding="0" width="100%" bgcolor="white" class="regular">
   <tr>
    <td>
      <a href="http://www.adapta-solutions.com/solutions/gadgets.html" target="_blank" onmouseover="document.m1.src ='http://www.meteo-si.com/images/kroglice2.gif';" onmouseout="document.m1.src ='http://www.meteo-si.com/images/kroglice.gif';"><img border="0" src="http://www.meteo-si.com/images/kroglice.gif" name="m1"> More gadgets</a>
    </td>    
   </tr>
  </table>
</td>
<td width="170px">
More options
</td></tr>
<tr><td valign="top">
   <table bgcolor="#EEEEEE" style="border:1px solid #CCCCCC">
   <tr>
   <td>
   <div id="thumbs" align="left"></div>
   </td>
   </tr>
   <tr>
   <td>
   <div id='navigation'></div>
   </td>
   </tr>
   <tr>
   <td>
   <div id="imidz"></div>
   </td>
   </tr>
   <tr>
   <td>
   <div id='navigation2'></div>
   </td>
   </tr>
   </table>
</td>
<td valign="top">
<div id="menuhelpdiv"><a onclick="showhelp();" style="cursor:pointer">Help</a></div>
<a href="http://www.adapta-solutions.com/solutions/gadgets.html" target="_blank">More gadgets</a><br>
<a href="http://www.google.com/ig/directory?url=www.meteo-si.com/meteo-si.xml" target="_blank">About this gadget</a><br>
<br>
Country editions<br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/meteo-USA.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Meteo-USA</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/meteo-CA.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Meteo-CA</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/meteo-UK.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Meteo-UK</a><br>
Space Weather<br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/moon/moon.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Moon</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/space/sun.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Sun</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/space/mercury.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Mercury</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/space/venus.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Venus</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/space/mars.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Mars</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/space/jupiter.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Jupiter</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/space/saturn.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Saturn</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/space/uranus.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Uranus</a><br>
<a href="http://fusion.google.com/ig/add?synd=open&amp;source=ggyp&amp;moduleurl=http://www.meteo-si.com/space/neptune.xml" target="_blank"><img border="0" src="http://www.meteo-si.com/images/google_icon.gif"> Neptune</a><br>
</td></tr>
</table>

  <script type="text/javascript">
// Get a reference to user preferences
var prefs = new _IG_Prefs();
// Get the user's current date/time
var now = new Date();
// Create a date string of the form yyyy-m-d
var today = (now.getFullYear?now.getFullYear():now.getYear())+'-'+(now.getMonth()+1)+'-'+now.getDate();
// Get the stored value of the "today" user preference.
var prefs_today = prefs.getString('today');

// If the "today" user preference is blank, then the user has never loaded
// this gadget. They must have just added it!
if (prefs_today=='') {
    _IG_Analytics("UA-6660391-1", "/novigadget/pic/our-picoftheday");
}
// If the generated date string doesn't match the one stored in the
// preferences, then this is the first time the user has loaded the
// gadget today. Record a hit and change the preferernce to be
// today's date string so it won't get recorded again.
if (prefs_today!=today) {
    prefs.set('today',today);
    _IG_Analytics("UA-6660391-1", "/gadget/pic/our-picoftheday");
}
</script>

</body>
</html>

]]>
</Content>
</Module>

