var imgWindow = "";function openPopup(img, width, height) {   if (img && width && height) {      width = Math.min(width + 36, 480);      height = Math.min(height + 30, 420);      if (imgWindow.location && !imgWindow.closed)         imgWindow.close();      imgWindow = window.open(img, "imgWindow" + width + height, "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height);      // imgWindow.focus();   }}function forceFlagValue(pRef) {	document.getElementById("_" + pRef.name).value=(pRef.checked?1:0);}function DBNPreviewUrl( pRef, pContId ) {		var pCont = DBN_findObj(pContId);	pCont.innerText = pRef.value;}Antville = {};
Antville.prefix = "Antville_";

Antville.pixel = new Image();
Antville.pixel.src = "/static/pixel.gif";

Antville.colors = {"aliceblue": true, "antiquewhite": true, "aqua": true,  "aquamarine": true, "azure": true, "beige": true, "bisque": true,  "black": true, "blanchedalmond": true, "blue": true, "blueviolet": true,  "brown": true, "burlywood": true, "cadetblue": true, "chartreuse": true,  "chocolate": true, "coral": true, "cornflowerblue": true,  "cornsilk": true, "crimson": true, "cyan": true, "darkblue": true,  "darkcyan": true, "darkgoldenrod": true, "darkgray": true,  "darkgreen": true, "darkkhaki": true, "darkmagenta": true,  "darkolivegreen": true, "darkorange": true, "darkorchid": true,  "darkred": true, "darksalmon": true, "darkseagreen": true,  "darkslateblue": true, "darkslategray": true, "darkturquoise": true,  "darkviolet": true, "deeppink": true, "deepskyblue": true, "dimgray": true,  "dodgerblue": true, "firebrick": true, "floralwhite": true, "forestgreen": true, "fuchsia": true, "gainsboro": true, "ghostwhite": true, "gold": true, "goldenrod": true, "gray": true, "green": true, "greenyellow": true, "honeydew": true, "hotpink": true, "indianred ": true, "indigo ": true, "ivory": true, "khaki": true, "lavender": true, "lavenderblush": true, "lawngreen": true, "lemonchiffon": true, "lightblue": true, "lightcoral": true, "lightcyan": true, "lightgoldenrodyellow": true, "lightgrey": true, "lightgreen": true, "lightpink": true, "lightsalmon": true, "lightseagreen": true, "lightskyblue": true, "lightslateblue": true, "lightslategray": true, "lightsteelblue": true, "lightyellow": true, "lime": true, "limegreen": true, "linen": true, "magenta": true, "maroon": true, "mediumaquamarine": true, "mediumblue": true, "mediumorchid": true, "mediumpurple": true, "mediumseagreen": true, "mediumslateblue": true, "mediumspringgreen": true, "mediumturquoise": true, "mediumvioletred": true, "midnightblue": true, "mintcream": true, "mistyrose": true, "moccasin": true, "navajowhite": true, "navy": true, "oldlace": true, "olive": true, "olivedrab": true, "orange": true, "orangered": true, "orchid": true, "palegoldenrod": true, "palegreen": true, "paleturquoise": true, "palevioletred": true, "papayawhip": true, "peachpuff": true, "peru": true, "pink": true, "plum": true, "powderblue": true, "purple": true, "red": true, "rosybrown": true, "royalblue": true, "saddlebrown": true, "salmon": true, "sandybrown": true, "seagreen": true, "seashell": true, "sienna": true, "silver": true, "skyblue": true, "slateblue": true, "slategray": true, "snow": true, "springgreen": true, "steelblue": true, "tan": true, "teal": true, "thistle": true, "tomato": true, "turquoise": true, "violet": true, "violetred": true, "wheat": true, "white": true, "whitesmoke": true, "yellow": true, "yellowgreen": true};

Antville.ColorPickerFactory = function() {
   this.prefix = Antville.prefix + "ColorPicker_";
   this.valuePrefix = Antville.prefix + "ColorValue_";

   this.open = function(name, text, skin) {
      if (skin == "colorpickerExt")
         var cpWindow = window.open("http://www.mywoman.at/?name=" + name + "&text=" + text + "&skin=" + skin, Antville.ColorPicker.prefix, "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=480,height=360");
      else
         var cpWindow = window.open("http://www.mywoman.at/?name=" + name + "&text=" + text + "&skin=" + skin, Antville.ColorPicker.prefix, "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=350,height=320");
   }

   this.set = function(name, color) {
      var prefix = Antville.ColorPicker.prefix;
      var valuePrefix = Antville.ColorPicker.valuePrefix;
      var color = Antville.parseColor(color);
      if (color)
         document.getElementById(prefix + name).style.backgroundColor = color;
      else
         color = Antville.parseColor(document.getElementById(prefix + name).style.backgroundColor);
      if (color.indexOf("#") == 0)
         color = color.substr(1,color.length-1);
      document.getElementById(valuePrefix + name).value = color;
      return;
   }

   return this;
}

Antville.ColorPicker = new Antville.ColorPickerFactory();

Antville.encode = function(str) {
   var chars = ["&", "<", ">", '"'];
   for (var i in chars) {
      var c = chars[i];
      var re = new RegExp(c, "g");
      str = str.replace(re, "&#" + c.charCodeAt() + ";");
   }
   return str;
}

Antville.decode = function(str) {
   return str.replace(/&amp;/g, "&");
}

Antville.parseColor = function(color) {
   var c = color.toLowerCase();
   if (Antville.colors[c]) {
      return c;
   }
   var rgb = new RegExp("rgb ?\\( ?([0-9^,]*), ?([0-9^,]*), ?([0-9^ \\)]*) ?\\)");
   var result = color.match(rgb);
   if (result) {
      var R = parseInt(result[1]).toString(16);
      var G = parseInt(result[2]).toString(16);
      var B = parseInt(result[3]).toString(16);
      if (R.length == 1) R="0"+R;
      if (G.length == 1) G="0"+G;
      if (B.length == 1) B="0"+B;
      return "#"+R+G+B;
   }
   if (c.indexOf("#") == 0) {
      c = c.substr(1,c.length-1);
   }
   if (c.length == 6) {
      var nonhex = new RegExp("[^0-9,a-f]");
      nonhex.ignoreCase = true;
      var found = c.match(nonhex);
      if (!found) {
         return "#" + c;
      }
   }
   return;
}

Antville.Referrer = function(url, text, count) {
   this.url = url;
   this.text = text;
   this.count = count;
   this.compose = function(key, prefix) {
      var query = new Antville.Query(this.url);
      if (query[key]) {
         if (prefix == null)
            prefix = "";
         return prefix + Antville.encode(query[key]);
      }
      return this.text;
   }
   return this;
}

Antville.Query = function(str) {
   if (str == undefined)
      var str = location.search.substring(1);
   else if (str.indexOf("?") > -1)
      var str = str.split("?")[1];
   if (str == "")
      return this;
   var parts = Antville.decode(unescape(str)).split("&");
   for (var i in parts) {
      var pair = parts[i].split("=");
      var key = pair[0];
      if (key) {
         key = key.replace(/\+/g, " ");
         var value = pair[1];
         if (value)
            value = value.replace(/\+/g, " ");
         this[key] = value;
      }
   }
   return this;
}

Antville.Filter = function(def, key) {
   this.key = key;
   if (def == null)
      this.items = [];
   else if (def instanceof Array)
      this.items = def;
   else
      this.items = def.replace(/\r/g, "\n").split("\n");
   this.test = function(str) {
      if (!str)
         return false;
      for (var n in this.items) {
         var re = new RegExp(this.items[n], "i");
         if (re.test(str))
            return true;
      }
      return false;
   }
   return this;
}












function DBN_preload(img)
{
	if (!document.images) { return; }
	if (!document.ImgArr) { document.ImgArr = new Array(); }
	
	for(i=0; i < arguments.length; i++) {
		var modstr = ( arguments[i+1] == null ) ? "1" : String(arguments[i+1]);
		document.ImgArr.push(new Image());
		document.ImgArr[document.ImgArr.length-1].src = img.src.substr(0, img.src.lastIndexOf("_")) + "_" + modstr + img.src.substr(img.src.lastIndexOf(".")); 
	}
}



function DBN_imgswap(img, mode)
{
	var modstr = ( mode == null ) ? "0" : String(mode);
	if ( !document.SwpArr ) { document.SwpArr = new Array() };
	while ( document.SwpArr.length > 0 ) 
	{ 
		var swpimg = DBN_swapone(document.SwpArr.pop(), "0");
	}
	DBN_swapone(img, modstr);	
	if ( mode > 0 ) { document.SwpArr.push(img); }
}


function DBN_swapone(img, modstr)
{
	img.src = img.src.substr(0, img.src.lastIndexOf("_")) + "_" + modstr + img.src.substr(img.src.lastIndexOf("."));
}


function DBN_openwin( url, param )
{
	param.l = (param.l) ? param.l : 100;
	param.t = (param.t) ? param.t : 100;
	param.w = (param.w) ? param.w : 800;
	param.h = (param.h) ? param.h : 600;
	
	if ( param.centered ) {
		param.l = (screen.width - param.w) / 2;
		param.t = (screen.height - param.h) / 2;
	}
	
	var winprops = "height="+param.h+",width="+param.w+",top="+param.t+",left="+param.l+",resizable";
	winprops += ( param.scroll != true ) ? ( ",scrollbars=no" ) : ( ",scrollbars=yes" );
	winprops += ( param.status != true ) ? ( ",status=no" ): ( ",status=yes" );
	winprops += ( param.location != true ) ? ( ",location=no" ) : ( ",location=yes" );
	winprops += ( param.menubar != true ) ? ( ",menubar=no" ) : ( ",menubar=yes" );
	
	winname = ( param.name ) ? param.name : "newwindow";	
	win = window.open( url, winname, winprops);
	
	if ( parseInt(navigator.appVersion) >= 4 ) { win.window.focus(); }
}



function DBN_assetswap( imgref, swaptarget, swapurl )
{	
	var swapimg = DBN_findObj(swaptarget);
	swapimg.src = swapurl;
}







/* * * * * * * * * * * * * * * * * * 
 * find images by name
 *
 * * * * * * * * * * * * * * * * * */
 
function DBN_lnkswap(imgname, mode)
{
	if ( (img = DBN_findObj(imgname)) != null )
	{
		DBN_imgswap(img, mode);
	}
};

function DBN_findObj(obj, scope) 
{ 
  	var p,i,x;  
  
	if (!scope){ scope=document };
	
	if ((( p = obj.indexOf("?")) > 0) && parent.frames.length ) {
		scope = parent.frames[obj.substring(p+1)].document; 
		obj=obj.substring( 0, p );
    }

	if (!(x = scope[obj]) && scope.all) { x = scope.all[obj]; }	
	for( i=0; !x && i < scope.forms.length; i++) { x = scope.forms[i][obj]; }	
	for( i=0; !x && scope.layers && i < scope.layers.length; i++) { x = DBN_findObj( obj, scope.layers[i].document); }
	if ( !x && scope.getElementById ) { x = scope.getElementById(obj); }	
	return x;
}


