/* ----------------------------------------------------------------------------------------
File Name: General_Functions.js

	This file handles general functions.
 ----------------------------------------------------------------------------------------*/
var _gGroup = 0;
var first_time2 = true;
var last_item	= "";
//var printObj;

function popUpWindow(URLStr, left, top, width, height)
{
	var popUpWin=0;
	if(popUpWin)
	{
		if(!popUpWin.closed) popUpWin.close();
	}
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	popUpWin.focus();
}

function limit(El)
{
	if(El.value.length >= 40)
		El.value = El.value.substring(0,40);
}

function OpenGalleryWin(hiddFileName)
{
	window.open("UploadPopUp.aspx?hiddName="+hiddFileName+"&imgWidth=187","Upload",'toolbar=no,menubar=no,dependent=yes,resizable=no,scrollbars=yes,height=550,width=600')
}

//--------------------------------------------------------------------------------

function GroupIt(El)
{
	if (El.state !== "down")
	{
		if(first_time2)
		{
			last_item = El.id;
			first_time2 = false;
		}
		else
		{
			if(document.getElementById(last_item))
			{
				document.getElementById(last_item).state = "";
				document.getElementById(last_item).style.cursor = "hand";
				document.getElementById(last_item).src =  "images/" + last_item + "_normal.gif";
			}
			last_item = El.id;
		}
				
		El.style.cursor = "normal";
		El.src = "images/" + El.id + "_over" + ".gif";
		El.state = "down";
	}
} 
function OverIt(El)
{
	if (El.state !== "down")
	{
		El.src = "images/" + El.id + "_over" + ".gif";
		El.state = "over";
	}	
}
function OutIt(El)
{
	if (El.state == "over")
	{
		El.state = "";
		El.src = "images/" + El.id + "_normal" + ".gif";
	}	
	else if (El.state !== "over" && El.state !== "down")
			El.src = "images/" + El.id+ "_normal" + ".gif";
}

function PrintData(type)
{
	/*switch(type)
	{
		case 1:
			printObj = document.getElementById("content");
			break;
	}*/
	
	printWin = open("includes/printWin.html", 'printWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=0,height=0,left=2000, top=2000');
}

function openLink(URI)
{
	win = window.open(URI,"secWin","width=800,height=800,left=100,scrollbars=yes,resiz able=yes,location=yes");
	win.focus;
}

//------------ FLASH NAME BANNER FUNCS ---------------------------//
/*function getName(str)
{
	//alert(str);
	//return "go for it";
}*/

/* ----- MOUSE OVER OUT MENU FUNCS -----*/
function get_obj(n, d)
{
	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 = get_obj(n,d.layers[i].document);
	if(!x && d.getElementById)
		x = d.getElementById(n);
	return x;
}

function display_hiddenMenu()
{
	var i, p, v, obj;
	var args = display_hiddenMenu.arguments;
	for (i=0; i<(args.length-2); i+=3)
	{
		if ((obj=get_obj(args[i])) != null)
		{
			v = args[i+2];
			if (obj.style) 
			{ 
				obj = obj.style; 
				v = (v=='show')?'visible':(v=='hide')?'hidden':v; 
			}
			obj.visibility=v; 
		}
	}
}
window.setInterval("display_hiddenMenu('sub1','','hide')", 8000);//,'sub2','','hide','sub3','','hide'

/* ----- DARK SCREEN FOR SLIDESHOW -----*/
function darkScreen(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';				 
  } else {
     dark.style.display='none';
  }
  
  if (vis)
	document.getElementById('divSlideShow').style.visibility = 'visible';
  else
	document.getElementById('divSlideShow').style.visibility = 'hidden';
}
function openWin(urlParam)
{
    var url = "http://"+urlParam+".missing-you.com";
    window.open(url)
}
