function preloader(images) 
 {
 imageObj = new Image();
 for (img in images)
  {
  imageObj.src=img;
  }
 } 

var x,y;

function getDimensions()
{
if (self.innerHeight) // all except Explorer
{
	x = self.innerWidth;
	y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	x = document.documentElement.clientWidth;
	y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
	x = document.body.clientWidth;
	y = document.body.clientHeight;
}
}

function setMapRegion(r)
 {
 maps=document.getElementsByClassName("map-square")
 maps.each(function(map) {
 map.style.visibility="hidden";
 }); 
// alert(maps.length)
 $(r).style.left=x/2-60;
 $(r).style.top=270;
 $(r).style.visibility="visible";
 }

function closeMap(r)
 {
 $(r).style.visibility="hidden"
 }

function limitText(area) 
 {

 max_cols=area.getAttribute("cols")?area.getAttribute("cols"):40
 max_rows=area.getAttribute("rows")?area.getAttribute("rows"):3

 text=area.value

 strings=text.split(/[\n\r\f\t]+/gi)

// for (i=0;i<strings.length;i++)
//  {
//  strings[i]=strings[i].replace(/[\n\r\f\t]+/gi,"",strings[i])
//  }

 var flag = false;
 for (var i in strings)
  {
  if (strings[i].length>max_cols)
   {
   strings[i]=strings[i].substring(0,max_cols)
   flag = true
   }
  i++
  }

 if (flag)
  area.value = strings.join("\n") 

 if (strings.length>max_rows)
  {
  area.value = strings.slice(0,max_rows).join("\n") 
  }

 }

/*
function implode(strings,index)
 {
 if (index>strings.length)
  index=strings.length
 if (index<1 || strings.length<=1)
  return strings[0]
 else
  {
//  alert(index)
  text_new = ""
  for (i=0;i<=index-1;i++) 
   {
   text_new+=strings[i]
   if (i!=index) 
    {
    text_new+="\n"
    }
   }
  return text_new
  }
 }
*/
