// mwsMaster.js

function callMyServer()
{
		document.callMyServer.submit();		
}
function mbrAppCloseDialog()
{
	var answer = confirm("Close without submitting? All data entered will be lost!")
	if (answer){
		window.location = "/index.jsp";
	}
	else{
		//alert("Thanks for sticking around!")
	}
	
}
function musicLibraryWindow(cUrl)
{
	var musicLibrary; 
	musicLibrary=window.open(cUrl,'musicLib','height=600,width=600'); 
   	musicLibrary.focus();
	
}

function globalNewsWindow(cUrl)
{
	var globalNews;
	globalNews=window.open(cUrl,'worldNews','height=300, width=1000, resizable=yes, scrollbars=yes, left=150, top=430');
   	globalNews.focus();
		
}

function pictureCollectionWindow(cUrl)
{
	var pictures; 
	pictures=window.open(cUrl,'pictures','height=400,width=400'); 
   	pictures.focus();
	
}

//function webmailApp(cUrl)
//{
//	var webmail;
//	webmail=window.open(cUrl,'_self');
//   	webmail.focus();
//		
//}


function playit(buttonPressed)
{
		var count = document.playButtons.playButtonCount.value;
		document.playButtons.playMode.value = buttonPressed;
		
		
		if (document.playButtons.playMode.value == "play")
		{
			count++;
			document.playButtons.playButtonCount.value = count;
		}
			
		alert ("count is " + count);
		//alert ("server mode is " + document.playButtons.serverPlayMode.value);
		
		document.playButtons.submit();
		
		//if (((document.playButtons.playMode.value == "stop") || (document.playButtons.playMode.value == "pause"))  && (count < 1))
		//{
			//return false;
		//}
		//else
		//{
			//document.playButtons.submit();
		//}		
		
}

//document.onkeypress = processFormSubmition;
var sendingFormName;

function setFormName(formName)
{
	if (formName == "LoginFormOn")
	{
		sendingFormName = formName;
		//alert("sendingFormName = " + sendingFormName);
		
	}
	else (formName == "")
	{
		sendingFormName = formName;
		//alert("sendingFormName = " + sendingFormName);
		
	}
	
		
}

document.onkeypress = processSubmit;

function processSubmit(e)
{
  if (null == e)
    	e = window.event ;
  
  if ((e.keyCode == 13) && (sendingFormName == "performQuote"))
  {
   		editQuoteForm() ;
  }
  else if ((e.keyCode == 13) && (sendingFormName == "BecomeMbrFormOn"))
  {
       editNewMbrApplication();
 }
  else if ((e.keyCode == 13) && (sendingFormName == "LoginFormOn"))
  {
    	editLoginForm() ;
  }
  else if ((e.keyCode == 13) && (sendingFormName == "EmailFormOn"))
  {
    	editEmailForm() ;
  }
}

function checkEmail(email)
{
		var at="@";
		var dot=".";
		var lat=email.indexOf(at);
		var lstr=email.length;
		var ldot=email.indexOf(dot);
		var a; 
		
		if (
			(email.indexOf(at)==-1) ||
			(email.indexOf(at)==-1 || email.indexOf(at)==0 || email.indexOf(at)==lstr) ||
			(email.indexOf(dot)==-1 || email.indexOf(dot)==0 || email.indexOf(dot)==lstr) ||
			(email.indexOf(at,(lat+1))!=-1) ||
			(email.substring(lat-1,lat)==dot || email.substring(lat+1,lat+2)==dot) ||
			(email.indexOf(dot,(lat+2))==-1) ||
			(email.indexOf(" ")!=-1)
			)
		{
			a = "bad";
			return a;
		}
		
}

function toggleDiv(id,flagit) {
	if (flagit=="1"){
	if (document.layers) document.layers[''+id+''].visibility = "show"
	else if (document.all) document.all[''+id+''].style.visibility = "visible"
	else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
	}
	else
	if (flagit=="0"){
	if (document.layers) document.layers[''+id+''].visibility = "hide"
	else if (document.all) document.all[''+id+''].style.visibility = "hidden"
	else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
	}
}



function openOnlineShop1(cUrl,cName) {
openOnlineShop1 = null;  

if(openOnlineShop1 == null || openOnlineShop1.closed)
/* explanation: if the pointer to the window object
in memory does not exist or
if such pointer exists but the window was closed
* ,resizable=yes,restore=yes,alwaysRaised=yes,scrollbars=yes,toolbar=yes,left=200,top=30
* 
* 
*  */
	{
		//alert("inside window1Popup if");
		openOnlineShop1 = window.open(cUrl,cName,'scrollbars=1,resizable=yes,toolbar=yes')
		openOnlineShop1.focus();
	}
/* explanation: else close existing window and create a new one. The new window will be created and
will be brought on top of any other window. */
else
	{
		//alert("inside window1Popup else");
		openOnlineShop1 = openOnlineShop1.close();
		openOnlineShop1 = window.open(cUrl,cName,'scrollbars=1,resizable=yes,toolbar=yes')
		openOnlineShop1.focus();
	};
/* explanation: else the window reference must exist and the window
is not closed; therefore, we can bring it back on top of any other
window with the focus() method. There would be no need to re-create
the window or to reload the referenced resource. */
}



function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}


