﻿		$(document).ready(function(){
				
				//$('#diginews-paper').css({height : '500px'});
				
				resizeDiginews();
		});
		
		$(window).resize(function(){
					resizeDiginews();
			});
			
		function resizeDiginews(){
				var pmaxsize = 680;
				var pminsize = 400;
				
				//calculate paperviewport height
				var ratio = $(window).height() - 100;
				if(ratio > pminsize && ratio < pmaxsize){
					$('#diginews-paper').css({height : $(window).height()-100});
				}
				if(ratio > pmaxsize){
					$('#diginews-paper').css({height : pmaxsize});
				}
				if(ratio < pminsize){
					$('#diginews-paper').css({height : pminsize});
				}
		}
		
		function zoomDiginews(zoom){
			var orig_height = $('#diginews-wrapper').height()-100;
			//console.log("original height " + orig_height);
			if(zoom == 'in'){
				$('#diginews-info-wrapper').hide();
				$('#diginews-wrapper').css({height: 100+'%', width: 100+'%'});
				$('#diginews-paper').css({height: 100+'%', width: 100+'%'});
				//alert("Wrapper height : " + $('#diginews-wrapper').height() + " Paper height: " + $('#diginews-paper').height());
				//overflow:hidden when ie6?
				
			}
			if(zoom == 'out'){
				$('#diginews-info-wrapper').show();
				resizeDiginews();
				//recheck sizes accordingly
			}
		
		}
		
		function setUrl(purl){
			//asettaa window.href parametrina annetuksi
			window.location.hash=purl;	
		}

		/*
		var flashvars = {
		    path: "http://www.diginews.fi/demo/pages.xml"
		}
		var params = {
		    scale: "noscale",
		    wmode: "direct",
			name : "digipaper",
			allowscriptaccess: "always"
		}
		swfobject.embedSWF("../diginews.swf", "paper", "100%", "100%", "10","", flashvars,params);*/
		
		function getUrl(){
			var getUrlHashMatch = window.location.hash.match(/\#([\d{1,}]*)/);
			if(getUrlHashMatch != null){
				getUrlHash = getUrlHashMatch[1];
				var testi = document.getElementById('paper');
				testi.sendUrl(getUrlHash);
			}
			
		}