var dWidth;
var dHeight;
var dTop;
var dLeft;
var dStart;
var popupHTML;
var popupMessageHTML;
var dialogProps = "dialogHeight: "+(dHeight+25)+"px; dialogWidth: "+(dWidth+7)+"px; dialogTop: "+(dTop-25)+"px; dialogLeft: "+(dLeft-7)+"px; edge: Raised; center: Yes; help: No; resizable: No; status: No;";

var blnCreatePopup = (window.createPopup) ? true : false; // IE 5.5 
var objPopup;
var popupStandby=true;
var popupTitle;
var headTag = '<head>';
var headDisableImageToolbar = '<meta http-equiv=\"imagetoolbar\" content=\"no\" />';
var headEndTag = '</head>';

if (navigator.appName == 'Microsoft Internet Explorer' ) {
var oPopupMessage					= window.createPopup();
var oPopMessageBody					= oPopupMessage.document.body;
}

if (blnCreatePopup)
{
	oPopMessageBody.style.backgroundColor	= "#65523D";
	oPopMessageBody.style.borderRight		= "solid #000000 1px";
	oPopMessageBody.style.borderBottom		= "solid #000000 1px";
	oPopMessageBody.style.borderTop			= "solid #FFFFFF 1px";
	oPopMessageBody.style.fontFamily		= "verdana";
	oPopMessageBody.style.color				= "#65523D";
}

var url = location.pathname;
var _Root = url.substring(0, url.toLowerCase().indexOf("/ui/") );


function DisableContextMenu()
{
      
}

function ShowUserMessageWithTitle(sMessage, sTitle)
{
	if (navigator.appName == 'Microsoft Internet Explorer' ) 
	{
		var sFullMessage = "<table cellpadding=\"0\" width=\"100%\" height=\"100%\" cellspacing=\"0\" border=\"0\" style=\"border:outset 2px #E4D196;border-top:solid 1px #FFFFFF\">";
		sFullMessage += "<tr valign=\"top\" style=\"padding:4px;\">";
		sFullMessage += "<td style=\"font-weight:bold;padding-left:10px;font-size:13px;color:#FFFFFF\">" + sTitle + "</td>"; 
		sFullMessage += "</tr>";
		sFullMessage += "<tr valign\"top\">";
		sFullMessage += "<td style=\"padding:1;\"><div style=\"padding:4px;font-size:11px;font-weight:bold;height:110px;background-color:#E4D196; border:inset 2px #E4D196 \">"+ sMessage +"</div></td>";
		sFullMessage += "</tr>";
		sFullMessage += "</table>";	
		
		dWidth	= 200;
		dHeight	= 140;
		dTop	= screen.availHeight-dHeight;
		dLeft	= screen.width-dWidth;
		
		// Set message
		if(typeof(sMessage)!='undefined'){
			oPopupMessage.document.body.innerHTML = sFullMessage;	
		}
		
		dStart=0;
		popupInt = window.setInterval("showPopup()",35);
		popupStandby=false;
	}
}

function ShowUserMessage(sMessage) {
    ShowUserMessageWithTitle(sMessage, "");
}

function SendEmailPhoto(PhotoDiscoId, PhotoURL)
{
    var URL = _Root + "/ui/forms/users/photos/SendPhotoEmail.aspx?PhotoDiscoId="+PhotoDiscoId+"&PhotoURL="+PhotoURL;
    var sFeatures = 'height=280,width=420,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes,center=yes,help=no';
    window.open(URL, 'SendEmailPhoto', sFeatures);
}

function SendToCellphone(PhotoURL)
{

	var sFeatures = 'status=no,toolbar=no,menubar=no,location=no';
	//var URL = 'http://mobile.freeway.dk/step2.aspx?image=' + PhotoURL + '&customer=B15F260D-DF71-4A36-BCCC-A3E6B8DCE7EC';
	var URL = 'http://mobile.arto.dk/section/mobileimage/?Customer=B15F260D-DF71-4A36-BCCC-A3E6B8DCE7EC&Image=' + PhotoURL;
	
	window.open( URL,'FreewayMobilePicture', sFeatures );
}

function SendToCellphoneTest(PhotoURL)
{
//FF884FC6-50E1-4802-AB35-8014423247C6
	var path = 'http://data02.media.dkbn.dk/Storage/Discos/834013d1-9755-4350-b46e-9ba5a15938c6/21273/dkbn/632970933604048652.jpg';	
	//window.open('http://crashsite.arto.dk/section/mobileimage/?Customer=B15F260D-DF71-4A36-BCCC-A3E6B8DCE7EC&Image=' + path, 'ArtoMobilePicture', 'status=no,toolbar=no,menubar=no,location=no');
	window.open('http://crashsite.arto.dk/section/mobileimage/?Customer=FF884FC6-50E1-4802-AB35-8014423247C6&Image=' + path, 'ArtoMobilePicture', 'status=no,toolbar=no,menubar=no,location=no');
}

function UpdateUserComment( ParentWindow )
{	
	if (window.showModalDialog) {
			window.showModalDialog(_Root + "/ui/forms/users/photos/EditUserComment.aspx?",window,"dialogHeight: 213px; dialogWidth: 343px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: No; status: No;");
	} 
	else {
		var modalWin = window.open(_Root + '/ui/forms/users/photos/EditUserComment.aspx?','modal', 'height=213,width=343,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes,center=yes');
		modalWin.dialogArguments = window;
		}
}

function SendFlirt(UserID, Username)
{
	/*if (window.showModalDialog)
	{
		win = window.showModalDialog("/ui/forms/users/flirts/SendFlirt.aspx?UserID="+UserID+"&Username="+Username,self,"dialogHeight: 167 px; dialogWidth: 338 px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: no; status: No;");
	}
	else
	{*/
		win = window.open(_Root + "/ui/forms/users/flirts/SendFlirt.aspx?UserID="+UserID+"&Username="+Username,'', 'height=167,width=338,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes,center=yes,help=no');
		//modalWin.dialogArguments = window;
	//}
}

function showPopup(){
	popupStandby=false;
	dStart+=(dHeight/15);
	if (dStart<dHeight){
		oPopupMessage.show((screen.width-dWidth),(screen.availHeight-dStart-1),dWidth,dStart);
	} else {
		window.clearInterval(popupInt);
		window.setTimeout("hidingPopup()",4000);
		oPopupMessage.show((screen.width-dWidth),(screen.availHeight-dHeight-1),dWidth,dHeight);
		popupStandby=true;
	}
}

function hidePopup(){
	popupStandby=false;
	dStart-=(dHeight/15);
	if (dStart>0){
		oPopupMessage.show((screen.width-dWidth),(screen.availHeight-dStart-1),dWidth,dStart);
	} else {
		window.clearInterval(popupInt);
		oPopupMessage.hide();
		popupStandby=true;
	}
}

function hidingPopup(){
	if ((popupStandby)&&(oPopupMessage.isOpen)){dStart=dHeight;
		popupInt = window.setInterval("hidePopup()",35);
		popupStandby=false;
	}
}

function ShowDisclaimer()
{
	var sFeatures = 'width=640, height=700, scrollbars=yes, centerScreen';
	
	window.open(_Root + '/ui/forms/guests/disclaimer.aspx', 'Disclaimer', sFeatures);
}

function ShowPrivacyPolicy() {
    var sFeatures = 'width=640, height=700, scrollbars=yes, centerScreen';

    window.open(_Root + '/ui/forms/guests/privacypolicy.aspx', 'Privacy Policy', sFeatures);
}

function PopConfirmBox(type, title, info)
{
    var sFeatures = 'width=320, height=200, scrollbars=no';
   
   window.open(_Root + '/ui/forms/ConfirmBoxTemplate.aspx?type='+type+'&Title='+title+'&Info='+info , 'DKBN :: Danmarks lækreste community for natteliv!', sFeatures); 
}

function PopPortraitInstructions ()
{
	var winwidth = 500;
	var winheight = 320;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';

	window.open(_Root + '/ui/forms/users/info/portraitinstructions.aspx', '', sFeatures);
}

function ShowSendMessage(lUserID, lMessageID)
{
	var sFeatures = 'width=900, height=460; scrollbars=yes';
	
	window.open(_Root + '/ui/forms/users/mail/composemessage.aspx?UserID='+ lUserID +'&MessageID='+lMessageID, 'SendMail', sFeatures);
}

function ShowDeleteProfilePhoto(lUserID)
{
	var sFeatures = 'width=660, height=460; scrollbars=yes';
	
	window.open(_Root + '/ui/forms/admins/users/DeleteProfilePhoto.aspx?UserID='+ lUserID, 'DeletePP', sFeatures);
}

var showprof = null;
/*
function ShowProfile(lUserID,bIncViewCount)
{
	var winwidth = 790;
	var winheight = 650;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';
	
	if ( showprof != null )
		showprof.close ();
		
	showprof = window.open('/ui/forms/users/showuser.aspx?UserID='+ lUserID +'&Increase='+bIncViewCount, 'Profile', sFeatures);	
}
*/

function ShowProfile(lUserID,bIncViewCount)
{
    ShowProfileTopList(lUserID,bIncViewCount, true)
}

function ShowProfileTopList(lUserID,bIncViewCount,bIgnoreInTopList)
{
	var winwidth = 920;
	var winheight = 665;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';
	
	if ( showprof != null )
		showprof.close ();
    
	var url = _Root + '/ui/forms/users/showuser.aspx?UserID='+ lUserID +'&IgnoreInTopList='+bIgnoreInTopList+'&Increase='+bIncViewCount;

    if(window.name == 'Profile')
    {
        window.location.href = url;
    }
    else
    {
    	showprof = window.open(url, 'Profile', sFeatures);	
    }	
}

function ShowGuestBookV3(lUserID)
{
	var winwidth = 920;
	var winheight = 665;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';
	
	if ( showprof != null )
		showprof.close ();

	var url = _Root + '/ui/forms/users/GuestBook/GuestBookV3.aspx?UserID='+ lUserID;

    if(window.name == 'Profile')
    {
        window.location.href = url;
    }
    else
    {
    	showprof = window.open(url, 'Profile', sFeatures);	
    }	
}

function ShowPhotoUserAlbum(lUserID, lPhotoAlbumId)
{
    ShowPhotoUserAlbumOpenPhoto(lUserID, lPhotoAlbumId, 0);
}

function ShowPhotoUserAlbumOpenPhoto(lUserID, lPhotoAlbumId, lPhotoUserId)
{
	var winwidth = 920;
	var winheight = 665;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';
	
	if ( showprof != null )
		showprof.close ();
    
	var url = _Root + '/ui/forms/users/photos/AlbumPhotos.aspx?UserID='+ lUserID +'&origin=3&PhotoAlbumID=' + lPhotoAlbumId;

    if(lPhotoUserId != 0)
    {
        url += '&PhotoUserId=' + lPhotoUserId;
    }
    
    if(window.name == 'Profile')
    {
        window.location.href = url;
    }
    else
    {
    	showprof = window.open(url, 'Profile', sFeatures);	
    }	

}

function ShowEditIndex(lUserID)
{
	var winwidth = 802;
	var winheight = 650;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';
	
	if ( showprof != null )
		showprof.close ();
		
	showprof = window.open(_Root + '/ui/forms/admins/users/EditPersonalDiscoPhotos.aspx?UserID='+ lUserID, 'Profile', sFeatures);	
}

function ShowEditAlbumPhotos(lUserID)
{
	var winwidth = 802;
	var winheight = 650;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';
	
	if ( showprof != null )
		showprof.close ();
		
	showprof = window.open(_Root + '/ui/forms/admins/users/EditPhotoAlbums.aspx?UserID='+ lUserID, 'Profile', sFeatures);	
}

function ShowDeleteFavouritePhotos(lUserID)
{
	var winwidth = 802;
	var winheight = 650;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';
	
	if ( showprof != null )
		showprof.close ();
		
	showprof = window.open(_Root + '/ui/forms/admins/users/DeleteFavouritePhotoDiscos.aspx?UserID='+ lUserID, 'Profile', sFeatures);	
}

function ShowRemoveFavouritePhotoTags(lUserID)
{
	var winwidth = 802;
	var winheight = 650;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';
	
	if ( showprof != null )
		showprof.close ();
		
	showprof = window.open(_Root + '/ui/forms/admins/users/RemoveFromFavourites.aspx?UserID='+ lUserID, 'Profile', sFeatures);	
}

function ShowCropAlbumPhotos(lUserID)
{
	var winwidth = 802;
	var winheight = 650;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+'; left='+ofsX.toString()+', top='+ofsY.toString ()+', scrollbars=yes';
	
	if ( showprof != null )
		showprof.close ();
		
	showprof = window.open(_Root + '/ui/forms/admins/users/CropPhotoAlbums.aspx?UserID='+ lUserID, 'Profile', sFeatures);	
}


function ShowCropPhoto ( lUserShownID, lPhotoUserID, sImageUrl, winwidth, winheight )
{
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}

	var sFeatures = 'left='+ofsX+', top='+ofsY+', width='+winwidth+', height='+winheight+', status=no, resizable=no, scrollbars=no';
	
	window.open(_Root + '/ui/forms/admins/users/CropUserPhotoV2.aspx?OriginalUrl=' + sImageUrl + '&PhotoUserID=' + lPhotoUserID + '&UserShownID=' + lUserShownID, '', sFeatures);
}

function ShowSessionPhoto(lPhotoID)
{
	//var sFeatures = 'width=800, height=560, status=no, resizable=no, scrollbars=no, location=no, titlebar=yes';
	//var sFeatures = 'width=960, height=680, status=no, resizable=no, scrollbars=no, location=no, titlebar=yes';
	var sFeatures = 'width=1020, height=700, status=no, resizable=no, scrollbars=yes, location=no, titlebar=yes';
	
	window.open(_Root + '/ui/forms/users/photos/ShowSessionPhoto.aspx?PhotoDiscoID='+ lPhotoID, '', sFeatures);	
}

function ShowSessionPhotoDiscoComment(lPhotoID, lPhotoDiscoCommentId)
{
	//var sFeatures = 'width=800, height=560, status=no, resizable=no, scrollbars=no, location=no, titlebar=yes';
	//var sFeatures = 'width=960, height=680, status=no, resizable=no, scrollbars=no, location=no, titlebar=yes';
	var sFeatures = 'width=1020, height=700, status=no, resizable=no, scrollbars=yes, location=no, titlebar=yes';
	
	window.open(_Root + '/ui/forms/users/photos/ShowSessionPhoto.aspx?PhotoDiscoID='+ lPhotoID + '&PhotoDiscoCommentId=' + lPhotoDiscoCommentId, '', sFeatures);	
}

function ShowLookPhoto(iVoteCandidateID, bIsMale)
{
	//var sFeatures = 'width=800, height=560, status=no, resizable=no, scrollbars=no, location=no, titlebar=yes';
	//var sFeatures = 'width=960, height=680, status=no, resizable=no, scrollbars=no, location=no, titlebar=yes';
	var sFeatures = 'width=650, height=700, status=no, resizable=no, scrollbars=no, location=no, titlebar=yes';
	
	window.open(_Root + '/ui/forms/users/look/ShowLookPhoto.aspx?VoteCandidateID='+ iVoteCandidateID + '&IsMale=' + bIsMale + '&IsArchive=false', '', sFeatures);	
}

function ShowLookArchivePhoto(iVoteCandidateID, bIsMale, sWeek, sYear)
{
	var sFeatures = 'width=650, height=700, status=no, resizable=no, scrollbars=no, location=no, titlebar=yes';
	window.open(_Root + '/ui/forms/users/look/ShowLookPhoto.aspx?VoteCandidateID='+ iVoteCandidateID + '&IsMale=' + bIsMale + '&IsArchive=true' + '&WeekNr=' + sWeek + '&Year=' + sYear, '', sFeatures);	
}


function ShowBadValidatedPhotoDiscos(lPhotoSessionRatingID)
{
	//var sFeatures = 'width=800, height=560, status=no, resizable=no, scrollbars=yes';
	var sFeatures = 'width=980, height=680, status=no, resizable=no, scrollbars=yes';
	
	window.open(_Root + '/ui/forms/photographers/BadValidatedPhotoDiscos.aspx?PhotoSessionRatingID='+ lPhotoSessionRatingID, '', sFeatures);
}

function ShowSessionPhotoNoViewCount(lPhotoID)
{
	//var sFeatures = 'width=800, height=560, status=no, resizable=no, scrollbars=no';
	var sFeatures = 'width=1000, height=720, status=no, resizable=no, scrollbars=yes';
	
	window.open(_Root + '/ui/forms/users/photos/ShowSessionPhoto.aspx?PhotoDiscoID='+ lPhotoID+ '&NoViewCount='+true, '', sFeatures);	
}

function PopAlbumPhoto ( url )
{
	var sFeatures = 'width=920, height=800, status=no, resizable=no, scrollbars=yes';
	
	window.open( url, 'Profile', sFeatures);	
}


function PopAlbumPhotoLB ( url )
{
	var sFeatures = 'width=840, height=720, status=no, resizable=no, scrollbars=yes';
	
	window.open( url, '', sFeatures);	
}

function PopShowUserUrl ( url )
{
	var winwidth = 920;
	var winheight = 665;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'width='+winwidth.toString()+', height='+winheight.toString()+', left='+ofsX.toString()+', top='+ofsY.toString ()+', resizable=no, scrollbars=yes';
	
	window.open( url, '', sFeatures);	
}

function ShowCreateCandidate(lPhotoID)
{
	var sFeatures = 'width=1000, height=600';
	
	window.open(_Root + '/ui/forms/admins/look/CreateLookCandidate.aspx?PhotoDiscoID='+ lPhotoID, '', sFeatures);	
}

/*
function ShowPhoto( sImageUrl, iWidth, iHeight)
{

	var sFeatures ='width='+ iWidth +', height=' + iHeight;
	
	winObj = window.open('', sFeatures);
	
	winObj.document.writeln( '<Html><Body><img src=' + sImageUrl + '></Body></Html>' );
	winObj.document.close();
}
*/
function ShowPhotoAlbum(lPhotoAlbumID)
{
}

function ShowPhotoAlbums(lUserID)
{
	document.location.href = _Root + '/ui/forms/users/photos/PhotoAlbums.aspx?UserID='+ lUserID;
}

function ShowFavouritePhotos(lUserID)
{
	document.location.href = _Root + '/ui/forms/users/photos/FavouriteDiscoPhotos.aspx?UserID='+ lUserID;
}

function ShowPersonalPhotos (lUserID)
{
	document.location.href = _Root + '/ui/forms/users/photos/PersonalDiscoPhotos.aspx?UserID='+ lUserID;
}

function ShowFavouriteDiscoPhoto( lUserID, lPhotoDiscoFavouriteID )
{
	//var sFeatures = 'width=800, height=560, status=yes';
	//var sFeatures = 'width=980, height=680, status=yes';
	var sFeatures = 'width=1020, height=780, status=yes, scrollbars=yes';
	
	window.open(_Root + '/ui/forms/users/photos/ShowFavouriteDiscoPhoto.aspx?Mode=2&PhotoDiscoFavouriteID=' + lPhotoDiscoFavouriteID + '&FavouriteUserID=' + lUserID, '', sFeatures);
}

function LoginAsDisco( lDiscoID )
{
	var sFeatures = 'width=900, height=600, status=yes resizable=yes scrollbars=yes';
	
	window.open(_Root + '/ui/forms/admins/discos/autologin.aspx?DiscoID=' + lDiscoID, '', sFeatures);
}


function ShowUserPhoto ( lPhotoUserID, winwidth, winheight )
{
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}
	
	var sFeatures = 'left='+ofsX.toString()+', top='+ofsY.toString ()+', width='+winwidth+', height='+winheight+', status=no, resizable=yes, scrollbars=no';
	
	window.open(_Root + '/ui/forms/users/photos/EditUserPhoto.aspx?PhotoUserID=' + lPhotoUserID, 'UserPhoto', sFeatures);
}

function ShowPhoto ( alertUrl, imgurl, winwidth, winheight )
{
    var windowPopFunc = "function PopCustomWindow(url, width, height, centerScreen, resizable, showStatusBar, scrollbars) { var sFeatures = 'width='+width+', height='+height+','; sFeatures += (scrollbars == true) ? 'scrollbars=yes,' : 'scrollbars=no,';sFeatures +=(showStatusBar == true) ? 'status=yes,' : 'status=no,';sFeatures += (resizable == true) ?  'resizable=yes,' : 'resizable=no,';if(centerScreen == true){var ofsX = (screen.width - width) / 2;var ofsY = (screen.height - height) / 2;if ( ofsX < 0 )ofsX = 0;if ( ofsY < 0 )	        ofsY = 0;sFeatures += 'left='+ofsX+', top='+ofsY+';';}window.open(url, \"popwindow\", sFeatures ); }";
       
     
    var pop = "PopCustomWindow('" +alertUrl + "' , 200, 80, true, false, false, false);";
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}

	var sFeatures = 'left='+ofsX.toString()+', top='+ofsY.toString ()+', width='+winwidth+', height='+winheight+', status=no, resizable=no, scrollbars=no';
	
	var headerTag;
	var mozDisableRightClick = " <script type=\"text/javascript\">"+windowPopFunc+"document.oncontextmenu = function(){ "+pop+"} ;</script>";
	
	var disableRightClick = "<script type=\"text/javascript\">"+windowPopFunc+"function right(e) { if(navigator.appName == \'Microsoft Internet Explorer\' &&  (event.button == 2 || event.button == 3)) { "+pop+" ;} else return true; } document.onmousedown=right;document.onmouseup=right; if (document.layers) window.captureEvents(Event.MOUSEDOWN);if (document.layers)window.captureEvents(Event.MOUSEUP);window.onmousedown=right;window.onmouseup=right;DisableContextMenu();</script>";
	
      if( navigator.appName == 'Microsoft Internet Explorer') {
        headerTag = headTag + headDisableImageToolbar + disableRightClick + headEndTag;
      }   else   {
        headerTag = headTag + mozDisableRightClick + headEndTag;
     }
        
    //navigator.appName == 'Netscape' && 

    
	win = window.open ( '', 'UserPhoto', sFeatures );
	win.document.open ();
	win.document.writeln ("<html>" + headerTag + "<body TopMargin=\"0\" LeftMargin=\"0\"><img style=\"cursor: pointer;\" onClick='javascript:window.close();' src='"+imgurl+"'></body></html>");
	
	//win.document.close ();
}

function ShowPhotoSimple( sImageUrl, iWidth, iHeight)
{   
    var ofsX = (screen.width - iWidth) / 2;
	var ofsY = (screen.height - iHeight) / 2;
	        	
	if ( ofsX < 0 )
	    ofsX = 0;
	    
    if ( ofsY < 0 )
	    ofsY = 0;
	
	var sFeatures ='width='+ iWidth +', height=' + iHeight;    	    
    sFeatures += ',left='+ofsX+', top='+ofsY+',';
    sFeatures += ',scrollbars=yes;';
   			
	winObj = window.open('','PhotoSimple', sFeatures);
	winObj.document.open();
		
	winObj.document.writeln( "<html><body style=\"margin: 0px;\"><img style=\"cursor: pointer;\" onClick='javascript:window.close();' src='"+sImageUrl+"'></img></body></html>");	
	winObj.document.close();
}


function ShowEditDiscoPhoto ( lPhotoDiscoID, winwidth, winheight )
{
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}

	var sFeatures = 'left='+ofsX+', top='+ofsY+', width='+winwidth+', height='+winheight+', status=no, resizable=no, scrollbars=no';
	
	window.open(_Root + '/ui/forms/users/photos/EditDiscoPhoto.aspx?PhotoDiscoID=' + lPhotoDiscoID, '', sFeatures);
}

function ShowCreatePortrait ( sImageUrl, winwidth, winheight )
{
    ShowCreatePortraitWindow( sImageUrl, winwidth, winheight, true );
}

function ShowCreatePortraitWindow ( sImageUrl, winwidth, winheight, showInNewWindow )
{
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	
	if ( ofsX < 0 )
	{
		ofsX = 0;
	}
	if ( ofsY < 0 )
	{
		ofsY = 0;
	}

	var sFeatures = 'left='+ofsX+', top='+ofsY+', width='+winwidth+', height='+winheight+', status=no, resizable=no, scrollbars=no';

	_Root = url.substring(0, url.toLowerCase().replace("//u", "u").indexOf("/ui/") );
	
	var redirectUrl = _Root + '/ui/forms/users/photos/CreatePortrait.aspx?OriginalUrl=' + sImageUrl;

	if(showInNewWindow == true)
	{
    	window.open(redirectUrl, '', sFeatures);
	}
	else
	{
        window.location.href = redirectUrl;
	}
}

function ShowPersonalUserPhoto(lUserID, lPhotoTagID)
{
	//var sFeatures = 'width=800, height=560, status=false';
	//var sFeatures = 'width=960, height=680, status=false';
	var sFeatures = 'width=1000, height=780, status=false,scrollbars=yes';

	window.open(_Root + '/ui/forms/users/photos/ShowPersonalUserPhoto.aspx?Mode=4&UserID=' + lUserID + '&PhotoTagID=' + lPhotoTagID, '', sFeatures);
}

function ShowPersonalDiscoPhoto( lUserID, lPhotoTagID )
{
	//var sFeatures = 'width=800, height=560, status=false';
	//var sFeatures = 'width=960, height=680, status=false';
	var sFeatures = 'width=1000, height=780, status=false,scrollbars=yes';

	window.open(_Root + '/ui/forms/users/photos/ShowPersonalDiscoPhoto.aspx?Mode=1&UserID=' + lUserID + '&PhotoTagID=' + lPhotoTagID, '', sFeatures);
}

function ShowAddPhotographerToRating( lPhotoSessionPhotographerID, lPhotoSessionID )
{
	var sFeatures = 'width=520, height=400, status=false';
	
	window.open(_Root + '/ui/forms/admins/photographers/AddPhotographerToRating.aspx?PhotoSessionPhotographerID=' + lPhotoSessionPhotographerID + '&PhotoSessionID=' + lPhotoSessionID, '', sFeatures);
}

function ShowAddNote( lPhotoSessionPhotographerID, lPhotoSessionPhotographerNoteID )
{
	var sFeatures = 'width=350, height=250, status=false';
	
	window.open(_Root + '/ui/forms/admins/photographers/AddPhotographerSessionNote.aspx?PhotoSessionPhotographerID=' + lPhotoSessionPhotographerID + '&NoteID=' + lPhotoSessionPhotographerNoteID, '', sFeatures);
}

function ShowSomeUrl( Url )
{
	var sFeatures = 'width=680, height=500, status=yes, scrollbars=yes, resizable=no';
	
	window.open( Url, '', sFeatures);
}

function ShowSomeUrlLarge( Url )
{
	var sFeatures = 'width=820, height=600, status=yes, scrollbars=yes, resizable=no';
	
	window.open( Url, '', sFeatures);
}

function ShowVideoPopup( Url )
{
	var sFeatures = 'width=860, height=590, status=yes, scrollbars=yes, resizable=no';
	
	window.open( Url, '', sFeatures);
}

function ShowActivateCode( Url )
{
	var sFeatures = 'width=680, height=500, status=yes, scrollbars=no resizable=no';
	
	window.open( Url, '', sFeatures);
}

function ClosePopupOnNotLoggedIn()
{
	window.opener.location.href = _Root + '/UI/Forms/Guests/Frontpage.aspx?Msg=SessionEnded';
	window.close();
}

function ClosePopup()
{
	window.opener.location.href = window.opener.location.href;
	window.close();
}

function ShowEventRegistrations(lDiscoEventID)
{
	window.opener.location.href = _Root + '/UI/Forms/Users/Events/EventRegistrations.aspx?DiscoEventID=' + lDiscoEventID;
	window.opener.focus();
}

function ShowDiscoNightRegistrations(lDiscoNightID)
{
	window.opener.location.href = _Root + '/UI/Forms/Users/Calendar/DiscoNightRegistrations.aspx?DiscoNightID=' + lDiscoNightID;
	window.opener.focus();
}

function ShowUserNightRegistrations(lUserNightID)
{
	window.opener.location.href = _Root + '/UI/Forms/Users/Calendar/UserNightRegistrations.aspx?UserNightID=' + lUserNightID;
	window.opener.focus();
}

function ShowUserDiscoPhotos(lUserID)
{
	var sURL = _Root + '/ui/forms/users/photos/UserPhotos.aspx?UserID='+ lUserID;
	if (this.opener != null)
	{
		location.href = sURL;	
	}
	else
	{
		var sFeatures = 'width=780, height=700';

		window.open(sURL, '', sFeatures);		
	}
}

function ShowDisco(lDiscoID, sMode)
{
	var sURL = _Root + '/ui/forms/users/discos/ShowDisco.aspx?DiscoID='+ lDiscoID +'&Mode='+ sMode;
	if (this.opener != null)
	{
		window.opener.location.href = sURL;	
	}
	else
	{
		location.href = sURL;
	}
}

function ShowDiscoFocus(lDiscoID, sMode, lModeID)
{
	var sURL = _Root + '/ui/forms/users/discos/ShowDisco.aspx?DiscoID='+ lDiscoID +'&Mode='+ sMode + '&ModeID=' + lModeID + '#aevent' + lModeID;
	if (this.opener != null)
	{
		window.opener.location.href = sURL;	
		window.opener.focus();	
	}
	else
	{
		location.href = sURL;
	}
}

function ShowMailView ( URL )
{
	if (this.opener != null)
	{
		location.href = URL;	
	}
	else
	{
		var sFeatures = 'width=970, height=520, scrollbars=yes';

		window.open( URL, '', sFeatures);
	}
}

function ShowSupportView( URL )
{
	var sFeatures = 'width=510, height=450, status=yes, resizable=no, scrollbars=yes';

	window.open( URL, '', sFeatures);	
}

function ShowFriendApplication( URL )
{
	var sFeatures = 'width=320, height=120, status=yes, resizable=no, scrollbars=no';

    var ofsX = (screen.width - 320) / 2;
    var ofsY = (screen.height - 120) / 2;
        	
    if ( ofsX < 0 )
        ofsX = 0;
    
    if ( ofsY < 0 )
        ofsY = 0;
    	    
    sFeatures += ', left='+ofsX+', top='+ofsY+';';

	window.open( URL, '', sFeatures);	
}

var imageobject = null;
var trycount = 0;

function ShowUrlFocus ( URL )
{
	window.opener.location.href=URL;
	window.opener.focus();
}

function ShowEventFlyer ( ImgURL )
{
    ShowEventFlyerOnLoad( ImgURL, "");
}

function ShowEventFlyerOnLoad ( ImgURL , Title)
{
    popupTitle = Title;
    
	imageobject = new Image ();
	imageobject.onload = ResizeEventFlyerWindow;
	imageobject.src = ImgURL;
}

function ResizeEventFlyerWindow()
{
	var WinEvent;

	var winwidth = this.width;
	var winheight = this.height;
	
	var ofsX = (screen.width - winwidth) / 2;
	var ofsY = (screen.height - winheight) / 2;
	var sFeatures = 'left='+ofsX.toString()+', top='+ofsY.toString ()+',resizable=no, status=no, scrollbars=no';

	WinEvent = window.open( '', '', sFeatures );
	WinEvent.document.write ( "<html><head><meta http-equiv=\"imagetoolbar\" content=\"no\" /></head><body TopMargin=\"0\" LeftMargin=\"0\"><img style=\"cursor: pointer;\" onClick='javascript:window.close();' src='"+this.src+"' name='imgItemPic'></body></html>" );
    WinEvent.document.title = popupTitle;
	WinEvent.resizeBy(winwidth-WinEvent.document.body.clientWidth,winheight-WinEvent.document.body.clientHeight);
	WinEvent.document.close ();
	
}

function showValidationNote(text)
 {
	var url = _Root + "/ui/forms/photographers/ShowValidationText.aspx?text="+text;		
	var sFeatures = "width=400, height=250; scrollbars=yes";
	window.open(url,'',sFeatures);
}

function showSomeText(text, head)
 {
	var url = _Root + "/ui/forms/users/ShowText.aspx?text="+text + "&head=" + head;		
	var sFeatures = "width=400, height=250; scrollbars=yes";
	window.open(url,'',sFeatures);
}

function ok(FriendApplicationID, status)
 {
	var url=_Root + "/ui/forms/users/friends/FAHandler.aspx?faID="+FriendApplicationID+"&Status="+status;		
	var sFeatures = "width=400, height=135; scrollbars=yes";
	window.open(url,'',sFeatures);
}

function ok2(NightDateInvitationID, status)
{
	var url=_Root + "/ui/forms/users/calendar/NDHandler.aspx?nID="+NightDateInvitationID+"&S="+status;
	var sFeatures = "width=400, height=135; scrollbars=yes";
	window.open(url,'',sFeatures);
}

function okDi(DiscoInvitationID)
{
	var url=_Root + "/ui/forms/users/calendar/DIHandler.aspx?DiID="+DiscoInvitationID;
	var sFeatures = "width=400, height=135; scrollbars=yes";
	window.open(url,'',sFeatures);
}

function df(UserID, FriendUserID)
{
	var url=_Root + "/ui/forms/users/calendar/FDel.aspx?uID="+UserID+"&fID="+FriendUserID;
	var sFeatures = "width=400, height=135; scrollbars=yes";
	window.open(url,'',sFeatures);
}

function UpdateParentAndMinimize(url)
{
    // Redirect Parent
   opener.window.location.href = url;      
    
   // Minimize current window
    window.blur(); 
}

function UpdateParentAndClose(url)
{
    // Redirect Parent
   opener.window.location.href = url;      
    
   // Minimize current window
    window.close(); 
}

function PopCustomWindow(url, width, height, centerScreen, resizable, showStatusBar, scrollbars)
{    
    var sFeatures = 'width='+width+', height='+height+',';
    
    sFeatures += (scrollbars == true) ? 'scrollbars=yes,' : 'scrollbars=no,' ;    
    sFeatures += (showStatusBar == true) ? 'status=yes,' : 'status=no,'; 
    sFeatures += (resizable == true) ?  'resizable=yes,' : 'resizable=no,';
        
    if(centerScreen == true)
    {    
        var ofsX = (screen.width - width) / 2;
	    var ofsY = (screen.height - height) / 2;
	        	
	    if ( ofsX < 0 )
	        ofsX = 0;
	    
	    if ( ofsY < 0 )
	        ofsY = 0;
	    	    
	    sFeatures += 'left='+ofsX+', top='+ofsY+';';
	}
	
	//alert(sFeatures);
	window.open(url, "popwindow", sFeatures );
	// window.open(_Root + '/ui/forms/users/photos/CreatePortrait.aspx?OriginalUrl=' + sImageUrl, '', sFeatures);   
    // window.open( url , /*'DKBN :: Danmarks lækreste community for natteliv!'*/'cusWin', sFeatures); 
}

// Translation methods

var trans_popup = null;

function PopTranslationWindow(url) {
   if ((trans_popup == null) || (trans_popup.closed))
	{
	    var sFeatures = 'width=640,height=480,scrollbars=no,titlebar=no,resizable=no';
         trans_popup = window.open(url, '', sFeatures);     
	}
	else
	{
		trans_popup.document.location.href = url;
	}
}

function ShowBlockings(lUserID) {
var sFeatures = 'width=600, height=175; scrollbars=no';
	
	window.open(_Root + '/ui/forms/admins/users/Blockings.aspx?UserID='+ lUserID, 'Blockings', sFeatures);
}

// HACK FOR NORDEA CAMPAIGN IN SHOUTCAST

function NordeaHack()
{
    window.open('http://www.nordea.dk');
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}



function toggleDiv(divname)
{
    if(document.getElementById(divname).style.display == 'none')
    {
      showdiv(divname);
    }
    else
    {
      hidediv(divname);
    }
}

function hidediv(divname) {
    if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById(divname).style.visibility = 'hidden';
    document.getElementById(divname).style.display = 'none';
    }
}

function showdiv(divname) {
    if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById(divname).style.visibility = 'visible';
    document.getElementById(divname).style.display = 'inline';
    }
}
