/***********************************
INLINE POPUP SETTINGS
************************************/
/*make sure only the faded BG is clickable and not its children elements */
function detectClick(evt) {
	if(!evt) { var evt = window.event; }
	var e = window.event ? evt.srcElement : evt.target;
	if(e.id != 'overlayinline') { return; }
	
	$('#overlayinline').fadeOut(500);
	$('#bruiserNews').fadeOut(500);
	$('#bruisermessage').fadeOut(500);
	
	
}

/***********************************
* JQUERY SETTINGS
***********************************/
/*NEWSLETTER SIGNUP AJAX STUFF*/
$('document').ready(
	function() {
	
	$('.all_news').hover(function() {
		$(this).addClass('toplevel_newsfeature_over');	
		$(this).removeClass('toplevel_newsfeature');
	}, function() {
		$(this).addClass('toplevel_newsfeature');
		$(this).removeClass('toplevel_newsfeature');
	});
	
	
	/* Elle's lounge AJAX submit */
		$(".elleslounge, .newsletterSignUpForm").submit(
			function() {
				$('#newsletterResponse').html('<img src="/img/ajax_arrows.gif" alt=""/>');
				$.ajax(
					{
						type: "POST",
						url: "/inc/ajax/newsletter_signup.php",
						data: $(".elleslounge, .newsletterSignUpForm").serialize(),
						dataType: "script"
					}
				);
				return false;
			}
		);
	}
);

function pop_up(url, wname, pwidth, pheight) {
	window.open(url, wname, "menubar=no, width=" + pwidth + ", height=" + pheight + ", toolbar=no, resizable=no, scrollbars=yes");
}

/* LINK OUT TO ELLESLOUGNE */
function goToEllesLounge() {
	window.open('http://fanclub.elleslounge.com');
}

/* CHECK TO SEE WHAT WAS CLICKED, EVALUATE IF TRUE */
function checkSelf(evt,myid,evl) {
	if (!evt) var evt = window.event;
	var e = (window.event) ? evt.srcElement : evt.target;
	if(e.id == myid) { eval(evl); }
}



/* LEGACY JAVASCRIPT FROM OLD LEGALLYBLONDETHEMUSICAL.COM */
var message;

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

function killpop(id) 
{
	document.getElementById("overlayinline").style.display='none';
	document.getElementById(id).style.display='none';
}

function killPhotos() 
{
	document.getElementById("overlayinline").style.display='none';
	document.getElementById("photospop_container").style.display='none';
	document.getElementById("photos_bts_container").style.display='none';
}


function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   message = "Invalid E-mail";
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   message = "Invalid E-mail";
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    message = "Invalid E-mail";
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    message = "Invalid E-mail";
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    message = "Invalid E-mail";
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    message = "Invalid E-mail";
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    message = "Invalid E-mail";
		    return false
		 }

 		 return true					
	}

function ValidateEmail(id){
	var emailID=document.getElementById(id);
	
	if ((emailID.value==null)||(emailID.value=="")){
		message = "Please enter your E-mail";
		document.getElementById('message').innerHTML=message;
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		message = "Invalid E-mail";
		document.getElementById('message').innerHTML=message;
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function newspop() 
{
	// Do some shit for IE
	if(BrowserDetect.browser == "Explorer") {
	
	
		if (typeof document.body.style.maxHeight != "undefined") {
		  
		  //Do some shit for sucky IE &
		  var pageWidth= 10;
		  
		} else {
		 
		 //Do some shit for equally sucky IE6	  
		  var pageWidth= (getPageSize('width') / 2) - 250;
		  
		}
		
		//alert(pageWidth);
		document.getElementById("deltanupop_container").style.left = pageWidth + 'px';
		document.getElementById("overlayinline").style.height = getPageSize('height');

	}

	//Element.setHeight('overlay', arrayPageSize[1]);	
	document.getElementById("overlayinline").style.display='block';
	document.getElementById("deltanupop_container").style.display='block';
	
}



function photoPop() 
{
	if(BrowserDetect.browser == "Explorer") {
	
	if (typeof document.body.style.maxHeight != "undefined") {
		  
		  //Do some shit for sucky IE &
		  var pageWidth= (getPageSize('width') / 2) - 341;
		  
		} else {
		 
		 //Do some shit for equally sucky IE6	  
		  var pageWidth= (getPageSize('width') / 2) - 341;
		  
		}
	
		
		document.getElementById("overlayinline").style.height = getPageSize('height');
		
	
			
	} else {
	 var pageWidth= (getPageSize('width') / 2) - 341;
	
	}
	document.getElementById("photospop_container").style.left = pageWidth + 'px';
	document.getElementById("overlayinline").style.display='block';
	document.getElementById("photospop_container").style.display='block';

}


function photobtsPop() 
{


	if(BrowserDetect.browser == "Explorer") {
	
	if (typeof document.body.style.maxHeight != "undefined") {
		  
		  //Do some shit for sucky IE &
		  var pageWidth= (getPageSize('width') / 2) - 341;
		  
		} else {
		 
		 //Do some shit for equally sucky IE6	  
		  var pageWidth= (getPageSize('width') / 2) - 341;
		  
		}
	
		
		document.getElementById("overlayinline").style.height = getPageSize('height');
	
			
	} else {

	 var pageWidth= (getPageSize('width') / 2) - 341;
	
	}

	document.getElementById("photos_bts_container").style.left = pageWidth + 'px';
	document.getElementById("overlayinline").style.display='block';
	document.getElementById("photos_bts_container").style.display='block';
	
}


function getPageSize(type) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  if(type == 'width') { return myWidth; } else {  return myHeight;  }
  
}