var _gC = new Object();
var _L = new Array();

_gC.top = function() {
	return scroll(0,0);
}

_gC.clearSearcher = function(ob) {
	if(ob.value == _L.SBI) {
		ob.value = '';
		dojo.connect(ob, "onblur", this, function() {
			_gC.renewSearcher(ob);
		});
	}
}

_gC.renewSearcher = function(ob) {
	if( ob.value == '' ) {
		ob.value = _L.SBI;
	}
}
_gC.validate = function(id, info) {
	var c = dojo.coords(id, 'true');
	var m = dojo.place('<div class="sysValidate"><div class="arrow"></div><div class="content">'+info+'</div><div class="clear"></div></div>', dojo.body());
	m.style.top = c.y+'px';
	m.style.left = c.x+c.w+14+'px';
	m.style.display = 'block';
	dojo.byId(id).style.border = 'solid 1px #e0007a';
	m.id = 'sysval_'+id;
}
_gC.unValidate = function(id, brd) {
	dojo.destroy('sysval_'+id);
	dojo.byId(id).style.border = brd;
}

_gC.displayNotice = function(text) {
	var noticeBox = dojo.place('<div class="noticeWindow" id="noticeWindow"><div class="text">'+text+'</div><a href="javascript:void(0)" onclick="_gC.closeNoticeWindow();" class="blueButton">OK</a></div>', dojo.body(),"first");
	noticeBox.style.left = (((window.innerWidth-560)/2)+'px');
	noticeBox.style.top = (((window.innerHeight-325)/2)+'px');
}

_gC.displayError = function(text) {
	var errorBox = dojo.place('<div class="errorWindow" id="errorWindow"><div class="text">'+text+'</div><a href="javascript:void(0)" onclick="_gC.closeErrorWindow();" class="blueButton">OK</a></div>', dojo.body(),"first");
}

_gC.closeNoticeWindow = function() {
	dojo.destroy('noticeWindow');
}

_gC.closeErrorWindow = function() {
	dojo.destroy('errorWindow');
}

_gC.searchControl = function(obj) {

	if (dojo.byId('searchMore').style.display == 'block')
	{
		dojo.byId('searchMore').style.display = 'none';
		obj.innerHTML = _L['SEARCH_1'];
	}
	else
	{
		dojo.byId('searchMore').style.display = 'block';
		obj.innerHTML = _L['SEARCH_2'];
	}
}

$(document).ready(function(){
	
	$('.sysValidate').livequery(function(){
		
		errorPosition();
		
	});
	
	
	$('.searcherMore form').submit(function(){
		
		if ($('#city').val()==_L['SEARCH_LOCALISATION_CITY_TIP'])
		{
			$('#city').val('');
		}
	});
	
	if ($('#search').get()!='')
	{
		$('.searchType a').click(function() {			
			$('#search').val($(this).html());
			$('.searcherMore form').submit();
		});
	}
});

function errorPosition()
{
	$('.sysValidate').each(function(item){
		
		var element= $(this).parent().find(':first');
				
		if ($(element).attr('type')=='hidden' && $(element).next().attr('type')=='checkbox')
		{
			element= $(element).parent();
		}
		else
		{
			$(element).css({border: '1px solid #E0007A'});
			
			if ($(this).parent().find('input:text').length>1)
			{
				element= $(this).parent().find('input:last');
			}
		}
		
		
		$(this).css({position: 'absolute', top: $(element).position().top, left: $(element).position().left+$(element).width()+11});
		$(this).show();
	});
}
