PositionX = 100;
PositionY = 100;
defaultWidth  = 800;
defaultHeight = 600;
var AutoClose = true;


if (parseInt(navigator.appVersion.charAt(0))>=4){
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}

var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function zoomWin(imageURL,imageTitle){
	if (isNN){
		imgWin=window.open('about:blank','',optNN);
	}
	if (isIE){
		imgWin=window.open('about:blank','',optIE);
	}
	
	with (imgWin.document){
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;cursor:url("../cursor/cd.cur");}</style>');writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
		writeln('width=100-(document.body.clientWidth-document.images[0].width);');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
		writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
		if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
		else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
		close();		
	}
}

function popLayer(content,title) {
	var pLayer = document.getElementById("popLayer");
	var pTitle = document.getElementById("popTitle");
	var pContent = document.getElementById("popContent");
	var newLeft = getOffSetLeft("container") + (getOffSetWidth("container") / 2) - (350 / 2);
							
	if (title!='') {
		pTitle.innerHTML = title;
		pTitle.style.display = "block"; 
	}
	else {
		pTitle.style.display = "none";
	}
	
	if (content!='') {
		pContent.innerHTML = content;
		pContent.style.display = "block"; 
	}
	else {
		pContent.style.display = "none";
	}
	
	if (pLayer.style.display == "block") {
		pLayer.style.display = "none";
		return false;
 	}
	
	
	pLayer.style.left = newLeft;
	pLayer.style.top = 150;		
	pLayer.style.display = "block";
}

function zoomImg(imgUrl,imgTitle) {
	var zImg = document.getElementById("zoomImg");
	var zLayer = document.getElementById("zoomLayer");
	var zTitle = document.getElementById("zoomLayerTitle");
	var newLeft = getOffSetLeft("container") + (getOffSetWidth("container") / 2) - (getImgWidth(imgUrl) / 2);
							
	if (imgTitle!='') {
		zTitle.innerHTML = imgTitle;
		zTitle.style.display = "block"; 
	}
	else {
		zTitle.style.display = "none";
	}
	
	if (zLayer.style.display == "block") {
		zLayer.style.display = "none";
		return false;
 	}
	
	zImg.src = imgUrl;
	zLayer.style.left = newLeft;
	zLayer.style.top = 150;		
	zLayer.style.display = "block";
}

function zoomLayer(imgUrl,imgTitle) {
	var zImg = document.getElementById("zoomImg");
	var zLayer = document.getElementById("zoomLayer");
	var zTitle = document.getElementById("zoomLayerTitle");
	//var newLeft = getOffSetLeft("container") + (getOffSetWidth("container") / 2) - (getImgWidth(imgUrl) / 2);
	var newLeft = 150;
							
	if (imgTitle!='') {
		zTitle.innerHTML = imgTitle;
		zTitle.style.display = "block"; 
	}
	else {
		zTitle.style.display = "none";
	}
	
	if (zLayer.style.display == "block") {
		zLayer.style.display = "none";
		return false;
 	}
	
	zImg.src = imgUrl;
	zLayer.style.left = newLeft;
	zLayer.style.top = 150;		
	zLayer.style.display = "block";
}

function closeLayer(element) {
	document.getElementById("zoomLayer").style.display = "none";
	document.getElementById("filterLayer").style.display = "none";
}

	
function getOffSetWidth(id) {
	var width = document.getElementById(id).offsetWidth;
	return width;
}

function getOffSetHeight(id) {
	var height = document.getElementById(id).offsetWidth;
	return height;
}

function getOffSetLeft(id) {
	var left = document.getElementById(id).offsetLeft;
	return left;
}

function getOffSetTop(id) {
	var top = document.getElementById(id).offsetTop;
	return top;
}

function getImgWidth(path) {
	var newImg = new Image();
	newImg.src = path;
	return newImg.width;
}

function getImgHeight(path) {
	var newImg = new Image();
	newImg.src = path;
	return newImg.height;
}

function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
  return h ? h : 0;
}

/*function subscribe(email)
{	
	var url = 'addtocart.asp?id='+id+'&number='+num+'&productname='+escape(productname)+'&btnAction=add';
	//document.location.href = 'addtocart.asp?id='+id+'&number='+num+'&productname='+escape(productname)+'&btnAction=add';
	window.frames['shopCartFrame'].location = url;
	
	if(useIframe=="true")
	{
		setTimeout("showLayer('shopCartFrameContainer')",1000); 
		setTimeout("hideLayer('shopCartFrameContainer')",4000);
	}
	else
	{
		var content;
		content = ''+num+' stk. '+productname+' er blevet tilføjet din bestillingsliste<br><br><input type="button" class="knap" value="Ok" onclick="document.getElementById(\'addedProduct\').style.display=\'none\';">';
		document.getElementById("addedProduct").innerHTML = content;
		document.getElementById("addedProduct").style.display="block";
		document.getElementById('num_'+i).style.border = "#A9A9A9 solid 1px";
		//document.all('num_'+i).value = '';
		//setTimeout("hideLayer('addedProduct')",2000);
	}
}	*/	

function subscribe(action) {
	ajaxCall("/ajax/subscribe.asp?e="+document.getElementById("pstrEmail").value+"&a="+action);
}	

function ajaxCall(url) {
	var xmlHttp;
	try {  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}
	catch (e) {  
		// Internet Explorer  
		try {    
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
		}
		catch (e) {    
			try
			{      
	 			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
			}
			catch (e) {      
				alert("Your browser does not support AJAX!");      
				return false;      
			}    
		}  	
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById("subscribeLabel").innerHTML=xmlHttp.responseText;
			//document.getElementById("template").height;
			//displayLightbox(w, h);
			document.getElementById("subscribeLabel").style.display='block';

	 	}
	}
		xmlHttp.open("GET",url,true);
		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=iso-8859-9");
		
		xmlHttp.send(null); 
}

var canSubmit=true;

function moveUp(url, id, itemId, sequence){
	if(!canSubmit)return;
	canSubmit=false;
	pageUrl = "" + url + "?action=move&id=" + id + "&itemid=" + itemId + "&seq=" + sequence + "&dir=up";
	//document.location = pageUrl;
	document.forms[0].action = pageUrl;
	document.forms[0].pstrIsMove.value = "move";
	document.forms[0].submit();
	setTimeout('canSubmit=true;',2000);			
}

function moveDown(url, id, itemId, sequence){
	if(!canSubmit)return;
	canSubmit=false;
	pageUrl = "" + url + "?action=move&id=" + id + "&itemid=" + itemId + "&seq=" + sequence + "&dir=down";
	//pageUrl = "" + url + "?action=move&pKey=CareerId&pKeyId=" + imageId + "&sequence=" + sequence + "&dir=down";
	//pageUrl = "CareerNewEdit.asp?ToDo=Sort&PrimaryKey=CareerId&PrimaryKeyId=" + CareerId + "&Sequence=" + Sequence + "&Direction=Down";
	//document.location = pageUrl;
	document.forms[0].action = pageUrl;
	document.forms[0].pstrIsMove.value = "move";
	document.forms[0].submit();
	setTimeout('canSubmit=true;',2000);
}



