//Array that stores the handles for all the popups
var popupWindows = new Array();
var popupCount=0;

//Set the opener for all the popups to null when the user leaves the current page
window.onunload = RemovePopupOpener;

function more(index)
        {
                var span = document.getElementById("more"+index);
                var more = document.getElementById("amore"+index);
                var less = document.getElementById("aless"+index);
                if(span)
                        span.style.display = "inline";
                if(more)
                        more.style.display = "none";
                if(less)
                        less.style.display = "inline";
        }
        function less(index)
        {
                var span = document.getElementById("more"+index);
                var more = document.getElementById("amore"+index);
                var less = document.getElementById("aless"+index);
                if(span)
                        span.style.display = "none";
                if(more)
                        more.style.display = "inline";
                if(less)
                        less.style.display = "none";
}

function PopUp3(theURL,winName,features)
//use 
//<a href="JavaScript:PopUp('http://www.abc.com/xyz.pl','Windo name','width=600,height=500,scrollbars,top=20,left=200,resizable');

{
	remote=window.open(theURL,winName,features);
	if (remote.opener == null) remote.opener = window; 
	remote.opener.name = "opener";
	remote.focus();

	popupWindows[popupCount++] = remote;
}

//This function sets the opener for the remote window to null
function RemovePopupOpener()
{
    	for(i=0; i < popupCount; i++)
	{
		remote = popupWindows[i];
		if (remote && remote.open && !remote.closed)
			remote.opener = null;
	}

}

//This function is used by the code that renders the popup.
//This populates a field in the parent window and then closes itself.
function PopulateParentField(field, value)
{
	if(window.opener && !window.opener.closed && eval("window.opener.document." + field))
		eval("window.opener.document." + field + ".value = " + value);

	window.close();
}


//See "How to Create Links" on Eng Web Site for Documentation on function

//============================================================================================

//The function handles all links inside popup. It targets the window "opener".
//If the "opener" window is closed, it creates it in the open call.
//If the "opener" window is open, it simply outputs the code there.
function gotoHref(szLink)
{
	if (window.opener.closed)
	{
		//each new window gets a unique name so the new page isn't
		//loaded in a window not with focus, which confuses the user.
		var szDate = new Date();
		win = window.open(szLink,"opener"+szDate.getTime());
	}
	else
	{
		window.opener.location.href = szLink;
	}
	window.close();
}


//these two functions are added for 24652
//they will open a popup window with the full member photo
var win
function memberphotoPopup(height, width, pid, nServiceID, nGroupID, nPmode, nDisplayPrice, strFLParams, strReturnURL)
{
	var strHeight = (height + 125);
	var strWidth = 150;
	var LeftPosition, TopPosition, settings
	var strUrl = '/memberpub/member_photo.asp?pid=' + pid + '&sid=' + nServiceID + '&gid=' + nGroupID + '&pmode=' + nPmode + '&dpr=' + nDisplayPrice + strFLParams + '&URL=' + strReturnURL
	var name
	if (width > strWidth)
	{
		strWidth = (width + 30);
	}
	
	name = pid
	
	if(!win || win.closed)
	{
		//setting the cookies (bug 36383)
		if (strFLParams != "")
		{
			document.cookie = "MPhV=1;path=/";
		}

		LeftPosition = (screen.width) ? (screen.width-strWidth)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-strHeight)/2 : 0;
		//settings ='height='+ strHeight +',width='+strWidth+',top='+TopPosition+',left='+LeftPosition+',notitlebar,nomenubar,scrollbars=no,resizable=no'
		settings ='height='+ strHeight +',width='+strWidth+',notitlebar,nomenubar,scrollbars=no,resizable=no'

		win = window.open(strUrl,pid,settings);
		win.focus()	
	}	
}


function wincloseRemote()
{
	//if (window.WinImage) WinImage.close();
	if (window.win && window.win.open && !window.win.closed) win.close();
}

//============================================================================================

//this function resizes a window based on the passed in dimensions.
//if the browser window is larger than these dimensions, no resize happens
function resizeWin(newWidth, newHeight)
{

	var frameWidth;
	var frameHeight;
	
	//determine window size for different browser types
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	
	//only resize window if new dimensions are larger than current.		
	if ((frameWidth < newWidth)||(frameHeight < newHeight))
	{ 
		//in netscape 4, window height is counted differently
		//from other browsers, so window height is artificially low 
		//and an extra 100 pixels need to be added
		newHeight += 100;
		
		//only resize up to the size of the screen resolution.
		if (newHeight > self.screen.height)
		{
			newHeight = self.screen.height
		}
		
		if (newWidth > self.screen.width)
		{
			newWidth = self.screen.width
		}

		//if netscape 4, must add in button and border layer sizes
		//so window is resized properly
		if (document.layers)
		{
			var tmp1 = parent.outerWidth - parent.innerWidth;
			var tmp2 = parent.outerHeight - parent.innerHeight;
			newWidth -= tmp1;
			newHeight -= tmp2;
		}
		
		//resize window
		window.resizeTo(newWidth, newHeight);	
		window.moveTo(0,0);		
	}
}

// New Popup
function popUp(x,e){
if (document.getElementById){
fromLeft = (document.all)?e.clientX + document.body.scrollLeft:e.pageX;
fromTop = (document.all)?e.clientY + document.body.scrollTop:e.pageY;
document.getElementById("dynamic-popup").style.display = "block";

document.getElementById("dynamic-popup-table-td").innerHTML = x;
document.getElementById("dynamic-popup").style.left = fromLeft+20;
document.getElementById("dynamic-popup").style.top = fromTop;
//setTimeout("popDown()",3000);
}
}
function popUp2(){
if (document.getElementById){
document.getElementById("dynamic-popup").style.display = "block";
}
}
function popDown(){
if (document.getElementById){
document.getElementById("dynamic-popup").style.display = "none";
}
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,location=0,status=1,menubar=0,scrollbars=1,resizable=1,width=750,height=570');");
}

function popUp3(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=880');");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



var urlAddress = 'http://www.mindworkzz.in'; 
var pageName = "MindWorkzz"; 
function addToFavorites() { 
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(pageName, urlAddress,"");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite( urlAddress, pageName); 
    }else { 
        alert("Sorry! Your browser doesn't support this function."); 
    } 
 }
 
 function emailPage() {
 
 var subject = "Interesting item";
  var body = 
      "I thought you'd be interested in this item \r\n\r\n" +
      urlAddress;
 
  // BUILD MAIL MESSAGE COMPONENTS 
  var doc = "mailto:?subject=" +
     escape(subject) + 
     "&body=" + escape(body); 
 
  // POP UP EMAIL MESSAGE WINDOW
  window.location = doc;
}

function addToFavorites() { 
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(pageName, urlAddress,"");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite( urlAddress, pageName); 
    }else { 
        alert("Sorry! Your browser doesn't support this function."); 
    } 
 }


function fnClear(f,def_value){
// usage: onclick="fnClear(this,'Enter City Name')";
        if (f.value == def_value) {
                f.value="";
        }
}

