function bmGetCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function bmSetPanelCookie(myDomain) 
{
   var name = "bm_panel_ie";
   var value = "true";
   var days = 365;
   var date = new Date();
   date.setTime(date.getTime()+(days*24*60*60*1000));
   var expires = "; expires="+date.toGMTString();
   document.cookie = name+"="+value+expires+"; path=/" + ( (myDomain) ? ";domain=" + myDomain : "");
}

function showFrame()
{
   if (document.getElementById)
   {
      document.getElementById("bm_frame").style.visibility ='visible';
	}
	else 
   {
	   if (document.layers)
      { 
		   document.bm_frame.visibility = 'visible';
		}
		else 
      { 
		   document.all.bm_frame.style.visibility = 'visible';
		}
	}
}

function hideFrame() 
{
   if (document.getElementById)
   {
	   document.getElementById("bm_frame").style.visibility ='hidden';
	}
	else 
   {
	   if (document.layers)
      { 
		   document.bm_frame.visibility = 'hidden';
		}
		else 
      { 
			document.all.bm_frame.style.visibility = 'hidden';
		}
	}
}

function center(){
 if( self.innerHeight ){
 	var x = self.innerWidth;
 	var y = self.innerHeight;
 }
 else if( document.body ){
 	var x = document.body.clientWidth;
 	var y = document.body.clientHeight;
 }
 else if( document.documentElement.clientWidth && document.documentElement.clientHeight ){
 	var x = document.documentElement.clientWidth;
 	var y = document.documentElement.clientHeight;
 }


 var bm_popup = document.getElementById("bm_frame");

// if( bm_popup.clientWidth ){
// 	x = (x-bm_popup.clientWidth)/2;
// 	y = (y-bm_popup.clientHeight)/2;
 //}
 
var surwidth = 426;//fixed as chrome and safari are reading the width and height wrong
var surheight = 492;
x = (x-surwidth)/2;
y = (y-surheight)/2;
 
 bm_popup.style.left = x + 'px' ;
 bm_popup.style.top = y + 'px' ;

}

function scroll_center(){
 var bm_popup = document.getElementById('bm_frame');
	
 if (document.documentElement){
 	var left1 = document.documentElement.scrollLeft;
 	var top1 = document.documentElement.scrollTop;
 	//alert(left1+" "+top1);
 }
 else if (document.body){
 	var left1 = document.body.scrollLeft;
 	var top1 = document.body.scrollTop;
 	//alert(left1+" "+top1);
  }
  
 if( self.innerHeight ){
 	var x = self.innerWidth;
 	var y = self.innerHeight;
 	//alert(self.innerWidth+" "+self.innerHeight);
 }
 else if( document.body ){
 	var x = document.body.clientWidth;
 	var y = document.body.clientHeight;
 	//alert(document.body.clientWidth+" "+document.body.clientHeight);
 }
 else if( document.documentElement && document.documentElement.clientHeight ){
 	var x = document.documentElement.clientWidth;
 	var y = document.documentElement.clientHeight;
 	//alert(document.documentElement.clientWidth+" "+document.documentElement.clientHeight);
 }

// left1 += x;
// top1 += y;
if( bm_popup.clientWidth ){
 	var x1 = (left1-bm_popup.clientWidth)/2;
 	var y1 = (top1-bm_popup.clientHeight)/2;
 }
 
 if( bm_popup.clientWidth ){
 	x = (x-bm_popup.clientWidth)/2;
 	y = (y-bm_popup.clientHeight)/2;
 }
 left1 += x;
 top1 += y;
 bm_popup.style.left = left1 + 'px' ;
 bm_popup.style.top = top1 + 'px' ;

 
}

function centerFrame() {
 	
	
    window.onload = center;
    window.onresize = center;
    center();
}


function center2(a, b){
if( self.innerHeight ){
 	var x = self.innerWidth;
 	var y = self.innerHeight;
 	//alert(x +" "+1);
 }
 else if( document.body ){
 	var x = document.body.clientWidth;
 	var y = document.body.clientHeight;
 	//alert(x +" "+2);
 }
 else if( document.documentElement.clientWidth && document.documentElement.clientHeight ){
 	var x = document.documentElement.clientWidth;
 	var y = document.documentElement.clientHeight;
 	//alert(x +" "+3);
 }

if (document.getElementById){
	   var bm_popup = document.getElementById('bm_frame');
	  
	}
	else {
	   if (document.layers){ 
		   var bm_popup = document.bm_frame;
		   
		}
		else { 
		   var bm_frame = document.all.bm_frame;
		  
		}
	}

var surwidth = 426;//fixed as chrome and safari were reading the width and height wrong
var surheight = 492;
	

//if( bm_popup.clientWidth ){
// 	x = (x-bm_popup.clientWidth)/2;
//	y = (y-bm_popup.clientHeight)/2;

// }

x = (x-surwidth)/2;
y = (y-surheight)/2;

 var a1 = x+a;
 var b1 = y+b;
 bm_popup.style.left = a1 + 'px' ;
 bm_popup.style.top = b1 + 'px' ;

}

function centerFrame2() {
 	
	
   // window.onload = center2;
    window.onresize = center2;
   // center2(a,b);
}


function onScrollResize(){
	
	//window.onscroll = scroll_center;
	window.onresize = center;

	
	//center();
}

function onScroll(){
	window.onscroll = scroll_center;
}


function IE6() {
	var browserName=navigator.appName; 
	var browserVer=parseInt(navigator.appVersion); //wrong number as IE from ver 4.0 has a ver number 4.0
	
	var arr = new Array;
	arr = navigator.appVersion.split(";");
	
	var arr2 = new Array;
	arr2 = navigator.appVersion.split(" ");
	var broVer=parseInt(arr2[3]);
	
	if (browserName=="Microsoft Internet Explorer" && broVer <= 6)
	 {
	  
	  document.all.bm_frame.style.backgroundImage = "url(http://www.irelandmetrix.ie/survey/images/new2f.gif)";
	 
	 }	
	 
	 

	
}

function close_button(){ 

    if (document.getElementById){
	  var iframe = document.getElementById('bm_framesurvey');
	  //var thankyou = document.getElementById('thankyou'); 
	}
	else {
	   if (document.layers){ 
		   var iframe = document.bm_framesurvey;
		   //var thankyou = document.thankyou;
		}
		else { 
		   var iframe = document.all.bm_framesurvey;
		   //var thankyou = document.all.thankyou;
		}
	}
    
    var url = iframe.src;   
    //if (thankyou.style.visibility == 'visible'; ){
	    
    //}
 	//alert(thankyou.style.visibility);
} 
