﻿var CNT_BACKGROUND = '#d7b262';
var CNT_PADDING = 5;
var CNT_CAPTION_HEIGHT = 21;
var CNT_DEF = 450;

function preloadImages(){if(document.images){if(!document.imageArray) document.imageArray = new Array();var i,j = document.imageArray.length, args = preloadImages.arguments;for(i=0; i<args.length; i++){if (args[i].indexOf("#")!=0){document.imageArray[j] = new Image;document.imageArray[j++].src = args[i];}}}}

function popUpWindow(popupName, popupObject, URLStr, features)
{
  if(popupObject)
  {
    popupObject.close();
  }
  if(features){
      var f = new Array('toolbar','titlebar','location','directories','status','menubar','scrollbars','resizable','copyhistory','width','height','left','top','screenX','screenY');
      var fstr = f[0]+'='+((features[f[0]])?features[f[0]]:'no');
      for(var i=1;i<f.length;i++){
        fstr+=','+f[i]+'='+((features[f[i]])?features[f[i]]:'no');
      }
      return open(URLStr, popupName, fstr);  
  }
  return open(URLStr, popupName);
}

function setStyleFontSize(className, size){
   var styles = document.styleSheets;
   for(var i=0;i<styles.length;i++){
      var rules = (styles[i].rules)?styles[i].rules:styles[i].cssRules;
      for(var j=0;j<rules.length;j++){
        if(rules[j].selectorText == className){
            if(rules[j].style){rules[j].style.fontSize = size;}
            return;
        }
      }
   } 
}

function styleSheetsToString(){
    var result='';
    var styles = document.styleSheets;
    for(var i=0;i<styles.length;i++){
      result+='<style type="'+styles[i].type+'">\n';
      var rules = (styles[i].rules)?styles[i].rules:styles[i].cssRules;
      for(var j=0;j<rules.length;j++){
        result+=rules[j].selectorText+'{'+rules[j].style.cssText+'}'+"\n";
      }
      result+='</style>\n';
   } 
   return result;
}

function fader(obj,opacity) {
	/* helper function to deal specifically with images and the cross-browser differences in opacity handling */	
	if (obj.style) {
		if (obj.style.MozOpacity!=null) {  
			/* Mozilla's pre-CSS3 proprietary rule */
			obj.style.MozOpacity = (opacity/100) - .001;
		} else if (obj.style.opacity!=null) {
			/* CSS3 compatible */
			obj.style.opacity = (opacity/100) - .001;
		} else if (obj.style.filter!=null) {
			/* IE's proprietary filter */
			if(document.all && !document.getElementById){
				obj.style.filter = "alpha(opacity="+opacity+")";
			}else{
				obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity="+opacity+",FinishOpacity="+opacity+", Style=0)";
			}			
		}
	}
}

function round(n, d){
    return Math.round(n * Math.pow(10,d))/100.0;
}

function callFunction(f){
    f = typeof(f) == 'function' ? f : window[f];
    return f.apply(window, Array.prototype.slice.call(callFunction.arguments, 1));
}

function getOffsetLeft(elm){    
   var value = 0;
    var oldElem  = null;
    while(elm && elm!=oldElem){
        value+=elm.offsetLeft;
        oldElem = elm;
        elm = elm.offsetParent;
    }
    if (navigator.userAgent.indexOf('Mac') != -1 &&
        typeof document.body.leftMargin != 'undefined') {
        value += document.body.leftMargin;
        
    }
    return value;
}

function getOffsetTop(elm){
    var value = 0;
    var oldElem  = null;
    while(elm && elm!=oldElem){
        value+=elm.offsetTop;
        oldElem = elm;
        elm = elm.offsetParent;
    }
    if (navigator.userAgent.indexOf('Mac') != -1 &&
        typeof document.body.topMargin != 'undefined') {
        value += document.body.topMargin;
        
    }
    return value;
}

function isEnterKey(evt) {
    evt = (evt) ? evt : (window.event) ? window.event : "";
    var theKey;
    if (evt) {
        theKey = (evt.which) ? evt.which : evt.keyCode;
    }
    return (theKey == 13);
}

function onEnter(f, evt)
{    
   if (isEnterKey(evt)){
        if(f){ 
            if(typeof f == 'function')
            {   
                f();
            }
            else
            {
                eval(f);
            }    
            return false;
        }   
               
   }
   return true; 
}

function onKeywordsFocus(ctrl, defaultValue)
{
    if(ctrl.value.toLowerCase() == defaultValue.toLowerCase())
    {
        ctrl.value = '';
        
    }
    return true;
}

function onKeywordsBlur(ctrl, defaultValue)
{
    if(ctrl.value == '')
    {
        ctrl.value = defaultValue;
    }
    return true;
}