﻿function ScalePic(picid,picwidth,picheight){
	var pic = document.getElementById(picid);
	if(typeof pic != 'undefined'){
		var widthPercent = screen.width /picwidth ;
		if(screen.width < picwidth){
			pic.width = screen.width-60;
			pic.height = picheight *widthPercent;
		}
	}
}

<!-- Copyright 2006,2007 Bontrager Connection, LLC
// http://bontragerconnection.com/ and http://willmaster.com/
// Version: July 28, 2007
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
d.style.left = (cX+10) + "px";
d.style.top = (cY+10) + "px";
}
function HideContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
dd.style.display = "none";
if(dd.getElementsByTagName('img')[0]){
					dd.removeChild(dd.getElementsByTagName('img')[0]);		
}
}
function ShowContent(d,sender) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
			    
if(dd != ""){
    var newimg=document.createElement('img');
    dd.appendChild(newimg);				    
    newimg.src=geturl(sender.href);									
}				

dd.style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}
//-->
	
	function geturl(url)
		{
			url=url.split('/');
			url="pics/thumbs/tn_"+url[url.length-1];
			return url;
		}
	
function ChangeFormActionAndSubmit(newaction,confirmdelete){
newaction = newaction + "&ScreenW=" + screen.width + "&ScreenH=" + screen.height;
if(confirmdelete == "c"){
    if(confirm("Oled kindel, et soovid kustutada selle kirje?")){    
        document.forms[0].action = newaction;
        document.forms[0].submit();
    }
}else{
    document.forms[0].action = newaction;
    document.forms[0].submit();
}
}
function RefreshOpener(){
    window.opener.location = window.opener.location;
}

function getSelectionStart(o) {
	if (o.createTextRange) {
		var r = document.selection.createRange().duplicate()
		r.moveEnd('character', o.value.length)
		if (r.text == '') return o.value.length
		return o.value.lastIndexOf(r.text)
	} else return o.selectionStart
}

function getSelectionEnd(o) {
	if (o.createTextRange) {
		var r = document.selection.createRange().duplicate()
		r.moveStart('character', -o.value.length)
		return r.text.length
	} else return o.selectionEnd
}

function UploadComplete(){
    document.forms[0].action = document.location.href;
    document.forms[0].submit();
}


