function customWindow(usePage,useWin,useWidth,useHeight) {
	window.open('' + usePage + '','' + useWin + '','width=' + useWidth + ',height=' + useHeight + ',fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no');
}

function redirectDomainSearch(){

	if (document.all) {
		document.all.DomainSearch.style.visibility='visible';
		document.all.DigiContent.style.visibility='hidden';
	} else {
		document.getElementById('DomainSearch').style.visibility='visible';
		document.getElementById('DigiContent').style.visibility='hidden';
	}

	domainName = document.DOMAINSEARCH.DOMAINNAME.value;
	domainType = document.DOMAINSEARCH.DOMAINTYPE.value;
	domainStr = domainName + "|" + domainType;

	document.DOMAINSEARCH.action = "/domene/search.asp?page=3633&lang=1&domain=" + domainStr;
	top.location.href = "/domene/search.asp?page=3633&lang=1&domain=" + domainStr;

	domainImage = new Image()
	domainImage.src="/images/domainsearch_ani.gif";

	document.images.DomainSearchAni.src=domainImage.src;

	window.status='Laster søke resultat...';
}

function validateDomainSearch(){

	domainName = document.DOMAINSEARCH.DOMAINNAME.value;
	domainType = document.DOMAINSEARCH.DOMAINTYPE.value;
	domainStr = domainName + "|" + domainType;

	document.DOMAINSEARCH.action = "/domene/search.asp?page=3633&lang=1&domain=" + domainStr;

	validChars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-æøåØÆÅ";	
	
	if (document.DOMAINSEARCH.DOMAINNAME.value == '') {
		document.DOMAINSEARCH.DOMAINNAME.focus();
		alert("Domenesøk: Feltet må fylles inn!");
		return false;
	}
	if (document.DOMAINSEARCH.DOMAINNAME.value.length < "2") {
		document.DOMAINSEARCH.DOMAINNAME.focus();
		alert("Domenesøk: Domenenavnet må være minst 2 tegn!");
		return false;
	}
	if (checkValidChars(document.DOMAINSEARCH.DOMAINNAME.value, validChars))	{
		redirectDomainSearch();
		return false;
	} else {
		document.DOMAINSEARCH.DOMAINNAME.focus();
		alert("Domenesøk: Ugyldig tegn i domenenavnet!");
		return false;
	}
}




function checkValidChars(inputStr,validChars) {
	var result = true;
	for (var i=0;i<inputStr.length;i++){
		if (validChars.indexOf(inputStr.substr(i,1))<0) {
			result = false;
			break;
		}
	}	
	return result;
}

// MOVE BASKET LAYER

var frameAmount = 40;
var frameCount = 0;
var frameSpeed = 10;

var targetWidth = 100;
var targetHeight = 10;

var targetLayerName = "Mod73TargetLayer";
var targetLayerWidth, targetLayerHeight, targetLayerPosX, targetLayerPosY

var moveLayerName = "Mod73BasketLayer";
var moveLayerFontsize;
var orgLayerWidth, orgLayerHeight, orgLayerPosX, orgLayerPosY, orgLayerFontsize;

function moveLayer(inputLayer,inputForm) {
	if (document.all) {
		// TARGET LAYER
		targetLayerObj = document.all[targetLayerName];
		targetLayerPosX = Math.floor(targetLayerObj.offsetLeft);
		targetLayerPosY = Math.floor(targetLayerObj.offsetTop);
		targetLayerWidth = targetLayerObj.style.width;
		targetLayerHeight = targetLayerObj.style.height;

		targetLayerWidth = targetLayerWidth.replace("px","");
		targetLayerHeight = targetLayerHeight.replace("px","");

		targetLayerPosX = targetLayerPosX + (targetLayerWidth / 2) - (targetWidth / 2);
		targetLayerPosY = targetLayerPosY + (targetLayerHeight / 2) - (targetHeight / 2);

		// ORG LAYER
		orgLayerName = inputLayer;
		orgLayerObj = document.all[orgLayerName];
		orgLayerPosX = Math.floor(orgLayerObj.offsetLeft);
		orgLayerPosY = Math.floor(orgLayerObj.offsetTop);
		orgLayerWidth = orgLayerObj.style.width;
		orgLayerHeight = orgLayerObj.style.height;

		orgLayerWidth = Math.floor(orgLayerWidth.replace("px",""));
		orgLayerHeight = Math.floor(orgLayerHeight.replace("px",""));

		// MOVE LAYER TO POSITION
		moveLayerObj = document.all[moveLayerName];
		moveLayerObj.style.width = orgLayerWidth;
		moveLayerObj.style.height = orgLayerHeight;
		moveLayerObj.style.pixelLeft = orgLayerPosX;
		moveLayerObj.style.pixelTop = orgLayerPosY;

		moveLayerFontsize = moveLayerObj.style.fontSize;
		moveLayerFontsize = Math.floor(moveLayerFontsize.replace("px",""));

		moveLayerWidthTot = orgLayerWidth - targetWidth;
		moveLayerHeightTot = orgLayerHeight - targetHeight;

		moveLengthX = targetLayerPosX - orgLayerPosX;
		moveLengthY = targetLayerPosY - orgLayerPosY;

		moveLayerStepX = moveLengthX / frameAmount;
		moveLayerStepY = moveLengthY / frameAmount;

		moveStepW = moveLayerWidthTot / frameAmount;
		moveStepH = moveLayerHeightTot / frameAmount;

		moveFontS = moveLayerFontsize - (moveLayerFontsize / (orgLayerWidth / targetLayerWidth));
		moveFontS = moveFontS / frameAmount;

		moveLayerObj.style.visibility = "";
		moveAnimation(moveLayerName,moveLayerStepX,moveLayerStepY,moveStepW,moveStepH,moveFontS)
	}
	inputForm.submit();
	// alert("SUBMIT");
}

function moveAnimation(inputMove,stepX,stepY,stepW,stepH,fontS) {
	if (document.all) {
		aniLayerName = inputMove;
		frameCount += 1;
	
		newWidth = Math.floor(orgLayerWidth - (stepW * frameCount));
		newHeight = Math.floor(orgLayerHeight - (stepH * frameCount));
		newFontSize = Math.floor(moveLayerFontsize - (fontS * frameCount));
			
		newWidthStr = newWidth + "px";
		newHeightStr = newHeight + "px";
		newFontSizeStr = newFontSize + "px";

		moveLayerObj = document.all[aniLayerName].style;
		moveLayerObj.width = newWidthStr;
		moveLayerObj.height = newHeightStr;
		moveLayerObj.pixelLeft += stepX;
		moveLayerObj.pixelTop += stepY;
		moveLayerObj.fontSize = newFontSizeStr;

		if (frameCount < frameAmount) {
			setTimeout("moveAnimation('"+aniLayerName+"',"+stepX+","+stepY+","+stepW+","+stepH+","+fontS+")",frameSpeed);
		} else {
			resetLayer(aniLayerName);
		}
	}
}

function resetLayer(layerName){
	if (document.all) {
		resetLayerName = layerName;

		resetLayerObj = document.all[resetLayerName].style;
		resetLayerObj.visibility = "hidden";
		resetLayerObj.pixelLeft = 0;
		resetLayerObj.pixelTop = 0;
		resetLayerObj.width = "1px";
		resetLayerObj.height = "1px";
		resetLayerObj.fontSize = moveLayerFontsize + "px";
		
		resetLayerName = "";
		frameCount = 0;
	}
}
