function checkFieldText(elem, svalidator, smessage) {
  
  if (elem.value.match(svalidator)) return true;
  
  alert(smessage);
  elem.focus();
  return false;
  
}

function fixPNG(element) {
  
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
    
    var src;
    
    if (element.tagName=='IMG') {
    
      if (/\.png$/.test(element.src)) {
        src = element.src;
		  	element.src = "/images/spacer.gif";
		  }
		
    } else {
        
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      
      if (src) {
			
        src = src[1];
			
        element.runtimeStyle.backgroundImage="none";
      }
    }
		
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
} 



function showMap(src, w, h) {
  
  var tmp = getPageSize();
  
  $_j('#auth_div').css({display: 'block', visibility: 'visible', height: tmp[1] + 'px'});
  
  $_j('#bg_popup').css({display: 'block', visibility: 'visible', height: tmp[1] + 'px'});
  
  $_j('#auth_form').css('padding-top', '100px');
  
  $_j('#table_img').width(w + 44).height(h + 66);
  
  $_j('#img_map').attr('width', w).attr('height', h).attr('src', src)
  
  $_j('#shadow_page').css({opacity: 0.67, height: tmp[1] + 'px' });
  
  $_j('#bg_popup').css({ opacity: 0 });
  
  return false;
}

function closeMap() {
  
  $_j('#auth_div').css({display: 'none', visibility: 'hidden'});
  
  $_j('#bg_popup').css({display: 'none', visibility: 'hidden'});
  
  return false;
  
}

function  getPageSize(){
       var xScroll, yScroll;

       if (window.innerHeight && window.scrollMaxY) {
               xScroll = document.body.scrollWidth;
               yScroll = window.innerHeight + window.scrollMaxY;
       } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
               xScroll = document.body.scrollWidth;
               yScroll = document.body.scrollHeight;
       } else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
               xScroll = document.documentElement.scrollWidth;
               yScroll = document.documentElement.scrollHeight;
       } else { // Explorer Mac...would also work in Mozilla and Safari
               xScroll = document.body.offsetWidth;
               yScroll = document.body.offsetHeight;
       }

       var windowWidth, windowHeight;
       if (self.innerHeight) { // all except Explorer
               windowWidth = self.innerWidth;
               windowHeight = self.innerHeight;
       } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
               windowWidth = document.documentElement.clientWidth;
               windowHeight = document.documentElement.clientHeight;
       } else if (document.body) { // other Explorers
               windowWidth = document.body.clientWidth;
               windowHeight = document.body.clientHeight;
       }

       // for small pages with total height less then height of the viewport
       if(yScroll < windowHeight){
               pageHeight = windowHeight;
       } else {
               pageHeight = yScroll;
       }

       // for small pages with total width less then width of the viewport
       if(xScroll < windowWidth){
               pageWidth = windowWidth;
       } else {
               pageWidth = xScroll;
       }
       
       return [pageWidth,pageHeight,windowWidth,windowHeight];
}

function getDocumentHeight()
{
    return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
}

//function getDocumentHeight()
//{
//	return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
//} 

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function OpenAskForm(a) {     
     
     var feedback_window = {
               width: 510,
               height: 436,               
               left: function() {return Math.ceil((screen.availWidth - this.width)/2)},
               top: function() {return Math.ceil((screen.availHeight - this.height)/2)},
               open: function(href) {
                    window.open(href, 'feedback', 'scrollbars=0,width='+this.width+',height='+this.height+',left='+this.left()+',top='+this.top()+',resizable=0,toolbar=0,location=0,status=0,menubar=0,directories=0');
               }
     };
     
     feedback_window.open(a.href);
     
     return false;
}

function showAllDates(k) {
  
  closeAllDiv();
  
  $_j('#d' + k).css({'display': 'block', 'margin-left': '-150px'});
  
  setTimeout('divBind()', 500);
  
  return false;
}

function closeAllDates(k) {
  
  $_j('#d' + k).css({display: 'none'});
  
  return false;
}

function divBind() {
  
  $_j('body').bind('click', function() {
    closeAllDiv();
  })
  
}

function closeAllDiv() {
  
  $_j('div.ps_cl_d').each(function() {
    $_j(this).css({display: 'none'});
  });
  
  $_j('body').unbind('click');
  
}

