/*
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
var closeButton = 'close.gif';		
var loadingImage = 'loading.gif';
/*-----------------------------------------------------------------------------------------------

//Browser detect script origionally created by Peter Paul Koch at http://www.quirksmode.org/

function getBrowserInfo() {
	if (checkIt('konqueror')) {
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser 	= "Safari"
	else if (checkIt('omniweb')) browser 	= "OmniWeb"
	else if (checkIt('opera')) browser 		= "Opera"
	else if (checkIt('webtv')) browser 		= "WebTV";
	else if (checkIt('icab')) browser 		= "iCab"
	else if (checkIt('msie')) browser 		= "Internet Explorer"
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS) {
		if (checkIt('linux')) OS 		= "Linux";
		else if (checkIt('x11')) OS 	= "Unix";
		else if (checkIt('mac')) OS 	= "Mac"
		else if (checkIt('win')) OS 	= "Windows"
		else OS 								= "an unknown operating system";
	}
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

/*-----------------------------------------------------------------------------------------------

Event.observe(window, 'load', initialize, false);
Event.observe(window, 'load', getBrowserInfo, false);
Event.observe(window, 'unload', Event.unloadCache, false);

var lightbox = Class.create();

lightbox.prototype = {
	
	yPos : 0,
	xPos : 0,

	initialize: function(ctrl) {
		this.content = ctrl.rel;
		Event.observe(ctrl, 'click', this.activate.bindAsEventListener(this), false);
		ctrl.onclick = function(){return false;};
	},
	
	// Turn everything on - mainly the IE fixes
	activate: function(){
		if (browser == 'Internet Explorer'){
			this.getScroll();
			this.prepareIE('100%', 'hidden');
			this.setScroll(0,0);
			this.hideSelects('hidden');
		}
		this.displayLightbox("block");
	},
	
	// Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox
	prepareIE: function(height, overflow){
		bod = document.getElementsByTagName('body')[0];
		bod.style.height = height;
		bod.style.overflow = overflow;
  
		htm = document.getElementsByTagName('html')[0];
		htm.style.height = height;
		htm.style.overflow = overflow; 
	},
	
	// In IE, select elements hover on top of the lightbox
	hideSelects: function(visibility){
		selects = document.getElementsByTagName('select');
		for(i = 0; i < selects.length; i++) {
			selects[i].style.visibility = visibility;
		}
	},
	
	// Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
	getScroll: function(){
		if (self.pageYOffset) {
			this.yPos = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){
			this.yPos = document.documentElement.scrollTop; 
		} else if (document.body) {
			this.yPos = document.body.scrollTop;
		}
	},
	
	setScroll: function(x, y){
		window.scrollTo(x, y); 
	},
	
	displayLightbox: function(display){
		$('overlay').style.display = display;
		$(this.content).style.display = display;
		if(display != 'none') this.actions();		
	},
	
	// Search through new links within the lightbox, and attach click event
	actions: function(){
		lbActions = document.getElementsByClassName('lbAction');

		for(i = 0; i < lbActions.length; i++) {
			Event.observe(lbActions[i], 'click', this[lbActions[i].rel].bindAsEventListener(this), false);
			lbActions[i].onclick = function(){return false;};
		}
		//this.startsearch();
			
			search_user_id = document.getElementsByClassName('search_user_id');			
			search_user_id[0].onclick = function(){     
				function showmessage(originalRequest){										
					eval(' var obj = '+originalRequest.responseText);											
					if(obj.response == "success" ){																				
						//$('overlay').style.display = "none";
						//$('lightbox1').style.display = "none";						
						setTimeout(function(){ new Effect.Fade('showform') ;},100);
						setTimeout(function(){$('lightbox2').style.display = "block"; },1000);
						setTimeout(function(){new Effect.Appear('searchwb'); },1000);
						//setTimeout(function(){$('lightbox2').style.display = "block"; },1000);
						//$('searcb_branch_waybill').style.display = "block";
						$('username_id').value ="";
						$('password_id').value ="";
					} else {	
						alert('User not found');
					}
			}									
			pars2 = 'verifyman-customers:submitaction=true&username='+$('username_id').value+'&password='+$('password_id').value+'&__req=true';									
			new Ajax.Updater('', 'index.php', {method: 'post', parameters:pars2, onComplete: showmessage});	
			};
			
			lbAction2 = document.getElementsByClassName('lbAction2');					
			lbAction2[0].onclick = function(){				
				//$('overlay').style.display = "none";
				//$('lightbox1').style.display = "none";
				$('lightbox2').style.display = "none";
				new Effect.Fade('lightbox2');
				//this.displayLightbox("none");
			}
		
			
		
	},
	
	// Example of creating your own functionality once lightbox is initiated
	deactivate: function(){
		if (browser == "Internet Explorer"){
			this.setScroll(0,this.yPos);
			this.prepareIE("auto", "auto");
			this.hideSelects("visible");
		}
		
		this.displayLightbox("none");
	}	
}

/*-----------------------------------------------------------------------------------------------

// Onload, make all links that need to trigger a lightbox active
function initialize(){
	alert('loading');
	addLightboxMarkup();
	lbox = document.getElementsByClassName('lbOn');
	for(i = 0; i < lbox.length; i++) {
		valid = new lightbox(lbox[i]);
	}
	
	
	
	
}

// Add in markup necessary to make this work. Basically two divs:
// Overlay holds the shadow
// Lightbox is the centered square that the content is put into.
function addLightboxMarkup() {
	bod 				= document.getElementsByTagName('body')[0];
	overlay 			= document.createElement('div');
	overlay.id			= 'overlay';
	bod.appendChild(overlay);
}
*/


var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
var closeButton = 'close.gif';		
var loadingImage = 'loading.gif';
/*-----------------------------------------------------------------------------------------------*/

//Browser detect script origionally created by Peter Paul Koch at http://www.quirksmode.org/

function getBrowserInfo() {
	if (checkIt('konqueror')) {
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser 	= "Safari"
	else if (checkIt('omniweb')) browser 	= "OmniWeb"
	else if (checkIt('opera')) browser 		= "Opera"
	else if (checkIt('webtv')) browser 		= "WebTV";
	else if (checkIt('icab')) browser 		= "iCab"
	else if (checkIt('msie')) browser 		= "Internet Explorer"
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS) {
		if (checkIt('linux')) OS 		= "Linux";
		else if (checkIt('x11')) OS 	= "Unix";
		else if (checkIt('mac')) OS 	= "Mac"
		else if (checkIt('win')) OS 	= "Windows"
		else OS 								= "an unknown operating system";
	}
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

/*-----------------------------------------------------------------------------------------------*/

Event.observe(window, 'load', initialize, false);
Event.observe(window, 'load', getBrowserInfo, false);
Event.observe(window, 'unload', Event.unloadCache, false);

var lightbox = Class.create();

lightbox.prototype = {
	
	yPos : 0,
	xPos : 0,

	initialize: function(ctrl) {
		this.content = ctrl.rel;
		Event.observe(ctrl, 'click', this.activate.bindAsEventListener(this), false);
		ctrl.onclick = function(){return false;};
	},
	
	// Turn everything on - mainly the IE fixes
	activate: function(){
		if (browser == 'Internet Explorer'){
			this.getScroll();
			this.prepareIE('100%', 'hidden');
			this.setScroll(0,0);
			this.hideSelects('hidden');
		}
		this.displayLightbox("block");
	},
	
	// Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox
	prepareIE: function(height, overflow){
		bod = document.getElementsByTagName('body')[0];
		bod.style.height = height;
		bod.style.overflow = overflow;
  
		htm = document.getElementsByTagName('html')[0];
		htm.style.height = height;
		htm.style.overflow = overflow; 
	},
	
	// In IE, select elements hover on top of the lightbox
	hideSelects: function(visibility){
		selects = document.getElementsByTagName('select');
		for(i = 0; i < selects.length; i++) {
			selects[i].style.visibility = visibility;
		}
	},
	
	// Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
	getScroll: function(){
		if (self.pageYOffset) {
			this.yPos = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){
			this.yPos = document.documentElement.scrollTop; 
		} else if (document.body) {
			this.yPos = document.body.scrollTop;
		}
	},
	
	setScroll: function(x, y){
		window.scrollTo(x, y); 
	},
	
	displayLightbox: function(display){
		$('overlay').style.display = display;
		$(this.content).style.display = display;
		if(display != 'none') this.actions();		
	},
	
	// Search through new links within the lightbox, and attach click event
	actions: function(){
		lbActions = document.getElementsByClassName('lbAction');

		for(i = 0; i < lbActions.length; i++) {
			Event.observe(lbActions[i], 'click', this[lbActions[i].rel].bindAsEventListener(this), false);
			lbActions[i].onclick = function(){return false;};
		}
		//this.startsearch();
				
			
		 
	},
	
	// Example of creating your own functionality once lightbox is initiated
	deactivate: function(){
		if (browser == "Internet Explorer"){
			this.setScroll(0,this.yPos);
			this.prepareIE("auto", "auto");
			this.hideSelects("visible");
		}
		
		this.displayLightbox("none");
	}	
}

/*-----------------------------------------------------------------------------------------------*/

// Onload, make all links that need to trigger a lightbox active
function initialize(){

	addLightboxMarkup();
	lbox = document.getElementsByClassName('lbOn');
	for(i = 0; i < lbox.length; i++) {
		valid = new lightbox(lbox[i]);
	}
	
	
	
	
}

// Add in markup necessary to make this work. Basically two divs:
// Overlay holds the shadow
// Lightbox is the centered square that the content is put into.
function addLightboxMarkup() {
	bod 				= document.getElementsByTagName('body')[0];
	overlay 			= document.createElement('div');
	overlay.id			= 'overlay';
	bod.appendChild(overlay);
}



//added by rodel 


var MyAlert = Class.create();
MyAlert.prototype = {
   initialize: function(header,content,timer,myconfirm) {
       
          this.header = header;
          this.content = content;
          this.timer  = timer ;
          this.myconfirm = myconfirm;
          this.myValue = "";
   },
   
   showConfirm: function(){
     //  this.Myvalue =  con;
     
     
     // return myval;
   },
   closeMe: function(){
          new Effect.Fade("midcom-service-uimessages-protogrowl");                      
          setTimeout(function(){ Element.hide("midcom-service-uimessages-protogrow1-overlay"); } ,900);          
          //alert(this.showConfirm());              
    }, 
    
    
    
   showAlert: function(ajaxResponse) {
     	new Insertion.After('subhead','<div id ="midcom-service-uimessages-protogrow1-overlay"><div id="midcom-service-uimessages-protogrowl" class="midcom-service-uimessages-protogrowl midcom-service-uimessages-protogrowl-type-info" style="z-index:1000;"><div class="midcom-service-uimessages-protogrowl-contenthelper-type-info"><div class="midcom-service-uimessages-protogrowl-closebutton" id ="mycloseme">X</div><div class="midcom-service-uimessages-protogrowl-title">'+this.header+'</div><div class="midcom-service-uimessages-protogrowl-content" id="myconfirm">'+this.content+'</div></div></div></div>');
          
       
      if(this.timer){         
       
           //var myalert = new MyAlert(); myalert.closeMe(); 
        setTimeout(function(){ new Effect.Fade("midcom-service-uimessages-protogrowl");                     
                 setTimeout(function(){ Element.hide("midcom-service-uimessages-protogrow1-overlay"); } ,900);             
         },this.timer);
                                              
      } 
      
      if(this.myconfirm ){
          new Insertion.After('myconfirm','<br><input type ="button" style="margin-left:120px;" value =" yes " id="myconfirm_yes">&nbsp;&nbsp;&nbsp;&nbsp;<input type ="button" value ="  no  " id="myconfirm_no"> ' );
          var myval = "";
           var myalert = new MyAlert();
          //Event.observe('myconfirm_yes', 'click', function(){  myval = 'true'; }, false);
         // Event.observe('myconfirm_no', 'click', function(){  myval = 'false'; }, false);
                                                                   
      }       
      
       $("mycloseme").onclick = function(){          
            var myalert = new MyAlert();
            myalert.closeMe();
       }   
       
     
   }
};	



