var num_of_files = 1;
var num_of_attachs = 1;
var files_limit = 9;
var attachs_limit = 9;
var glat = 0;
var glng = 0;
var gzoom = 0;
var aTmpCount = new Array();
var request_send = false;
var bFlag = false;
var nX = 0;
var aImages = new Array();
var wW = screenSize().w;
var wH = screenSize().h;
var sX = defScroll().x;
var sY = defScroll().y;
var bAccess = false;
var num_of_c = 0;
var bDetailPage = false;

window.onload = function()
{
	wW = screenSize().w;
	wH =  screenSize().h;	
}
window.onresize = function()
{
	wW = screenSize().w;
	wH =  screenSize().h;
}
window.onscroll = function()
{
	sX = defScroll().x;
	sY = defScroll().y;
}

function screenSize() 
{
    var w, h; // Объявляем переменные, w - длина, h - высота
    
    if(typeof(window.innerWidth) == 'number')
    {
    	w = window.innerWidth;
    	h = window.innerHeight;
    }
    else if(typeof(document.documentElement.clientHeight) == 'number')
    {
    	w = document.documentElement.clientWidth;
    	h = document.documentElement.clientHeight;
    }
    else
    {
    	w = document.body.offsetWidth;
    	h = document.body.offsetHeight;
    }
    
    return {w:w, h:h};
}

function defScroll() 
{
      var x = y = 0;
      // Gecko поддерживает свойства scrollX(scrollY)
      // Для IE & Opera приходится идти в обход
      
      if(typeof(window.scrollX) == 'number')
      {
      	x = window.scrollX;
      	y = window.scrollY;
      }
      else if(typeof(document.documentElement.scrollLeft) == 'number')
      {
      	x = document.documentElement.scrollLeft;
      	y = document.documentElement.scrollTop;
      }
      else
      {
      	x = document.body.scrollLeft;
   	y = document.body.scrollTop;
      }

      return {x:x, y:y};
}

// форматирует вывод числа, аналог number_format() в PHP
function number_format(number, decimals, dec_point, thousands_sep){
  var exponent = "";
  var numberstr = number.toString ();
  var eindex = numberstr.indexOf ("e");
 var i, z;
  if(eindex > -1){
    exponent = numberstr.substring (eindex);
    number = parseFloat (numberstr.substring (0, eindex));
  }
  
  if(decimals != null){
    var temp = Math.pow (10, decimals);
    number = Math.round (number * temp) / temp;
  }
  var sign = number < 0 ? "-" : "";
  var integer = (number > 0 ? 
      Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
  
  var fractional = number.toString ().substring (integer.length + sign.length);
  dec_point = dec_point != null ? dec_point : ".";
  fractional = decimals != null && decimals > 0 || fractional.length > 1 ? (dec_point + fractional.substring (1)) : "";
  if(decimals != null && decimals > 0){
    for(i = fractional.length - 1, z = decimals; i < z; ++i)
      fractional += "0";
  }
  
  thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? 
                  thousands_sep : null;
  if(thousands_sep != null && thousands_sep != ""){
  for (i = integer.length - 3; i > 0; i -= 3)
   integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
  }
  return sign + integer + fractional + exponent;
}

function str2num(num)
{
	return num.replace(/[\D]/g,"");
}

/* function $() 
{
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
} */

function getr()
{
	var oDate = new Date();
	return oDate.getSeconds();
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function confirm_event(msg)
{
	this.blur();
	return confirm(msg);
}

function set_display(the_id)
{
	$("#" + the_id).css("display", (($("#" + the_id).css("display") == 'none') ? '' : 'none'));
	return false;
}
function add_new_file()
{	
	if(num_of_files > files_limit)
	{
		alert('Превышено максимальное количество изображений = ' + (files_limit+1));
		return false;
	}
	
	var the_box = document.getElementById("file_box");
	var new_file = document.createElement("div");
	new_file.id = 'bfile_name_' + num_of_files;
	new_file.innerHTML += '<input type="file" name="file_name_' + num_of_files + '" value="" class="p40" size="29" id="file_name_' + num_of_files + '"> <a class="forfield" href="javascript:void(0);" onclick="this.blur();return del_new_file(' + num_of_files + ');">Удалить</a>';
	new_file.innerHTML += '<input type="text" name="name_file_' + num_of_files + '" value="Название изображения" class="p30" id="name_file_' + num_of_files + '" onclick="this.value=\'\';">';
	the_box.appendChild(new_file);
	$("#file_name_" + num_of_files).focus();
	num_of_files++;
	return false;
}
function del_new_file(num)
{
	set_display('bfile_name_' + num);
	$('#bfile_name_'+num).remove();
	num_of_files--;
	return false;
}

function add_new_attach()
{	
	if(num_of_attachs > attachs_limit)
	{
		alert('Превышено максимальное количество файлов = ' + (attachs_limit+1));
		return false;
	}
	
	var the_box = document.getElementById("attachs_box");
	var new_file = document.createElement("div");
	new_file.id = 'afile_name_' + num_of_files;
	new_file.innerHTML += '<input type="text" name="name_attachs_' + num_of_attachs + '" value="Название файла" class="p40" id="name_attachs_' + num_of_attachs + '" onclick="this.value=\'\';">';
	new_file.innerHTML += '<input type="file" name="attachs_' + num_of_attachs + '" value="" class="p30" size="20" id="attachs_' + num_of_attachs + '"> <a class="forfield" href="javascript:void(0);" onclick="this.blur();return del_new_attach(' + num_of_attachs + ');">Удалить</a>';
	the_box.appendChild(new_file);
	$("#attachs_" + num_of_attachs).focus();
	num_of_attachs++;
	return false;
}
function del_new_attach(num)
{
	set_display('afile_name_' + num);
	$('#afile_name_'+num).remove();
	num_of_attachs--;
	return false;
}

// google maps management

function gmapchooser_open()
{
	window.open('gmapchooser.html?r' + getr());
	return false;
}
function gmapchooser_initcoords()
{
	glat = window.opener.document.getElementById('gmaplat').value;
	glng = window.opener.document.getElementById('gmaplng').value;
	gzoom = window.opener.document.getElementById('gmapzoom').value;
}
function gmapchooser_checkpoint()
{
	if(glat == 0 || glng == 0)
	{
		if(!confirm_event('Вы уверены, что хотите установить нулевые координаты?'))
		{
			return false;
		}
	}

	window.opener.document.getElementById('gmaplat').value = glat;
	window.opener.document.getElementById('gmaplng').value = glng;
	window.opener.document.getElementById('gmapzoom').value = gzoom;
	window.close();
}

// end gmaps

function select_updown(the_id,the_do)
{
	var oObj = document.getElementById(the_id);
	var nIndex = oObj.selectedIndex;
	var nLen = oObj.options.length;
	
	if(typeof(nIndex) == 'undefined')
	{
		return false;
	}
	
	if(the_do == 'up')
	{
		if(oObj.selectedIndex >= 0)
		{
			oObj.selectedIndex--;
		}
		else
		{
			oObj.selectedIndex = nLen-1;
		}
	}
	else if(the_do == 'down')
	{
		if(oObj.selectedIndex < nLen)
		{
			oObj.selectedIndex++;
		}
		else
		{
			oObj.selectedIndex = 0;
		}
	}
	else if(the_do == 'tup')
	{
		oObj.selectedIndex = 0;
	}
	else if(the_do == 'tdown')
	{
		oObj.selectedIndex = oObj.options.length-1;
	}
	else
	{
		oObj.selectedIndex = 0;
	}
}
function checkbox_set(the_id)
{
	$('#'+the_id).attr('checked',($('#'+the_id).attr('checked') ? false : true));
}
function disable_savebutton()
{
	$('#save_continue').click(function()
	{
		return false;
	});
	$('#save_exit').click(function()
	{
		return false;
	});
}
function checkbox_continent(the_id,continent_id,item_id)
{
	if(typeof(aTmpCount[item_id]) == 'undefined')
	{
		aTmpCount[item_id] = 0;
	}

	if(!$('#'+the_id).attr('checked'))
	{
		aTmpCount[item_id]++;
	}
	else
	{
		aTmpCount[item_id]--;
	}
	
	if(aTmpCount[item_id] == 0)
	{
		$('#'+continent_id).attr('checked',false);
		$('#'+continent_id).attr('disabled',false);
	}
	else
	{
		$('#'+continent_id).attr('checked',true);
		$('#'+continent_id).attr('disabled',true);
	}
}
function select_countries(aCountries,continent_id,country_id,item_id)
{
	if(typeof(aCountries) == 'undefined' || aCountries.length <= 0)
	{
		return false;
	}
	
	var _cid = $('#'+continent_id).attr('value');
	var aCur;
	var x = 1;
	var oSelect = document.getElementById(country_id);
	oSelect.options.length = 0;
	oSelect.options[0] = new Option('Выберите','0');
	
	for(var i=0;i<aCountries.length;i++)
	{
		aCur = aCountries[i];
		
		if(aCur[0] == _cid)
		{
			oSelect.options[x] = new Option(aCur[2],aCur[1]);
			
			if(typeof(item_id) != 'undefined' && aCur[1] == item_id)
			{
				oSelect.options[x].selected = true;
			}
			x++;
		}
	}
}

function w_select_countries(the_id, from_id)
{
	set_display(the_id);
	$('#'+the_id).css('top',(sY+(wH/2-80))+'px');
//	$('#'+the_id).css('left',(wW-800)+'px');
	$('#'+the_id).css('left','30%');
	$('#'+from_id).blur();
}

function email_check(str) 
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
}

function show_requestform(item_id)
{
	var strTop = ($(window).scrollTop()+25) + 'px';
	var strLeft = ($(window).width()/2-200) + 'px';

	$('#_requestdiv').css('display','');
	$('#_requestdiv').css('top',strTop);
	$('#_requestdiv').css('left',strLeft);
	$('#_requestcancel').css('display','');
	$('#_requestitemid').attr('value',item_id);

	$('#_requestcancel').click(function()
	{
		$('#_requestemail').css('border','2px solid silver');
		$('#_requestphone').css('border','2px solid silver');
		$('#_requesttext').css('border','2px solid silver');
		$('#_requestdiv').css('display','none');
	});
		
	return false;
}

function show_orderform()
{
	var strTop = ($(window).scrollTop()+25) + 'px';
	var strLeft = ($(window).width()/2-200) + 'px';

	$('#_orderdiv').css('display','');
	$('#_orderdiv').css('top',strTop);
	$('#_orderdiv').css('left',strLeft);
	$('#_ordercancel').css('display','');

	$('#_ordercancel').click(function()
	{
		$('#_orderemail').css('border','2px solid silver');
		$('#_orderephone').css('border','2px solid silver');
		$('#_ordertext').css('border','2px solid silver');
		$('#_orderdiv').css('display','none');
	});
		
	return false;
}

function show_bookmarkform(item_id)
{
	if(bAccess)
	{
		_do_bookmark(item_id,$('#_bookmarkemail').attr('value'));
		return false;
	}

	var strTop = ($(window).scrollTop()+80) + 'px';
	var strLeft = ($(window).width()/2-200) + 'px';

	$('#_bookmarkdiv').css('display','');
	$('#_bookmarkdiv').css('top',strTop);
	$('#_bookmarkdiv').css('left',strLeft);
	$('#_requestcancel').css('display','');
	$('#_bookmarkcancel').css('display','');
	$('#_bookmarkitemid').attr('value',item_id);

	$('#_bookmarkcancel').click(function()
	{
		$('#_bookmarkemail').css('border','2px solid silver');
		$('#_bookmarkdiv').css('display','none');
	});
		
	return false;
}

function show_answerform(item_id)
{
	$('#_answerdiv').css('display','');
	$('#_answerdiv').css('top',(sY+30)+'px');
	$('#_answerdiv').css('left',(wW/2-275)+'px');
	$('#_answercancel').css('display','');
	$('#_answercancel').css('display','');
	$('#_answeritemid').attr('value',item_id);

	$('#_answercancel').click(function()
	{
		$('#_answertext').css('border','2px solid silver');
		$('#_answerdiv').css('display','none');
	});

	return false;
}

function show_uimessage(msg)
{
	var the_id = '_messagediv';
	document.getElementById(the_id).innerHTML = msg + ' <a href="#" onclick="set_display(\''+the_id+'\');">Скрыть</a>';
	$('#'+the_id).css('display','');
}

function recount_cu(from_id,the_id,price,skip_cu,extra) // требуется доработка
{
	extra = (!extra || extra == 'undefined') ? '' : extra;
	var recount = parseFloat(str2num(price) / $('#'+from_id+' option:selected').val());
	$('#'+the_id).attr('innerHTML',number_format(recount, 0, '.', ' ') + (skip_cu ? '' : ' '+$('#'+from_id+' option:selected').text()) + extra);
}

function printrecount_cu(from_id,the_id,price,extra)
{
	recount_cu(from_id,the_id,price,false,extra);
	var recount = parseFloat(str2num(price) / $('#'+from_id+' option:selected').val());
	var strcu = number_format(recount, 0, '.', ' ')+' '+$('#'+from_id+' option:selected').text();
	
	if(typeof(_page_title) == 'string')
	{
		document.title = _page_title+' (стоимость: '+strcu+')';
	}
}

function show_image(file_name,bfile_name)
{
	document.getElementById('_bigimageimg').src = file_name;
	document.getElementById('_bigimagehref').href = bfile_name;
	return false;
}

function roll_images(the_id,the_do,limit)
{
	var html = '';
	limit = (typeof(limit) != 'number') ? 2 : limit;
	var nY = 0;
	
	if(aImages.length > 0)
	{
		limit = (aImages.length < limit) ? aImages.length-1 : limit;
	
		if(typeof(the_do) == 'string')
		{
			if(the_do == 'prev')
			{
				nX = (nX > 0) ? nX-1 : aImages.length-limit-1;
		}
			else if(the_do == 'next')
			{
				nX = (nX < aImages.length-limit-1) ? nX+1 : 0;
			}
		}

		for(var i=nX;i<aImages.length;i++)
		{
			html += '<div style="float:left;"><a href="#" onclick="return show_image(\'_bigimagediv\',\''+aImages[i][1]+'\',\''+i+'\');">';
			html += '<img src="'+aImages[i][0]+'" border="0" style="margin:2px;border:1px solid orange;" />';
			html += '</a><br /><div style="min-width:1px;text-align:center;font-size:10px;font-family:arial;color:silver;">' + (i+1) + '</div></div>';

			if(nY%limit == 0 && nY > 0)
			{
				break;
			}
			
			nY++;
		}
		
		$('#'+the_id).attr('innerHTML',html);
	}
	
	return false;
}

function set_c(the_id)
{
	if($('#'+the_id).attr('checked'))
	{
		num_of_c ++;
	}
	else
	{
		num_of_c --;
	}
	
	if(num_of_c)
	{
		document.getElementById('scountry').options[0].text = 'выбрано стран: '+(num_of_c);
	}
	else
	{
		document.getElementById('scountry').options[0].text = 'все страны';
	}
}

function recount_mortgage()
{
	// price - _mortgageprice
	// start pay - _mortgagestart
	// percent - _mortgagepercent
	// period - _mortgageperiod
	// monprice - _mortgagemonprice
	// monpricecu - _mortgagemonpricecu
	// real price - _mortgagemonpricereal (hidden field)
	
	var percent = $('#_mortgagepercent').val()/100+1;
	var price = $('#_mortgageprice').val() - $('#_mortgagestart').val();
	price /= $('#_mortgageperiod').val();
	price *= percent;
	price /= 12;
	$('#_mortgagemonprice').attr('innerHTML',number_format(price, 0, '', ' '));
	
	$('#_mortgagemonpricereal').attr('value',number_format(price,2));
	
	return false;
}

function set_minmax()
{
	var cu = $('#cu :selected').text();
	document.getElementById('price').options[0].text = 'min ' + cu;
	document.getElementById('price_to').options[0].text = 'max ' + cu;
}

function set_areas()
{
	var otype = $('#objtypeid :selected').val();

	/*
		1 - замки
		2 - пентхаусы
		3 - земельные участки (жил)
		4 - земельные участки (комм)
		5 - апартаменты
		6 - виллы и коттеджи
		7 - здания
		8 - помещения
		9 - готовый бизнес
		10 - студия
	*/
	
	if(otype == 1 || otype == 6 || otype == 7)
	{
		$('#area').attr('disabled',false);
		$('#area_total').attr('disabled',false);
		$('#area_plot').attr('disabled',false);
		$('#area_unit').attr('disabled',false);
	}
	if(otype == 2 || otype == 5 || otype == 10)
	{
		$('#area').attr('disabled',false);
		$('#area_total').attr('disabled',false);
		$('#area_plot').attr('disabled',true);
		$('#area_unit').attr('disabled',true);
	}
	else if(otype == 3 || otype == 4)
	{
		$('#area').attr('disabled',true);
		$('#area_total').attr('disabled',true);
		$('#area_plot').attr('disabled',false);
		$('#area_unit').attr('disabled',false);
	}
	else if(otype == 8)
	{
		$('#area').attr('disabled',true);
		$('#area_total').attr('disabled',false);
		$('#area_plot').attr('disabled',true);
		$('#area_unit').attr('disabled',true);
	}
	else if(otype == 9)
	{
		$('#area').attr('disabled',true);
		$('#area_total').attr('disabled',false);
		$('#area_plot').attr('disabled',false);
		$('#area_unit').attr('disabled',false);
	}
	else
	{
		$('#area').attr('disabled',false);
		$('#area_total').attr('disabled',false);
		$('#area_plot').attr('disabled',false);
		$('#area_unit').attr('disabled',false);
	}
}

function set_aunit(unit)
{
	var area = $('#area_plot').val();
	//var unit = $('#area_unit :selected').val();
	
	if(unit == 'm2')
	{
		area *= 10000;
		document.getElementById('area_unit').options[0].selected = true;
	}
	else
	{
		area /= 10000;
		document.getElementById('area_unit').options[1].selected = true;
	}
	
	$('#area_plot').val(area);
	
	return false;
}

function do_print()
{
	if(!window.print())
	{
		setTimeout("set_display('_recountc'); set_display('printbutton');",600);
	}
	else
	{
		setTimeout("set_display('_recountc'); set_display('printbutton');",600);
	}

	return false;
}

function do_changeemail(email)
{
	var bTmp = ($('#mail').attr('disabled') ? true : false);
	
	if(bTmp && !confirm('Нужно ввести существующий e-mail, владельцем которого вы являетесь.\nПродолжить?'))
	{
		$('#mailchange').blur();
		return false;
	}
	
	$('#mailchange').attr('innerHTML',(bTmp ? 'отмена' : 'изменить'));
	$('#mail').attr('disabled',(bTmp ? false : true));
	
	if(bTmp)
	{
		$('#mail').focus();
		$('#mail').attr('name','form[email]');
		$('#mail').attr('class','musthave');
	}
	else
	{
		$('#mail').val(email);
		$('#mail').attr('name','');
		$('#mail').attr('class','');
	}
	
	return false;
}

function set_otype_enabled(the_id)
{
	var aTmp1;
	var aTmp2;
	var strCur;
	
	if(the_id == 1) // live
	{
		aTmp1 = acomm;
		aTmp2 = alive;
	}
	else
	{
		aTmp1 = alive;
		aTmp2 = acomm;
	}
	
	for(var i=0;i<aTmp1.length;i++)
	{
		strCur = aTmp1[i];
		$('#'+strCur).attr('disabled',true);
	}
	for(var i=0;i<aTmp2.length;i++)
	{
		strCur = aTmp2[i];
		$('#'+strCur).attr('disabled',false);
	}
}

function choose_variant(chval,type)
{
	chval = (typeof(chval) == 'undefined') ? 1 : chval;
	var _chval = (chval == 1) ? 2 : 1;

	$('#'+type+'div_'+chval).attr('class','bargain_checked');
	$('#'+type+'div_'+_chval).attr('class','bargain_unchecked');
	$('#'+type+'_'+chval).attr('checked',true);
	$('#'+type+'_'+chval).blur();
	$('#'+type+'_'+_chval).attr('checked',false);

	if(type == 'bargain')
	{
		if(_chval == 1)
		{
			$('#otypediv_2').attr('onclick','');
			$('#otypediv_2').css('color','#ccc');
			$('#otype_2').attr('disabled',true);

			choose_variant(1,'otype');
		}
		else
		{
			$('#otypediv_2').attr('onclick','choose_variant(2,\'otype\');');
			$('#otypediv_2').css('color','#000');
			$('#otype_2').attr('disabled',false);
		}
	}

	$('#'+type).val(chval);
}

function set_price2week()
{
	var price = parseInt($('#price').val());

	if(price)
	{
		$('#price').val(number_format(price/4));
	}

	return false;
}

function absPosition(obj) { // Опрелеляем top - left координаты блока obj
	this.x = 0;
	this.y = 0;
	while(obj) 
	{
		this.x += obj.offsetLeft;
		this.y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return {x:this.x,y:this.y};
}

/* client front-end non ajax funcs */

function set_countries_by_scond(aCountries)
{
	// ids _ac
	var i = 0;

	for(i=0;i<aCountries.length;i++)
	{
		$('#_ac'+aCountries[i]).attr('checked',true);
	}
}
function _removeC(oObj)
{
	var _aElms = $(oObj).attr('id').split('_');
	var _nId = _aElms[_aElms.length-1];
	$('#_countrieslist_key_'+_nId).remove();
	$('#form_keyupselect_key_'+_nId).attr('clicked',0);
	$('#form_keyupselect_key_'+_nId).attr('class','nowselected_key mb5 p5');
	$('#_countrieslist').val($('#_countrieslist').val().replace(','+_nId+' ',''));

	if($('#_countrieslist').val() == '')
	{
		$('#form_nowselected_box').hide();
	}

	return false;
}
function _removeAllC()
{
	$('#_countrieslist').val('');
	$('#form_nowselected').html('');
	$('div[clicked|=1]').attr('clicked',0);
	$('div[clicked|=1]').attr('class','nowselected_key mb5 p5');
	$('#form_nowselected_box').hide();
	return false;
}

function closediv()
{
	$('#container').html('');
	$('#container').css('display','none');
	$('#container').css('left',0);
	$('#container').css('top',0);
	bEdit = false;
	return false;
}

// talk manage

function showErrorContainer(strMsg)
{
	var strContainerId = 'errorcontainer1';
	var strTop = $(window).scrollTop() + 'px';
	var strWidth = ($(document).width() ? $(document).width()-40 + 'px' : '100%'); // dont supported in Opera.

	$('#'+strContainerId).html(strMsg);

	if($('#'+strContainerId).css('opacity') < 1 && $('#'+strContainerId).css('opacity') > 0)
	{
		return false;
	}

	$('#'+strContainerId).css('position','absolute');
	$('#'+strContainerId).css('top',strTop);
	$('#'+strContainerId).css('z-index','10101');
	$('#'+strContainerId).css('background-color','#fff');
	$('#'+strContainerId).css('width',strWidth);
	$('#'+strContainerId).css('height',50);
	$('#'+strContainerId).css('color','red');
	$('#'+strContainerId).css({opacity:1.0});
	$('#'+strContainerId).addClass('p10');
	$('#'+strContainerId).addClass('bold');
	$('#'+strContainerId).css('text-align','center');
	$('#'+strContainerId).css('padding','20px');
	$('#'+strContainerId).show().animate({opacity: 0.0}, 5000);
}

function showSuccessContainer(strMsg)
{
	var strContainerId = 'successcontainer1';
	var strTop = $(window).scrollTop() + 'px';
	var strWidth = ($(document).width() ? $(document).width()-40 + 'px' : '100%'); // dont supported in Opera.

	$('#'+strContainerId).html(strMsg);

	if($('#'+strContainerId).css('opacity') < 1 && $('#'+strContainerId).css('opacity') > 0)
	{
		return false;
	}

	$('#'+strContainerId).css('position','absolute');
	$('#'+strContainerId).css('top',strTop);
	$('#'+strContainerId).css('z-index','10101');
	$('#'+strContainerId).css('background-color','#fff');
	$('#'+strContainerId).css('width',strWidth);
	$('#'+strContainerId).css('height',50);
	$('#'+strContainerId).css('color','green');
	$('#'+strContainerId).css({opacity:1.0});
	$('#'+strContainerId).addClass('p10');
	$('#'+strContainerId).addClass('bold');
	$('#'+strContainerId).css('text-align','center');
	$('#'+strContainerId).css('padding','20px');
	$('#'+strContainerId).show().animate({opacity: 0.0}, 5000);
}
