function resizeImage()
  {
		 
	var image_width   = document.getElementById("watermarkImage").width;
	var image_height  = document.getElementById("watermarkImage").height;

	if (image_height > image_width )
	{
		
	  if(image_height < 400){
	    document.getElementById("watermarkImage").style.width  = "auto";
	    document.getElementById("watermarkImage").style.height = "400px";
	  }
	  else
	  {
	    document.getElementById("watermarkImage").style.width  = "auto";
	    document.getElementById("watermarkImage").style.height = "600px";
	  }	  
		
	}
	else
	{
		
	 if(image_width < 600){
	   document.getElementById("watermarkImage").style.width  = "600px";
	   document.getElementById("watermarkImage").style.height = "auto";
	 }
     else
     {
       document.getElementById("watermarkImage").style.width  = "600px";
	   document.getElementById("watermarkImage").style.height = "400px";
     }
	}
  }

function resizeFotoStoryImage()
{
		 
	var image_width   = document.getElementById("watermarkImage").width;
	var image_height  = document.getElementById("watermarkImage").height;

	if (image_height > image_width )
	{
		
	  if(image_height < 400){
	    document.getElementById("watermarkImage").style.width  = "auto";
	    document.getElementById("watermarkImage").style.height = "400px";
	  }
	  else
	  {
	    document.getElementById("watermarkImage").style.width  = "auto";
	    document.getElementById("watermarkImage").style.height = "400px";
	  }	  
		
	}
	else
	{	
	 if(image_height < 400){
	    document.getElementById("watermarkImage").style.width  = "auto";
	    document.getElementById("watermarkImage").style.height = "400px";
	 }
		
	 if(image_width < 600){
	   document.getElementById("watermarkImage").style.width  = "600px";
	   document.getElementById("watermarkImage").style.height = "auto";
	 }
     else
     {
       document.getElementById("watermarkImage").style.width  = "600px";
	   document.getElementById("watermarkImage").style.height = "400px";
     }
	}
}


function resizeImageSmall(image)
{

	var image_width   = image.width;
	var image_height  = image.height;

	if (image_height > image_width )
	{
		
	  if(image_height < 135){
		  image.style.width  = "180px";
		  image.style.height = "auto";
	  }
	  else
	  {
		  image.style.width  = "180px";
		  image.style.height = "auto";
	  }	  
		
	  }
	else
	{
		
	 if(image_width < 180){
		 image.style.width  = "180px";
		 image.style.height = "auto";
	 }
	 else if(image_width == 180){
		 image.style.width  = "180px";
		 image.style.height = "auto";
	 }
     else
     {
    	 if(image_width/image_height > 1.34){
    		 image.style.width  = "auto";
        	 image.style.height = "135px";
    	 }
    	 if(image_width/image_height < 1.34){
    	     image.style.width  = "180px";
    	     image.style.height = "auto";
    	 }
      }
	}
}

function resizeImageSmaller(image)
{
    /* 120 x 90  */
	var image_width   = image.width;
	var image_height  = image.height;

	if (image_height > image_width )
	{
		
	  if(image_height < 90){
		  image.style.width  = "120px";
		  image.style.height = "auto";
	  }
	  else
	  {
		  image.style.width  = "120px";
		  image.style.height = "auto";
	  }	  
		
	}
	else
	{
		
	 if(image_width < 120){
		 image.style.width  = "120px";
		 image.style.height = "auto";
	 }
     else
     {
    	 if(image_width/image_height > 1.34){
    		 image.style.width  = "auto";
        	 image.style.height = "90px";
    	 }
    	 if(image_width/image_height < 1.34){
    	     image.style.width  = "120px";
    	     image.style.height = "auto";
    	 }
     }
	}
}


function resizePhotoOfTheDay()
{
    /* 210 x 157  */
	var image_width   = document.getElementById("imagephotoOfTheDay").width;
	var image_height  = document.getElementById("imagephotoOfTheDay").height;

	if (image_height > image_width )
	{
		
	  if(image_height < 135){
	    document.getElementById("imagephotoOfTheDay").style.width  = "180px";
	    document.getElementById("imagephotoOfTheDay").style.height = "auto";
	  }
	  else
	  {
	    document.getElementById("imagephotoOfTheDay").style.width  = "180px";
	    document.getElementById("imagephotoOfTheDay").style.height = "auto";
	  }	  
		
	}
	else
	{
		
	 if(image_width < 180){
	   document.getElementById("imagephotoOfTheDay").style.width  = "180px";
	   document.getElementById("imagephotoOfTheDay").style.height = "auto";
	 }
     else
     {
    	 if(image_width/image_height > 1.34){
    		 document.getElementById("imagephotoOfTheDay").style.width  = "auto";
    		 document.getElementById("imagephotoOfTheDay").style.height = "135px";
    	 }
    	 if(image_width/image_height < 1.34){
    		 document.getElementById("imagephotoOfTheDay").style.width  = "180px";
    		 document.getElementById("imagephotoOfTheDay").style.height = "auto";
    	 }
      
     }
	}
}

function resizeImageThumbnail(image)
{

	var image_width   = image.width;
	var image_height  = image.height;

	if (image_height > image_width )
	{
		
	  if(image_height < 45){
		  image.style.width  = "60px";
		  image.style.height = "auto";
	  }
	  else
	  {
		  image.style.width  = "60px";
		  image.style.height = "auto";
	  }	  
		
	  }
	else
	{
		
	 if(image_width < 60){
		 image.style.width  = "60px";
		 image.style.height = "auto";
	 }
     else
     {
    	 image.style.width  = "60px";
    	 image.style.height = "45px";
      }
	}
}
function resizeImageCustom(image, newWidth, newHeight)
{
	var w = newWidth;
	var h = newHeight;
	var d = (w/h);
	var r = roundNumber(d, 1);
	
	var image_width   = image.width;
	var image_height  = image.height;

	if (image_height > image_width )
	{
		
	  if(image_height < newHeight){
		  image.style.width  = newWidth+"px";
		  image.style.height = "auto";
	  }
	  else
	  {
		  image.style.width  = newWidth+"px";
		  image.style.height = "auto";
	  }	  
		
	  }
	else
	{
		
	 if(image_width < newWidth){
		 image.style.width  = newWidth+"px";
		 image.style.height = "auto";
	 }
	 else if(image_width == newWidth){
		 image.style.width  = newWidth+"px";
		 image.style.height = "auto";
	 }
     else
     {
    	 if(image_width/image_height > r){
    		 image.style.width  = "auto";
        	 image.style.height = newHeight+"px";
    	 }
    	 if(image_width/image_height < r){
    	     image.style.width  = newWidth+"px";
    	     image.style.height = "auto";
    	 }
    	 if(image_width/image_height == 1){
    		 image.style.width  = newWidth+"px";
    	     image.style.height = newHeight+"px";
    	 }
      }
	}
}

function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
	  var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
	  return newnumber; 
	}