/** 
** The Following are functions for the login page. 
** Created by Brent Wejrowski (Bizzark LLC on 5-18-2010
**/



var updateNav = function(){};

function setNavFunction(f){
	updateNav = f;
}

var updateNav2 = function(){};

function waitAndUpdateNav(){
	setTimeout(updateNav, 3000);
}


/*
* 
* If shadowbox is open, close it.
* Gets called when home page is loaded and would apply if it gets loaded inside box
* 
**/

function closeShadows(){
	if(self.parent.Shadowbox){
		/*self.parent.updateNav2(); / mtUpdateSignInWidget();*/
		self.parent.Shadowbox.close();
	}	
	
}



/*
* 
* This checks if window is the popup, then closes any shadowbox's, and itself
* 
* SHOULD get called separate of onClose method 
* 
**/


function checkServiceWindow(){
	closeShadows();
	if(window.name=='servicewindow' && !opener.closed){
		window.opener.location.href=window.location.href;
		if(window.opener.parent.Shadowbox){
			/*window.opener.parent.updateNav2(); / mtUpdateSignInWidget();*/
			window.opener.parent.Shadowbox.close();
		}
		/*opener.parent.mtUpdateSignInWidget();*/
		/*taken from sb close func: mtUpdateSignInWidget();checkServiceWindow();*/
		self.close();
	}
}

/*
* 
* Get's called when external service login button is clicked.
* Makes the service website popup to login
* 
**/

function initServiceLogin(type){
	/*status=yes,resizable=yes,scrollbars=yes*/
  window.open('', 'servicewindow', 'width=700,height=400,modal=yes,alwaysRaised=yes');
}

/*
* Gets called on each page
**/

function checkAndUpdateLogin(){
//if(window.name=='servicewindow' && !opener.closed){
	if(window.opener){
		if(window.opener.parent){
			window.opener.parent.updateNav();/*mtUpdateSignInWidget();*/
		}else{

		}
	}else if(window.parent!=window.self){
		parent.updateNav();		
	}
	if (window.parent){

	}

//	if(parent){
//			parent.updateNav();
//	}
	checkServiceWindow();
//}
}
function WaitAndCheckAndUpdateLogin(){
	setTimeout(checkAndUpdateLogin, 500);
}

/* 
* This function should be called separate from any onClose methods. Otherwise something goes awry 
**/

function sbonclosefunction(){ /*checkServiceWindow();*//*updateNav2();*/}

