
function closepopup() {
	var dv = document.getElementById("dvpopup");
	var outer = document.getElementById("dvmask");
	dv.style.display = outer.style.display = "none";
	
	var ifcontent = document.getElementById("ifcontent");
	ifcontent.src = "";
}

function showpopup(url) {
	var ifcontent = document.getElementById("ifcontent");
	//scr = getScrollXY();
	ifcontent.src = url;
	var mask = document.getElementById("dvmask");
	var outer = document.getElementById("dvouter");
	var docY = getWindowHeight() / 2 - 103;
	
	if(navigator.userAgent.indexOf("Firefox")!=-1)
	{
	    
	    docY = docY + 19;
	}
	
	if(navigator.userAgent.indexOf("Safari")!=-1)
	{
	    
	    docY = docY + 19;
	}
	
	var docX = getWindowWidth() / 2 + 84;
	outer.style.top = docY + "px";
	outer.style.left = docX + "px";
	mask.style.width = getDocumentWidth();
	mask.style.height = getDocumentHeight();
	mask.style.display = "";
	
	/*var dv = document.getElementById("dvpopup");
	dv.style.width = getDocumentWidth();
	dv.style.height = getDocumentHeight();
	dv.style.display = "";*/
}

function closeparrentpopup() {
	var flag = true;
	var dv = parent.document.getElementById("dvpopup");
	var outer = parent.document.getElementById("dvmask");
	dv.style.display = outer.style.display = "none";
	
	var ifcontent = parent.document.getElementById("ifcontent");
	ifcontent.src = "";
	
	return true;
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
function getWindowHeight(){
	return (document.body.clientHeight || document.documentElement.clientHeight || window.innerHeight || 0);
}
function getWindowWidth(){
	return (document.body.clientWidth || document.documentElement.clientWidth || window.innerWidth || 0);
}
function getDocumentWidth(){
	return Math.max(document.body.scrollWidth, getWindowWidth());
}
function getDocumentHeight(){
	return Math.max(document.body.scrollHeight, getWindowHeight());
}	
function GetEstBoundary(base, child, pos, padding) {
	
	var scroll = getScrollXY();
	var basetop = getElementTopPosition(base);
	var baseleft = getElementLeftPosition(base);
	var basewidth = base.clientWidth;
	var baseheight = base.clientHeight;
	var calloutheight =  child.clientHeight - 10;
	var calloutwidth =  child.clientWidth - 10;
	
	//alert ("basetop: "+basetop+", baseleft: "+baseleft+", basewidth: "+basewidth+", baseheight: "+baseheight+", height: "+calloutheight+", width: "+calloutwidth);

	var top = basetop;
	var left = baseleft;
	switch (pos) {
		case 1:	top = basetop - padding - calloutheight; break;
		case 2: left = baseleft + basewidth + padding; break;
		case 3: top = basetop + baseheight + padding; break;
		case 4: left = baseleft - padding - calloutwidth; break;
		case 5:
			top = basetop + (baseheight / 2) - (calloutheight / 2);
			left = baseleft + (basewidth / 2) - (calloutwidth / 2);
			break;
		case 6:
			top = scroll[1] + (getWindowHeight() / 2) - (calloutheight / 2); 
			left = scroll[0] + (getWindowWidth() / 2) - (calloutwidth / 2);
			break;
	}
	return [top , left, calloutheight, calloutwidth];
}
// 0: on screen
// 2^1: top
// 2^2: right
// 2^3: bottom
// 2^4: left
function IsOffScreen(boundary) {
	
	var scroll = getScrollXY();
	var top = boundary[0];
	var left = boundary[1];
	var height = boundary[2];
	var width = boundary[3];
	var result = 0;
	
	if (top < scroll[1]) result += 2;
	if (left + width > scroll[0] + getWindowWidth()) result += 4;
	if (top + height > scroll[1] + getWindowHeight()) result += 8;
	if (left < scroll[0]) result += 16;
	
	return result;
}
function ForceOnScreen(boundary) {
	
	var scroll = getScrollXY();
	var top = boundary[0];
	var left = boundary[1];
	var height = boundary[2];
	var width = boundary[3];
	if (top + height > scroll[1] + getWindowHeight())
		top -= top + height - (scroll[1] + getWindowHeight()) + 10;
	top = Math.max(scroll[1], top);
	
	if (left + width > scroll[0] + getWindowWidth())
		left -= left + width - (scroll[0] + getWindowWidth()) + 10;
	left = Math.max(scroll[0], left);
	
	return [top , left, height, width];
}
function SetPosition(element, boundary) {
	element.style.top = boundary[0];
	element.style.left = boundary[1];
}

//===============================================
function confirmdelete(type, id) {
	if (!confirm('Do you want to delete selected item?'))
		return;
		
	if (type == "album") {
		document.location = "deletealbum.php?albumid=" + id;
	}
	else if (type == "photo") {
		document.location = "deletephoto.php?photoid=" + id;
	}
	else if (type == "video") {
		document.location = "deletevideo.php?videoid=" + id;
	}
	else if (type == "playlist") {
		document.location = "deleteplaylist.php?playlistid=" + id;
	}
	else if (type == "event") {
		document.location = "deleteevent.php?eventid=" + id;
	}
	else if (type == "link") {
		document.location = "deletelink.php?linkid=" + id;
	}
	else if (type == "blog") {
		document.location = "deleteblog.php?blogid=" + id;
	}
}
//=============preload image===============
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//==============Delete person from contact ================
function DeletePerson(personid)
{
	if(confirm('Are you sure you want to delete this person from your contact list ?'))
		window.location.href= 'mynetwork.php?deleteperson='+personid;
		
}
//=============================================================
function removeFavoriteItem(ItemID)
{
	if(confirm('Are you sure you want to delete this Favorite ?'))
		window.location.href= 'myfavorites.php?deletefavorite=' + ItemID;
}
//============================================================
function removeFavoriteRater(Rater)
{
	if(confirm('Are you sure you want to delete this Favorite ?'))
		window.location.href= 'myfavoriteraters.php?deletefavorite=' + Rater;
}