
var newwin = null;
function doPopupDIBS(fnr)
{
	if (document.forms[fnr].prodspec.value == 0)
	{
		alert('Välj antal');
	}
	else
	{
		var user_paytype = '';
		
		for (i=0; i<document.forms[fnr].paytype.length; i++)
		{
			if (document.forms[fnr].paytype[i].checked)
			{
				user_paytype = document.forms[fnr].paytype[i].value;
			}
		}

		
		if (user_paytype == '')
		{
			alert('Välj typ av kort');
		}
		else
		{
			link   = 'http://www.allabolag.se/dibs/service.php?prodspec=' + document.forms[fnr].prodspec.value + '&paytype=' + user_paytype + '&orgnr=' + document.forms[fnr].orgnr.value
			newwin = window.open(link, 'paywin', 'scrollbars,status,width=550,height=700');
			newwin.focus();
		}
		
		return true;
	
	}
}


function popAd(url)
{
	window.open(url, "addwindow");
}


function abIntr()
{
	window.open("http://www.allabolag.se/retriever.php","abIntr","0,0,0,0,0,resizable=1,scrollbars=1,width=800,height=800,top=100,left=100");
}

function abValorder(xo, xf)
{
	window.open("http://www.allabolag.se/adeqvat.php?x_orgnr="+xo+"&x_ftgnamn="+xf,"abIntr","0,0,0,0,0,resizable=1,scrollbars=1,width=480,height=860,top=100,left=100");
}

function abArorder()
{
		window.open("http://www.orderannualreports.com/?cp_code=P629","Arorder","0,0,0,0,0,resizable=1,scrollbars=1,width=850,height=800,top=100,left=100");
}

function popMap(url)
{
	window.open(url,"link","0,0,0,0,0,resizable=1,0,width=850,height=800,top=100,left=100");
}

function popLink(orgnr, jurnamn)
{
	window.open("http://www.allabolag.se/link.php?orgnr="+orgnr+"&jurnamn="+jurnamn,"link","0,0,0,0,0,resizable=1,0,width=800,height=800,top=100,left=100");
}

function popTipsa(orgnr, jurnamn)
{
	window.open("http://www.allabolag.se/tipsa.php?orgnr="+orgnr+"&jurnamn="+jurnamn,"tipsa","0,0,0,0,0,resizable=1,0,width=800,height=800,top=100,left=100");
}

function displayOnOff(item)
{
	var divId = document.getElementById(item);

	if (divId.style.display != null)
	{
		var divId = document.getElementById(item);
		divId.style.display = (divId.style.display == "none" ? "block" : "none");
	}
}

function displayOn(item)
{
	var divId = document.getElementById(item);

	if (divId.style.display != null)
	{
		var divId = document.getElementById(item);
		divId.style.display = "block";
	}
}


function displayOff(item)
{
	var divId = document.getElementById(item);

	if (divId.style.display != null)
	{
		var divId = document.getElementById(item);
		divId.style.display = "none";
	}
}


function getAnnualReport(org,period,mons,fnr)
{
	if (org && period)
	{
		document.aform.nrmon.value = mons;
		document.aform.tom.value = period;
		document.aform.orgnr.value = org;
		document.aform.smscode.value = document.forms[fnr].code.value;

		if (document.aform.smscode.value.length == 6)
		{
			document.aform.submit();
			document.forms[fnr].code.value = "";
			document.aform.smscode.value = "";
			displayOnOff(period);
		}
		else
		{
			alert('Kontrollera SMS-koden');
		}
	}
	else
	{
		alert('Data saknas');
	}	

}


function getAnnualReportInvoice(org,period,mons)
{
	if (org && period)
	{
		document.aform.nrmon.value = mons;
		document.aform.tom.value = period;
		document.aform.orgnr.value = org;
		document.aform.paytype.value = "INVOICE";
		
		document.aform.submit();
		
		document.aform.paytype.value = "";
		displayOnOff('A'+period);
		
	}
	else
	{
		alert('Data saknas');
	}	

}


function getCreditReportInvoice(org,ctype)
{
	if (org && ctype)
	{
		document.cform.orgnr.value = org;
		document.cform.ctype.value = ctype;
		document.cform.paytype.value = "INVOICE";
		
		document.cform.submit();

		document.cform.paytype.value = "";		
		displayOnOff('id'+ctype);

	}
	else
	{
		alert('Data saknas');
	}	
	
}

function getCreditReport(org,ctype,fnr)
{
	if (org && ctype && fnr)
	{
		document.cform.orgnr.value = org;
		document.cform.ctype.value = ctype;
		document.cform.smscode.value = document.forms[fnr].code.value;

		if (document.cform.smscode.value.length == 6)
		{
			document.cform.submit();

			document.forms[fnr].code.value = "";
			document.cform.smscode.value = "";
			displayOnOff('id'+ctype);

		}
		else
		{
			alert('Kontrollera SMS-koden');
		}

	}
	else
	{
		alert('Data saknas');
	}	
	
}

function getBoredaReport(org,byear,btype,fnr)
{
	if (org && byear && btype && fnr)
	{
		document.bform.orgnr.value = org;
		document.bform.btype.value = btype;
		document.bform.byear.value = byear;
		document.bform.smscode.value = document.forms[fnr].code.value;

		if (document.bform.smscode.value.length == 6)
		{
			document.bform.submit();
			document.forms[fnr].code.value = "";
			document.bform.smscode.value = "";
			displayOnOff('id'+btype+byear);
		}
		else
		{
			alert('Kontrollera SMS-koden');
		}
	}
	else
	{
		alert('Data saknas');
	}	
}


function getCompanyReport(org,fnr,fid,rtype)
{
	if (org && fnr && fid)
	{
		document.rform.orgnr.value = org;
		document.rform.rtype.value = rtype;
		document.rform.smscode.value = document.forms[fnr].code.value;
		document.rform.email.value = document.forms[fnr].epost.value;

		if (document.rform.smscode.value.length == 6)
		{
			document.rform.submit();
			document.forms[fnr].code.value = "";
			document.rform.smscode.value = "";
			displayOnOff(fid);
		}
		else
		{
			alert('Kontrollera SMS-koden');
		}
	}
	else
	{
		alert('Data saknas');
	}	
}


function doProfilePopup(org)
{
	if (org == 2)
	{
		link = 'http://ret-ab-stage01.int.retriever.no/profile/service.php?step=1&si=2';
	}
	else
	{
		link = 'http://www.allabolag.se/profile/service.php?step=1&si=1&orgnr='+org;
	}
	
	newwin = window.open(link, 'wizard', 'scrollbars,status,width=600,height=790');
	newwin.focus();
}


function getWindowHeight()
{
	// pos height
	if (typeof window.innerHeight != 'undefined') // Non-IE
	{
		windowHeight = window.innerHeight;
	}
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) // IE 6+ in 'standards compliant mode'
	{
		windowHeight = document.documentElement.clientHeight;
	}
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) // IE 4 compatible
	{
		windowHeight = document.body.clientHeight;
	}
	
	return windowHeight;
}


function getWindowWidth()
{
	// pos width
	if (typeof window.innerWidth != 'undefined') // Non-IE
	{
		windowWidth = window.innerWidth;
	}
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) // IE 6+ in 'standards compliant mode'
	{
		windowWidth = document.documentElement.clientWidth;
	}
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) // IE 4 compatible
	{
		windowWidth = document.body.clientWidth;
	}
	
	return windowWidth;
}

function popTV(id)
{
	windowHeight = (getWindowHeight() / 2) - 150;
	windowWidth = (getWindowWidth() / 2) - 50;
	
	window.open("http://www.allabolag.se/media_player.php?video_id="+id,"tv","0,0,0,0,0,resizable=1,scrollbars=0,width=500,height=380,top="+windowHeight+",left="+windowWidth);
}
