// JavaScript Document
window.onload = function () {
new Ajax.Autocompleter("v_prefarence", "show_vola", base_url+"myuser/get_volatility_options/", {});
new Ajax.Autocompleter("aum_preference", "show_aum", base_url+"myuser/get_aum_preferenct/", {});
new Ajax.Autocompleter("req_country", "show_country", base_url+"myuser/get_country_options/", {});
return false;
}
J(document).ready(function() {
	J('#login').submit(function(){
			var st=false;					
			if(document.getElementById('user_name').value==''){
			//alert('User name cannot be blank');
			document.getElementById('user_name').style.borderColor='#ff0000';
			st=true;
			}
			else{
				document.getElementById('user_name').style.borderColor='';
			}
			if(document.getElementById('password').value==''){
			document.getElementById('password').style.borderColor='#ff0000';
			st=true;
			}
			else{
				document.getElementById('password').style.borderColor='';
			}
			
			if(st)
			return false;
			
	});
});
J(document).ready(function() {
	J('#investor_form').submit(function(){
	
	var message='';
	
	var for_geographic=0;
	var g_focus=document.getElementById('total_g_focus').value;
	for(var i=0;i<g_focus;i++)
	{
		if(document.getElementById('g_focus_'+i).checked)
		{
			for_geographic++;
		}
	}
	if(for_geographic==0)
	{
		message=message+'Please select at least one geographic focus. ';
	}
	
	var for_strategy=0;
	var s_focus=document.getElementById('total_s_focus').value;
	for(var i=0;i<s_focus;i++)
	{
		if(document.getElementById('s_focus_'+i).checked)
		{
			for_strategy++;
		}
	}
	if(for_strategy==0)
	{
		message=message+'\nPlease select at least one strategy focus. ';
	}
	
	if(message!='')	
	{
		alert(message);
		return false;
	}

	});
});



/*function check_unchecked(total_field,key,msg){
	var message='';
	var hold=0;
	total=document.getElementById(''+total_field).value;
	for(var i=0; i<total; i++)
	{
		if(document.getElementById(''+key+i).checked)
		hold++;
	}
	if(hold==0)
	{
		message=message+msg;
	}	
	
	return message;
}*/


function check_uncheck_all_strategy_for_user(check_div,chk_id,status,n,checked_field_count)
{	var i=0;
	if(status=='yes')
	{	
		document.getElementById(checked_field_count).value=n;
		for(i=0; i<n; i++)
		{
			document.getElementById(chk_id+i).checked=1;
			document.getElementById(check_div+i).className='inv_selected';
		}
	}
	else
	{
		document.getElementById(checked_field_count).value=n;
		for(i=0; i<n; i++)
		{	
			document.getElementById(chk_id+i).checked=0;
			document.getElementById(check_div+i).className='inv_non_selected';
		}
	}
}

function confirmation_message(str_n,geo_n,type_n,str,geo,inv_type)
{
	var output='';
	var a=0;
	var b=0;
	var c=0;
	
	for(var i=0; i<str_n; i++)
	{
		if(document.getElementById(str+i).checked==false)
		a++;
	}
	for(var j=0; j<geo_n; j++)
	{
		if(document.getElementById(geo+j).checked==false)
		b++;
	}
	for(var k=0; k<type_n; k++)
	{
		if(document.getElementById(inv_type+k).checked==false)
		c++;
	}
	if(str_n == a)
	{
		output=output+'Please select at list one item from strategy focus';
		alert(output);
		return false;
	}
	if(geo_n == b)
	{
		output=output+'Please select at list one item from geographic focus';
		alert(output);
		return false;
	}
	if(type_n == c)
	{
		output=output+'Please select at list one item from investor type';
		alert(output);
		return false;	
	}
}

function admin()
{
	document.getElementById('member_level').disabled=1;
	document.getElementById('member_level').value='';
}
function general()
{
	document.getElementById('member_level').disabled=0;
}


function show_div_for_search(readio_btn,show_text)
{
	J('#'+readio_btn).show('slow');
	J('#'+show_text).show('slow');
}
function checkAll( n, fldName ) {
  if (!fldName) {
     fldName = 'cb';
  }
	var f = document.adminForm;
	var c = f.toggle.checked;
	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}
	if (c) {
		document.adminForm.boxchecked.value = n2;
	} else {
		document.adminForm.boxchecked.value = 0;
	}
}

function isChecked(isitchecked){
	if (isitchecked == true){
		document.adminForm.boxchecked.value++;
	}
	else {
		document.adminForm.boxchecked.value--;
	}
}


function DeleteUsers(n,fldName){
if (!fldName) {
     fldName = 'cb';
  }
var f = document.adminForm;
 f.ids.value='';
for (i=0; i < n; i++) {
	cb = eval( 'f.' + fldName + '' + i );
	if (cb) {
		if(cb.checked){
			if(f.ids.value!="")
			 f.ids.value=f.ids.value+','+cb.value;
			 else
			 f.ids.value=cb.value;
		}
				}
}	
if(document.adminForm.boxchecked.value==0)
alert('Please select an item');
else{
if(confirm('Are you sure to delete the selected item?'))	
{
	new Ajax.Updater ('view_all_accounts', base_url+'site_admin/delete', {method:'post', postBody:'ids='+$F('ids')+'&user_level='+$F('user_level')});	
}
}

return false;
}

function enableUserData(n,fldName)
{
	if (!fldName) 
	{
		fldName = 'cb';
  	}
	var f = document.adminForm;
	f.ids.value='';
	for (i=0; i < n; i++) 
	{
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) 
		{
			if(cb.checked)
			{
				if(f.ids.value!="")
					f.ids.value=f.ids.value+','+cb.value;
				else
					f.ids.value=cb.value;
			}
		}
	}	
	if(document.adminForm.boxchecked.value==0)
		alert('Please select an item');
	else
	{
		new Ajax.Updater ('view_all_accounts', base_url+'site_admin/enableUserData', {method:'post', postBody:'ids='+$F('ids')+'&user_level='+$F('user_level')});	
	
	}
	return false;
}


function disableUserData(n,fldName)
{
	if (!fldName) 
	{
		fldName = 'cb';
  	}
	var f = document.adminForm;
	f.ids.value='';
	for (i=0; i < n; i++) 
	{
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) 
		{
			if(cb.checked)
			{
				if(f.ids.value!="")
					f.ids.value=f.ids.value+','+cb.value;
				else
					f.ids.value=cb.value;
			}
		}
	}	
	if(document.adminForm.boxchecked.value==0)
		alert('Please select an item');
	else
	{
		
		new Ajax.Updater ('view_all_accounts', base_url+'site_admin/disableUserData', {method:'post', postBody:'ids='+$F('ids')+'&user_level='+$F('user_level')});	
	
	}
	return false;
}

function deleteLevelData(n,fldName)
{
	if (!fldName) 
	{
		fldName = 'cb';
  	}
	var f = document.adminForm;
	f.ids.value='';
	for (i=0; i < n; i++) 
	{
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) 
		{
			if(cb.checked)
			{
				if(f.ids.value!="")
					f.ids.value=f.ids.value+','+cb.value;
				else
					f.ids.value=cb.value;
			}
		}
	}	
	if(document.adminForm.boxchecked.value==0)
		alert('Please select an item');
	else
	{
		if(confirm('Are you sure to delete the selected item?'))
		{
			new Ajax.Updater ('view_all_levels', base_url+'site_admin/deleteLevel', {method:'post', postBody:'ids='+$F('ids')});	
		}
	
	}
	return false;
}

function editLevelData(n,fldName)
{
	if (!fldName) 
	{
		fldName = 'cb';
  	}
	var f = document.adminForm;
	f.ids.value='';
	for (i=0; i < n; i++) 
	{
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) 
		{
			if(cb.checked)
			{
				if(f.ids.value!="")
					f.ids.value=f.ids.value+','+cb.value;
				else
					f.ids.value=cb.value;
			}
		}
	}	
	if(document.adminForm.boxchecked.value==0)
		alert('Please select an item');
	else
	{
		//new Ajax.Updater ('view_all_levels', base_url+'site_admin/update_level_data', {method:'post', postBody:'ids='+$F('ids')});	
	
	}
	return false;
}

function filter()
{
	new Ajax.Updater ('view_all_accounts', base_url+'site_admin/filteAccountData', {method:'post', postBody:'user_status='+$F('user_status')+'&user_level='+$F('user_level')});
}

function shortedByStatus()
{
	new Ajax.Updater ('view_all_accounts', base_url+'site_admin/accountShortedByStatus', {method:'post', postBody:'user_status='+$F('user_status')+'&user_level='+$F('user_level')});
}

function save_note(show_note_div, hide_messege_div, hide_note_div, notes, user_name, inv_id)
{
	new Ajax.Updater(show_note_div, base_url+'myuser/save_and_get_note', {method:'post', postBody:'notes='+$F(notes)+'&user_name='+$F(user_name)+'&inv_id='+$F(inv_id)});
	document.getElementById(notes).value='';
	J('#'+hide_messege_div).hide('slow');
	J('#'+hide_note_div).hide('slow');
	J('#'+show_note_div).show('slow');
	return false;
}

function send_user_email(hide_div_note,hide_note_div,show_messege_div,mail_to,mail_sub,mail_des,user_name)
{
	new Ajax.Updater(show_messege_div, base_url+'myuser/send_user_email', {method:'post', postBody:'mail_to='+$F(mail_to)+'&mail_sub='+$F(mail_sub)+'&mail_des='+$F(mail_des)+'&user_name='+$F(user_name)});
	
	J('#'+hide_div_note).hide('slow');
	J('#'+hide_note_div).hide('slow');
	J('#'+show_messege_div).show('slow');
	return false;
}

function editUserAccount(n,fldName)
{
	if(document.adminForm.boxchecked.value==0)
	{
		alert('Please select an item for edit');
		return false;
	}
	else
	{/*
	
&nbsp;&nbsp;&nbsp;Shorted by &nbsp;&nbsp;<select name="user_status" id="user_status" onchange="return shortedByStatus()"  style=" border: 1px #0033FF solid; background-color:#ccccff;">
	<option>Enable</option>
	<option >Disable</option>
	</select>



&nbsp;&nbsp;&nbsp;Shorted by &nbsp;&nbsp;<select name="user_status" id="user_status" onchange="return shortedByStatus()"  style=" border: 1px #0033FF solid; background-color:#ccccff;">
	<option>Select an item</option>';
		
		 if($userstatus == $enable)
		 $checked1='selected="seleceted"';
		 else
		 $checked1='';
		 $output.='<option '.$checked1.'>Enable</option>';
	$output.='
	<option '.$checked1.'>Disable</option>
	</select>
	
if (!fldName) {
     fldName = 'cb';
  }
var f = document.adminForm;
 f.ids.value='';
for (i=0; i < n; i++) {
	cb = eval( 'f.' + fldName + '' + i );
	if (cb) {
		if(cb.checked){
			if(f.ids.value!="")
			 f.ids.value=f.ids.value+','+cb.value;
			 else
			 f.ids.value=cb.value;
		}
				}
}
		//new Ajax.Updater ('light', base_url+'site_admin/editData', {method:'post', postBody:'ids='+$F('ids')});
		document.getElementById('light').style.display='block';
		document.getElementById('fade').style.display='block';
		*/
	}
	
	
}

function newMembershipLevelForm()
{
		//new Ajax.Updater ('light', base_url+'site_admin/member_level_form');
		document.getElementById('light').style.display='block';
		document.getElementById('fade').style.display='block';

}

function closePopupWindow()
{
	 document.getElementById('light').style.display='none'; 
	 document.getElementById('fade').style.display='none';
	 return false;
}

function add_another_contact(){
	var number=document.getElementById('number').value;
	var newnumber=number;
	newnumber++;
	if(newnumber>=number)
	new Effect.Appear('removelink');	
	var write_html='<table width=100% border=0 cellspacing=4 cellpadding=0><tr><td align=right valign=top><span>Contact person '+ newnumber +': </span></td><td></td><td align=right valign=top></td><td></td></tr><tr><td width=26% align=right valign=top>First Name : </td><td width=22%><input class=validate[required] type=text name=contact_first_name_'+ newnumber +' id=contact_first_name_'+ newnumber +' /></td><td width=30% align=right valign=top>Last Name  : </td><td width=22%><input class=validate[required] type=text name=contact_last_name_'+ newnumber +' id=contact_last_name_'+ newnumber +' /></td></tr> <tr><td align=right valign=top>Position : </td><td><input class=validate[required] type=text name=contact_position_'+ newnumber +' id=contact_position_'+ newnumber +' /></td><td align=right valign=top>Email : </td><td><input class=validate[required,custom[email]] text-input type=text name=contact_email_'+ newnumber +' id=contact_position_'+ newnumber +' /></td></tr><tr><td align=right valign=top>Phone : </td><td align=left valign=top><input class=validate[required] type=text name=contact_phone_'+ newnumber +' id=contact_phone_'+ newnumber +' /></td><td align=right valign=top></td><td></td></tr><tr><td colspan=4 align=left valign=top></td></tr></table><div id=another_contacts'+ newnumber +' ></div>';
	new Effect.Appear('another_contacts'+number);
	document.getElementById('another_contacts'+number).innerHTML=write_html;
	document.getElementById('number').value= newnumber;
	document.getElementById('another_contacts'+newnumber).style.display='none';	
}

function edit_another_contact(){
	var number=document.getElementById('number').value;
	var newnumber=number;
	newnumber++;
	if(newnumber>=number){
	new Effect.Appear('removelink');	
	var write_html='<table width=100% border=0 cellspacing=4 cellpadding=0><tr><td align=right valign=top><span>Contact person '+ newnumber +': </span></td><td></td><td align=right valign=top></td><td></td></tr><tr><td width=26% align=right valign=top>First Name : </td><td width=22%><input class=validate[required] type=text name=contact_first_name_'+ newnumber +' id=contact_first_name_'+ newnumber +' /></td><td width=30% align=right valign=top>Last Name  : </td><td width=22%><input class=validate[required] type=text name=contact_last_name_'+ newnumber +' id=contact_last_name_'+ newnumber +' /></td></tr> <tr><td align=right valign=top>Position : </td><td><input class=validate[required] type=text name=contact_position_'+ newnumber +' id=contact_position_'+ newnumber +' /></td><td align=right valign=top>Email : </td><td><input class=validate[required,custom[email]] text-input type=text name=contact_email_'+ newnumber +' id=contact_position_'+ newnumber +' /></td></tr><tr><td align=right valign=top>Phone : </td><td align=left valign=top><input class=validate[required] type=text name=contact_phone_'+ newnumber +' id=contact_phone_'+ newnumber +' /></td><td align=right valign=top></td><td></td></tr><tr><td colspan=4 align=left valign=top></td></tr></table><div id=another_contacts'+ newnumber +' ></div>';
	new Effect.Appear('another_contacts'+number);
	document.getElementById('another_contacts'+number).innerHTML=write_html;
	document.getElementById('number').value= newnumber;
	document.getElementById('another_contacts'+newnumber).style.display='none';	
	}
}

function remove_edit_last_one(n){
	var number=document.getElementById('number').value;
	number--;
	if(number==n)
	new Effect.Fade('removelink');
	new Effect.Fade('another_contacts'+number);

	document.getElementById('another_contacts'+number).innerHTML='';	
	document.getElementById('number').value= number;	
}

function remove_last_one(){
	var number=document.getElementById('number').value;
	number--;
	if(number==1)
	new Effect.Fade('removelink');
	new Effect.Fade('another_contacts'+number);

	document.getElementById('another_contacts'+number).innerHTML='';	
	document.getElementById('number').value= number;	
}

function add_another_profile(){
	var p_number=document.getElementById('p_number').value;
	var p_newnumber=p_number;
	p_newnumber++;
	if(p_newnumber==16)
	new Effect.Appear('remove_profile');	
	var write_html='<table width=100% border=0 cellspacing=4 cellpadding=0><tr><td width=2% align=right valign=top>&nbsp;</td><td width=7% align=right valign=top>Line '+ p_newnumber +' : </td><td width=79% align=left valign=top><input class=profile_fild type=text name=txt_'+ p_newnumber +' id=txt_'+ p_newnumber +'/></td><td width=12% align=left valign=top><input type=checkbox name=chk_'+ p_newnumber +' value=chk_'+ p_newnumber +' />Published</td> </tr></table><div id=another_profile'+ p_newnumber +' ></div>';
	new Effect.Appear('another_profile'+p_number);
	document.getElementById('another_profile'+p_number).innerHTML=write_html;
	document.getElementById('p_number').value= p_newnumber;
	document.getElementById('another_profile'+p_newnumber).style.display='none';	
}

function remove_last_one_profile(){
	var p_number=document.getElementById('p_number').value;
	p_number--;
	if(p_number==15)
	new Effect.Fade('remove_profile');
	new Effect.Fade('another_profile'+p_number);

	document.getElementById('another_profile'+p_number).innerHTML='';	
	document.getElementById('p_number').value= p_number;	
}

function show_hide(div_id){
J('#'+div_id).toggle('slow');	
}
function show_hide_div(div_id,div_id1){
J('#'+div_id).toggle('slow');
J('#'+div_id1).toggle('slow');
}
function colups_div(div_id){
J('#'+div_id).toggle('slow');	
}
function show_div_for_search(readio_btn,show_text)
{
	J('#'+readio_btn).show('slow');
	J('#'+show_text).show('slow');
}

function show_note_description(div_id)
{
	J('#'+div_id).toggle('slow');
}

function check_uncheck_all_option(chk_id,status,n)
{	var i=0;
	if(status=='yes')
	{
		for(i=0; i<n; i++)
		{
			document.getElementById(chk_id+i).checked='checked';
		}
	}
	else
	{	
		for(i=0; i<n; i++)
		{
			document.getElementById(chk_id+i).checked='';
		}
	}
}

function check_uncheck_all_strategy(chk_id,status,n,boxchecked)
{	var i=0;
	if(status=='yes')
	{
		document.getElementById(boxchecked).value=n;
		for(i=0; i<n; i++)
		{
			document.getElementById(chk_id+i).checked='checked';
		}
	}
	else
	{	
		document.getElementById(boxchecked).value='0';
		for(i=0; i<n; i++)
		{
			document.getElementById(chk_id+i).checked='';
		}
	}
}
function collups_div_for_hide(show_text,target_div)
{	
	if(document.getElementById(target_div).style.display=='block'){
	J('#'+target_div).hide('slow');
	document.getElementById(show_text).innerHTML='Expand';
	}else{
	J('#'+target_div).show('slow');
	document.getElementById(show_text).innerHTML='Collapse';		
	}
}

function check_search_form(){
if(document.getElementById('str_focus_checked').value==0){
	
	alert('Please select at least one strategy focus');
	return false;
}
if(document.getElementById('geo_focus_checked').value==0){
	
	alert('Please select at least one geograhpy focus');
	return false;
}
if(document.getElementById('inv_type_checked').value==0){
	
	alert('Please select at least one investor type');
	return false;
}
}

function show_hide_contact_person(id){
J('#'+id).toggle('slow');	
}

J(document).ready(function(){
J('#tabs div').hide(); // Hide all divs
J('#tabs div:first').show(); // Show the first div
J('#tabs ul li:first').addClass('active'); // Set the class of the first link to active
J('#tabs ul li a').click(function(){ //When any link is clicked
J('#tabs ul li').removeClass('active'); // Remove active class from all links
J(this).parent().addClass('active'); //Set clicked link class to active
var currentTab = J(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
J('#tabs div').hide(); // Hide all divs
J(currentTab).show(); // Show div with id equal to variable currentTab
return false;
});
});


function edit_information(view_div,edit_div)
{
	J('#'+edit_div).show('slow');
	J('#'+view_div).hide('slow');
	//document.getElementById(view_div).style.display='none'; 
	//document.getElementById(edit_div).style.display='block'; 
	document.getElementById('display_mode').value='edit';
	document.getElementById('div_name').value=edit_div;
}
function show_hide(div_id,edit_div)
{
	var selected_div=document.getElementById('div_name').value;
	var display_mode=document.getElementById('display_mode').value;
	var all_div_id=new Array('investroform_sectors','contact_person_view','strategy_view','geographic_view','profile_view');
	
	for(var i=0; i<all_div_id.length; i++)
	{
		if(all_div_id[i]==div_id && display_mode== 'edit')
		{
			J('#'+all_div_id[i]).toggle('slow');
			J('#'+edit_div).hide('slow');
			document.getElementById('div_name').value=edit_div;
			
			if(document.getElementById('arrow_'+all_div_id[i]).className=='arrow_down')
			document.getElementById('arrow_'+all_div_id[i]).className='arrow_up';
			else
			document.getElementById('arrow_'+all_div_id[i]).className='arrow_down';
		}
		else
		{
			J('#'+all_div_id[i]).hide('slow');
			J('#'+selected_div).hide('slow');
			document.getElementById('arrow_'+all_div_id[i]).className='arrow_down';
				
		}
	}
}

function note_message(none_div,none_div1,block_div)
{
	J('#'+none_div).hide('slow');
	J('#'+none_div1).hide('slow');
	J('#'+block_div).show('slow');
}

function btn_cancel(block_div,none_div)
{
	//document.getElementById(block_div).style.display='block'; 
	//new Effect.Fade(block_div);
	J('#'+block_div).show('slow');
	//new Effect.Appear(block_div);
	//document.getElementById(none_div).style.display='none';
	J('#'+none_div).hide('slow');
	document.getElementById('div_name').value=block_div;
	return false;
}

function filter()
{
	new Ajax.Updater ('view_all_accounts', base_url+'site_admin/filteAccountData', {method:'post', postBody:'user_status='+$F('user_status')+'&user_level='+$F('user_level')});
}


function write_profile(fld_name,chk_box)
{
	var f=document.investor_form;
	if(document.getElementById(fld_name).value=='')
	{
		alert('Write something in ta profile fill');
		document.getElementById(fld_name).style.borderColor='#ff0000';
		document.getElementById(fld_name).focus();
		document.getElementById(chk_box).checked=false;
	}
	else
	{
		document.getElementById(fld_name).style.borderColor='#BDC7D8';
	}
	
}

function edit_task(task)
{
	document.getElementById('do_task').value=task;
	if(task=='delete')
	{
		if(document.adminForm.boxchecked.value==0)
		{
			alert('Please select an item');
			return false;
		}
		
		else
		{
			if(confirm('Are you sure to delete the selected item?'))	
			{
			}
			else
			return false;
		}
	}
}

function try_div(inv_id)
{
	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.display='block';
	new Ajax.Updater ('light', base_url+'investor/view_all_investor_details', {method:'post', postBody:'inv_id='+$F('inv_id')});
}
function edit_basic_info()
{
	new Ajax.Updater ('investroform_sectors', base_url+'investor/update_passic_info', {method:'post', postBody:'user_status='+$F('user_status')+'&user_level='+$F('user_level')});
}
function clear_text(field_id,field_value)
{
	if(document.getElementById(field_id).value==field_value)
	document.getElementById(field_id).value='';
}
function add_text(field_id,field_value)
{
	if(document.getElementById(field_id).value=='')
	document.getElementById(field_id).value=field_value;
}
function get_state()
{
	//document.getElementById('search_state').style.display='block';
	new Ajax.Updater ('search_state_div', base_url+'myuser/get_state', {method:'post', postBody:'search_counrty='+$F('search_counrty')});
	new Effect.Appear('search_state_div');
	//J('#'+'search_state_div').show('slow');
}

function get_cities()
{

	new Ajax.Updater ('search_city_div', base_url+'myuser/get_city_for_search', {method:'post', postBody:'search_state='+$F('search_state')+'&search_counrty='+$F('search_counrty')});
	//J('#'+'search_city_div').show('slow');
	new Effect.Appear('search_city_div');
	
}

function get_type_country_date(div_id)
{
	//new Effect.Fade(div_id);
	J('#'+div_id).hide('slow');	
	new Ajax.Updater (div_id, base_url+'myuser/create_type_country_date', {method:'post', postBody:'choose_option='+$F('choose_option')});
	J('#'+div_id).show('slow');
	
	
}

function for_validation()
{
	
	if((document.getElementById('search_key').value=='' && document.getElementById('choose_option').value=='Select an item') || document.getElementById('type_country_date').value=='Select type' || document.getElementById('type_country_date').value=='Select country' || document.getElementById('type_country_date').value=='Select an option')
	{
		alert('Please select an item for sorting \n or enter a keyword for searching');
		return false;
	}
	else
	{
		return true;
	}
}

function rating_investor(rate,rated_div,inv_id)
{
	new Ajax.Updater (rated_div, base_url+'myuser/save_and_update_rating', {method:'post', postBody:'rate='+rate+'&inv_id='+inv_id});

	document.getElementById('rate_label_'+inv_id).innerHTML='Update your rate : ';
	document.getElementById('rate_label_'+inv_id).style.fontWeight="bold";
}

function rating_investor_from_snf(rate,rated_div,inv_id)
{
	new Ajax.Updater ('for_reading', base_url+'myuser/save_and_update_rating', {method:'post', postBody:'rate='+rate+'&inv_id='+inv_id});
}

function confirm_delete()
{
	if(confirm('Are you sure you want to delete this item'))
	{
		
	}
	else
	return false;
}

function change_email(for_change_email,email_span,loading_gif)
{
	J('#'+loading_gif).show('slow');
	new Ajax.Updater (email_spanfor_change_email, base_url+'myuser/for_change_email', {method:'post', postBody:'current_email='+$F('current_email')+'&new_email='+$F('new_email')});
	
	new Ajax.Updater (email_span, base_url+'myuser/get_email', {method:'post', postBody:''});
	J('#'+loading_gif).show('slow');
}

function change_password(for_change_password,loading_gif)
{
	J('#'+loading_gif).show('slow');
	
	new Ajax.Updater (for_change_password, base_url+'myuser/for_change_password', {method:'post', postBody:'current_pass='+$F('current_pass')+'&new_pass='+$F('new_pass')});
	
	J('#'+loading_gif).show('slow');
	
	//J('#loding_gif').hide('slow');
}

function save_not_and_prospect_list(inv_id,inv_name,user_name)
{
	alert(inv_id);
	new Ajax.Updater ('confirm_message', base_url+'myuser/save_not_and_prospect_list', {method:'post', postBody:'notes='+$F('prospect_note')+'&inv_id='+inv_id+'&inv_name='+inv_name+'&user_name='+user_name});
	return false;
}

function save_search(post_data)
{
	new Ajax.Updater ('save_search_data', base_url+'myuser/save_search_data', {method:''});
}

function add_to_favorite(div_id,inv_id,inv_name)
{
	new Ajax.Updater (div_id, base_url+'myuser/add_to_favorite', {method:'post', postBody:'inv_name='+inv_name+'&inv_id='+inv_id});
}

function remove_to_favorite(div_id,inv_id,inv_name)
{
	new Ajax.Updater (div_id, base_url+'myuser/remove_to_favorite', {method:'post', postBody:'inv_name='+inv_name+'&inv_id='+inv_id});
}

function seleted_none_selected(div_id,chk_id,checked_field_count)
{
	if(document.getElementById(chk_id).checked==1){
	document.getElementById(div_id).className='inv_selected';
	document.getElementById(checked_field_count).value++;
	}
	else{
	document.getElementById(div_id).className='inv_non_selected';
	document.getElementById(checked_field_count).value--;
	}
}

function show_span(check,uncheck)
{
	J('#'+check).show('slow');
	J('#'+uncheck).show('slow');
}

function hide_span(check,uncheck)
{
	J('#'+check).hide('slow');
	J('#'+uncheck).hide('slow');
}

function chnage_grey_to_red(inv_id,id){

	for(var i=1;i<=id;i++){
		document.getElementById(inv_id+'_'+i).className='selected1';
	}

}

function chnage_red_to_grey(inv_id){

	for(var i=1;i<=5;i++){
		document.getElementById(inv_id+'_'+i).className='not_selected';
	}

}

function return_validation()
{
	if(confirm('Are you sure to delete the selected item?'))
	{
		
	}
	else
	{
		return false;
	}
}


