// Sazzad Hossain
function onVMenuMouseOver(who, ev)
{
	var mainDiv = document.getElementById("VNavBar");
	var subDiv;
	var x, y;
	if (mainDiv)
	{
		if (mainDiv.autoCloseId) window.clearInterval(mainDiv.autoCloseId);
		if (mainDiv.cDiv)
		{			
			mainDiv.cDiv.style.visibility = "hidden";
			if (mainDiv.cDiv.parentDiv)
			{
				mainDiv.cDiv.parentDiv.style.backgroundColor = "transparent";
			}
		}
		if (who)
		{
			subDiv = document.getElementById(who);
			if (subDiv)
			{
				if (ev)
				{
					x = findXPosition(ev) - 50;
					y = findYPosition(ev);
					subDiv.style.left = x + ev.offsetWidth;
					subDiv.style.top = y; // - (subDiv.offsetHeight/2) + ev.offsetHeight;
					subDiv.parentDiv = ev;
					ev.style.backgroundColor = "white";
				}
				subDiv.style.visibility = "visible";
				mainDiv.cDiv = subDiv;
				mainDiv.autoCloseId = window.setInterval(AutoCloseVMenu, 3000);
			}
		}
	}
}

function AutoCloseVMenu()
{
	var mainDiv = document.getElementById("VNavBar");
	if (mainDiv.cDiv)
	{
		mainDiv.cDiv.style.visibility = "hidden";
		if (mainDiv.cDiv.parentDiv)
		{
			mainDiv.cDiv.parentDiv.style.backgroundColor = "transparent";
		}
	}
}

function onMouseOverSubItem()
{
	var mainDiv = document.getElementById("VNavBar");
	window.clearInterval(mainDiv.autoCloseId);
}

function onMouseOutSubItem()
{
	var mainDiv = document.getElementById("VNavBar");
	mainDiv.autoCloseId = window.setInterval(AutoCloseVMenu, 1000);
}

function findYPosition(thisObject)
{
  if (thisObject.offsetParent)
  {
    return (thisObject.offsetTop + findYPosition(thisObject.offsetParent));
  } 
  else 
  { 
	return thisObject.offsetTop;
  }
}
function findXPosition(thisObject)
{
  if (thisObject.offsetParent)
  {
    return (thisObject.offsetLeft + findXPosition(thisObject.offsetParent));
  } 
  else 
  { 
	return thisObject.offsetLeft;
  }
}

// Popup WIndows
function openIML(qry)
{
	var x, y, x1, y1;
	var vWinCal, url;	
	x=(screen.availWidth)/2;
	y=(screen.availHeight)/2;
	x1=screen.availWidth-50;
	y1=screen.availHeight-75;
	url = "/CMyAbc/BrowseIML.aspx";
	if (qry)
	{
		url = url + qry;
	}
	vWinCal = window.open(url,"","height="+y1+",width="+x1+",left=25,top=25,status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,resize=yes");
	vWinCal.opener = self;
	vWinCal.focus();
}
function openSSLWin(urlPath)
{
	var x, y, hh, ww;
	var vWinCal, url;	
	ww = 800;
	hh = 650;
	x=(screen.availWidth - ww)/2;
	y=(screen.availHeight - hh)/2;
	
	url = "http://" + window.location.host + urlPath;
	vWinCal = window.open(url,"","height="+hh+",width="+ww+",left="+x+",top="+y+",status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,resize=yes");
	vWinCal.opener = self;
	vWinCal.focus();
}

function favorites()
{
	var url="http://www.photosigns.com.au/CMyAbc/Default.aspx";
	var title="ABC Photosigns - My ABC";

	if (document.all)
	window.external.AddFavorite(url,title)
}

function favoritesNZ()
{
	var url="http://www.photosigns.co.nz/CMyAbc/Default.aspx";
	var title="ABC Photosigns New Zealand - My ABC";

	if (document.all)
	window.external.AddFavorite(url,title)
}

function OpenPromo(id)
{
	var x, y, hh, ww, url, vWinCal;
	hh = 390;
	ww = 400;
	x=(screen.availWidth - ww)/2;
	y=(screen.availHeight - hh)/2;
	
	url = "tools/PromoDetails.aspx?ID=" + id;
	vWinCal = window.open(url,"PromoDetails","height="+hh+",width="+ww+",status=no,toolbar=no,menubar=no,location=no,resize=no,left=" + x + ", top=" + y);
	vWinCal.opener = self;
	vWinCal.focus();	
}

function QSearch()
{
	var aObj;
	var url;
	aObj = document.getElementById("qsID");
	if (aObj)
	{
		if (aObj.value>0)
		{
			if (aObj.value>900000)
			{
				url = "/CMyAbc/SBQuickStatus.aspx?ID=" + aObj.value;
			}
			else
			{
				url = "/CMyAbc/JobStatus.aspx?ID=" + aObj.value;
			}
			location.href = url;
		}
		else
		{
			alert("Invalid Job ID!!!");
		}		
	}
}
function QProSearch(txtname, pgname, para)
{
	var aObj;
	var url;
	aObj = document.getElementById(txtname);
	if (aObj)
	{
		url = "/cmyabc/" + pgname + ".aspx?" + para + "=" + aObj.value;
		location.href = url;
	}
	else
	{
		alert("Invalid Property!!!");
	}
}
function QKey(e)
{
	if (e.keyCode==13)
	{
		QSearch();
		return false;
	}
	else
	{
		return true;
	}
}
function QProKey(e, txtname, pgname, para)
{
	if (e.keyCode==13)
	{
		QProSearch(txtname, pgname, para);
		return false;
	}
	else
	{
		return true;
	}
}
function QHover(who, isrc)
{
	who.src = isrc;
}

// ABCRE
function URLEncoder(str)
{
    var outSt = "";
    for(var c = 0;c < str.length;c++){
        var cCode = str.charCodeAt(c);
        if(((cCode > 47)&&(cCode < 58))||
            ((cCode > 64)&&(cCode < 91))||
            ((cCode > 96)&&(cCode < 123))){
            outSt += str.charAt(c);
        }else if(cCode == 32){
            outSt += "+";
        }else{
            var hex = cCode.toString(16);
            var len = hex.length;
            switch(len){
                case 0:
                    hex = "00";
                    break;
                case 1:
                    hex = "0"+hex;
                case 2:
                    break;
                defalt:
                    hex = hex.substring((len-2), len);
                    break;
            }
            outSt += "%"+hex;
        }
    }
    return outSt;
}
function QuickEditListing()
{
	var txt = document.getElementById("txtQListingId");
	var num;
	if (txt.value.length>0)
	{		
		if (isNaN(txt.value))
		{
			alert("Invalid Listing Id. Must be of digits");
		}
		else
		{
			window.location.href = "EditListing.aspx?ID=" + txt.value;
		}		
	}
	else
	{
		alert("Please Enter a Listing Id");
		txt.focus();
	}
}
function QuickListingSearch()
{
var txt = document.getElementById("txtQListingAddress");
	var num;
	if (txt.value.length>2)
	{		
		window.location.href = "Search.aspx?ID=" + URLEncoder(txt.value);
	}
	else
	{
		alert("Please Enter a Property Address\r\n\r\nMinimum 3 character is needed for a Search");
		txt.focus();
	}
}
function txtQListingId_OnKeyUp(e)
{
	if (e.keyCode)
	{
		if (e.keyCode==13)
		{
			QuickEditListing();
		}
	}
}
function txtQListingAddress_OnKeyUp(e)
{
	if (e.keyCode)
	{
		if (e.keyCode==13)
		{
			QuickListingSearch();
		}
	}
}
function MM_OpenDialogWindow(url, width, height)
{
	var x, y, hh, ww, vWin;
	x=(screen.availWidth - width)/2;
	y=(screen.availHeight - height)/2;		
	vWin = window.open(url,"","height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,resize=no,left=" + x + ", top=" + y);
	if (vWin!=null)
	{
		vWin.opener = self;
		vWin.focus();
	}	
}

function MM_OpenResWindow(url, width, height)
{
	var x, y, hh, ww, vWin;
	x=(screen.availWidth - width)/2;
	y=(screen.availHeight - height)/2;		
	vWin = window.open(url,"","height="+height+",width="+width+",status=no,scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes,left=" + x + ", top=" + y);
	if (vWin!=null)
	{
		vWin.opener = self;
		vWin.focus();
	}	
}

function openAOP(url)
{
	MM_OpenResWindow(url, screen.availWidth * 0.9, screen.availHeight * 0.9);
}


// Popup WIndows
function openUpload(qry)
{
	var url = "/CmyAbc/Uploads/UploadPage1.aspx";
	if (qry) url = url + "?" + qry;
	MM_OpenDialogWindow(url, 610,400);
}