function checkorgnr(orgnr) {
    num=0, n=0, calc=0, adder = 2, remi=0, check=0, last=0;

	//alert(orgnr)
    if(orgnr.length != 10) return 1001;
	
    for(n=0;n<9;n++)
    {
	  num = parseInt(orgnr.charAt(n));
	  if(isNaN(num)) return 1002;
	  num *= adder++;
	  if(num > 9) num -= 9;
	  calc += num;
	  if(adder == 3) adder = 1;
     }
     remi = (calc % 10) ? (parseInt(calc / 10) + 1) * 10 : calc;
     check = remi - calc;
     last  =  parseInt(orgnr.charAt(9));
     return (isNaN(last) ? 1002 : check - last);
  }

  function sendthisform(issendable,id){
   	var Xwin = 0; var Ywin = 0;
   	var 	w = 480;
	var h = 555;
   	if (parseInt(navigator.appVersion) >= 4) {
            Xwin = (screen.availWidth - w)*.5;
            Ywin = (screen.availHeight - h)*.5;
    }
	

    if(issendable == 0) {
		theURL = document.getElementById(id+"tourl").value+"&personnr="+document.getElementById(id+"personnr").value
		//alert(theURL);
		//theURL = theURL.replace(/^\s+|\s+$/, '');
		ordWindow = window.open(theURL,'ordWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width='+w+',height='+h+',left='+Xwin+',top='+Ywin)
  
	}
    if(issendable == 1001) alert("Du måste ange 10 tecken i personnumret.");
    if(issendable == 1002) alert("Personnumret måste anges i siffror.");
    if(issendable != 0 && issendable != 1001 && issendable != 1002) alert ("Kontrollera personnumret.\nKontrollsiffran visar att det inte är korrekt ifyllt.");
  }
  
  

function sendthisflashform(persnr,url){
   	var Xwin = 0; var Ywin = 0;
   	var 	w = 480;
	var h = 555;
   	if (parseInt(navigator.appVersion) >= 4) {
            Xwin = (screen.availWidth - w)*.5;
            Ywin = (screen.availHeight - h)*.5;
    	}
	
	
	issendable = checkorgnr(persnr+"")
    if(issendable == 0) {
	theURL = url +"&personnr="+persnr
	//alert(theURL);
		
	persWindow = window.open(theURL,'persWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width='+w+',height='+h+',left='+Xwin+',top='+Ywin)
  
    }
    if(issendable == 1001) alert("Du måste ange 10 tecken i personnumret.");
    if(issendable == 1002) alert("Personnumret måste anges i siffror.");
    if(issendable != 0 && issendable != 1001 && issendable != 1002) alert ("Kontrollera personnumret.\nKontrollsiffran visar att det inte är korrekt ifyllt.");
}

function openWin(HTMLPage){
        var Xwin = 0; var Ywin = 0;
        if (parseInt(navigator.appVersion) >= 4) {
            Xwin = (screen.availWidth - 10)*.5;
            Ywin = (screen.availHeight - 10)*.5;
        }
ARWindow = window.open(HTMLPage,'ARWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=10,height=10,left='+Xwin+',top='+Ywin)
}
  



function openDropLink(theURL,selIndex){	
	if(theURL.indexOf('javascript')>-1){
		eval(theURL);
	}
	else{
		tmpWinName = "collectumWin"+selIndex;
		window.open(theURL,tmpWinName);
	}
}

function openHelpWord(HTMLPage){
        var Xwin = 0; var Ywin = 0;
		var h= 250;
		var w= 310;
        if (parseInt(navigator.appVersion) >= 4) {
            Xwin = (screen.availWidth - w)*.5;
            Ywin = (screen.availHeight - h)*.5;
        }
wordWindow = window.open(HTMLPage,'wordWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width='+w+',height='+h+',left='+Xwin+',top='+Ywin)
}



//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	getHeight: function(element) {
	   	element = $(element);
	   	return element.offsetHeight; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},
	setLeft: function(element,t) {
	   	element = $(element);
    	element.style.left = t +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

var objOverlay;
var objProplay;

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}