


var afterloing  = {

	wentLogin : function()
	{ 
		//		THIS FUNCTION IS INTO www/connector/web/js/connector.js				
		//		new Ajax.Updater( 'msgcount', '/ajax/getunreaded' , {
		//			insertion: Insertion.Bottom,
		//			onComplete: function(transport) 
		//			{
		//				if (200 == transport.status)
		//				{
		//					$('msgcount').innerHTML = transport.responseText;
		//					$('connector_unreaded').innerHTML = transport.responseText;
		//				}
		//			}
		//		});

		new PeriodicalExecuter(function(pe) 
		{
		
			$('msgcount').innerHTML = ' ';

			
			/*
			try {
				$('connector_unreaded').innerHTML = ' ';
			}
			catch(e){} */
			if( $('connector_unreaded') == undefined )
			return ;
				$('connector_unreaded').innerHTML = ' ';
						
					new Ajax.Updater( 'msgcount', '/ajax/getunreaded' , {
					insertion: Insertion.Bottom,
					onComplete: function(transport) 
					{
										if (200 == transport.status)
										{
											$('msgcount').innerHTML = transport.responseText;
										//	try {
												$('connector_unreaded').innerHTML = transport.responseText;
										//	}
										//	catch(e){}
										}
						}});}, 30);
		
					}
					
				
	
	} 




var fcontrol  = {
	a:Array(),
	set : function(a)
	{ 
	 this.a =a;
	 	
	} ,
	
	
	selected: function()
	{ 
		
		for( var i=0 ; i < this.a.length; i++ ) {
			$(this.a[i]).selectedIndex  = 0 ; 
		} 
		
	
		
	} ,
	
	_dis :	function()
	{ 
	

		for( var i=0 ; i < this.a.length; i++ ) {
			$(this.a[i]).disabled  = true  ; 
		
		} 
		
	} ,
	_enb :	function()
	{ 
	

		for( var i=0 ; i < this.a.length; i++ ) {
			$(this.a[i]).disabled  = false  ; 
		} 
	
	} ,
	
	set_dis :   function (val,pThis) 
	{ 

		
		
		var  current  =   $F(pThis);
		if(current == val )
		{ 
			this.selected();
			this._dis();
		} 
		else
			{ 
			this._enb();
			} 
	} 
	
	
} 
	



var multioption = {
	
	selectedActions: Array(),
	dublicate:0,
	select_id:'representation',
	div_plot_id:'representation_plot',
	bodyinitreg : function(string)
	{ 
	
	
	if( document.getElementById(this.div_plot_id)==null)
	return ;
		
  	 if( string ==  '') return ;
		
	
		var regions_array  = string.split(",");
	    this.select_id = 	$(this.select_id);
	
	
			
		for (var loop=1; loop < regions_array.length; loop++)
		{
		//alert(regions_array.length);
		//	if(this.select_id.options[regions_array[loop]].value)
		//	alert(regions_array[loop]);
		//		this.select_id.selectedIndex = regions_array[loop];
		//		this.init();
			this.selectedActions.push(Array(
			this.select_id.options[regions_array[loop]].value,
			this.select_id.options[regions_array[loop]].text));
		} 
	
		this.buildselectedActions();

	},
	
	init: function()
	{
	
	
	this.select_id = 	$(this.select_id);
		
	this.dublicate=0;
	
	
	if(this.select_id.selectedIndex==0 )
	return ;
	
	for (var i = 0;i<this.selectedActions.length;i++)
	{
		
		
	if (this.selectedActions[i][1] == this.select_id.options[this.select_id.selectedIndex].text)	this.dublicate=1;
	}
	if ( this.selectedActions.length > 4 ) { alert('You can select maximum 5 countries!'); }
	else if (this.dublicate==0) {this.selectedActions.push(Array(
	this.select_id.options[this.select_id.selectedIndex].value,this.select_id.options[this.select_id.selectedIndex].text));
	this.buildselectedActions();}
	
	this.select_id.selectedIndex=0;
	
		
		
	},
	
	
	buildselectedActions: function()
	{
		html = '';
    for (var i = 0;i<this.selectedActions.length;i++)
   {
   html += '<div class="selectActions">* '+this.selectedActions[i][1]+' '+'<a href="javascript:multioption.removeselectedAction('+i+');">remove</a><input type="hidden" name="selectedactionhidden[]" value="'+this.selectedActions[i][0]+'"></div>';
   }
   document.getElementById(this.div_plot_id).innerHTML = html;
	
		
		
		
	},
	
	
	removeselectedAction: function(id)
	{
		
		this.selectedActions.splice(id,1);
	    this.buildselectedActions();
	 	
		
		
	}
	
	
	
}



/****************************************************************************************************************/


function _DoInput($blockid,$name, $val)
{ 
	$block  = $($blockid);
	$block.innerHTML =  '<input type="text"  name="' + $name + '"  id="' + $name + '"  value="' + $val  + '" >';

} 

			
function _DoButton(val,id1,id2,id3)
{ 	
	if(  (val.options[val.selectedIndex].text )=='Other' )
	{ 
	 	$(id3).value = "type other language";
	} else 
	{
			$(id3).value = val.options[val.selectedIndex].text;
	} 
} 



function confirmation(url) {
	var answer = confirm("Are you sure you want to delete?")
	if (answer){
		window.location = url;
	}
	else 
	{ 
		return false;
	} 
}


function verifyDelete() {
    if( confirm("Are you sure you want to delete?") ) return true;
	return false;
}


Event.observe(window, 'load', function() {
	var lagent = 	$("license0");
	if( lagent == null ) return ;
	_Dodisble(lagent);
	}
);


function _Dodisble(_select)
{ 
	if ( 	($F(_select) == 2 )  ) 
	{ 
		$("license1").disable();
		$("license2").disable();
	} else {
		$("license1").enable();
		$("license2").enable();
	} 
} 



function goToURL(myLink) 
{ 
	if ( !$F('confirm') ) 
	{ 
		alert('Please confirm before apply.');return ;
	} 
	window.location = myLink; 
}

